Lines Matching refs:key

8 #include <linux/key-type.h>
19 dst->key = kmemdup(src->key, src->len, GFP_NOFS);
20 if (!dst->key)
25 int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end)
27 if (*p + sizeof(u16) + sizeof(key->created) +
28 sizeof(u16) + key->len > end)
30 ceph_encode_16(p, key->type);
31 ceph_encode_copy(p, &key->created, sizeof(key->created));
32 ceph_encode_16(p, key->len);
33 ceph_encode_copy(p, key->key, key->len);
37 int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end)
39 ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad);
40 key->type = ceph_decode_16(p);
41 ceph_decode_copy(p, &key->created, sizeof(key->created));
42 key->len = ceph_decode_16(p);
43 ceph_decode_need(p, end, key->len, bad);
44 key->key = kmalloc(key->len, GFP_NOFS);
45 if (!key->key)
47 ceph_decode_copy(p, key->key, key->len);
51 dout("failed to decode crypto key\n");
55 int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey)
73 ret = ceph_crypto_key_decode(key, &p, p + blen);
77 dout("crypto_key_unarmor key %p type %d len %d\n", key,
78 key->type, key->len);
163 static int ceph_aes_encrypt(const void *key, int key_len,
191 crypto_blkcipher_setkey((void *)tfm, key, key_len);
197 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1,
198 key, key_len, 1);
222 static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
252 crypto_blkcipher_setkey((void *)tfm, key, key_len);
258 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1,
259 key, key_len, 1);
285 static int ceph_aes_decrypt(const void *key, int key_len,
309 crypto_blkcipher_setkey((void *)tfm, key, key_len);
315 print_hex_dump(KERN_ERR, "dec key: ", DUMP_PREFIX_NONE, 16, 1,
316 key, key_len, 1);
349 static int ceph_aes_decrypt2(const void *key, int key_len,
375 crypto_blkcipher_setkey((void *)tfm, key, key_len);
381 print_hex_dump(KERN_ERR, "dec key: ", DUMP_PREFIX_NONE, 16, 1,
382 key, key_len, 1);
439 return ceph_aes_decrypt(secret->key, secret->len, dst,
471 return ceph_aes_decrypt2(secret->key, secret->len,
492 return ceph_aes_encrypt(secret->key, secret->len, dst,
514 return ceph_aes_encrypt2(secret->key, secret->len, dst, dst_len,
561 static void ceph_key_destroy(struct key *key)
563 struct ceph_crypto_key *ckey = key->payload.data;