public class SymmetricKeyType
extends java.lang.Object
Currently, only the following symmetric key types are supported by the Toolkit on a PKCS#11 device.
DES3AESSHA1_HMAC_NCIPHER NCipher Vendor defined KeyGenSHA224_HMAC_NCIPHER NCipher Vendor defined KeyGenSHA256_HMAC_NCIPHER NCipher Vendor defined KeyGenSHA384_HMAC_NCIPHER NCipher Vendor defined KeyGenSHA512_HMAC_NCIPHER NCipher Vendor defined KeyGenregisterSymmetricKeyType(int, SymmetricKeyType)
method.| Modifier and Type | Field and Description |
|---|---|
static SymmetricKeyType |
AES
Key type for AES secret keys (CKK_AES).
|
static int |
CKK_AES
The PKCS#11 key type indicator for AES secret keys.
|
static int |
CKK_DES3
The PKCS#11 key type indicator for 3-key Triple DES secret keys.
|
static int |
CKK_SHA_1_HMAC
The PKCS#11 key type indicator for HMAC_224 Symmetric Keys.
|
static int |
CKK_SHA224_HMAC
The PKCS#11 key type indicator for HMAC_224 Symmetric Keys.
|
static int |
CKK_SHA256_HMAC
The PKCS#11 key type indicator for HMAC_256 Symmetric Keys.
|
static int |
CKK_SHA384_HMAC
The PKCS#11 key type indicator for HMAC_384 Symmetric Keys.
|
static int |
CKK_SHA512_HMAC
The PKCS#11 key type indicator for HMAC_512 Symmetric Keys.
|
static SymmetricKeyType |
DES3
Key type for 3-key Triple DES secret keys (CKK_DES3).
|
static SymmetricKeyType |
SHA1_HMAC_NCIPHER
Key type for HMAC_SHA1 secret keys (CKK_SHA1_HMAC) Using NCIPHER vendor defined
|
static SymmetricKeyType |
SHA224_HMAC_NCIPHER
Key type for HMAC_224 secret keys (CKK_SHA224_HMAC) Using NCIPHER vendor defined
|
static SymmetricKeyType |
SHA256_HMAC_NCIPHER
Key type for HMAC_256 secret keys (CKK_SHA256_HMAC) Using NCIPHER vendor defined
|
static SymmetricKeyType |
SHA384_HMAC_NCIPHER
Key type for HMAC_224 secret keys (CKK_SHA384_HMAC) Using NCIPHER vendor defined
|
static SymmetricKeyType |
SHA512_HMAC_NCIPHER
Key type for HMAC_256 secret keys (CKK_SHA512_HMAC) Using NCIPHER vendor defined
|
| Constructor and Description |
|---|
SymmetricKeyType(int p11KeyType,
long p11KeyGenMechanism,
java.lang.String algorithmName,
int defaultLength,
int[] keyLengths,
boolean hasValueLenAttribute)
The constructor; creates a new
SymmetricKeyType instance. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getAlgorithm()
Returns the JCA name of the cipher algorithm this key is used with.
|
int |
getDefaultLength()
Return the default length, in bytes, of keys with this type.
|
static SymmetricKeyType |
getInstance(int p11KeyType)
Returns the
SymmetricKeyType instance the the key type
identified by the PKCS#11 key type indicator. |
static java.util.Map<java.lang.Integer,SymmetricKeyType> |
getRegisteredSymmetricKeyTypes()
Get the underlying Map
|
boolean |
hasValueLenAttribute()
Indicates whether or not keys of this type have the CKA_VALUE_LEN
attribute.
|
static void |
registerSymmetricKeyType(int p11KeyType,
SymmetricKeyType type)
Convenience method to register a SymmetricKeyType for use with the toolkit.
|
public static final int CKK_DES3
public static final int CKK_AES
public static final int CKK_SHA_1_HMAC
public static final int CKK_SHA224_HMAC
public static final int CKK_SHA256_HMAC
public static final int CKK_SHA384_HMAC
public static final int CKK_SHA512_HMAC
public static final SymmetricKeyType DES3
public static final SymmetricKeyType AES
public static final SymmetricKeyType SHA1_HMAC_NCIPHER
public static final SymmetricKeyType SHA224_HMAC_NCIPHER
public static final SymmetricKeyType SHA256_HMAC_NCIPHER
public static final SymmetricKeyType SHA384_HMAC_NCIPHER
public static final SymmetricKeyType SHA512_HMAC_NCIPHER
public SymmetricKeyType(int p11KeyType,
long p11KeyGenMechanism,
java.lang.String algorithmName,
int defaultLength,
int[] keyLengths,
boolean hasValueLenAttribute)
SymmetricKeyType instance.p11KeyType - the PKCS#11 key type indicatorp11KeyGenMechanism - the PKCS11 key generation mechanism indicatoralgorithmName - the JCA name of the cipher algorithm this key is used withdefaultLength - default length of the key, in byteskeyLengths - the possible key lengths, in bytes, allowed for this key typehasValueLenAttribute - indicates whether or not keys of this type have the
CKA_VALUE_LEN attributepublic static SymmetricKeyType getInstance(int p11KeyType)
SymmetricKeyType instance the the key type
identified by the PKCS#11 key type indicator.p11KeyType - the PKCS#11 key type indicatorjava.lang.IllegalArgumentException - if the identified key type is not supportedpublic static java.util.Map<java.lang.Integer,SymmetricKeyType> getRegisteredSymmetricKeyTypes()
public static void registerSymmetricKeyType(int p11KeyType,
SymmetricKeyType type)
SymmetricKeyType.getRegisteredSymmetricKeyTypes().put(Integer.valueOf(p11KeyType, type).
For example to register a vendor defined mechanism such as one defined by NCIPHER, you would do the following:
//set vendor mechanism values
long NFCK_VENDOR_NCIPHER = 0xde436972L;
long CKM_NCIPHER = MechanismList.CKM_VENDOR_DEFINED | NFCK_VENDOR_NCIPHER;
int CKK_SHA_1_HMAC = 0x00000028;
long CKM_NC_SHA1_HMAC_KEY_GEN = CKM_NCIPHER + 0x03L;
//add the Mechanism into the toolkit
MechanismList.addMechanism(CKM_NC_SHA1_HMAC_KEY_GEN, "CKM_NC_SHA1_HMAC_KEY_GEN");
//define the symmetricKeyType
SymmetricKeyType SHA1_HMAC_NCIPHER = new SymmetricKeyType(CKK_SHA_1_HMAC, CKM_NC_SHA1_HMAC_KEY_GEN, "HMACSHA1NC", 20,
new int[] { 20 }, true);
//register the symmetric key type
SymmetricKeyType.registerSymmetricKeyType(CKK_SHA_1_HMAC, SHA1_HMAC_NCIPHER);
If an existing registration already exists, it will be overwritten with the
new registration.p11KeyType - The PKCS11 Key Type specified by PKCS11type - The Symmetric Key Type, which binds the PKCS11 type to the vendor defined key generation mechanismpublic int getDefaultLength()
When keys for the same algorithm can be of different lengths, e.g with AES, and PKCS#11 does not specify a default length, then the default length is the longest length supported by this key type.
public java.lang.String getAlgorithm()
public boolean hasValueLenAttribute()
true if the key has the CKA_VALUE_LEN attribute;
false otherwise