/* * Wrapper around pkey_handler_gen_key() which deals with the * ENODEV return code and then tries to enforce a pkey handler * module load.
*/ staticint sys_pkey_handler_gen_key(u32 keytype, u32 keysubtype,
u32 keybitsize, u32 flags,
u8 *keybuf, u32 *keybuflen, u32 *keyinfo)
{ int rc;
/* * Sysfs attribute read function for all protected key binary attributes. * The implementation can not deal with partial reads, because a new random * protected key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned.
*/ static ssize_t pkey_protkey_aes_attr_read(u32 keytype, bool is_xts, char *buf,
loff_t off, size_t count)
{ struct protaeskeytoken protkeytoken; struct pkey_protkey protkey; int rc;
if (off != 0 || count < sizeof(protkeytoken)) return -EINVAL; if (is_xts) if (count < 2 * sizeof(protkeytoken)) return -EINVAL;
/* * Sysfs attribute read function for the AES XTS prot key binary attributes. * The implementation can not deal with partial reads, because a new random * protected key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned.
*/ static ssize_t pkey_protkey_aes_xts_attr_read(u32 keytype, char *buf,
loff_t off, size_t count)
{ struct protkeytoken *t = (struct protkeytoken *)buf;
u32 protlen, prottype; int rc;
switch (keytype) { case PKEY_KEYTYPE_AES_XTS_128:
protlen = 64; break; case PKEY_KEYTYPE_AES_XTS_256:
protlen = 96; break; default: return -EINVAL;
}
/* * Sysfs attribute read function for the HMAC prot key binary attributes. * The implementation can not deal with partial reads, because a new random * protected key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned.
*/ static ssize_t pkey_protkey_hmac_attr_read(u32 keytype, char *buf,
loff_t off, size_t count)
{ struct protkeytoken *t = (struct protkeytoken *)buf;
u32 protlen, prottype; int rc;
switch (keytype) { case PKEY_KEYTYPE_HMAC_512:
protlen = 96; break; case PKEY_KEYTYPE_HMAC_1024:
protlen = 160; break; default: return -EINVAL;
}
/* * Sysfs attribute read function for all secure key ccadata binary attributes. * The implementation can not deal with partial reads, because a new random * protected key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned.
*/ static ssize_t pkey_ccadata_aes_attr_read(u32 keytype, bool is_xts, char *buf,
loff_t off, size_t count)
{ struct pkey_seckey *seckey = (struct pkey_seckey *)buf;
u32 buflen; int rc;
if (off != 0 || count < sizeof(struct secaeskeytoken)) return -EINVAL; if (is_xts) if (count < 2 * sizeof(struct secaeskeytoken)) return -EINVAL;
/* * Sysfs attribute read function for all secure key ccacipher binary attributes. * The implementation can not deal with partial reads, because a new random * secure key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned.
*/ static ssize_t pkey_ccacipher_aes_attr_read(enum pkey_key_size keybits, bool is_xts, char *buf, loff_t off,
size_t count)
{
u32 keysize = CCACIPHERTOKENSIZE; int rc;
if (off != 0 || count < CCACIPHERTOKENSIZE) return -EINVAL; if (is_xts) if (count < 2 * CCACIPHERTOKENSIZE) return -EINVAL;
/* * Sysfs attribute read function for all ep11 aes key binary attributes. * The implementation can not deal with partial reads, because a new random * secure key blob is generated with each read. In case of partial reads * (i.e. off != 0 or count < key blob size) -EINVAL is returned. * This function and the sysfs attributes using it provide EP11 key blobs * padded to the upper limit of MAXEP11AESKEYBLOBSIZE which is currently * 336 bytes.
*/ static ssize_t pkey_ep11_aes_attr_read(enum pkey_key_size keybits, bool is_xts, char *buf, loff_t off,
size_t count)
{
u32 keysize = MAXEP11AESKEYBLOBSIZE; int rc;
if (off != 0 || count < MAXEP11AESKEYBLOBSIZE) return -EINVAL; if (is_xts) if (count < 2 * MAXEP11AESKEYBLOBSIZE) return -EINVAL;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.