Generating secure keys using the pkey device driver
The pkey device driver uses random data from an AP queue to generate secure keys.
Such keys can be used for example, for swap disks where you might want a new key to be generated at every boot. Secure keys for this and other purposes can be read from secure key sysfs attributes.
Alternatively to sysfs, you can use the ioctl calls, see External programming interfaces.
Procedure
Read the sysfs attribute according to the required the type, length, and cipher mode of the key.
Results
Attributes for non-XTS keys yield exactly one secure-key token. Attributes for XTS cipher mode yield two concatenated secure-key tokens. The length of a token also varies by key type and length as summarized in Table 1.
Key type | Attribute length non-XTS (single key token) | Attribute length XTS (two key tokens) |
---|---|---|
CCA AES data secure key | 64 bytes | 128 bytes |
CCA AES cipher secure key | 136 bytes | 272 bytes |
EP11 AES secure key | 320 bytes | 640 bytes |