public class KeyFactory
extends javax.crypto.SecretKeyFactorySpi
Keys may appear in two representations within the Java Security environment:
java.security.Key
DESKeySpec
This SecretKey factory may be used for converting opaque secret keys
(instances of javax.crypto.SecretKey, iaik.security.cipher.PBEKey
) into transparent PBE key material (instances of
javax.crypto.spec.PBEKeySpec) according to the PKCS#5 Password-Based
Encryption 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("PBE", "IAIK"); SecretKey sk = kf.generateSecret(keySpec);
Modifier and Type | Class and Description |
---|---|
static class |
KeyFactory.PBES2KeyFactory
PBES2 KeyFactory.
|
static class |
KeyFactory.PBEWithHmacSHA1AndAES128KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA1AndAES_128.
|
static class |
KeyFactory.PBEWithHmacSHA1AndAES256KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA1AndAES_256.
|
static class |
KeyFactory.PBEWithHmacSHA1AndDESedeKeyFactory
PBES2 KeyFactory for PBEWithHmacSHA1AndDESede.
|
static class |
KeyFactory.PBEWithHmacSHA224AndAES128KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA224AndAES_128.
|
static class |
KeyFactory.PBEWithHmacSHA224AndAES256KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA224AndAES_256.
|
static class |
KeyFactory.PBEWithHmacSHA256AndAES128KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA256AndAES_128.
|
static class |
KeyFactory.PBEWithHmacSHA256AndAES256KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA256AndAES_256.
|
static class |
KeyFactory.PBEWithHmacSHA384AndAES128KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA384AndAES_128.
|
static class |
KeyFactory.PBEWithHmacSHA384AndAES192KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA384AndAES_192.
|
static class |
KeyFactory.PBEWithHmacSHA384AndAES256KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA384AndAES_256.
|
static class |
KeyFactory.PBEWithHmacSHA512AndAES128KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA512AndAES_128.
|
static class |
KeyFactory.PBEWithHmacSHA512AndAES256KeyFactory
PBES2 KeyFactory for PBEWithHmacSHA512AndAES_256.
|
static class |
KeyFactory.PBEWithMD5AndDESKeyFactory
PBE KeyFactory for the PBEWithMD5AndDES 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, iteration count or derived key length) that may be provided by the PBEKeySpec
is ignored by this KeyFactory. Salt, iteration count and/or key length may be provided by
a proper PBE(KeyAnd)ParameterSpec, PBKDF2(KeyAnd)ParameterSpec,... when initializing a PBE cipher or
PBKDF2 KeyGenerator.
engineGenerateSecret
in class javax.crypto.SecretKeyFactorySpi
keySpec
- the specification (key material) to be converted into SecretKey
representation.iaik.security.cipher.PBEKey
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.PBEKey
.
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.PBEKey
java.security.InvalidKeyException
- if the given key cannot be translated by this key factory