Attribute
|
Data type
|
Meaning
|
CKA_VALUE1,4,6,7
|
Byte array
|
Key value (always 8 bytes long)
|
DES keys must always have their parity bits properly set as described in FIPS PUB 46-2. Attempting to create or unwrap a DES key with incorrect parity will return an error.
The following is a sample template for creating a DES secret key object:
CK_OBJECT_CLASS class = CKO_SECRET_KEY;
CK_KEY_TYPE keyType = CKK_DES;
CK_CHAR label[] = “A DES secret key object”;
CK_BYTE value[8] = {...};
CK_BBOOL true = TRUE;
CK_ATTRIBUTE template[] = {
{CKA_CLASS, &class, sizeof(class)},
{CKA_KEY_TYPE, &keyType, sizeof(keyType)},
{CKA_TOKEN, &true, sizeof(true)},
{CKA_LABEL, label, sizeof(label)},
{CKA_ENCRYPT, &true, sizeof(true)},
{CKA_VALUE, value, sizeof(value)}
};
DES2 secret key objects (object class CKO_SECRET_KEY, key type CKK_DES2) hold double-length DES keys. The following table defines the DES2 secret key object attributes, in addition to the common attributes listed in Table 14, Table 19, and Table 32:
Table 38, DES2 Secret Key Object Attributes
Attribute
|
Data type
|
Meaning
|
CKA_VALUE1,4,6,7
|
Byte array
|
Key value (always 16 bytes long)
|
DES2 keys must always have their parity bits properly set as described in FIPS PUB 46-2 (i.e., each of the DES keys comprising a DES2 key must have its parity bits properly set). Attempting to create or unwrap a DES2 key with incorrect parity will return an error.
The following is a sample template for creating a double-length DES secret key object:
CK_OBJECT_CLASS class = CKO_SECRET_KEY;
CK_KEY_TYPE keyType = CKK_DES2;
CK_CHAR label[] = “A DES2 secret key object”;
CK_BYTE value[16] = {...};
CK_BBOOL true = TRUE;
CK_ATTRIBUTE template[] = {
{CKA_CLASS, &class, sizeof(class)},
{CKA_KEY_TYPE, &keyType, sizeof(keyType)},
{CKA_TOKEN, &true, sizeof(true)},
{CKA_LABEL, label, sizeof(label)},
{CKA_ENCRYPT, &true, sizeof(true)},
{CKA_VALUE, value, sizeof(value)}
};
Share with your friends: |