Lines Matching refs:key
27 static void *key_data(struct key *key) in key_data() argument
29 struct encrypted_key_payload *epayload = dereference_key_locked(key); in key_data()
31 lockdep_assert_held_read(&key->sem); in key_data()
36 static void nvdimm_put_key(struct key *key) in nvdimm_put_key() argument
38 if (!key) in nvdimm_put_key()
41 up_read(&key->sem); in nvdimm_put_key()
42 key_put(key); in nvdimm_put_key()
50 static struct key *nvdimm_request_key(struct nvdimm *nvdimm) in nvdimm_request_key()
52 struct key *key = NULL; in nvdimm_request_key() local
58 key = request_key(&key_type_encrypted, desc, ""); in nvdimm_request_key()
59 if (IS_ERR(key)) { in nvdimm_request_key()
60 if (PTR_ERR(key) == -ENOKEY) in nvdimm_request_key()
64 key = NULL; in nvdimm_request_key()
68 down_read(&key->sem); in nvdimm_request_key()
69 epayload = dereference_key_locked(key); in nvdimm_request_key()
71 up_read(&key->sem); in nvdimm_request_key()
72 key_put(key); in nvdimm_request_key()
73 key = NULL; in nvdimm_request_key()
77 return key; in nvdimm_request_key()
81 struct key **key) in nvdimm_get_key_payload() argument
83 *key = nvdimm_request_key(nvdimm); in nvdimm_get_key_payload()
84 if (!*key) in nvdimm_get_key_payload()
87 return key_data(*key); in nvdimm_get_key_payload()
90 static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm, in nvdimm_lookup_user_key()
94 struct key *key; in nvdimm_lookup_user_key() local
102 key = key_ref_to_ptr(keyref); in nvdimm_lookup_user_key()
103 if (key->type != &key_type_encrypted) { in nvdimm_lookup_user_key()
104 key_put(key); in nvdimm_lookup_user_key()
108 dev_dbg(dev, "%s: key found: %#x\n", __func__, key_serial(key)); in nvdimm_lookup_user_key()
110 down_read_nested(&key->sem, subclass); in nvdimm_lookup_user_key()
111 epayload = dereference_key_locked(key); in nvdimm_lookup_user_key()
113 up_read(&key->sem); in nvdimm_lookup_user_key()
114 key_put(key); in nvdimm_lookup_user_key()
115 key = NULL; in nvdimm_lookup_user_key()
117 return key; in nvdimm_lookup_user_key()
121 key_serial_t id, int subclass, struct key **key) in nvdimm_get_user_key_payload() argument
123 *key = NULL; in nvdimm_get_user_key_payload()
131 *key = nvdimm_lookup_user_key(nvdimm, id, subclass); in nvdimm_get_user_key_payload()
132 if (!*key) in nvdimm_get_user_key_payload()
135 return key_data(*key); in nvdimm_get_user_key_payload()
141 struct key *key; in nvdimm_key_revalidate() local
148 data = nvdimm_get_key_payload(nvdimm, &key); in nvdimm_key_revalidate()
156 nvdimm_put_key(key); in nvdimm_key_revalidate()
160 nvdimm_put_key(key); in nvdimm_key_revalidate()
169 struct key *key; in __nvdimm_security_unlock() local
206 data = nvdimm_get_key_payload(nvdimm, &key); in __nvdimm_security_unlock()
209 dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key), in __nvdimm_security_unlock()
214 nvdimm_put_key(key); in __nvdimm_security_unlock()
253 struct key *key; in security_disable() local
274 NVDIMM_BASE_KEY, &key); in security_disable()
280 dev_dbg(dev, "key: %d disable_master: %s\n", key_serial(key), in security_disable()
284 dev_dbg(dev, "key: %d disable: %s\n", key_serial(key), in security_disable()
288 nvdimm_put_key(key); in security_disable()
302 struct key *key, *newkey; in security_update() local
318 NVDIMM_BASE_KEY, &key); in security_update()
325 nvdimm_put_key(key); in security_update()
331 key_serial(key), key_serial(newkey), in security_update()
336 nvdimm_put_key(key); in security_update()
351 struct key *key = NULL; in security_erase() local
374 NVDIMM_BASE_KEY, &key); in security_erase()
381 dev_dbg(dev, "key: %d erase%s: %s\n", key_serial(key), in security_erase()
385 nvdimm_put_key(key); in security_erase()
394 struct key *key = NULL; in security_overwrite() local
410 NVDIMM_BASE_KEY, &key); in security_overwrite()
417 dev_dbg(dev, "key: %d overwrite submission: %s\n", key_serial(key), in security_overwrite()
420 nvdimm_put_key(key); in security_overwrite()
527 unsigned int key, newkey; in nvdimm_security_store() local
542 rc = kstrtouint(keystr, 0, &key); in nvdimm_security_store()
552 dev_dbg(dev, "disable %u\n", key); in nvdimm_security_store()
553 rc = security_disable(nvdimm, key, NVDIMM_USER); in nvdimm_security_store()
555 dev_dbg(dev, "disable_master %u\n", key); in nvdimm_security_store()
556 rc = security_disable(nvdimm, key, NVDIMM_MASTER); in nvdimm_security_store()
558 dev_dbg(dev, "%s %u %u\n", ops[i].name, key, newkey); in nvdimm_security_store()
559 rc = security_update(nvdimm, key, newkey, i == OP_UPDATE in nvdimm_security_store()
562 dev_dbg(dev, "%s %u\n", ops[i].name, key); in nvdimm_security_store()
567 rc = security_erase(nvdimm, key, i == OP_ERASE in nvdimm_security_store()
570 dev_dbg(dev, "overwrite %u\n", key); in nvdimm_security_store()
575 rc = security_overwrite(nvdimm, key); in nvdimm_security_store()