APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.pkcs11

pack-priv final Class P11SecretKeyFactory

extends SecretKeyFactorySpi
Class Inheritance
Imports
java.nio.charset.StandardCharsets, java.util.*, java.security.*, java.security.spec.*, javax.crypto.*, javax.crypto.interfaces.PBEKey, javax.crypto.spec.*, jdk.internal.access.SharedSecrets, sun.security.pkcs11.wrapper.*

SecretKeyFactory implementation class. This class currently supports DES, DESede, AES, ARCFOUR, and Blowfish.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv abstract static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final String
private static final Map<String, P11SecretKeyFactory.KeyInfo>
private final P11SecretKeyFactory.PBEKeyInfo
private final Token

Constructor Summary

AccessConstructor and Description
pack-priv
P11SecretKeyFactory(Token token, String algorithm)

Method Summary

Modifier and TypeMethod and Description
pack-priv static P11Key
convertKey(Token token, Key key, String svcAlgo)

Convert an arbitrary key of algorithm into a P11Key of provider.

pack-priv static P11Key
convertKey(Token token, Key key, String svcAlgo, CK_ATTRIBUTE[] extraAttrs)

Convert an arbitrary key of algorithm w/ custom attributes into a P11Key of provider.

private static P11Key
createKey(Token token, byte[] encoded, String algorithm, P11SecretKeyFactory.KeyInfo ki, CK_ATTRIBUTE[] extraAttrs)

pack-priv static P11Key.P11PBKDFKey
protected SecretKey
engineGenerateSecret(KeySpec keySpec)

Implements abstract javax.crypto.SecretKeyFactorySpi.engineGenerateSecret.

Generates a SecretKey object from the provided key specification (key material).

protected KeySpec
engineGetKeySpec(SecretKey key, Class<?> keySpec)

Implements abstract javax.crypto.SecretKeyFactorySpi.engineGetKeySpec.

Returns a specification (key material) of the given key object in the requested format.

protected SecretKey
engineTranslateKey(SecretKey key)

Implements abstract javax.crypto.SecretKeyFactorySpi.engineTranslateKey.

Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory.

pack-priv static void
fixDESParity(byte[] key, int offset)

private SecretKey
generateDESSecret(byte[] keyBytes, String desAlgo)

pack-priv static P11SecretKeyFactory.HKDFKeyInfo
pack-priv static P11SecretKeyFactory.HMACKeyInfo
private byte[]
pack-priv static P11SecretKeyFactory.KeyInfo
pack-priv static long
getKeyType(String algorithm)

pack-priv static P11SecretKeyFactory.PBEKeyInfo
private static PBEKeySpec
pack-priv static long
private static void

Field Detail

algorithmback to summary
private final String algorithm
keyInfoback to summary
private static final Map<String, P11SecretKeyFactory.KeyInfo> keyInfo
svcPbeKiback to summary
private final P11SecretKeyFactory.PBEKeyInfo svcPbeKi
tokenback to summary
private final Token token

Constructor Detail

P11SecretKeyFactoryback to summary
pack-priv P11SecretKeyFactory(Token token, String algorithm)

Method Detail

convertKeyback to summary
pack-priv static P11Key convertKey(Token token, Key key, String svcAlgo) throws InvalidKeyException

Convert an arbitrary key of algorithm into a P11Key of provider. Used in engineTranslateKey(), P11Cipher.init(), and P11Mac.init().

convertKeyback to summary
pack-priv static P11Key convertKey(Token token, Key key, String svcAlgo, CK_ATTRIBUTE[] extraAttrs) throws InvalidKeyException

Convert an arbitrary key of algorithm w/ custom attributes into a P11Key of provider. Used in P11KeyStore.storeSkey.

createKeyback to summary
private static P11Key createKey(Token token, byte[] encoded, String algorithm, P11SecretKeyFactory.KeyInfo ki, CK_ATTRIBUTE[] extraAttrs) throws InvalidKeyException
derivePBEKeyback to summary
pack-priv static P11Key.P11PBKDFKey derivePBEKey(Token token, PBEKeySpec keySpec, P11SecretKeyFactory.PBEKeyInfo pbeKi) throws InvalidKeySpecException
engineGenerateSecretback to summary
protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException

Implements abstract javax.crypto.SecretKeyFactorySpi.engineGenerateSecret.

Doc from javax.crypto.SecretKeyFactorySpi.engineGenerateSecret.

