public class KeyFactory
extends javax.crypto.SecretKeyFactorySpi
Keys may appear in two representations within the Java Security environment:
java.security.Key
This SecretKey factory may be used for converting opaque secret keys
(instances of javax.crypto.SecretKey, iaik.security.cipher.PBEKeyBMP
) into transparent PBE key material (instances
of javax.crypto.spec.PBEKeySpec) according to the PKCS#12
Personal Information Exchange Syntax Standard.
An application shall use the getInstance
factory method of the
javax.crypto.SecretKeyFactory
engine class for accessing this
PBE KeyFactory, e.g.:
PBEKeySpec keySpec = new PBEKeySpec("password".toCharArray()); SecretKeyFactory kf = SecretKeyFactory.getInstance("PKCS#12", "IAIK"); SecretKey sk = kf.generateSecret(keySpec);
Modifier and Type | Class and Description |
---|---|
static class |
KeyFactory.PBEWithSHA1AndDESedeKeyFactory
PBE KeyFactory for the PBEWithSHA1AndDESede algorithm.
|
static class |
KeyFactory.PBEWithSHA1AndRC2_40KeyFactory
PBE KeyFactory for the PBEWithSHA1AndDESede algorithm.
|
Constructor and Description |
---|
KeyFactory()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected javax.crypto.SecretKey |
engineGenerateSecret(java.security.spec.KeySpec keySpec)
Converts the given key specification (key material) into a SecretKey
object.
|
protected java.security.spec.KeySpec |
engineGetKeySpec(javax.crypto.SecretKey secretKey,
java.lang.Class classSpec)
Converts the given secret key into the requested key specification (key
material).
|
protected javax.crypto.SecretKey |
engineTranslateKey(javax.crypto.SecretKey secretKey)
Translates a key object of some unknown or untrusted provider into a secret
key object of this key factory.
|
protected javax.crypto.SecretKey engineGenerateSecret(java.security.spec.KeySpec keySpec) throws java.security.spec.InvalidKeySpecException
The supplied keySpec has to be an instance of javax.crypto.spec.PBEKeySpec
holding the password to be converted to a SecretKey. Note that any additional information
(like salt or iteration count) that may be provided by the PBEKeySpec
is ignored by this KeyFactory. Salt and iteration count may be provided by
a proper PBEParameterSpec when initializing a PBE cipher.
engineGenerateSecret
in class javax.crypto.SecretKeyFactorySpi
keySpec
- the specification (key material) to be converted into SecretKey
representation.iaik.security.cipher.PBEKeyBMP
java.security.spec.InvalidKeySpecException
- if the given key material cannot be converted into a SecretKey
object by this key factoryprotected java.security.spec.KeySpec engineGetKeySpec(javax.crypto.SecretKey secretKey, java.lang.Class classSpec) throws java.security.spec.InvalidKeySpecException
This method may be used for getting a
javax.crypto.spec.PBEKeySpec
from the given secret key. The
supplied secret key has to be an instance of
iaik.security.cipher.PBEKeyBMP
.
engineGetKeySpec
in class javax.crypto.SecretKeyFactorySpi
secretKey
- the secret key to be convertedclassSpec
- the class implementing the requested secret key specjava.security.spec.InvalidKeySpecException
- if the given secret key cannot be converted into the requested
key specification object by this key factoryprotected javax.crypto.SecretKey engineTranslateKey(javax.crypto.SecretKey secretKey) throws java.security.InvalidKeyException
engineTranslateKey
in class javax.crypto.SecretKeyFactorySpi
secretKey
- the key of some unknown or untrusted provideriaik.security.cipher.PBEKeyBMP
java.security.InvalidKeyException
- if the given key cannot be translated by this key factory