Attributes Configuration
The attributes option allows you to specify additional PKCS#11 attributes that should be set when creating PKCS#11 key objects. By default, the IBMPKCS11Impl provider only specifies mandatory PKCS#11 attributes when creating objects. For example, for RSA public keys it specifies the key type and algorithm (CKA_CLASS and CKA_KEY_TYPE) and the key values for RSA public keys (CKA_MODULUS and CKA_PUBLIC_EXPONENT). The PKCS#11 library you are using will assign implementation specific default values to the other attributes of an RSA public key, for example that the key can be used to encrypt and verify messages (CKA_ENCRYPT and CKA_VERIFY = true).
The attributes option can be used if you do not
like the default values your PKCS#11 implementation assigns or if
your PKCS#11 implementation does not support defaults and requires
a value to be specified explicitly. Note that specifying attributes
that your PKCS#11 implementation does not support or that are invalid
for the type of key in question may cause the operation to fail at
run time.
attributes option
has the format:
attributes(operation, keytype, keyalgorithm) = {
name1 = value1
[...]
}
operation are: generate, for keys generated via a KeyPairGenerator or KeyGeneratorimport, for keys created via a KeyFactory or SecretKeyFactory. This also applies to Java™ software keys automatically converted to PKCS#11 key objects when they are passed to the initialization method of a cryptographic operation, for exampleSignature.initSign().*, for keys created using either a generate or a create operation.
Valid values for keytype are CKO_PUBLIC_KEY, CKO_PRIVATE_KEY,
and CKO_SECRET_KEY, for public, private, and secret
keys, respectively, and * to match any type of key.
Valid values for keyalgorithm are one of the CKK_xxx constants
from the PKCS#11 specification, or * to match keys
of any algorithm. The algorithms currently supported by the IBMPKCS11Impl
provider are CKK_RSA, CKK_DSA, CKK_DH, CKK_AES, CKK_DES, CKK_DES3,
CKK_RC4, CKK_BLOWFISH, and CKK_GENERIC_SECRET.
name must be a CKA_xxx constant
from the PKCS#11 specification, for example CKA_SENSITIVE. value can
be one of the following: - a boolean value,
trueorfalse - an integer, in decimal form (default) or in hexadecimal form if
it begins with
0x. null, indicating that this attribute should not be specified when creating objects.
attributes option is specified multiple times, the entries are processed
in the order specified with the attributes aggregated and later attributes overriding earlier ones.
For example, consider the following configuration file excerpt:
attributes(*,CKO_PRIVATE_KEY,*) = {
CKA_SIGN = true
}
attributes(*,CKO_PRIVATE_KEY,CKK_DH) = {
CKA_SIGN = null
}
attributes(*,CKO_PRIVATE_KEY,CKK_RSA) = {
CKA_DECRYPT = true
}
The first entry says to specify CKA_SIGN = true for
all private keys. The second option overrides that with null for
Diffie-Hellman private keys, so the CKA_SIGN attribute
will not specified for them at all. Finally, the third option says
to also specify CKA_DECRYPT = true for RSA private
keys. That means RSA private keys will have both CKA_SIGN
= true and CKA_DECRYPT = true set.
There is also a special form of the attributes option.
You can write attributes = compatibility in the
configuration file. That is a shortcut for a whole set of attribute
statements. They are designed to provider maximum compatibility with
existing Java applications,
which may expect, for example, all key components to be accessible
and secret keys to be useable for both encryption and decryption.
The compatibility attributes line can be used together
with other attributes lines, in which case the same
aggregation and overriding rules apply as described earlier.