Generates a SecretKey object from the provided key specification (key material).

Exceptions
InvalidKeySpecException:
if the given key specification is inappropriate for this secret key factory to produce a secret key.
engineGetKeySpecback to summary
protected KeySpec engineGetKeySpec(SecretKey key, Class<?> keySpec) throws InvalidKeySpecException

Implements abstract javax.crypto.SecretKeyFactorySpi.engineGetKeySpec.

Doc from javax.crypto.SecretKeyFactorySpi.engineGetKeySpec.

Returns a specification (key material) of the given key object in the requested format.

Exceptions
InvalidKeySpecException:
if the requested key specification is inappropriate for the given key (e.g., the algorithms associated with key and keySpec do not match, or key references a key on a cryptographic hardware device whereas keySpec is the specification of a software-based key), or the given key cannot be dealt with (e.g., the given key has an algorithm or format not supported by this secret key factory).
engineTranslateKeyback to summary
protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException

Implements abstract javax.crypto.SecretKeyFactorySpi.engineTranslateKey.

Doc from javax.crypto.SecretKeyFactorySpi.engineTranslateKey.

Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret key factory.

Exceptions
InvalidKeyException:
if the given key cannot be processed by this secret key factory.
fixDESParityback to summary
pack-priv static void fixDESParity(byte[] key, int offset)
generateDESSecretback to summary
private SecretKey generateDESSecret(byte[] keyBytes, String desAlgo) throws InvalidKeySpecException
getHKDFKeyInfoback to summary
pack-priv static P11SecretKeyFactory.HKDFKeyInfo getHKDFKeyInfo(String algo)
getHMACKeyInfoback to summary
pack-priv static P11SecretKeyFactory.HMACKeyInfo getHMACKeyInfo(String algo)
getKeyBytesback to summary
private byte[] getKeyBytes(SecretKey key) throws InvalidKeySpecException
getKeyInfoback to summary
pack-priv static P11SecretKeyFactory.KeyInfo getKeyInfo(String algo)
getKeyTypeback to summary
pack-priv static long getKeyType(String algorithm)
getPBEKeyInfoback to summary
pack-priv static P11SecretKeyFactory.PBEKeyInfo getPBEKeyInfo(String algo)
getPbeKeySpecback to summary
private static PBEKeySpec getPbeKeySpec(PBEKey pbeKey)
getPKCS11KeyTypeback to summary
pack-priv static long getPKCS11KeyType(String algorithm)
putKeyInfoback to summary
private static void putKeyInfo(P11SecretKeyFactory.KeyInfo ki)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.AESPBEKeyInfo

extends PBEKeyInfo
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CK_ATTRIBUTE[]
Inherited from sun.security.pkcs11.P11SecretKeyFactory.PBEKeyInfo:
extraAttrsINVALID_PRFkdfMechkeyLenprfMech

Constructor Summary

AccessConstructor and Description
pack-priv
AESPBEKeyInfo(String algo, long prfMech, int keyLen)

Field Detail

attrback to summary
private static final CK_ATTRIBUTE[] attr

Constructor Detail

AESPBEKeyInfoback to summary
pack-priv AESPBEKeyInfo(String algo, long prfMech, int keyLen)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.HKDFKeyInfo

extends KeyInfo
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final long
public final int
public static final long
Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
algokeyGenMechkeyType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
checkUse

Field Detail

hmacMechback to summary
public final long hmacMech
prkLenback to summary
public final int prkLen
UNKNOWN_KEY_TYPEback to summary
public static final long UNKNOWN_KEY_TYPE

Constructor Detail

HKDFKeyInfoback to summary
pack-priv HKDFKeyInfo(String algo, P11SecretKeyFactory.HMACKeyInfo hmacKi)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.HMACKeyInfo

extends KeyInfo
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final int
public final long
Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
algokeyGenMechkeyType

Constructor Summary

AccessConstructor and Description
pack-priv
HMACKeyInfo(String algo, long mech, int keyLen)

Method Summary

Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
checkUse

Field Detail

keyLenback to summary
public final int keyLen
mechback to summary
public final long mech

Constructor Detail

HMACKeyInfoback to summary
pack-priv HMACKeyInfo(String algo, long mech, int keyLen)
sun.security.pkcs11 back to summary

pack-priv sealed Class P11SecretKeyFactory.KeyInfo

extends Object
permits PBEKeyInfo, HMACKeyInfo, HKDFKeyInfo, TLSKeyInfo
Class Inheritance
Known Direct Subclasses
sun.security.pkcs11.P11SecretKeyFactory.TLSKeyInfo, sun.security.pkcs11.P11SecretKeyFactory.HMACKeyInfo, sun.security.pkcs11.P11SecretKeyFactory.HKDFKeyInfo, sun.security.pkcs11.P11SecretKeyFactory.PBEKeyInfo

Field Summary

Modifier and TypeField and Description
public final String
public final long
public final long

Constructor Summary

AccessConstructor and Description
pack-priv
KeyInfo(String algo, long keyType)

pack-priv
KeyInfo(String algo, long keyType, long keyGenMech)

Method Summary

Modifier and TypeMethod and Description
pack-priv static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algoback to summary
public final String algo
keyGenMechback to summary
public final long keyGenMech
keyTypeback to summary
public final long keyType

Constructor Detail

KeyInfoback to summary
pack-priv KeyInfo(String algo, long keyType)
KeyInfoback to summary
pack-priv KeyInfo(String algo, long keyType, long keyGenMech)

Method Detail

checkUseback to summary
pack-priv static boolean checkUse(P11SecretKeyFactory.KeyInfo ki, P11SecretKeyFactory.KeyInfo si)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.P12MacPBEKeyInfo

extends PBEKeyInfo
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CK_ATTRIBUTE[]
Inherited from sun.security.pkcs11.P11SecretKeyFactory.PBEKeyInfo:
extraAttrsINVALID_PRFkdfMechkeyLenprfMech

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

attrback to summary
private static final CK_ATTRIBUTE[] attr

Constructor Detail

P12MacPBEKeyInfoback to summary
pack-priv P12MacPBEKeyInfo(String algo, long kdfMech, P11SecretKeyFactory.HMACKeyInfo hmacKi)
sun.security.pkcs11 back to summary

pack-priv abstract sealed Class P11SecretKeyFactory.PBEKeyInfo

extends KeyInfo
permits AESPBEKeyInfo, PBKDF2KeyInfo, P12MacPBEKeyInfo
Class Inheritance
Known Direct Subclasses
sun.security.pkcs11.P11SecretKeyFactory.AESPBEKeyInfo, sun.security.pkcs11.P11SecretKeyFactory.PBKDF2KeyInfo, sun.security.pkcs11.P11SecretKeyFactory.P12MacPBEKeyInfo

Field Summary

Modifier and TypeField and Description
public final CK_ATTRIBUTE[]
public static final long
public final long
public final int
public final long
Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
algokeyGenMechkeyType

Constructor Summary

AccessConstructor and Description
protected
PBEKeyInfo(String algo, long kdfMech, long prfMech, long keyType, int keyLen, CK_ATTRIBUTE[] extraAttrs)

Method Summary

Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
checkUse

Field Detail

extraAttrsback to summary
public final CK_ATTRIBUTE[] extraAttrs
INVALID_PRFback to summary
public static final long INVALID_PRF
kdfMechback to summary
public final long kdfMech
keyLenback to summary
public final int keyLen
prfMechback to summary
public final long prfMech

Constructor Detail

PBEKeyInfoback to summary
protected PBEKeyInfo(String algo, long kdfMech, long prfMech, long keyType, int keyLen, CK_ATTRIBUTE[] extraAttrs)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.PBKDF2KeyInfo

extends PBEKeyInfo
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CK_ATTRIBUTE[]
Inherited from sun.security.pkcs11.P11SecretKeyFactory.PBEKeyInfo:
extraAttrsINVALID_PRFkdfMechkeyLenprfMech

Constructor Summary

AccessConstructor and Description
pack-priv
PBKDF2KeyInfo(String algo, long prfMech)

Field Detail

attrback to summary
private static final CK_ATTRIBUTE[] attr

Constructor Detail

PBKDF2KeyInfoback to summary
pack-priv PBKDF2KeyInfo(String algo, long prfMech)
sun.security.pkcs11 back to summary

pack-priv final Class P11SecretKeyFactory.TLSKeyInfo

extends KeyInfo
Class Inheritance

Field Summary

Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
algokeyGenMechkeyType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from sun.security.pkcs11.P11SecretKeyFactory.KeyInfo:
checkUse

Constructor Detail

TLSKeyInfoback to summary
pack-priv TLSKeyInfo(String algo)