Searched refs:key (Results 1 - 200 of 2278) sorted by relevance

1234567891011>>

/linux-4.1.27/include/linux/
H A Djump_label_ratelimit.h9 struct static_key key; member in struct:static_key_deferred
16 extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
18 jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
22 struct static_key key; member in struct:static_key_deferred
24 static inline void static_key_slow_dec_deferred(struct static_key_deferred *key) static_key_slow_dec_deferred() argument
27 static_key_slow_dec(&key->key); static_key_slow_dec_deferred()
30 jump_label_rate_limit(struct static_key_deferred *key, jump_label_rate_limit() argument
H A Dkey.h1 /* Authentication token and access key management
30 /* key handle serial number */
33 /* key handle permissions mask */
36 struct key;
42 #define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */
43 #define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */
44 #define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */
45 #define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */
46 #define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */
47 #define KEY_POS_SETATTR 0x20000000 /* possessor can set key attributes */
94 * key reference with possession attribute handling
98 * flag to indicate whether the calling process possesses that key in one of
108 static inline key_ref_t make_key_ref(const struct key *key, make_key_ref() argument
111 return (key_ref_t) ((unsigned long) key | possession); make_key_ref()
114 static inline struct key *key_ref_to_ptr(const key_ref_t key_ref) key_ref_to_ptr()
116 return (struct key *) ((unsigned long) key_ref & ~1UL); key_ref_to_ptr()
127 * - types of key include:
132 struct key { struct
134 key_serial_t serial; /* key serial number */
140 struct key_user *user; /* owner of this key */
141 void *security; /* security data for this key */
143 time_t expiry; /* time at which key expires (or 0) */
144 time_t revoked_at; /* time at which key was revoked */
163 #define KEY_FLAG_INSTANTIATED 0 /* set if key has been instantiated */
164 #define KEY_FLAG_DEAD 1 /* set if key type has been deleted */
165 #define KEY_FLAG_REVOKED 2 /* set if key had been revoked */
166 #define KEY_FLAG_IN_QUOTA 3 /* set if key consumes quota */
167 #define KEY_FLAG_USER_CONSTRUCT 4 /* set if key is being constructed in userspace */
168 #define KEY_FLAG_NEGATIVE 5 /* set if key is negative */
169 #define KEY_FLAG_ROOT_CAN_CLEAR 6 /* set if key can be cleared by root without permission */
170 #define KEY_FLAG_INVALIDATED 7 /* set if key has been invalidated */
171 #define KEY_FLAG_TRUSTED 8 /* set if key is trusted */
173 #define KEY_FLAG_BUILTIN 10 /* set if key is builtin */
174 #define KEY_FLAG_ROOT_CAN_INVAL 11 /* set if key can be invalidated by root without permission */
176 /* the key type and key description string
177 * - the desc is used to match a key against search criteria
184 struct key_type *type; /* type of key */
199 /* key data
214 extern struct key *key_alloc(struct key_type *type,
227 extern void key_revoke(struct key *key);
228 extern void key_invalidate(struct key *key);
229 extern void key_put(struct key *key);
231 static inline struct key *__key_get(struct key *key) __key_get() argument
233 atomic_inc(&key->usage); __key_get()
234 return key; __key_get()
237 static inline struct key *key_get(struct key *key) key_get() argument
239 return key ? __key_get(key) : key; key_get()
247 extern struct key *request_key(struct key_type *type,
251 extern struct key *request_key_with_auxdata(struct key_type *type,
257 extern struct key *request_key_async(struct key_type *type,
262 extern struct key *request_key_async_with_auxdata(struct key_type *type,
268 extern int wait_for_key_construction(struct key *key, bool intr);
270 extern int key_validate(const struct key *key);
280 extern int key_update(key_ref_t key,
284 extern int key_link(struct key *keyring,
285 struct key *key);
287 extern int key_unlink(struct key *keyring,
288 struct key *key);
290 extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,
294 struct key *dest);
296 extern int keyring_clear(struct key *keyring);
302 extern int keyring_add_key(struct key *keyring,
303 struct key *key);
305 extern struct key *key_lookup(key_serial_t id);
307 static inline key_serial_t key_serial(const struct key *key) key_serial() argument
309 return key ? key->serial : 0; key_serial()
312 extern void key_set_timeout(struct key *, unsigned);
315 * The permissions required on a key that we're looking up.
320 #define KEY_NEED_SEARCH 0x08 /* Require permission to search (keyring) or find (key) */
326 * key_is_instantiated - Determine if a key has been positively instantiated
327 * @key: The key to check.
329 * Return true if the specified key has been positively instantiated, false
332 static inline bool key_is_instantiated(const struct key *key) key_is_instantiated() argument
334 return test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && key_is_instantiated()
335 !test_bit(KEY_FLAG_NEGATIVE, &key->flags); key_is_instantiated()
340 rwsem_is_locked(&((struct key *)(KEY))->sem)))
H A Dkey-type.h1 /* Definitions for key type implementations
15 #include <linux/key.h>
21 * key under-construction record
25 struct key *key; /* key being constructed */ member in struct:key_construction
26 struct key *authkey;/* authorisation for key being constructed */
30 * Pre-parsed payload, used by key add, update and instantiate.
34 * def_datalen from the key type. Then if the preparse() op is provided by the
35 * key type, that will be called. Then the struct will be passed to the
42 char *description; /* Proposed key description (or NULL) */
43 void *type_data[2]; /* Private key-type data */
48 time_t expiry; /* Expiry time of key */
49 bool trusted; /* True if key is trusted */
52 typedef int (*request_key_actor_t)(struct key_construction *key,
63 bool (*cmp)(const struct key *key,
74 * kernel managed key type definition
99 /* instantiate a key of this type
103 int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
105 /* update a key of this type (optional)
108 * - the key must be locked against read when modifying
110 int (*update)(struct key *key, struct key_preparsed_payload *prep);
122 /* clear some of the data from a key on revokation (optional)
123 * - the key's semaphore will be write-locked by the caller
125 void (*revoke)(struct key *key);
127 /* clear the data from a key (optional) */
128 void (*destroy)(struct key *key);
130 /* describe a key */
131 void (*describe)(const struct key *key, struct seq_file *p);
133 /* read a key's data (optional)
135 * - the key's semaphore will be readlocked by the caller
140 long (*read)(const struct key *key, char __user *buffer, size_t buflen);
143 * /sbin/request-key (optional)
144 * - key is the key to instantiate
145 * - authkey is the authority to assume when instantiating this key
154 struct lock_class_key lock_class; /* key->sem lock class */
162 extern int key_payload_reserve(struct key *key, size_t datalen);
163 extern int key_instantiate_and_link(struct key *key,
166 struct key *keyring,
167 struct key *instkey);
168 extern int key_reject_and_link(struct key *key,
171 struct key *keyring,
172 struct key *instkey);
175 static inline int key_negate_and_link(struct key *key, key_negate_and_link() argument
177 struct key *keyring, key_negate_and_link()
178 struct key *instkey) key_negate_and_link()
180 return key_reject_and_link(key, timeout, ENOKEY, keyring, instkey); key_negate_and_link()
183 extern int generic_key_instantiate(struct key *key, struct key_preparsed_payload *prep);
H A Dbtree-type.h37 static inline void *BTREE_FN(lookup)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key) lookup() argument
39 unsigned long _key = key; lookup()
43 static inline int BTREE_FN(insert)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key, insert() argument
46 unsigned long _key = key; insert()
50 static inline int BTREE_FN(update)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key, update() argument
53 unsigned long _key = key; update()
57 static inline void *BTREE_FN(remove)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key) remove() argument
59 unsigned long _key = key; remove()
63 static inline void *BTREE_FN(last)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key) last() argument
68 *key = _key; last()
72 static inline void *BTREE_FN(get_prev)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key) get_prev() argument
74 unsigned long _key = *key; get_prev()
77 *key = _key; get_prev()
81 static inline void *BTREE_FN(lookup)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key) lookup() argument
83 return btree_lookup(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key); lookup()
86 static inline int BTREE_FN(insert)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key, insert() argument
89 return btree_insert(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key, insert()
93 static inline int BTREE_FN(update)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key, update() argument
96 return btree_update(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key, val); update()
99 static inline void *BTREE_FN(remove)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE key) remove() argument
101 return btree_remove(&head->h, BTREE_TYPE_GEO, (unsigned long *)&key); remove()
104 static inline void *BTREE_FN(last)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key) last() argument
106 return btree_last(&head->h, BTREE_TYPE_GEO, (unsigned long *)key); last()
109 static inline void *BTREE_FN(get_prev)(BTREE_TYPE_HEAD *head, BTREE_KEYTYPE *key) get_prev() argument
111 return btree_get_prev(&head->h, BTREE_TYPE_GEO, (unsigned long *)key); get_prev()
115 void VISITOR_FN(void *elem, unsigned long opaque, unsigned long *key,
119 BTREE_KEYTYPE key, size_t index);
H A Dbsearch.h6 void *bsearch(const void *key, const void *base, size_t num, size_t size,
7 int (*cmp)(const void *key, const void *elt));
H A Dbtree-128.h23 u64 key[2] = {k1, k2}; btree_lookup128() local
24 return btree_lookup(&head->h, &btree_geo128, (unsigned long *)&key); btree_lookup128()
30 u64 key[2] = {*k1, *k2}; btree_get_prev128() local
34 (unsigned long *)&key); btree_get_prev128()
35 *k1 = key[0]; btree_get_prev128()
36 *k2 = key[1]; btree_get_prev128()
43 u64 key[2] = {k1, k2}; btree_insert128() local
45 (unsigned long *)&key, val, gfp); btree_insert128()
51 u64 key[2] = {k1, k2}; btree_update128() local
53 (unsigned long *)&key, val); btree_update128()
58 u64 key[2] = {k1, k2}; btree_remove128() local
59 return btree_remove(&head->h, &btree_geo128, (unsigned long *)&key); btree_remove128()
64 u64 key[2]; btree_last128() local
67 val = btree_last(&head->h, &btree_geo128, (unsigned long *)&key[0]); btree_last128()
69 *k1 = key[0]; btree_last128()
70 *k2 = key[1]; btree_last128()
H A Dsysrq.h10 * overhauled to use key registration
41 * ASCII code of the key, pointer to registers and kbd/tty structs (if they
45 void handle_sysrq(int key);
46 void __handle_sysrq(int key, bool check_mask);
47 int register_sysrq_key(int key, struct sysrq_key_op *op);
48 int unregister_sysrq_key(int key, struct sysrq_key_op *op);
49 struct sysrq_key_op *__sysrq_get_key_op(int key);
55 static inline void handle_sysrq(int key) handle_sysrq() argument
59 static inline void __handle_sysrq(int key, bool check_mask) __handle_sysrq() argument
63 static inline int register_sysrq_key(int key, struct sysrq_key_op *op) register_sysrq_key() argument
68 static inline int unregister_sysrq_key(int key, struct sysrq_key_op *op) unregister_sysrq_key() argument
H A Djump_label.h12 * of a "if (static_key_false(&key))" statement is an unconditional branch (which
16 * static_key_slow_{inc,dec}(). These function as a 'reference' count on the key
18 * that particular key will point to the (out of line) true block.
40 * will result in the true case being in-line and starts the key with a single
41 * reference. Mixing static_key_true() and static_key_false() on the same key is not
44 * Not initializing the key (static data is initialized to 0s anyway) is the
97 static inline int static_key_count(struct static_key *key) static_key_count() argument
99 return atomic_read(&key->enabled); static_key_count()
109 inline struct jump_entry *jump_label_get_entries(struct static_key *key) jump_label_get_entries() argument
111 return (struct jump_entry *)((unsigned long)key->entries jump_label_get_entries()
115 static inline bool jump_label_get_branch_default(struct static_key *key) jump_label_get_branch_default() argument
117 if (((unsigned long)key->entries & JUMP_LABEL_TYPE_MASK) == jump_label_get_branch_default()
123 static __always_inline bool static_key_false(struct static_key *key) static_key_false() argument
125 return arch_static_branch(key); static_key_false()
128 static __always_inline bool static_key_true(struct static_key *key) static_key_true() argument
130 return !static_key_false(key); static_key_true()
144 extern void static_key_slow_inc(struct static_key *key);
145 extern void static_key_slow_dec(struct static_key *key);
162 static __always_inline bool static_key_false(struct static_key *key) static_key_false() argument
164 if (unlikely(static_key_count(key) > 0)) static_key_false()
169 static __always_inline bool static_key_true(struct static_key *key) static_key_true() argument
171 if (likely(static_key_count(key) > 0)) static_key_true()
176 static inline void static_key_slow_inc(struct static_key *key) static_key_slow_inc() argument
179 atomic_inc(&key->enabled); static_key_slow_inc()
182 static inline void static_key_slow_dec(struct static_key *key) static_key_slow_dec() argument
185 atomic_dec(&key->enabled); static_key_slow_dec()
211 static inline bool static_key_enabled(struct static_key *key) static_key_enabled() argument
213 return static_key_count(key) > 0; static_key_enabled()
H A Dbtree.h13 * use binary search to find the key on lookups.
23 * Each key here is an array of unsigned longs, geo->no_longs in total. The
91 * btree_lookup - look up a key in the btree
95 * @key: the key to look up
97 * This function returns the value for the given key, or %NULL.
100 unsigned long *key);
107 * @key: the key to add (must not already be present)
115 unsigned long *key, void *val, gfp_t gfp);
121 * @key: the key to update
125 * -%ENOENT if the key could not be found.
128 unsigned long *key, void *val);
134 * @key: the key to remove
136 * This function returns the removed entry, or %NULL if the key
140 unsigned long *key);
165 * @key: last key
167 * Returns the last entry in the btree, and sets @key to the key
169 * key is not changed.
172 unsigned long *key);
179 * @key: pointer to key
182 * @key, and updates @key with its key, or returns %NULL when there is no
183 * entry with a key smaller than the given key.
186 unsigned long *key);
193 unsigned long *key, size_t index,
201 unsigned long *key,
215 #define btree_for_each_safel(head, key, val) \
216 for (val = btree_lastl(head, &key); \
218 val = btree_get_prevl(head, &key))
226 #define btree_for_each_safe32(head, key, val) \
227 for (val = btree_last32(head, &key); \
229 val = btree_get_prev32(head, &key))
238 #define btree_for_each_safe64(head, key, val) \
239 for (val = btree_last64(head, &key); \
241 val = btree_get_prev64(head, &key))
H A Ddigsig.h18 #include <linux/key.h>
32 uint8_t version; /* key format version */
33 uint32_t timestamp; /* key made, always 0 for now */
51 int digsig_verify(struct key *keyring, const char *sig, int siglen,
56 static inline int digsig_verify(struct key *keyring, const char *sig, digsig_verify()
H A Dhashtable.h53 * @key: the key of the object to be added
55 #define hash_add(hashtable, node, key) \
56 hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
62 * @key: the key of the object to be added
64 #define hash_add_rcu(hashtable, node, key) \
65 hlist_add_head_rcu(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
158 * @key: the key of the objects to iterate over
160 #define hash_for_each_possible(name, obj, member, key) \
161 hlist_for_each_entry(obj, &name[hash_min(key, HASH_BITS(name))], member)
170 * @key: the key of the objects to iterate over
172 #define hash_for_each_possible_rcu(name, obj, member, key) \
173 hlist_for_each_entry_rcu(obj, &name[hash_min(key, HASH_BITS(name))],\
182 * @key: the key of the objects to iterate over
187 #define hash_for_each_possible_rcu_notrace(name, obj, member, key) \
189 &name[hash_min(key, HASH_BITS(name))], member)
198 * @key: the key of the objects to iterate over
200 #define hash_for_each_possible_safe(name, obj, tmp, member, key) \
202 &name[hash_min(key, HASH_BITS(name))], member)
H A Dfutex.h18 * Futexes are matched on equal values of this key.
19 * The key type depends on whether it's a shared or private mapping.
23 * We use the two low order bits of offset to tell what is the kind of key :
32 #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
33 #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
H A Dlockdep.h47 * lockclass-key into the kernel (or module) .data section. (For
48 * static locks we use the lock address itself as the key.)
76 struct lockdep_subclass_key *key; member in struct:lock_class
151 struct lock_class_key *key; member in struct:lockdep_map
222 * to have a unique key value for every unique dependency path
280 struct lock_class_key *key, int subclass);
287 { .name = (_name), .key = (void *)(_key), }
290 * Reinitialize a lock key - for cases where there is special locking or
295 #define lockdep_set_class(lock, key) \
296 lockdep_init_map(&(lock)->dep_map, #key, key, 0)
297 #define lockdep_set_class_and_name(lock, key, name) \
298 lockdep_init_map(&(lock)->dep_map, name, key, 0)
299 #define lockdep_set_class_and_subclass(lock, key, sub) \
300 lockdep_init_map(&(lock)->dep_map, #key, key, sub)
303 (lock)->dep_map.key, sub)
310 #define lockdep_match_class(lock, key) lockdep_match_key(&(lock)->dep_map, key)
313 struct lock_class_key *key) lockdep_match_key()
315 return lock->key == key; lockdep_match_key()
344 struct lock_class_key *key, unsigned int subclass,
350 lock_set_class(lock, lock->name, lock->key, subclass, ip); lock_set_subclass()
390 # define lockdep_init_map(lock, name, key, sub) \
391 do { (void)(name); (void)(key); } while (0)
392 # define lockdep_set_class(lock, key) do { (void)(key); } while (0)
393 # define lockdep_set_class_and_name(lock, key, name) \
394 do { (void)(key); (void)(name); } while (0)
395 #define lockdep_set_class_and_subclass(lock, key, sub) \
396 do { (void)(key); } while (0)
412 * The class key takes no space if lockdep is disabled:
312 lockdep_match_key(struct lockdep_map *lock, struct lock_class_key *key) lockdep_match_key() argument
H A Djhash.h60 /* jhash - hash an arbitrary key
61 * @k: sequence of bytes as key
62 * @length: the length of the key
66 * No alignment or length assumptions are made about the input key.
68 * Returns the hash value of the key. The result depends on endianness.
70 static inline u32 jhash(const void *key, u32 length, u32 initval) jhash() argument
73 const u8 *k = key; jhash()
111 * @k: the key which must be an array of u32's
112 * @length: the number of u32's in the key
115 * Returns the hash value of the key.
124 /* Handle most of the key */ jhash2()
/linux-4.1.27/samples/bpf/
H A Dtest_maps.c23 long long key, next_key, value; test_hashmap_sanity() local
26 map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), 2); test_hashmap_sanity()
32 key = 1; test_hashmap_sanity()
34 /* insert key=1 element */ test_hashmap_sanity()
35 assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0); test_hashmap_sanity()
39 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && test_hashmap_sanity()
40 /* key=1 already exists */ test_hashmap_sanity()
43 assert(bpf_update_elem(map_fd, &key, &value, -1) == -1 && errno == EINVAL); test_hashmap_sanity()
45 /* check that key=1 can be found */ test_hashmap_sanity()
46 assert(bpf_lookup_elem(map_fd, &key, &value) == 0 && value == 1234); test_hashmap_sanity()
48 key = 2; test_hashmap_sanity()
49 /* check that key=2 is not found */ test_hashmap_sanity()
50 assert(bpf_lookup_elem(map_fd, &key, &value) == -1 && errno == ENOENT); test_hashmap_sanity()
53 assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == -1 && test_hashmap_sanity()
54 /* key=2 is not there */ test_hashmap_sanity()
57 /* insert key=2 element */ test_hashmap_sanity()
58 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0); test_hashmap_sanity()
60 /* key=1 and key=2 were inserted, check that key=0 cannot be inserted test_hashmap_sanity()
63 key = 0; test_hashmap_sanity()
64 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && test_hashmap_sanity()
67 /* check that key = 0 doesn't exist */ test_hashmap_sanity()
68 assert(bpf_delete_elem(map_fd, &key) == -1 && errno == ENOENT); test_hashmap_sanity()
71 assert(bpf_get_next_key(map_fd, &key, &next_key) == 0 && test_hashmap_sanity()
79 key = 1; test_hashmap_sanity()
80 assert(bpf_delete_elem(map_fd, &key) == 0); test_hashmap_sanity()
81 key = 2; test_hashmap_sanity()
82 assert(bpf_delete_elem(map_fd, &key) == 0); test_hashmap_sanity()
83 assert(bpf_delete_elem(map_fd, &key) == -1 && errno == ENOENT); test_hashmap_sanity()
85 key = 0; test_hashmap_sanity()
87 assert(bpf_get_next_key(map_fd, &key, &next_key) == -1 && test_hashmap_sanity()
94 int key, next_key, map_fd; test_arraymap_sanity() local
97 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), 2); test_arraymap_sanity()
103 key = 1; test_arraymap_sanity()
105 /* insert key=1 element */ test_arraymap_sanity()
106 assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0); test_arraymap_sanity()
109 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && test_arraymap_sanity()
112 /* check that key=1 can be found */ test_arraymap_sanity()
113 assert(bpf_lookup_elem(map_fd, &key, &value) == 0 && value == 1234); test_arraymap_sanity()
115 key = 0; test_arraymap_sanity()
116 /* check that key=0 is also found and zero initialized */ test_arraymap_sanity()
117 assert(bpf_lookup_elem(map_fd, &key, &value) == 0 && value == 0); test_arraymap_sanity()
120 /* key=0 and key=1 were inserted, check that key=2 cannot be inserted test_arraymap_sanity()
123 key = 2; test_arraymap_sanity()
124 assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == -1 && test_arraymap_sanity()
127 /* check that key = 2 doesn't exist */ test_arraymap_sanity()
128 assert(bpf_lookup_elem(map_fd, &key, &value) == -1 && errno == ENOENT); test_arraymap_sanity()
131 assert(bpf_get_next_key(map_fd, &key, &next_key) == 0 && test_arraymap_sanity()
139 key = 1; test_arraymap_sanity()
140 assert(bpf_delete_elem(map_fd, &key) == -1 && errno == EINVAL); test_arraymap_sanity()
152 } key; test_map_large() local
156 map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), test_map_large()
164 key = (struct bigkey) {.c = i}; test_map_large()
166 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0); test_map_large()
168 key.c = -1; test_map_large()
169 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && test_map_large()
174 assert(bpf_get_next_key(map_fd, &key, &key) == 0); test_map_large()
175 assert(bpf_get_next_key(map_fd, &key, &key) == -1 && errno == ENOENT); test_map_large()
177 key.c = 0; test_map_large()
178 assert(bpf_lookup_elem(map_fd, &key, &value) == 0 && value == 0); test_map_large()
179 key.a = 1; test_map_large()
180 assert(bpf_lookup_elem(map_fd, &key, &value) == -1 && errno == ENOENT); test_map_large()
223 int key, value; do_work() local
226 key = value = i; do_work()
228 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0); do_work()
230 assert(bpf_delete_elem(map_fd, &key) == 0); do_work()
236 int i, map_fd, key = 0, value = 0; test_map_parallel() local
239 map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value), test_map_parallel()
250 * child_0 adds key=0, key=1024, key=2048, ... test_map_parallel()
251 * child_1 adds key=1, key=1025, key=2049, ... test_map_parallel()
252 * child_1023 adds key=1023, ... test_map_parallel()
256 /* check that key=0 is already there */ test_map_parallel()
257 assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && test_map_parallel()
261 key = -1; test_map_parallel()
263 assert(bpf_get_next_key(map_fd, &key, &key) == 0); test_map_parallel()
264 assert(bpf_get_next_key(map_fd, &key, &key) == -1 && errno == ENOENT); test_map_parallel()
268 key = MAP_SIZE - i - 1; test_map_parallel()
269 assert(bpf_lookup_elem(map_fd, &key, &value) == 0 && test_map_parallel()
270 value == key); test_map_parallel()
278 key = -1; test_map_parallel()
279 assert(bpf_get_next_key(map_fd, &key, &key) == -1 && errno == ENOENT); test_map_parallel()
H A Dsockex1_user.c32 int key; main() local
34 key = IPPROTO_TCP; main()
35 assert(bpf_lookup_elem(map_fd[0], &key, &tcp_cnt) == 0); main()
37 key = IPPROTO_UDP; main()
38 assert(bpf_lookup_elem(map_fd[0], &key, &udp_cnt) == 0); main()
40 key = IPPROTO_ICMP; main()
41 assert(bpf_lookup_elem(map_fd[0], &key, &icmp_cnt) == 0); main()
H A Dtracex2_user.c25 int key; print_hist() local
33 for (key = 0; key < MAX_INDEX; key++) { print_hist()
34 bpf_lookup_elem(fd, &key, &value); print_hist()
35 data[key] = value; print_hist()
36 if (value && key > max_ind) print_hist()
37 max_ind = key; print_hist()
60 long key, next_key, value; main() local
82 key = 0; main()
83 while (bpf_get_next_key(map_fd[0], &key, &next_key) == 0) { main()
86 key = next_key; main()
88 if (key) main()
H A Dtracex3_user.c23 __u32 key; clear_stats() local
26 for (key = 0; key < SLOTS; key++) clear_stats()
27 bpf_update_elem(fd, &key, &value, BPF_ANY); clear_stats()
78 __u32 key; print_hist() local
84 for (key = 0; key < SLOTS; key++) { print_hist()
86 bpf_lookup_elem(fd, &key, &value); print_hist()
87 cnt[key] = value; print_hist()
93 for (key = full_range ? 0 : 29; key < SLOTS; key++) { print_hist()
94 int c = num_colors * cnt[key] / (max_cnt + 1); print_hist()
H A Dlibbpf.c34 int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags) bpf_update_elem() argument
38 .key = ptr_to_u64(key), bpf_update_elem()
46 int bpf_lookup_elem(int fd, void *key, void *value) bpf_lookup_elem() argument
50 .key = ptr_to_u64(key), bpf_lookup_elem()
57 int bpf_delete_elem(int fd, void *key) bpf_delete_elem() argument
61 .key = ptr_to_u64(key), bpf_delete_elem()
67 int bpf_get_next_key(int fd, void *key, void *next_key) bpf_get_next_key() argument
71 .key = ptr_to_u64(key), bpf_get_next_key()
H A Dtracex4_user.c34 __u64 key, next_key; print_old_objects() local
37 key = write(1, "\e[1;1H\e[2J", 12); /* clear screen */ print_old_objects()
39 key = -1; print_old_objects()
40 while (bpf_get_next_key(map_fd[0], &key, &next_key) == 0) { print_old_objects()
42 key = next_key; print_old_objects()
H A Dsock_example.c2 * - creates arraymap in kernel with key 4 bytes and value 8 bytes
33 int sock = -1, map_fd, prog_fd, i, key; test_sock() local
36 map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), test_sock()
74 key = IPPROTO_TCP; test_sock()
75 assert(bpf_lookup_elem(map_fd, &key, &tcp_cnt) == 0); test_sock()
77 key = IPPROTO_UDP; test_sock()
78 assert(bpf_lookup_elem(map_fd, &key, &udp_cnt) == 0); test_sock()
80 key = IPPROTO_ICMP; test_sock()
81 assert(bpf_lookup_elem(map_fd, &key, &icmp_cnt) == 0); test_sock()
H A Dsockex2_user.c36 int key = 0, next_key; main() local
39 while (bpf_get_next_key(map_fd[0], &key, &next_key) == 0) { main()
44 key = next_key; main()
/linux-4.1.27/fs/ubifs/
H A Dkey.h24 * This header contains various key-related definitions and helper function.
25 * UBIFS allows several key schemes, so we access key fields only via these
26 * helpers. At the moment only one key scheme is supported.
28 * Simple key scheme
32 * in case of direntry key). Next 3 bits are node type. The last 29 bits are
91 * ino_key_init - initialize inode key.
93 * @key: key to initialize
97 union ubifs_key *key, ino_t inum) ino_key_init()
99 key->u32[0] = inum; ino_key_init()
100 key->u32[1] = UBIFS_INO_KEY << UBIFS_S_KEY_BLOCK_BITS; ino_key_init()
104 * ino_key_init_flash - initialize on-flash inode key.
106 * @k: key to initialize
112 union ubifs_key *key = k; ino_key_init_flash() local
114 key->j32[0] = cpu_to_le32(inum); ino_key_init_flash()
115 key->j32[1] = cpu_to_le32(UBIFS_INO_KEY << UBIFS_S_KEY_BLOCK_BITS); ino_key_init_flash()
120 * lowest_ino_key - get the lowest possible inode key.
122 * @key: key to initialize
126 union ubifs_key *key, ino_t inum) lowest_ino_key()
128 key->u32[0] = inum; lowest_ino_key()
129 key->u32[1] = 0; lowest_ino_key()
133 * highest_ino_key - get the highest possible inode key.
135 * @key: key to initialize
139 union ubifs_key *key, ino_t inum) highest_ino_key()
141 key->u32[0] = inum; highest_ino_key()
142 key->u32[1] = 0xffffffff; highest_ino_key()
146 * dent_key_init - initialize directory entry key.
148 * @key: key to initialize
153 union ubifs_key *key, ino_t inum, dent_key_init()
159 key->u32[0] = inum; dent_key_init()
160 key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); dent_key_init()
164 * dent_key_init_hash - initialize directory entry key without re-calculating
167 * @key: key to initialize
172 union ubifs_key *key, ino_t inum, dent_key_init_hash()
176 key->u32[0] = inum; dent_key_init_hash()
177 key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); dent_key_init_hash()
181 * dent_key_init_flash - initialize on-flash directory entry key.
183 * @k: key to initialize
190 union ubifs_key *key = k; dent_key_init_flash() local
194 key->j32[0] = cpu_to_le32(inum); dent_key_init_flash()
195 key->j32[1] = cpu_to_le32(hash | dent_key_init_flash()
201 * lowest_dent_key - get the lowest possible directory entry key.
203 * @key: where to store the lowest key
207 union ubifs_key *key, ino_t inum) lowest_dent_key()
209 key->u32[0] = inum; lowest_dent_key()
210 key->u32[1] = UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS; lowest_dent_key()
214 * xent_key_init - initialize extended attribute entry key.
216 * @key: key to initialize
221 union ubifs_key *key, ino_t inum, xent_key_init()
227 key->u32[0] = inum; xent_key_init()
228 key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS); xent_key_init()
232 * xent_key_init_flash - initialize on-flash extended attribute entry key.
234 * @k: key to initialize
241 union ubifs_key *key = k; xent_key_init_flash() local
245 key->j32[0] = cpu_to_le32(inum); xent_key_init_flash()
246 key->j32[1] = cpu_to_le32(hash | xent_key_init_flash()
252 * lowest_xent_key - get the lowest possible extended attribute entry key.
254 * @key: where to store the lowest key
258 union ubifs_key *key, ino_t inum) lowest_xent_key()
260 key->u32[0] = inum; lowest_xent_key()
261 key->u32[1] = UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS; lowest_xent_key()
265 * data_key_init - initialize data key.
267 * @key: key to initialize
272 union ubifs_key *key, ino_t inum, data_key_init()
276 key->u32[0] = inum; data_key_init()
277 key->u32[1] = block | (UBIFS_DATA_KEY << UBIFS_S_KEY_BLOCK_BITS); data_key_init()
281 * highest_data_key - get the highest possible data key for an inode.
283 * @key: key to initialize
287 union ubifs_key *key, ino_t inum) highest_data_key()
289 data_key_init(c, key, inum, UBIFS_S_KEY_BLOCK_MASK); highest_data_key()
293 * trun_key_init - initialize truncation node key.
295 * @key: key to initialize
302 union ubifs_key *key, ino_t inum) trun_key_init()
304 key->u32[0] = inum; trun_key_init()
305 key->u32[1] = UBIFS_TRUN_KEY << UBIFS_S_KEY_BLOCK_BITS; trun_key_init()
309 * invalid_key_init - initialize invalid node key.
311 * @key: key to initialize
313 * This is a helper function which marks a @key object as invalid.
316 union ubifs_key *key) invalid_key_init()
318 key->u32[0] = 0xDEADBEAF; invalid_key_init()
319 key->u32[1] = UBIFS_INVALID_KEY; invalid_key_init()
323 * key_type - get key type.
325 * @key: key to get type of
328 const union ubifs_key *key) key_type()
330 return key->u32[1] >> UBIFS_S_KEY_BLOCK_BITS; key_type()
334 * key_type_flash - get type of a on-flash formatted key.
336 * @k: key to get type of
340 const union ubifs_key *key = k; key_type_flash() local
342 return le32_to_cpu(key->j32[1]) >> UBIFS_S_KEY_BLOCK_BITS; key_type_flash()
346 * key_inum - fetch inode number from key.
348 * @k: key to fetch inode number from
352 const union ubifs_key *key = k; key_inum() local
354 return key->u32[0]; key_inum()
358 * key_inum_flash - fetch inode number from an on-flash formatted key.
360 * @k: key to fetch inode number from
364 const union ubifs_key *key = k; key_inum_flash() local
366 return le32_to_cpu(key->j32[0]); key_inum_flash()
372 * @key: the key to get hash from
375 const union ubifs_key *key) key_hash()
377 return key->u32[1] & UBIFS_S_KEY_HASH_MASK; key_hash()
381 * key_hash_flash - get directory entry hash from an on-flash formatted key.
383 * @k: the key to get hash from
387 const union ubifs_key *key = k; key_hash_flash() local
389 return le32_to_cpu(key->j32[1]) & UBIFS_S_KEY_HASH_MASK; key_hash_flash()
395 * @key: the key to get the block number from
398 const union ubifs_key *key) key_block()
400 return key->u32[1] & UBIFS_S_KEY_BLOCK_MASK; key_block()
404 * key_block_flash - get data block number from an on-flash formatted key.
406 * @k: the key to get the block number from
411 const union ubifs_key *key = k; key_block_flash() local
413 return le32_to_cpu(key->j32[1]) & UBIFS_S_KEY_BLOCK_MASK; key_block_flash()
417 * key_read - transform a key to in-memory format.
419 * @from: the key to transform
420 * @to: the key to store the result
432 * key_write - transform a key from in-memory format.
434 * @from: the key to transform
435 * @to: the key to store the result
448 * key_write_idx - transform a key from in-memory format for the index.
450 * @from: the key to transform
451 * @to: the key to store the result
463 * key_copy - copy a key.
465 * @from: the key to copy from
466 * @to: the key to copy to
477 * @key1: the first key to compare
478 * @key2: the second key to compare
502 * @key1: the first key to compare
503 * @key2: the second key to compare
520 * is_hash_key - is a key vulnerable to hash collisions.
522 * @key: key
524 * This function returns %1 if @key is a hashed key or %0 otherwise.
527 const union ubifs_key *key) is_hash_key()
529 int type = key_type(c, key); is_hash_key()
535 * key_max_inode_size - get maximum file size allowed by current key format.
96 ino_key_init(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) ino_key_init() argument
125 lowest_ino_key(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) lowest_ino_key() argument
138 highest_ino_key(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) highest_ino_key() argument
152 dent_key_init(const struct ubifs_info *c, union ubifs_key *key, ino_t inum, const struct qstr *nm) dent_key_init() argument
171 dent_key_init_hash(const struct ubifs_info *c, union ubifs_key *key, ino_t inum, uint32_t hash) dent_key_init_hash() argument
206 lowest_dent_key(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) lowest_dent_key() argument
220 xent_key_init(const struct ubifs_info *c, union ubifs_key *key, ino_t inum, const struct qstr *nm) xent_key_init() argument
257 lowest_xent_key(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) lowest_xent_key() argument
271 data_key_init(const struct ubifs_info *c, union ubifs_key *key, ino_t inum, unsigned int block) data_key_init() argument
286 highest_data_key(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) highest_data_key() argument
301 trun_key_init(const struct ubifs_info *c, union ubifs_key *key, ino_t inum) trun_key_init() argument
315 invalid_key_init(const struct ubifs_info *c, union ubifs_key *key) invalid_key_init() argument
327 key_type(const struct ubifs_info *c, const union ubifs_key *key) key_type() argument
374 key_hash(const struct ubifs_info *c, const union ubifs_key *key) key_hash() argument
397 key_block(const struct ubifs_info *c, const union ubifs_key *key) key_block() argument
526 is_hash_key(const struct ubifs_info *c, const union ubifs_key *key) is_hash_key() argument
H A Dtnc_misc.c124 * @key: key to search for
127 * This is a helper function which search branch with key @key in @znode using
133 * greater than @key, then %-1 is returned in @n.
137 const union ubifs_key *key, int *n) ubifs_search_zbranch()
147 cmp = keys_cmp(c, key, &zbr[mid].key); ubifs_search_zbranch()
163 ubifs_assert(keys_cmp(c, key, &zbr[0].key) < 0); ubifs_search_zbranch()
165 ubifs_assert(keys_cmp(c, key, &zbr[*n].key) > 0); ubifs_search_zbranch()
167 ubifs_assert(keys_cmp(c, key, &zbr[*n + 1].key) < 0); ubifs_search_zbranch()
308 key_read(c, &br->key, &zbr->key); read_znode()
324 switch (key_type(c, &zbr->key)) { read_znode()
331 ubifs_err(c, "bad key type at slot %d: %d", read_znode()
332 i, key_type(c, &zbr->key)); read_znode()
340 type = key_type(c, &zbr->key); read_znode()
362 * Ensure that the next key is greater or equivalent to the read_znode()
368 key1 = &znode->zbranch[i].key; read_znode()
369 key2 = &znode->zbranch[i + 1].key; read_znode()
373 ubifs_err(c, "bad key order (keys %d and %d)", i, i + 1); read_znode()
451 * @zbr: key and position of the node
461 union ubifs_key key1, *key = &zbr->key; ubifs_tnc_read_node() local
462 int err, type = key_type(c, key); ubifs_tnc_read_node()
478 dbg_tnck(key, "key "); ubifs_tnc_read_node()
482 /* Make sure the key of the read node is correct */ ubifs_tnc_read_node()
484 if (!keys_eq(c, key, &key1)) { ubifs_tnc_read_node()
485 ubifs_err(c, "bad key in node at LEB %d:%d", ubifs_tnc_read_node()
487 dbg_tnck(key, "looked for key "); ubifs_tnc_read_node()
488 dbg_tnck(&key1, "but found node's key "); ubifs_tnc_read_node()
135 ubifs_search_zbranch(const struct ubifs_info *c, const struct ubifs_znode *znode, const union ubifs_key *key, int *n) ubifs_search_zbranch() argument
H A Dtnc.c322 ubifs_assert(is_hash_key(c, &zbr->key)); lnc_add()
384 * @zbr: key and position of the node
397 ubifs_assert(is_hash_key(c, &zbr->key)); tnc_read_node_nm()
480 * @key: key of node to read
487 static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, fallible_read_node() argument
492 dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs); fallible_read_node()
494 ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum, fallible_read_node()
500 /* All nodes have key in the same place */ fallible_read_node()
501 key_read(c, &dent->key, &node_key); fallible_read_node()
502 if (keys_cmp(c, key, &node_key) != 0) fallible_read_node()
506 dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ", fallible_read_node()
678 * @key: key of a directory or extended attribute entry
683 * This function is called for "hashed" keys to make sure that the found key
688 * This means that @n may be set to %-1 if the leftmost key in @zn is the
691 static int resolve_collision(struct ubifs_info *c, const union ubifs_key *key, resolve_collision() argument
714 if (keys_cmp(c, &(*zn)->zbranch[*n].key, key)) { resolve_collision()
742 * 'tnc_insert()' would correct the parent key. resolve_collision()
778 if (keys_cmp(c, &znode->zbranch[nn].key, key)) resolve_collision()
822 err = fallible_read_node(c, &zbr->key, zbr, dent); fallible_matches_name()
860 * @key: key
864 * @adding: indicates caller is adding a key to the TNC
880 const union ubifs_key *key, fallible_resolve_collision()
915 if (keys_cmp(c, &(*zn)->zbranch[*n].key, key)) { fallible_resolve_collision()
960 if (keys_cmp(c, &znode->zbranch[nn].key, key)) fallible_resolve_collision()
982 dbg_mntk(key, "dangling match LEB %d:%d len %d key ", fallible_resolve_collision()
1009 * @key: key of directory entry
1024 const union ubifs_key *key, resolve_collision_directly()
1043 if (keys_cmp(c, &znode->zbranch[nn].key, key)) resolve_collision_directly()
1061 if (keys_cmp(c, &znode->zbranch[nn].key, key)) resolve_collision_directly()
1075 * If we do not have a unique key that resides in a znode, then we cannot
1140 * @key: key to lookup
1145 * refers key @key. The found zero-level znode is returned in @zn. There are 3
1147 * o exact match, i.e. the found zero-level znode contains key @key, then %1
1150 * @key, then %0 is returned and slot number of the closest branch is stored
1152 * o @key is so small that it is even less than the lowest key of the
1159 int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, ubifs_lookup_level0() argument
1166 dbg_tnck(key, "search key "); ubifs_lookup_level0()
1167 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); ubifs_lookup_level0()
1181 exact = ubifs_search_zbranch(c, znode, key, n); ubifs_lookup_level0()
1203 if (exact || !is_hash_key(c, key) || *n != -1) { ubifs_lookup_level0()
1209 * Here is a tricky place. We have not found the key and this is a ubifs_lookup_level0()
1210 * "hashed" key, which may collide. The rest of the code deals with ubifs_lookup_level0()
1225 * In the examples, if we are looking for key "5", we may reach nodes ubifs_lookup_level0()
1227 * left and see if there is "5" key there. If there is, we have to ubifs_lookup_level0()
1231 * elements which are equivalent to the next key in the parent in the ubifs_lookup_level0()
1239 * And this becomes what is at the first "picture" after key "5" marked ubifs_lookup_level0()
1242 * removing the leftmost key, we would have to correct the key of the ubifs_lookup_level0()
1244 * if we changed the leftmost key of the parent znode, the garbage ubifs_lookup_level0()
1259 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { ubifs_lookup_level0()
1273 * @key: key to lookup
1278 * refers key @key. The found zero-level znode is returned in @zn. There are 3
1280 * o exact match, i.e. the found zero-level znode contains key @key, then %1
1282 * o not exact match, which means that zero-level znode does not contain @key
1285 * o @key is so small that it is even less than the lowest key of the
1295 static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key, lookup_level0_dirty() argument
1302 dbg_tnck(key, "search and dirty key "); lookup_level0_dirty()
1320 exact = ubifs_search_zbranch(c, znode, key, n); lookup_level0_dirty()
1347 if (exact || !is_hash_key(c, key) || *n != -1) { lookup_level0_dirty()
1364 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { lookup_level0_dirty()
1420 * @key: node key to lookup
1425 * This function looks up and reads node with key @key. The caller has to make
1430 int ubifs_tnc_locate(struct ubifs_info *c, const union ubifs_key *key, ubifs_tnc_locate() argument
1439 found = ubifs_lookup_level0(c, key, &znode, &n); ubifs_tnc_locate()
1452 if (is_hash_key(c, key)) { ubifs_tnc_locate()
1475 err = fallible_read_node(c, key, &zbr, node); ubifs_tnc_locate()
1508 unsigned int block = key_block(c, &bu->key); ubifs_tnc_get_bu_keys()
1516 /* Find first key */ ubifs_tnc_get_bu_keys()
1517 err = ubifs_lookup_level0(c, &bu->key, &znode, &n); ubifs_tnc_get_bu_keys()
1528 /* Add this key */ ubifs_tnc_get_bu_keys()
1536 union ubifs_key *key; ubifs_tnc_get_bu_keys() local
1539 /* Find next key */ ubifs_tnc_get_bu_keys()
1544 key = &zbr->key; ubifs_tnc_get_bu_keys()
1545 /* See if there is another data key for this file */ ubifs_tnc_get_bu_keys()
1546 if (key_inum(c, key) != key_inum(c, &bu->key) || ubifs_tnc_get_bu_keys()
1547 key_type(c, key) != UBIFS_DATA_KEY) { ubifs_tnc_get_bu_keys()
1552 /* First key found */ ubifs_tnc_get_bu_keys()
1574 next_block = key_block(c, key); ubifs_tnc_get_bu_keys()
1579 /* Add this key */ ubifs_tnc_get_bu_keys()
1616 block = key_block(c, &bu->key) + bu->blk_cnt; ubifs_tnc_get_bu_keys()
1619 if (key_block(c, &bu->zbranch[bu->cnt - 1].key) < block) ubifs_tnc_get_bu_keys()
1704 /* Make sure the key of the read node is correct */ validate_data_node()
1706 if (!keys_eq(c, &zbr->key, &key1)) { validate_data_node()
1707 ubifs_err(c, "bad key in node at LEB %d:%d", validate_data_node()
1709 dbg_tnck(&zbr->key, "looked for key "); validate_data_node()
1710 dbg_tnck(&key1, "found node's key "); validate_data_node()
1763 dbg_tnck(&bu->key, "key "); ubifs_tnc_bulk_read()
1782 * @key: node key to lookup
1786 * This function look up and reads a node which contains name hash in the key.
1788 * key, so we have to sequentially look to all of them until the needed one is
1792 static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, do_lookup_nm() argument
1798 dbg_tnck(key, "name '%.*s' key ", nm->len, nm->name); do_lookup_nm()
1800 found = ubifs_lookup_level0(c, key, &znode, &n); do_lookup_nm()
1811 err = resolve_collision(c, key, &znode, &n, nm); do_lookup_nm()
1830 * @key: node key to lookup
1834 * This function look up and reads a node which contains name hash in the key.
1836 * key, so we have to sequentially look to all of them until the needed one is
1840 int ubifs_tnc_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, ubifs_tnc_lookup_nm() argument
1850 err = ubifs_tnc_lookup(c, key, node); ubifs_tnc_lookup_nm()
1862 return do_lookup_nm(c, key, node, nm); ubifs_tnc_lookup_nm()
1870 * This is a helper function for 'tnc_insert()'. When the key of the leftmost
1877 union ubifs_key *key, *key1; correct_parent_keys() local
1882 key = &znode->zbranch[0].key; correct_parent_keys()
1883 key1 = &znode->parent->zbranch[0].key; correct_parent_keys()
1885 while (keys_cmp(c, key, key1) < 0) { correct_parent_keys()
1886 key_copy(c, key, key1); correct_parent_keys()
1891 key1 = &znode->parent->zbranch[0].key; correct_parent_keys()
1929 * After inserting at slot zero, the lower bound of the key range of insert_zbranch()
1931 * then the upper bound of the key range may change, and furthermore insert_zbranch()
1934 * TNC using the key from the index node on flash. That is bad because insert_zbranch()
1963 union ubifs_key *key = &zbr->key, *key1; tnc_insert() local
1972 dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level); tnc_insert()
1976 /* Ensure parent's key is correct */ tnc_insert()
1987 dbg_tnck(key, "splitting level %d, key ", znode->level); tnc_insert()
1991 * We can no longer be sure of finding this znode by key, so we tnc_insert()
2003 if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) { tnc_insert()
2006 key1 = &znode->zbranch[n - 1].key; tnc_insert()
2007 if (key_inum(c, key1) == key_inum(c, key) && tnc_insert()
2017 key1 = &znode->zbranch[0].key; tnc_insert()
2018 if (key_inum(c, key1) == key_inum(c, key) && tnc_insert()
2020 key1 = &znode->zbranch[n].key; tnc_insert()
2021 if (key_inum(c, key1) != key_inum(c, key) || tnc_insert()
2080 /* Insert new key and branch */ tnc_insert()
2081 dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level); tnc_insert()
2094 zbr->key = zn->zbranch[0].key; tnc_insert()
2117 zi->zbranch[0].key = znode->zbranch[0].key; tnc_insert()
2122 zi->zbranch[1].key = zn->zbranch[0].key; tnc_insert()
2141 * @key: key to add
2146 * This function adds a node with key @key to TNC. The node may be new or it may
2150 int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum, ubifs_tnc_add() argument
2157 dbg_tnck(key, "%d:%d, len %d, key ", lnum, offs, len); ubifs_tnc_add()
2158 found = lookup_level0_dirty(c, key, &znode, &n); ubifs_tnc_add()
2166 key_copy(c, key, &zbr.key); ubifs_tnc_add()
2188 * @key: key to add
2195 * This function replaces a node with key @key in the TNC only if the old node
2199 int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key, ubifs_tnc_replace() argument
2206 dbg_tnck(key, "old LEB %d:%d, new LEB %d:%d, len %d, key ", old_lnum, ubifs_tnc_replace()
2208 found = lookup_level0_dirty(c, key, &znode, &n); ubifs_tnc_replace()
2227 } else if (is_hash_key(c, key)) { ubifs_tnc_replace()
2228 found = resolve_collision_directly(c, key, &znode, &n, ubifs_tnc_replace()
2273 * @key: key to add
2282 int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key, ubifs_tnc_add_nm() argument
2289 dbg_tnck(key, "LEB %d:%d, name '%.*s', key ", ubifs_tnc_add_nm()
2291 found = lookup_level0_dirty(c, key, &znode, &n); ubifs_tnc_add_nm()
2299 found = fallible_resolve_collision(c, key, &znode, &n, ubifs_tnc_add_nm()
2302 found = resolve_collision(c, key, &znode, &n, nm); ubifs_tnc_add_nm()
2337 key_copy(c, key, &zbr.key); ubifs_tnc_add_nm()
2345 * by passing 'ubifs_tnc_remove_nm()' the same key but ubifs_tnc_add_nm()
2354 return ubifs_tnc_remove_nm(c, key, &noname); ubifs_tnc_add_nm()
2383 dbg_tnck(&znode->zbranch[n].key, "deleting key "); tnc_delete()
2483 * @key: key of node
2487 int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key) ubifs_tnc_remove() argument
2493 dbg_tnck(key, "key "); ubifs_tnc_remove()
2494 found = lookup_level0_dirty(c, key, &znode, &n); ubifs_tnc_remove()
2512 * @key: key of node
2517 int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key, ubifs_tnc_remove_nm() argument
2524 dbg_tnck(key, "%.*s, key ", nm->len, nm->name); ubifs_tnc_remove_nm()
2525 err = lookup_level0_dirty(c, key, &znode, &n); ubifs_tnc_remove_nm()
2531 err = fallible_resolve_collision(c, key, &znode, &n, ubifs_tnc_remove_nm()
2534 err = resolve_collision(c, key, &znode, &n, nm); ubifs_tnc_remove_nm()
2559 * key_in_range - determine if a key falls within a range of keys.
2561 * @key: key to check
2562 * @from_key: lowest key in range
2563 * @to_key: highest key in range
2565 * This function returns %1 if the key is in range and %0 otherwise.
2567 static int key_in_range(struct ubifs_info *c, union ubifs_key *key, key_in_range() argument
2570 if (keys_cmp(c, key, from_key) < 0) key_in_range()
2572 if (keys_cmp(c, key, to_key) > 0) key_in_range()
2580 * @from_key: lowest key to remove
2581 * @to_key: highest key to remove
2592 union ubifs_key *key; ubifs_tnc_remove_range() local
2602 key = from_key; ubifs_tnc_remove_range()
2611 key = &znode->zbranch[n].key; ubifs_tnc_remove_range()
2612 if (!key_in_range(c, key, from_key, to_key)) { ubifs_tnc_remove_range()
2629 key = &znode->zbranch[i].key; ubifs_tnc_remove_range()
2630 if (!key_in_range(c, key, from_key, to_key)) ubifs_tnc_remove_range()
2639 dbg_tnck(key, "removing key "); ubifs_tnc_remove_range()
2716 key_read(c, &xent->key, &key1); ubifs_tnc_remove_ino()
2729 * @key: key of last entry
2733 * after the given key (@key) if there is one. @nm is used to resolve
2736 * If the name of the current entry is not known and only the key is known,
2738 * little bit different and it returns the entry corresponding to this key, not
2739 * the next one. If the key was not found, the closest "right" entry is
2742 * If the fist entry has to be found, @key has to contain the lowest possible
2743 * key value for this inode and @name has to be %NULL.
2750 union ubifs_key *key, ubifs_tnc_next_ent()
2753 int n, err, type = key_type(c, key); ubifs_tnc_next_ent()
2759 dbg_tnck(key, "%s ", nm->name ? (char *)nm->name : "(lowest)"); ubifs_tnc_next_ent()
2760 ubifs_assert(is_hash_key(c, key)); ubifs_tnc_next_ent()
2763 err = ubifs_lookup_level0(c, key, &znode, &n); ubifs_tnc_next_ent()
2770 err = resolve_collision(c, key, &znode, &n, nm); ubifs_tnc_next_ent()
2789 * However, the given key does not exist in the TNC ubifs_tnc_next_ent()
2810 dkey = &zbr->key; ubifs_tnc_next_ent()
2811 if (key_inum(c, dkey) != key_inum(c, key) || ubifs_tnc_next_ent()
2950 * @key: index node key to lookup
2955 * This function searches an indexing node by its first key @key and its
2960 * looked for does not have to have exactly the same leftmost key @key, because
2961 * the leftmost key may have been changed, in which case TNC will contain a
2973 union ubifs_key *key, int level, lookup_znode()
2979 ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); lookup_znode()
3002 ubifs_search_zbranch(c, znode, key, &n); lookup_znode()
3005 * We reached a znode where the leftmost key is greater lookup_znode()
3006 * than the key we are searching for. This is the same lookup_znode()
3017 ubifs_search_zbranch(c, znode, key, &n); lookup_znode()
3029 /* If the key is unique, there is nowhere else to look */ lookup_znode()
3030 if (!is_hash_key(c, key)) lookup_znode()
3033 * The key is not unique and so may be also in the znodes to either lookup_znode()
3055 /* Stop if the key is less than the one we are looking for */ lookup_znode()
3056 if (keys_cmp(c, &znode->zbranch[n].key, key) < 0) lookup_znode()
3077 /* Stop if the key is greater than the one we are looking for */ lookup_znode()
3078 if (keys_cmp(c, &znode->zbranch[n].key, key) > 0) lookup_znode()
3087 * @key: key of index node
3097 * Note, the @key argument has to be the key of the first child. Also note,
3101 int is_idx_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, int level, is_idx_node_in_tnc() argument
3106 znode = lookup_znode(c, key, level, lnum, offs); is_idx_node_in_tnc()
3118 * @key: node key
3128 static int is_leaf_node_in_tnc(struct ubifs_info *c, union ubifs_key *key, is_leaf_node_in_tnc() argument
3134 const int unique = !is_hash_key(c, key); is_leaf_node_in_tnc()
3136 found = ubifs_lookup_level0(c, key, &znode, &n); is_leaf_node_in_tnc()
3147 * Because the key is not unique, we have to look left is_leaf_node_in_tnc()
3159 if (keys_cmp(c, key, &znode->zbranch[n].key)) is_leaf_node_in_tnc()
3175 if (keys_cmp(c, key, &znode->zbranch[n].key)) is_leaf_node_in_tnc()
3187 * @key: node key
3194 * negative error code in case of failure. For index nodes, @key has to be the
3195 * key of the first child. An index node is considered to be in the TNC only if
3198 int ubifs_tnc_has_node(struct ubifs_info *c, union ubifs_key *key, int level, ubifs_tnc_has_node() argument
3205 err = is_idx_node_in_tnc(c, key, level, lnum, offs); ubifs_tnc_has_node()
3217 err = is_leaf_node_in_tnc(c, key, lnum, offs); ubifs_tnc_has_node()
3227 * @key: index node key
3233 * collected. The @key argument has to be the key of the first child. This
3238 int ubifs_dirty_idx_node(struct ubifs_info *c, union ubifs_key *key, int level, ubifs_dirty_idx_node() argument
3245 znode = lookup_znode(c, key, level, lnum, offs); ubifs_dirty_idx_node()
3278 union ubifs_key from_key, to_key, *key; dbg_check_inode_size() local
3297 key = &from_key; dbg_check_inode_size()
3310 key = &znode->zbranch[n].key; dbg_check_inode_size()
3311 if (!key_in_range(c, key, &from_key, &to_key)) dbg_check_inode_size()
3315 block = key_block(c, key); dbg_check_inode_size()
879 fallible_resolve_collision(struct ubifs_info *c, const union ubifs_key *key, struct ubifs_znode **zn, int *n, const struct qstr *nm, int adding) fallible_resolve_collision() argument
1023 resolve_collision_directly(struct ubifs_info *c, const union ubifs_key *key, struct ubifs_znode **zn, int *n, int lnum, int offs) resolve_collision_directly() argument
2749 ubifs_tnc_next_ent(struct ubifs_info *c, union ubifs_key *key, const struct qstr *nm) ubifs_tnc_next_ent() argument
2972 lookup_znode(struct ubifs_info *c, union ubifs_key *key, int level, int lnum, int offs) lookup_znode() argument
/linux-4.1.27/include/uapi/linux/
H A Dkeyctl.h16 #define KEY_SPEC_THREAD_KEYRING -1 /* - key ID for thread-specific keyring */
17 #define KEY_SPEC_PROCESS_KEYRING -2 /* - key ID for process-specific keyring */
18 #define KEY_SPEC_SESSION_KEYRING -3 /* - key ID for session-specific keyring */
19 #define KEY_SPEC_USER_KEYRING -4 /* - key ID for UID-specific keyring */
20 #define KEY_SPEC_USER_SESSION_KEYRING -5 /* - key ID for UID-session keyring */
21 #define KEY_SPEC_GROUP_KEYRING -6 /* - key ID for GID-specific keyring */
22 #define KEY_SPEC_REQKEY_AUTH_KEY -7 /* - key ID for assumed request_key auth key */
23 #define KEY_SPEC_REQUESTOR_KEYRING -8 /* - key ID for request_key() dest keyring */
25 /* request-key default keyrings */
39 #define KEYCTL_UPDATE 2 /* update a key */
40 #define KEYCTL_REVOKE 3 /* revoke a key */
41 #define KEYCTL_CHOWN 4 /* set ownership of a key */
42 #define KEYCTL_SETPERM 5 /* set perms on a key */
43 #define KEYCTL_DESCRIBE 6 /* describe a key */
45 #define KEYCTL_LINK 8 /* link a key into a keyring */
46 #define KEYCTL_UNLINK 9 /* unlink a key from a keyring */
47 #define KEYCTL_SEARCH 10 /* search for a key in a keyring */
48 #define KEYCTL_READ 11 /* read a key or keyring's contents */
49 #define KEYCTL_INSTANTIATE 12 /* instantiate a partially constructed key */
50 #define KEYCTL_NEGATE 13 /* negate a partially constructed key */
51 #define KEYCTL_SET_REQKEY_KEYRING 14 /* set default request-key keyring */
52 #define KEYCTL_SET_TIMEOUT 15 /* set key timeout */
54 #define KEYCTL_GET_SECURITY 17 /* get key security label */
56 #define KEYCTL_REJECT 19 /* reject a partially constructed key */
57 #define KEYCTL_INSTANTIATE_IOV 20 /* instantiate a partially constructed key */
58 #define KEYCTL_INVALIDATE 21 /* invalidate a key */
/linux-4.1.27/security/keys/
H A Dkey.c1 /* Basic authentication token and access key management
30 unsigned int key_quota_root_maxkeys = 1000000; /* root's key count quota */
31 unsigned int key_quota_root_maxbytes = 25000000; /* root's key space quota */
32 unsigned int key_quota_maxkeys = 200; /* general key count quota */
33 unsigned int key_quota_maxbytes = 20000; /* general key space quota */
38 /* We serialise key instantiation and link */
42 void __key_check(const struct key *key) __key_check() argument
44 printk("__key_check: key %p {%08x} should be {%08x}\n", __key_check()
45 key, key->magic, KEY_DEBUG_MAGIC); __key_check()
51 * Get the key quota record for a user, allocating a new record if one doesn't
134 * Allocate a serial number for a key. These are assigned randomly to avoid
137 static inline void key_alloc_serial(struct key *key) key_alloc_serial() argument
140 struct key *xkey; key_alloc_serial()
145 get_random_bytes(&key->serial, sizeof(key->serial)); key_alloc_serial()
147 key->serial >>= 1; /* negative numbers are not permitted */ key_alloc_serial()
148 } while (key->serial < 3); key_alloc_serial()
158 xkey = rb_entry(parent, struct key, serial_node); key_alloc_serial()
160 if (key->serial < xkey->serial) key_alloc_serial()
162 else if (key->serial > xkey->serial) key_alloc_serial()
168 /* we've found a suitable hole - arrange for this key to occupy it */ key_alloc_serial()
169 rb_link_node(&key->serial_node, parent, p); key_alloc_serial()
170 rb_insert_color(&key->serial_node, &key_serial_tree); key_alloc_serial()
175 /* we found a key with the proposed serial number - walk the tree from key_alloc_serial()
179 key->serial++; key_alloc_serial()
180 if (key->serial < 3) { key_alloc_serial()
181 key->serial = 3; key_alloc_serial()
189 xkey = rb_entry(parent, struct key, serial_node); key_alloc_serial()
190 if (key->serial < xkey->serial) key_alloc_serial()
196 * key_alloc - Allocate a key of the specified type.
197 * @type: The type of key to allocate.
198 * @desc: The key description to allow the key to be searched out.
199 * @uid: The owner of the new key.
200 * @gid: The group ID for the new key's group permissions.
202 * @perm: The permissions mask of the new key.
205 * Allocate a key of the specified type with the attributes given. The key is
207 * key before returning.
209 * The user's key count quota is updated to reflect the creation of the key and
210 * the user's key data quota has the default for the key type reserved. The
214 * The LSM security modules can prevent a key being created, in which case
217 * Returns a pointer to the new key if successful and an error code otherwise.
219 * Note that the caller needs to ensure the key type isn't uninstantiated.
221 * be done by either never unregistering the key type, or making sure
224 struct key *key_alloc(struct key_type *type, const char *desc, key_alloc()
229 struct key *key; key_alloc() local
233 key = ERR_PTR(-EINVAL); key_alloc()
240 key = ERR_PTR(ret); key_alloc()
248 /* get hold of the key tracking for this user */ key_alloc()
253 /* check that the user's quota permits allocation of another key and key_alloc()
274 /* allocate and initialise the key and its description */ key_alloc()
275 key = kmem_cache_zalloc(key_jar, GFP_KERNEL); key_alloc()
276 if (!key) key_alloc()
279 key->index_key.desc_len = desclen; key_alloc()
280 key->index_key.description = kmemdup(desc, desclen + 1, GFP_KERNEL); key_alloc()
281 if (!key->description) key_alloc()
284 atomic_set(&key->usage, 1); key_alloc()
285 init_rwsem(&key->sem); key_alloc()
286 lockdep_set_class(&key->sem, &type->lock_class); key_alloc()
287 key->index_key.type = type; key_alloc()
288 key->user = user; key_alloc()
289 key->quotalen = quotalen; key_alloc()
290 key->datalen = type->def_datalen; key_alloc()
291 key->uid = uid; key_alloc()
292 key->gid = gid; key_alloc()
293 key->perm = perm; key_alloc()
296 key->flags |= 1 << KEY_FLAG_IN_QUOTA; key_alloc()
298 key->flags |= 1 << KEY_FLAG_TRUSTED; key_alloc()
301 key->magic = KEY_DEBUG_MAGIC; key_alloc()
304 /* let the security module know about the key */ key_alloc()
305 ret = security_key_alloc(key, cred, flags); key_alloc()
309 /* publish the key by giving it a serial number */ key_alloc()
311 key_alloc_serial(key); key_alloc()
314 return key; key_alloc()
317 kfree(key->description); key_alloc()
318 kmem_cache_free(key_jar, key); key_alloc()
326 key = ERR_PTR(ret); key_alloc()
330 kmem_cache_free(key_jar, key); key_alloc()
340 key = ERR_PTR(-ENOMEM); key_alloc()
346 key = ERR_PTR(-EDQUOT); key_alloc()
352 * key_payload_reserve - Adjust data quota reservation for the key's payload
353 * @key: The key to make the reservation for.
356 * Adjust the amount of the owning user's key data quota that a key reserves.
362 int key_payload_reserve(struct key *key, size_t datalen) key_payload_reserve() argument
364 int delta = (int)datalen - key->datalen; key_payload_reserve()
367 key_check(key); key_payload_reserve()
370 if (delta != 0 && test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { key_payload_reserve()
371 unsigned maxbytes = uid_eq(key->user->uid, GLOBAL_ROOT_UID) ? key_payload_reserve()
374 spin_lock(&key->user->lock); key_payload_reserve()
377 (key->user->qnbytes + delta >= maxbytes || key_payload_reserve()
378 key->user->qnbytes + delta < key->user->qnbytes)) { key_payload_reserve()
382 key->user->qnbytes += delta; key_payload_reserve()
383 key->quotalen += delta; key_payload_reserve()
385 spin_unlock(&key->user->lock); key_payload_reserve()
390 key->datalen = datalen; key_payload_reserve()
397 * Instantiate a key and link it into the target keyring atomically. Must be
398 * called with the target keyring's semaphore writelocked. The target key's
402 static int __key_instantiate_and_link(struct key *key, __key_instantiate_and_link() argument
404 struct key *keyring, __key_instantiate_and_link()
405 struct key *authkey, __key_instantiate_and_link()
410 key_check(key); __key_instantiate_and_link()
419 if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { __key_instantiate_and_link()
420 /* instantiate the key */ __key_instantiate_and_link()
421 ret = key->type->instantiate(key, prep); __key_instantiate_and_link()
424 /* mark the key as being instantiated */ __key_instantiate_and_link()
425 atomic_inc(&key->user->nikeys); __key_instantiate_and_link()
426 set_bit(KEY_FLAG_INSTANTIATED, &key->flags); __key_instantiate_and_link()
428 if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) __key_instantiate_and_link()
433 __key_link(key, _edit); __key_instantiate_and_link()
435 /* disable the authorisation key */ __key_instantiate_and_link()
440 key->expiry = prep->expiry; __key_instantiate_and_link()
448 /* wake up anyone waiting for a key to be constructed */ __key_instantiate_and_link()
450 wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT); __key_instantiate_and_link()
456 * key_instantiate_and_link - Instantiate a key and link it into the keyring.
457 * @key: The key to instantiate.
463 * Instantiate a key that's in the uninstantiated state using the provided data
468 * waiting for the key is woken up. If the key was already instantiated,
471 int key_instantiate_and_link(struct key *key, key_instantiate_and_link() argument
474 struct key *keyring, key_instantiate_and_link()
475 struct key *authkey) key_instantiate_and_link()
484 prep.quotalen = key->type->def_datalen; key_instantiate_and_link()
486 if (key->type->preparse) { key_instantiate_and_link()
487 ret = key->type->preparse(&prep); key_instantiate_and_link()
493 ret = __key_link_begin(keyring, &key->index_key, &edit); key_instantiate_and_link()
498 ret = __key_instantiate_and_link(key, &prep, keyring, authkey, &edit); key_instantiate_and_link()
501 __key_link_end(keyring, &key->index_key, edit); key_instantiate_and_link()
504 if (key->type->preparse) key_instantiate_and_link()
505 key->type->free_preparse(&prep); key_instantiate_and_link()
512 * key_reject_and_link - Negatively instantiate a key and link it into the keyring.
513 * @key: The key to instantiate.
514 * @timeout: The timeout on the negative key.
515 * @error: The error to return when the key is hit.
519 * Negatively instantiate a key that's in the uninstantiated state and, if
521 * destination keyring if one is supplied. The key and any links to the key
526 * key expires.
529 * waiting for the key is woken up. If the key was already instantiated,
532 int key_reject_and_link(struct key *key, key_reject_and_link() argument
535 struct key *keyring, key_reject_and_link()
536 struct key *authkey) key_reject_and_link()
542 key_check(key); key_reject_and_link()
549 link_ret = __key_link_begin(keyring, &key->index_key, &edit); key_reject_and_link()
554 if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { key_reject_and_link()
555 /* mark the key as being negatively instantiated */ key_reject_and_link()
556 atomic_inc(&key->user->nikeys); key_reject_and_link()
557 key->type_data.reject_error = -error; key_reject_and_link()
559 set_bit(KEY_FLAG_NEGATIVE, &key->flags); key_reject_and_link()
560 set_bit(KEY_FLAG_INSTANTIATED, &key->flags); key_reject_and_link()
562 key->expiry = now.tv_sec + timeout; key_reject_and_link()
563 key_schedule_gc(key->expiry + key_gc_delay); key_reject_and_link()
565 if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags)) key_reject_and_link()
572 __key_link(key, &edit); key_reject_and_link()
574 /* disable the authorisation key */ key_reject_and_link()
582 __key_link_end(keyring, &key->index_key, edit); key_reject_and_link()
584 /* wake up anyone waiting for a key to be constructed */ key_reject_and_link()
586 wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT); key_reject_and_link()
593 * key_put - Discard a reference to a key.
594 * @key: The key to discard a reference from.
596 * Discard a reference to a key, and when all the references are gone, we
600 void key_put(struct key *key) key_put() argument
602 if (key) { key_put()
603 key_check(key); key_put()
605 if (atomic_dec_and_test(&key->usage)) key_put()
612 * Find a key by its serial number.
614 struct key *key_lookup(key_serial_t id) key_lookup()
617 struct key *key; key_lookup() local
621 /* search the tree for the specified key */ key_lookup()
624 key = rb_entry(n, struct key, serial_node); key_lookup()
626 if (id < key->serial) key_lookup()
628 else if (id > key->serial) key_lookup()
635 key = ERR_PTR(-ENOKEY); key_lookup()
640 if (atomic_read(&key->usage) == 0) key_lookup()
644 * doesn't actually change the key key_lookup()
646 __key_get(key); key_lookup()
650 return key; key_lookup()
654 * Find and lock the specified key type against removal.
665 /* look up the key type to see if it's one of the registered kernel key_type_lookup()
679 void key_set_timeout(struct key *key, unsigned timeout) key_set_timeout() argument
685 down_write(&key->sem); key_set_timeout()
692 key->expiry = expiry; key_set_timeout()
693 key_schedule_gc(key->expiry + key_gc_delay); key_set_timeout()
695 up_write(&key->sem); key_set_timeout()
700 * Unlock a key type locked by key_type_lookup().
708 * Attempt to update an existing key.
710 * The key is given to us with an incremented refcount that we need to discard
716 struct key *key = key_ref_to_ptr(key_ref); __key_update() local
719 /* need write permission on the key to update it */ __key_update()
725 if (!key->type->update) __key_update()
728 down_write(&key->sem); __key_update()
730 ret = key->type->update(key, prep); __key_update()
732 /* updating a negative key instantiates it */ __key_update()
733 clear_bit(KEY_FLAG_NEGATIVE, &key->flags); __key_update()
735 up_write(&key->sem); __key_update()
743 key_put(key); __key_update()
749 * key_create_or_update - Update or create and instantiate a key.
751 * @type: The type of key.
752 * @description: The searchable description for the key.
753 * @payload: The data to use to instantiate or update the key.
755 * @perm: The permissions mask for a new key.
756 * @flags: The quota flags for a new key.
758 * Search the destination keyring for a key of the same description and if one
762 * If perm is KEY_PERM_UNDEF then an appropriate key permissions mask will be
765 * Returns a pointer to the new key if successful, -ENODEV if the key type
768 * creation of the key.
771 * the key ref before it is returned.
787 struct key *keyring, *key = NULL; key_create_or_update() local
791 /* look up the key type to see if it's one of the registered kernel key_create_or_update()
843 /* if we're going to allocate a new key, we're going to have key_create_or_update()
851 /* if it's possible to update this type of key, search for an existing key_create_or_update()
852 * key of the same type and description in the destination keyring and key_create_or_update()
874 /* allocate a new key */ key_create_or_update()
875 key = key_alloc(index_key.type, index_key.description, key_create_or_update()
877 if (IS_ERR(key)) { key_create_or_update()
878 key_ref = ERR_CAST(key); key_create_or_update()
883 ret = __key_instantiate_and_link(key, &prep, keyring, NULL, &edit); key_create_or_update()
885 key_put(key); key_create_or_update()
890 key_ref = make_key_ref(key, is_key_possessed(keyring_ref)); key_create_or_update()
903 /* we found a matching key, so we're going to try to update it key_create_or_update()
904 * - we can drop the locks first as we have the key pinned key_create_or_update()
914 * key_update - Update a key's contents.
915 * @key_ref: The pointer (plus possession flag) to the key.
916 * @payload: The data to be used to update the key.
919 * Attempt to update the contents of a key with the given payload data. The
920 * caller must be granted Write permission on the key. Negative keys can be
923 * Returns 0 on success, -EACCES if not permitted and -EOPNOTSUPP if the key
924 * type does not support updating. The key type may return other errors.
929 struct key *key = key_ref_to_ptr(key_ref); key_update() local
932 key_check(key); key_update()
934 /* the key must be writable */ key_update()
941 if (!key->type->update) key_update()
947 prep.quotalen = key->type->def_datalen; key_update()
949 if (key->type->preparse) { key_update()
950 ret = key->type->preparse(&prep); key_update()
955 down_write(&key->sem); key_update()
957 ret = key->type->update(key, &prep); key_update()
959 /* updating a negative key instantiates it */ key_update()
960 clear_bit(KEY_FLAG_NEGATIVE, &key->flags); key_update()
962 up_write(&key->sem); key_update()
965 if (key->type->preparse) key_update()
966 key->type->free_preparse(&prep); key_update()
972 * key_revoke - Revoke a key.
973 * @key: The key to be revoked.
975 * Mark a key as being revoked and ask the type to free up its resources. The
976 * revocation timeout is set and the key and all its links will be
980 void key_revoke(struct key *key) key_revoke() argument
985 key_check(key); key_revoke()
987 /* make sure no one's trying to change or use the key when we mark it key_revoke()
989 * authorisation key whilst holding the sem on a key we've just key_revoke()
992 down_write_nested(&key->sem, 1); key_revoke()
993 if (!test_and_set_bit(KEY_FLAG_REVOKED, &key->flags) && key_revoke()
994 key->type->revoke) key_revoke()
995 key->type->revoke(key); key_revoke()
1000 if (key->revoked_at == 0 || key->revoked_at > time) { key_revoke()
1001 key->revoked_at = time; key_revoke()
1002 key_schedule_gc(key->revoked_at + key_gc_delay); key_revoke()
1005 up_write(&key->sem); key_revoke()
1010 * key_invalidate - Invalidate a key.
1011 * @key: The key to be invalidated.
1013 * Mark a key as being invalidated and have it cleaned up immediately. The key
1016 void key_invalidate(struct key *key) key_invalidate() argument
1018 kenter("%d", key_serial(key)); key_invalidate()
1020 key_check(key); key_invalidate()
1022 if (!test_bit(KEY_FLAG_INVALIDATED, &key->flags)) { key_invalidate()
1023 down_write_nested(&key->sem, 1); key_invalidate()
1024 if (!test_and_set_bit(KEY_FLAG_INVALIDATED, &key->flags)) key_invalidate()
1026 up_write(&key->sem); key_invalidate()
1032 * generic_key_instantiate - Simple instantiation of a key from preparsed data
1033 * @key: The key to be instantiated
1036 * Instantiate a key from preparsed data. We assume we can just copy the data
1039 * This can be pointed to directly by the key type instantiate op pointer.
1041 int generic_key_instantiate(struct key *key, struct key_preparsed_payload *prep) generic_key_instantiate() argument
1047 ret = key_payload_reserve(key, prep->quotalen); generic_key_instantiate()
1049 key->type_data.p[0] = prep->type_data[0]; generic_key_instantiate()
1050 key->type_data.p[1] = prep->type_data[1]; generic_key_instantiate()
1051 rcu_assign_keypointer(key, prep->payload[0]); generic_key_instantiate()
1052 key->payload.data2[1] = prep->payload[1]; generic_key_instantiate()
1064 * register_key_type - Register a type of key.
1065 * @ktype: The new key type.
1067 * Register a new key type.
1081 /* disallow key types with the same name */ register_key_type()
1100 * unregister_key_type - Unregister a type of key.
1101 * @ktype: The key type.
1103 * Unregister a key type and mark all the extant keys of this type as dead.
1119 * Initialise the key management state.
1124 key_jar = kmem_cache_create("key_jar", sizeof(struct key), key_init()
1127 /* add the special key types */ key_init()
H A Dpermission.c17 * key_task_permission - Check a key can be used
18 * @key_ref: The key to check.
22 * Check to see whether permission is granted to use a key in the desired way,
33 struct key *key; key_task_permission() local
37 key = key_ref_to_ptr(key_ref); key_task_permission()
40 if (uid_eq(key->uid, cred->fsuid)) { key_task_permission()
41 kperm = key->perm >> 16; key_task_permission()
47 if (gid_valid(key->gid) && key->perm & KEY_GRP_ALL) { key_task_permission()
48 if (gid_eq(key->gid, cred->fsgid)) { key_task_permission()
49 kperm = key->perm >> 8; key_task_permission()
53 ret = groups_search(cred->group_info, key->gid); key_task_permission()
55 kperm = key->perm >> 8; key_task_permission()
61 kperm = key->perm; key_task_permission()
69 kperm |= key->perm >> 24; key_task_permission()
82 * key_validate - Validate a key.
83 * @key: The key to be validated.
85 * Check that a key is valid, returning 0 if the key is okay, -ENOKEY if the
86 * key is invalidated, -EKEYREVOKED if the key's type has been removed or if
87 * the key has been revoked or -EKEYEXPIRED if the key has expired.
89 int key_validate(const struct key *key) key_validate() argument
91 unsigned long flags = key->flags; key_validate()
102 if (key->expiry) { key_validate()
104 if (now.tv_sec >= key->expiry) key_validate()
H A Dproc.c1 /* procfs files for key database enumeration
72 p = proc_create("key-users", 0, NULL, &proc_key_users_fops); key_proc_init()
74 panic("Cannot create /proc/key-users\n"); key_proc_init()
91 struct key *key = rb_entry(n, struct key, serial_node); key_serial_next() local
92 if (kuid_has_mapping(user_ns, key->user->uid)) key_serial_next()
104 static struct key *find_ge_key(struct seq_file *p, key_serial_t id) find_ge_key()
108 struct key *minkey = NULL; find_ge_key()
111 struct key *key = rb_entry(n, struct key, serial_node); find_ge_key() local
112 if (id < key->serial) { find_ge_key()
113 if (!minkey || minkey->serial > key->serial) find_ge_key()
114 minkey = key; find_ge_key()
116 } else if (id > key->serial) { find_ge_key()
119 minkey = key; find_ge_key()
122 key = NULL; find_ge_key()
134 minkey = rb_entry(n, struct key, serial_node); find_ge_key()
142 struct key *key; __acquires() local
148 key = find_ge_key(p, pos); __acquires()
149 if (!key) __acquires()
151 *_pos = key->serial; __acquires()
152 return &key->serial_node; __acquires()
157 struct key *key = rb_entry(n, struct key, serial_node); key_node_serial() local
158 return key->serial; key_node_serial()
180 struct key *key = rb_entry(_p, struct key, serial_node); proc_keys_show() local
188 .index_key.type = key->type, proc_keys_show()
189 .index_key.description = key->description, proc_keys_show()
192 .match_data.raw_data = key, proc_keys_show()
197 key_ref = make_key_ref(key, 0); proc_keys_show()
199 /* determine if the key is possessed by this process (a test we can proc_keys_show()
200 * skip if the key does not indicate the possessor can view it proc_keys_show()
202 if (key->perm & KEY_POS_VIEW) { proc_keys_show()
206 key_ref = make_key_ref(key, 1); proc_keys_show()
210 /* check whether the current task is allowed to view the key (assuming proc_keys_show()
224 if (key->expiry == 0) { proc_keys_show()
226 } else if (now.tv_sec >= key->expiry) { proc_keys_show()
229 timo = key->expiry - now.tv_sec; proc_keys_show()
247 key->serial, proc_keys_show()
248 showflag(key, 'I', KEY_FLAG_INSTANTIATED), proc_keys_show()
249 showflag(key, 'R', KEY_FLAG_REVOKED), proc_keys_show()
250 showflag(key, 'D', KEY_FLAG_DEAD), proc_keys_show()
251 showflag(key, 'Q', KEY_FLAG_IN_QUOTA), proc_keys_show()
252 showflag(key, 'U', KEY_FLAG_USER_CONSTRUCT), proc_keys_show()
253 showflag(key, 'N', KEY_FLAG_NEGATIVE), proc_keys_show()
254 showflag(key, 'i', KEY_FLAG_INVALIDATED), proc_keys_show()
255 atomic_read(&key->usage), proc_keys_show()
257 key->perm, proc_keys_show()
258 from_kuid_munged(seq_user_ns(m), key->uid), proc_keys_show()
259 from_kgid_munged(seq_user_ns(m), key->gid), proc_keys_show()
260 key->type->name); proc_keys_show()
264 if (key->type->describe) proc_keys_show()
265 key->type->describe(key, m); proc_keys_show()
295 * Implement "/proc/key-users" to provides a list of the key users and their
H A Drequest_key.c1 /* Request a key from userspace
11 * See Documentation/security/keys-request-key.txt
22 #define key_negative_timeout 60 /* default timeout on a negative key's existence */
25 * complete_request_key - Complete the construction of a key.
26 * @cons: The key construction record.
29 * Complete the attempt to construct a key. The key will be negated
30 * if an error is indicated. The authorisation key will be revoked
35 kenter("{%d,%d},%d", cons->key->serial, cons->authkey->serial, error); complete_request_key()
38 key_negate_and_link(cons->key, key_negative_timeout, NULL, complete_request_key()
43 key_put(cons->key); complete_request_key()
58 struct key *keyring = info->data; umh_keys_init()
68 struct key *keyring = info->data; umh_keys_cleanup()
76 struct key *session_keyring, int wait) call_usermodehelper_keys()
91 * Request userspace finish the construction of a key
92 * - execute "/sbin/request-key <op> <key> <uid> <gid> <keyring> <keyring> <keyring>"
100 struct key *key = cons->key, *authkey = cons->authkey, *keyring, call_sbin_request_key() local
107 kenter("{%d},{%d},%s", key->serial, authkey->serial, op); call_sbin_request_key()
114 sprintf(desc, "_req.%u", key->serial); call_sbin_request_key()
126 /* attach the auth key to the session keyring */ call_sbin_request_key()
135 /* we say which key is under construction */ call_sbin_request_key()
136 sprintf(key_str, "%d", key->serial); call_sbin_request_key()
164 argv[i++] = "/sbin/request-key"; call_sbin_request_key()
180 if (test_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags) || call_sbin_request_key()
181 key_validate(key) < 0) call_sbin_request_key()
184 /* ignore any errors from userspace if the key was call_sbin_request_key()
199 * Call out to userspace for key construction.
201 * Program failure is ignored in favour of key status.
203 static int construct_key(struct key *key, const void *callout_info, construct_key() argument
205 struct key *dest_keyring) construct_key()
209 struct key *authkey; construct_key()
212 kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux); construct_key()
218 /* allocate an authorisation key */ construct_key()
219 authkey = request_key_auth_new(key, callout_info, callout_len, construct_key()
227 cons->key = key_get(key); construct_key()
231 if (key->type->request_key) construct_key()
232 actor = key->type->request_key; construct_key()
253 static void construct_get_dest_keyring(struct key **_dest_keyring) construct_get_dest_keyring()
257 struct key *dest_keyring = *_dest_keyring, *authkey; construct_get_dest_keyring()
324 * Allocate a new key in under-construction state and attempt to link it in to
327 * May return a key that's already under construction instead if there was a
331 struct key *dest_keyring, construct_alloc_key()
334 struct key **_key) construct_alloc_key()
337 struct key *key; construct_alloc_key() local
356 key = key_alloc(ctx->index_key.type, ctx->index_key.description, construct_alloc_key()
359 if (IS_ERR(key)) construct_alloc_key()
362 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); construct_alloc_key()
370 /* attach the key to the destination keyring under lock, but we do need construct_alloc_key()
380 __key_link(key, &edit); construct_alloc_key()
386 *_key = key; construct_alloc_key()
387 kleave(" = 0 [%d]", key_serial(key)); construct_alloc_key()
390 /* the key is now present - we tell the caller that we found it by construct_alloc_key()
393 key_put(key); construct_alloc_key()
395 key = key_ref_to_ptr(key_ref); construct_alloc_key()
397 ret = __key_link_check_live_key(dest_keyring, key); construct_alloc_key()
399 __key_link(key, &edit); construct_alloc_key()
405 *_key = key; construct_alloc_key()
406 kleave(" = -EINPROGRESS [%d]", key_serial(key)); construct_alloc_key()
411 key_put(key); construct_alloc_key()
417 key_put(key); construct_alloc_key()
423 kleave(" = %ld", PTR_ERR(key)); construct_alloc_key()
424 return PTR_ERR(key); construct_alloc_key()
428 * Commence key construction.
430 static struct key *construct_key_and_link(struct keyring_search_context *ctx, construct_key_and_link()
434 struct key *dest_keyring, construct_key_and_link()
438 struct key *key; construct_key_and_link() local
449 ret = construct_alloc_key(ctx, dest_keyring, flags, user, &key); construct_key_and_link()
453 ret = construct_key(key, callout_info, callout_len, aux, construct_key_and_link()
466 kleave(" = key %d", key_serial(key)); construct_key_and_link()
467 return key; construct_key_and_link()
470 key_negate_and_link(key, key_negative_timeout, NULL, NULL); construct_key_and_link()
471 key_put(key); construct_key_and_link()
479 * request_key_and_link - Request a key and cache it in a keyring.
480 * @type: The type of key we want.
481 * @description: The searchable description of the key.
485 * @dest_keyring: Where to cache the key.
488 * A key matching the specified criteria is searched for in the process's
490 * if callout_info is not NULL, a key will be allocated and some service
493 * If successfully found or created, the key will be linked to the destination
496 * Returns a pointer to the key if successful; -EACCES, -ENOKEY, -EKEYREVOKED
497 * or -EKEYEXPIRED if an inaccessible, negative, revoked or expired key was
498 * found; -ENOKEY if no key was found and no @callout_info was given; -EDQUOT
499 * if insufficient key quota was available to create a new key; or -ENOMEM if
502 * If the returned key was created, then it may still be under construction,
505 struct key *request_key_and_link(struct key_type *type, request_key_and_link()
510 struct key *dest_keyring, request_key_and_link()
523 struct key *key; request_key_and_link() local
534 key = ERR_PTR(ret); request_key_and_link()
539 /* search all the process keyrings for a key */ request_key_and_link()
543 key = key_ref_to_ptr(key_ref); request_key_and_link()
546 ret = key_link(dest_keyring, key); request_key_and_link()
549 key_put(key); request_key_and_link()
550 key = ERR_PTR(ret); request_key_and_link()
555 key = ERR_CAST(key_ref); request_key_and_link()
559 key = ERR_PTR(-ENOKEY); request_key_and_link()
563 key = construct_key_and_link(&ctx, callout_info, callout_len, request_key_and_link()
571 kleave(" = %p", key); request_key_and_link()
572 return key; request_key_and_link()
576 * wait_for_key_construction - Wait for construction of a key to complete
577 * @key: The key being waited for.
580 * Wait for a key to finish being constructed.
583 * if the key was negated; or -EKEYREVOKED or -EKEYEXPIRED if the key was
586 int wait_for_key_construction(struct key *key, bool intr) wait_for_key_construction() argument
590 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT, wait_for_key_construction()
594 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { wait_for_key_construction()
596 return key->type_data.reject_error; wait_for_key_construction()
598 return key_validate(key); wait_for_key_construction()
603 * request_key - Request a key and wait for construction
604 * @type: Type of key.
605 * @description: The searchable description of the key.
608 * As for request_key_and_link() except that it does not add the returned key
616 struct key *request_key(struct key_type *type, request_key()
620 struct key *key; request_key() local
626 key = request_key_and_link(type, description, callout_info, callout_len, request_key()
628 if (!IS_ERR(key)) { request_key()
629 ret = wait_for_key_construction(key, false); request_key()
631 key_put(key); request_key()
635 return key; request_key()
640 * request_key_with_auxdata - Request a key with auxiliary data for the upcaller
641 * @type: The type of key we want.
642 * @description: The searchable description of the key.
647 * As for request_key_and_link() except that it does not add the returned key
653 struct key *request_key_with_auxdata(struct key_type *type, request_key_with_auxdata()
659 struct key *key; request_key_with_auxdata() local
662 key = request_key_and_link(type, description, callout_info, callout_len, request_key_with_auxdata()
664 if (!IS_ERR(key)) { request_key_with_auxdata()
665 ret = wait_for_key_construction(key, false); request_key_with_auxdata()
667 key_put(key); request_key_with_auxdata()
671 return key; request_key_with_auxdata()
676 * request_key_async - Request a key (allow async construction)
677 * @type: Type of key.
678 * @description: The searchable description of the key.
682 * As for request_key_and_link() except that it does not add the returned key
687 * completion of the returned key if it is still undergoing construction.
689 struct key *request_key_async(struct key_type *type, request_key_async()
701 * request a key with auxiliary data for the upcaller (allow async construction)
702 * @type: Type of key.
703 * @description: The searchable description of the key.
708 * As for request_key_and_link() except that it does not add the returned key
712 * completion of the returned key if it is still undergoing construction.
714 struct key *request_key_async_with_auxdata(struct key_type *type, request_key_async_with_auxdata()
H A Duser_defined.c1 /* user_defined.c: user defined key type
42 * This key type is essentially the same as key_type_user, but it does
61 * Preparse a user defined key payload
85 * Free a preparse of a user defined key payload
94 * update a user defined key
95 * - the key's semaphore is write-locked
97 int user_update(struct key *key, struct key_preparsed_payload *prep) user_update() argument
119 ret = key_payload_reserve(key, datalen); user_update()
123 if (!test_bit(KEY_FLAG_NEGATIVE, &key->flags)) user_update()
124 zap = key->payload.data; user_update()
127 rcu_assign_keypointer(key, upayload); user_update()
128 key->expiry = 0; user_update()
142 * - called with the key sem write-locked
144 void user_revoke(struct key *key) user_revoke() argument
146 struct user_key_payload *upayload = key->payload.data; user_revoke()
149 key_payload_reserve(key, 0); user_revoke()
152 rcu_assign_keypointer(key, NULL); user_revoke()
160 * dispose of the data dangling from the corpse of a user key
162 void user_destroy(struct key *key) user_destroy() argument
164 struct user_key_payload *upayload = key->payload.data; user_destroy()
172 * describe the user key
174 void user_describe(const struct key *key, struct seq_file *m) user_describe() argument
176 seq_puts(m, key->description); user_describe()
177 if (key_is_instantiated(key)) user_describe()
178 seq_printf(m, ": %u", key->datalen); user_describe()
184 * read the key data
185 * - the key's semaphore is read-locked
187 long user_read(const struct key *key, char __user *buffer, size_t buflen) user_read() argument
192 upayload = rcu_dereference_key(key); user_read()
209 /* Vet the description for a "logon" key */ logon_vet_description()
H A Dgc.c19 * Delay between key revocation/expiry in seconds
39 #define KEY_GC_KEY_EXPIRED 0 /* A key expired and needs unlinking */
45 * Any key whose type gets unregistered will be re-typed to this if it can't be
84 * Some key's cleanup time was met after it expired, so we need to get the
130 struct key *key = key_gc_unused_keys() local
131 list_entry(keys->next, struct key, graveyard_link); key_gc_unused_keys()
132 list_del(&key->graveyard_link); key_gc_unused_keys()
134 kdebug("- %u", key->serial); key_gc_unused_keys()
135 key_check(key); key_gc_unused_keys()
137 /* Throw away the key data if the key is instantiated */ key_gc_unused_keys()
138 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags) && key_gc_unused_keys()
139 !test_bit(KEY_FLAG_NEGATIVE, &key->flags) && key_gc_unused_keys()
140 key->type->destroy) key_gc_unused_keys()
141 key->type->destroy(key); key_gc_unused_keys()
143 security_key_free(key); key_gc_unused_keys()
145 /* deal with the user's key tracking and quota */ key_gc_unused_keys()
146 if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { key_gc_unused_keys()
147 spin_lock(&key->user->lock); key_gc_unused_keys()
148 key->user->qnkeys--; key_gc_unused_keys()
149 key->user->qnbytes -= key->quotalen; key_gc_unused_keys()
150 spin_unlock(&key->user->lock); key_gc_unused_keys()
153 atomic_dec(&key->user->nkeys); key_gc_unused_keys()
154 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) key_gc_unused_keys()
155 atomic_dec(&key->user->nikeys); key_gc_unused_keys()
157 key_user_put(key->user); key_gc_unused_keys()
159 kfree(key->description); key_gc_unused_keys()
162 key->magic = KEY_DEBUG_MAGIC_X; key_gc_unused_keys()
164 kmem_cache_free(key_jar, key); key_gc_unused_keys()
183 #define KEY_GC_REAPING_DEAD_2 0x20 /* - We need to reap dead key links */ key_garbage_collector()
185 #define KEY_GC_FOUND_DEAD_KEY 0x80 /* - We found at least one dead key */ key_garbage_collector()
188 struct key *key; key_garbage_collector() local
211 /* As only this function is permitted to remove things from the key key_garbage_collector()
220 key = rb_entry(cursor, struct key, serial_node); key_garbage_collector()
223 if (atomic_read(&key->usage) == 0) key_garbage_collector()
227 if (key->type == key_gc_dead_keytype) { key_garbage_collector()
229 set_bit(KEY_FLAG_DEAD, &key->flags); key_garbage_collector()
230 key->perm = 0; key_garbage_collector()
236 if (key->expiry > limit && key->expiry < new_timer) { key_garbage_collector()
238 key_serial(key), key->expiry - limit); key_garbage_collector()
239 new_timer = key->expiry; key_garbage_collector()
244 if (key->type == key_gc_dead_keytype) key_garbage_collector()
249 if (key->type == &key_type_keyring) key_garbage_collector()
254 if (key->type == key_gc_dead_keytype) key_garbage_collector()
325 /* We found an unreferenced key - once we've removed it from the tree, key_garbage_collector()
329 kdebug("unrefd key %d", key->serial); key_garbage_collector()
330 rb_erase(&key->serial_node, &key_serial_tree); key_garbage_collector()
333 list_add_tail(&key->graveyard_link, &graveyard); key_garbage_collector()
344 keyring_gc(key, limit); key_garbage_collector()
347 /* We found a dead key that is still referenced. Reset its type and key_garbage_collector()
352 kdebug("destroy key %d", key->serial); key_garbage_collector()
353 down_write(&key->sem); key_garbage_collector()
354 key->type = &key_type_dead; key_garbage_collector()
356 key_gc_dead_keytype->destroy(key); key_garbage_collector()
357 memset(&key->payload, KEY_DESTROY, sizeof(key->payload)); key_garbage_collector()
358 up_write(&key->sem); key_garbage_collector()
H A DMakefile2 # Makefile for key management
10 key.o \
H A Drequest_key_auth.c1 /* Request key authorisation token key definition.
11 * See Documentation/security/keys-request-key.txt
25 static int request_key_auth_instantiate(struct key *,
27 static void request_key_auth_describe(const struct key *, struct seq_file *);
28 static void request_key_auth_revoke(struct key *);
29 static void request_key_auth_destroy(struct key *);
30 static long request_key_auth_read(const struct key *, char __user *, size_t);
33 * The request-key authorisation key type definition.
57 * Instantiate a request-key authorisation key.
59 static int request_key_auth_instantiate(struct key *key, request_key_auth_instantiate() argument
62 key->payload.data = (struct request_key_auth *)prep->data; request_key_auth_instantiate()
69 static void request_key_auth_describe(const struct key *key, request_key_auth_describe() argument
72 struct request_key_auth *rka = key->payload.data; request_key_auth_describe()
74 seq_puts(m, "key:"); request_key_auth_describe()
75 seq_puts(m, key->description); request_key_auth_describe()
76 if (key_is_instantiated(key)) request_key_auth_describe()
82 * - the key's semaphore is read-locked
84 static long request_key_auth_read(const struct key *key, request_key_auth_read() argument
87 struct request_key_auth *rka = key->payload.data; request_key_auth_read()
107 * Handle revocation of an authorisation token key.
109 * Called with the key sem write-locked.
111 static void request_key_auth_revoke(struct key *key) request_key_auth_revoke() argument
113 struct request_key_auth *rka = key->payload.data; request_key_auth_revoke()
115 kenter("{%d}", key->serial); request_key_auth_revoke()
124 * Destroy an instantiation authorisation token key.
126 static void request_key_auth_destroy(struct key *key) request_key_auth_destroy() argument
128 struct request_key_auth *rka = key->payload.data; request_key_auth_destroy()
130 kenter("{%d}", key->serial); request_key_auth_destroy()
144 * Create an authorisation token for /sbin/request-key or whoever to gain
147 struct key *request_key_auth_new(struct key *target, const void *callout_info, request_key_auth_new()
148 size_t callout_len, struct key *dest_keyring) request_key_auth_new()
152 struct key *authkey = NULL; request_key_auth_new()
171 /* see if the calling process is already servicing the key request of request_key_auth_new()
177 /* if the auth key has been revoked, then the key we're request_key_auth_new()
199 /* allocate the auth key */ request_key_auth_new()
211 /* construct the auth key */ request_key_auth_new()
239 * Search the current process's keyrings for the authorisation key for
240 * instantiation of a key.
242 struct key *key_get_instantiation_authkey(key_serial_t target_id) key_get_instantiation_authkey()
254 struct key *authkey; key_get_instantiation_authkey()
H A Dbig_key.c1 /* Large capacity key type
46 * Preparse a big key
69 * TODO: Encrypt the stored data with a temporary key. big_key_preparse()
85 /* Pin the mount and dentry to the key so that we can open it again big_key_preparse()
122 * - called with the key sem write-locked
124 void big_key_revoke(struct key *key) big_key_revoke() argument
126 struct path *path = (struct path *)&key->payload.data2; big_key_revoke()
129 key_payload_reserve(key, 0); big_key_revoke()
130 if (key_is_instantiated(key) && key->type_data.x[1] > BIG_KEY_FILE_THRESHOLD) big_key_revoke()
135 * dispose of the data dangling from the corpse of a big_key key
137 void big_key_destroy(struct key *key) big_key_destroy() argument
139 if (key->type_data.x[1] > BIG_KEY_FILE_THRESHOLD) { big_key_destroy()
140 struct path *path = (struct path *)&key->payload.data2; big_key_destroy()
145 kfree(key->payload.data); big_key_destroy()
146 key->payload.data = NULL; big_key_destroy()
151 * describe the big_key key
153 void big_key_describe(const struct key *key, struct seq_file *m) big_key_describe() argument
155 unsigned long datalen = key->type_data.x[1]; big_key_describe()
157 seq_puts(m, key->description); big_key_describe()
159 if (key_is_instantiated(key)) big_key_describe()
166 * read the key data
167 * - the key's semaphore is read-locked
169 long big_key_read(const struct key *key, char __user *buffer, size_t buflen) big_key_read() argument
171 unsigned long datalen = key->type_data.x[1]; big_key_read()
178 struct path *path = (struct path *)&key->payload.data2; big_key_read()
193 if (copy_to_user(buffer, key->payload.data, datalen) != 0) big_key_read()
H A Dinternal.h1 /* Authentication token and access key management internal defs
16 #include <linux/key-type.h>
91 extern int __key_link_begin(struct key *keyring,
94 extern int __key_link_check_live_key(struct key *keyring, struct key *key);
95 extern void __key_link(struct key *key, struct assoc_array_edit **_edit);
96 extern void __key_link_end(struct key *keyring,
103 extern struct key *keyring_search_instkey(struct key *keyring,
106 extern int iterate_over_keyring(const struct key *keyring,
107 int (*func)(const struct key *key, void *data),
131 extern bool key_default_cmp(const struct key *key,
139 extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check);
144 extern int install_session_keyring_to_cred(struct cred *, struct key *);
146 extern struct key *request_key_and_link(struct key_type *type,
151 struct key *dest_keyring,
154 extern bool lookup_user_key_possessed(const struct key *key,
167 extern void keyring_gc(struct key *keyring, time_t limit);
177 * Check to see whether permission is granted to use a key in the desired way.
188 struct key *target_key;
189 struct key *dest_keyring;
197 extern struct key *request_key_auth_new(struct key *target,
200 struct key *dest_keyring);
202 extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
205 * Determine whether a key is dead.
207 static inline bool key_is_dead(const struct key *key, time_t limit) key_is_dead() argument
210 key->flags & ((1 << KEY_FLAG_DEAD) | key_is_dead()
212 (key->expiry > 0 && key->expiry <= limit); key_is_dead()
261 * Debugging key validation
264 extern void __key_check(const struct key *);
266 static inline void key_check(const struct key *key) key_check() argument
268 if (key && (IS_ERR(key) || key->magic != KEY_DEBUG_MAGIC)) key_check()
269 __key_check(key); key_check()
274 #define key_check(key) do {} while(0)
H A Dkeyctl.c1 /* Userspace key control operations
17 #include <linux/key.h>
49 * Extract the description of a new key from userspace and either add it as a
50 * new key to the specified keyring or update a matching key in that keyring.
52 * If the description is NULL or an empty string, the key type is asked to
55 * The keyring must be writable so that we can attach the key to it.
57 * If successful, the new key's serial number is returned, otherwise an error
126 /* create or update the requested key and add it to the target SYSCALL_DEFINE5()
153 * matching key. Keyrings must have appropriate Search permission to be
156 * If a key is found, it will be attached to the destination keyring if there's
157 * one specified and the serial number of the key will be returned.
159 * If no key is found, /sbin/request-key will be invoked if _callout_info is
160 * non-NULL in an attempt to create a key. The _callout_info string will be
161 * passed to /sbin/request-key to aid with completing the request. If the
170 struct key *key; SYSCALL_DEFINE4() local
211 /* find the key type */ SYSCALL_DEFINE4()
219 key = request_key_and_link(ktype, description, callout_info, SYSCALL_DEFINE4()
222 if (IS_ERR(key)) { SYSCALL_DEFINE4()
223 ret = PTR_ERR(key); SYSCALL_DEFINE4()
227 /* wait for the key to finish being constructed */ SYSCALL_DEFINE4()
228 ret = wait_for_key_construction(key, 1); SYSCALL_DEFINE4()
232 ret = key->serial; SYSCALL_DEFINE4()
235 key_put(key); SYSCALL_DEFINE4()
308 * Update a key's data payload from the given data.
310 * The key must grant the caller Write permission and the key type must support
311 * updating for this to work. A negative key can be positively instantiated
314 * If successful, 0 will be returned. If the key type does not support
342 /* find the target key (which must be writable) */ keyctl_update_key()
349 /* update the key */ keyctl_update_key()
360 * Revoke a key.
362 * The key must be grant the caller Write or Setattr permission for this to
363 * work. The key type should give up its quota claim when revoked. The key
364 * and any links to the key will be automatically garbage collected after a
395 * Invalidate a key.
397 * The key must be grant the caller Invalidate permission for this to work.
398 * The key and any links to the key will be automatically garbage collected
477 * Create a link from a keyring to a key if there's no matching key in the
478 * keyring, otherwise replace the link to the matching key with a link to the
479 * new key.
481 * The key must grant the caller Link permission and the the keyring must grant
514 * Unlink a key from a keyring.
516 * The keyring must grant the caller Write permission for this to work; the key
517 * itself need not grant the caller anything. If the last link to a key is
518 * removed then that key will be scheduled for destruction.
549 * Return a description of a key to userspace.
551 * The key must grant the caller View permission for this to work.
565 struct key *key, *instkey; keyctl_describe_key() local
573 /* viewing a key under construction is permitted if we have the keyctl_describe_key()
592 key = key_ref_to_ptr(key_ref); keyctl_describe_key()
593 desclen = strlen(key->description); keyctl_describe_key()
599 key->type->name, keyctl_describe_key()
600 from_kuid_munged(current_user_ns(), key->uid), keyctl_describe_key()
601 from_kgid_munged(current_user_ns(), key->gid), keyctl_describe_key()
602 key->perm); keyctl_describe_key()
611 copy_to_user(buffer + infolen, key->description, keyctl_describe_key()
625 * key. Only keyrings that grant the caller Search permission will be searched
629 * If successful, the found key will be linked to the destination keyring if
630 * supplied and the key has Link permission, and the found key ID will be
672 /* find the key type */ keyctl_keyring_search()
684 /* treat lack or presence of a negative key the same */ keyctl_keyring_search()
690 /* link the resulting key to the destination keyring if we can */ keyctl_keyring_search()
718 * Read a key's payload.
720 * The key must either grant the caller Read permission, or it must grant the
724 * is provided, and return the amount of data that is available in the key,
729 struct key *key; keyctl_read_key() local
733 /* find the key first */ keyctl_read_key()
740 key = key_ref_to_ptr(key_ref); keyctl_read_key()
751 * dangling off an instantiation key keyctl_read_key()
758 /* the key is probably readable - now try to read it */ keyctl_read_key()
761 if (key->type->read) { keyctl_read_key()
763 * to protect against the key being updated or revoked. keyctl_read_key()
765 down_read(&key->sem); keyctl_read_key()
766 ret = key_validate(key); keyctl_read_key()
768 ret = key->type->read(key, buffer, buflen); keyctl_read_key()
769 up_read(&key->sem); keyctl_read_key()
773 key_put(key); keyctl_read_key()
779 * Change the ownership of a key
781 * The key must grant the caller Setattr permission for this to work, though
782 * the key need not be fully instantiated yet. For the UID to be changed, or
788 * accept the key. The quota deduction will be removed from the old user to
796 struct key *key; keyctl_chown_key() local
821 key = key_ref_to_ptr(key_ref); keyctl_chown_key()
825 down_write(&key->sem); keyctl_chown_key()
828 /* only the sysadmin can chown a key to some other UID */ keyctl_chown_key()
829 if (user != (uid_t) -1 && !uid_eq(key->uid, uid)) keyctl_chown_key()
832 /* only the sysadmin can set the key's GID to a group other keyctl_chown_key()
834 if (group != (gid_t) -1 && !gid_eq(gid, key->gid) && !in_group_p(gid)) keyctl_chown_key()
839 if (user != (uid_t) -1 && !uid_eq(uid, key->uid)) { keyctl_chown_key()
846 if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { keyctl_chown_key()
854 newowner->qnbytes + key->quotalen >= maxbytes || keyctl_chown_key()
855 newowner->qnbytes + key->quotalen < keyctl_chown_key()
860 newowner->qnbytes += key->quotalen; keyctl_chown_key()
863 spin_lock(&key->user->lock); keyctl_chown_key()
864 key->user->qnkeys--; keyctl_chown_key()
865 key->user->qnbytes -= key->quotalen; keyctl_chown_key()
866 spin_unlock(&key->user->lock); keyctl_chown_key()
869 atomic_dec(&key->user->nkeys); keyctl_chown_key()
872 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) { keyctl_chown_key()
873 atomic_dec(&key->user->nikeys); keyctl_chown_key()
877 zapowner = key->user; keyctl_chown_key()
878 key->user = newowner; keyctl_chown_key()
879 key->uid = uid; keyctl_chown_key()
884 key->gid = gid; keyctl_chown_key()
889 up_write(&key->sem); keyctl_chown_key()
890 key_put(key); keyctl_chown_key()
904 * Change the permission mask on a key.
906 * The key must grant the caller Setattr permission for this to work, though
907 * the key need not be fully instantiated yet. If the caller does not have
912 struct key *key; keyctl_setperm_key() local
927 key = key_ref_to_ptr(key_ref); keyctl_setperm_key()
931 down_write(&key->sem); keyctl_setperm_key()
933 /* if we're not the sysadmin, we can only change a key that we own */ keyctl_setperm_key()
934 if (capable(CAP_SYS_ADMIN) || uid_eq(key->uid, current_fsuid())) { keyctl_setperm_key()
935 key->perm = perm; keyctl_setperm_key()
939 up_write(&key->sem); keyctl_setperm_key()
940 key_put(key); keyctl_setperm_key()
951 struct key **_dest_keyring) get_instantiation_keyring()
974 * authorisation key (any KEY_SPEC_*_KEYRING) */ get_instantiation_keyring()
984 * Change the request_key authorisation key on the current process.
986 static int keyctl_change_reqkey_auth(struct key *key) keyctl_change_reqkey_auth() argument
995 new->request_key_auth = key_get(key); keyctl_change_reqkey_auth()
1001 * Instantiate a key with the specified payload and link the key into the
1015 struct key *instkey, *dest_keyring; keyctl_instantiate_key_common()
1029 /* the appropriate instantiation authorisation key must have been keyctl_instantiate_key_common()
1065 /* instantiate the key and link it into a keyring */ keyctl_instantiate_key_common()
1072 * instantiation of the key */ keyctl_instantiate_key_common()
1083 * Instantiate a key with the specified payload and link the key into the
1113 * Instantiate a key with the specified multipart payload and link the key into
1143 * Negatively instantiate the key with the given timeout (in seconds) and link
1144 * the key into the destination keyring if one is given.
1149 * The key and any links to the key will be automatically garbage collected
1153 * them to return -ENOKEY until the negative key expires.
1163 * Negatively instantiate the key with the given timeout (in seconds) and error
1164 * code and link the key into the destination keyring if one is given.
1169 * The key and any links to the key will be automatically garbage collected
1173 * them to return the specified error code until the negative key expires.
1182 struct key *instkey, *dest_keyring; keyctl_reject_key()
1196 /* the appropriate instantiation authorisation key must have been keyctl_reject_key()
1213 /* instantiate the key and link it into a keyring */ keyctl_reject_key()
1220 * instantiation of the key */ keyctl_reject_key()
1289 * Set or clear the timeout on a key.
1291 * Either the key must grant the caller Setattr permission or else the caller
1292 * must hold an instantiation authorisation token for the key.
1295 * the current time. The key and any links to the key will be automatically
1302 struct key *key, *instkey; keyctl_set_timeout() local
1309 /* setting the timeout on a key under construction is permitted keyctl_set_timeout()
1328 key = key_ref_to_ptr(key_ref); keyctl_set_timeout()
1329 key_set_timeout(key, timeout); keyctl_set_timeout()
1330 key_put(key); keyctl_set_timeout()
1338 * Assume (or clear) the authority to instantiate the specified key.
1340 * This sets the authoritative token currently in force for key instantiation.
1341 * This must be done for a key to be instantiated. It has the effect of making
1343 * key to request_key() calls made by the caller of this function.
1345 * The caller must have the instantiation key in their process keyrings with a
1350 * If the ID given has a matching an authorisation key, then that key will be
1351 * set and its ID will be returned. The authorisation key can be read to get
1356 struct key *authkey; keyctl_assume_authority()
1359 /* special key IDs aren't permitted */ keyctl_assume_authority()
1371 * instantiate the specified key keyctl_assume_authority()
1372 * - the authorisation key must be in the current task's keyrings keyctl_assume_authority()
1392 * Get a key's the LSM security label.
1394 * The key must grant the caller View permission for this to work.
1405 struct key *key, *instkey; keyctl_get_security() local
1415 /* viewing a key under construction is also permitted if we keyctl_get_security()
1427 key = key_ref_to_ptr(key_ref); keyctl_get_security()
1428 ret = security_key_getsecurity(key, &context); keyctl_get_security()
1557 * The key control system call
H A Dprocess_keys.c47 struct key *uid_keyring, *session_keyring; install_user_keyrings()
133 struct key *keyring; install_thread_keyring_to_cred()
176 struct key *keyring; install_process_keyring_to_cred()
219 int install_session_keyring_to_cred(struct cred *cred, struct key *keyring) install_session_keyring_to_cred()
222 struct key *old; install_session_keyring_to_cred()
255 static int install_session_keyring(struct key *keyring) install_session_keyring()
303 * matching key.
308 * parameter to the key's description.
315 * Returns a pointer to the key with the key usage count incremented if
316 * successful, -EAGAIN if we didn't find any matching key or -ENOKEY if we only
320 * returned key reference.
327 * searchable, but we failed to find a key or we found a negative key; search_my_process_keyrings()
345 case -EAGAIN: /* no key */ search_my_process_keyrings()
346 case -ENOKEY: /* negative key */ search_my_process_keyrings()
363 case -EAGAIN: /* no key */ search_my_process_keyrings()
366 case -ENOKEY: /* negative key */ search_my_process_keyrings()
387 case -EAGAIN: /* no key */ search_my_process_keyrings()
390 case -ENOKEY: /* negative key */ search_my_process_keyrings()
407 case -EAGAIN: /* no key */ search_my_process_keyrings()
410 case -ENOKEY: /* negative key */ search_my_process_keyrings()
419 /* no key - decide on the error we're going to go for */ search_my_process_keyrings()
428 * matching key in the manner of search_my_process_keyrings(), but also search
429 * the keys attached to the assumed authorisation key using its credentials if
446 /* if this process has an instantiation authorisation key, then we also search_process_keyrings()
456 /* defend against the auth key being revoked */ search_process_keyrings()
477 /* no key - decide on the error we're going to go for */ search_process_keyrings()
490 * See if the key we're looking at is the target key.
492 bool lookup_user_key_possessed(const struct key *key, lookup_user_key_possessed() argument
495 return key == match_data->raw_data; lookup_user_key_possessed()
499 * Look up a key ID given us by userspace with a given permissions mask to get
500 * the key it refers to.
504 * validity and permission checks on the found key.
506 * Returns a pointer to the key with an incremented usage count if successful;
507 * -EINVAL if the key ID is invalid; -ENOKEY if the key ID does not correspond
508 * to a key or the best found key was a negative key; -EKEYREVOKED or
509 * -EKEYEXPIRED if the best found key was revoked or expired; -EACCES if the
510 * found key doesn't grant the requested permit or the LSM denied access to it;
514 * returned key reference.
525 struct key *key; lookup_user_key() local
547 key = ctx.cred->thread_keyring; lookup_user_key()
548 __key_get(key); lookup_user_key()
549 key_ref = make_key_ref(key, 1); lookup_user_key()
565 key = ctx.cred->process_keyring; lookup_user_key()
566 __key_get(key); lookup_user_key()
567 key_ref = make_key_ref(key, 1); lookup_user_key()
596 key = rcu_dereference(ctx.cred->session_keyring); lookup_user_key()
597 __key_get(key); lookup_user_key()
599 key_ref = make_key_ref(key, 1); lookup_user_key()
609 key = ctx.cred->user->uid_keyring; lookup_user_key()
610 __key_get(key); lookup_user_key()
611 key_ref = make_key_ref(key, 1); lookup_user_key()
621 key = ctx.cred->user->session_keyring; lookup_user_key()
622 __key_get(key); lookup_user_key()
623 key_ref = make_key_ref(key, 1); lookup_user_key()
632 key = ctx.cred->request_key_auth; lookup_user_key()
633 if (!key) lookup_user_key()
636 __key_get(key); lookup_user_key()
637 key_ref = make_key_ref(key, 1); lookup_user_key()
648 key = NULL; lookup_user_key()
651 key = rka->dest_keyring; lookup_user_key()
652 __key_get(key); lookup_user_key()
655 if (!key) lookup_user_key()
657 key_ref = make_key_ref(key, 1); lookup_user_key()
665 key = key_lookup(id); lookup_user_key()
666 if (IS_ERR(key)) { lookup_user_key()
667 key_ref = ERR_CAST(key); lookup_user_key()
671 key_ref = make_key_ref(key, 0); lookup_user_key()
673 /* check to see if we possess the key */ lookup_user_key()
674 ctx.index_key.type = key->type; lookup_user_key()
675 ctx.index_key.description = key->description; lookup_user_key()
676 ctx.index_key.desc_len = strlen(key->description); lookup_user_key()
677 ctx.match_data.raw_data = key; lookup_user_key()
683 key_put(key); lookup_user_key()
690 /* unlink does not use the nominated key in any way, so can skip all lookup_user_key()
698 ret = wait_for_key_construction(key, true); lookup_user_key()
709 ret = key_validate(key); lookup_user_key()
716 !test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) lookup_user_key()
724 key->last_used_at = current_kernel_time().tv_sec; lookup_user_key()
757 struct key *keyring; join_session_keyring()
H A Dkeyring.c26 * When plumbing the depths of the key tree, this sets a hard limit
46 static inline struct key *keyring_ptr_to_key(const struct assoc_array_ptr *x) keyring_ptr_to_key()
49 return (struct key *)((unsigned long)object & ~KEYRING_PTR_SUBTYPE); keyring_ptr_to_key()
51 static inline void *keyring_key_to_ptr(struct key *key) keyring_key_to_ptr() argument
53 if (key->type == &key_type_keyring) keyring_key_to_ptr()
54 return (void *)((unsigned long)key | KEYRING_PTR_SUBTYPE); keyring_key_to_ptr()
55 return key; keyring_key_to_ptr()
72 * The keyring key type definition. Keyrings are simply keys of this type and
78 static int keyring_instantiate(struct key *keyring,
80 static void keyring_revoke(struct key *keyring);
81 static void keyring_destroy(struct key *keyring);
82 static void keyring_describe(const struct key *keyring, struct seq_file *m);
83 static long keyring_read(const struct key *keyring,
109 static void keyring_publish_name(struct key *keyring) keyring_publish_name()
137 * Free a preparse of a user defined key payload
148 static int keyring_instantiate(struct key *keyring, keyring_instantiate()
169 * Hash a key type and description.
216 * Build the next index key chunk.
218 * On 32-bit systems the index key is laid out as:
274 const struct key *key = keyring_ptr_to_key(object); keyring_get_object_key_chunk() local
275 return keyring_get_key_chunk(&key->index_key, level); keyring_get_object_key_chunk()
281 const struct key *key = keyring_ptr_to_key(object); keyring_compare_object() local
283 return key->index_key.type == index_key->type && keyring_compare_object()
284 key->index_key.desc_len == index_key->desc_len && keyring_compare_object()
285 memcmp(key->index_key.description, index_key->description, keyring_compare_object()
295 const struct key *key_a = keyring_ptr_to_key(object); keyring_diff_objects()
385 static void keyring_destroy(struct key *keyring) keyring_destroy()
403 static void keyring_describe(const struct key *keyring, struct seq_file *m) keyring_describe()
427 const struct key *key = keyring_ptr_to_key(object); keyring_read_iterator() local
431 key->type->name, key->serial, ctx->count, ctx->qty); keyring_read_iterator()
436 ret = put_user(key->serial, ctx->buffer); keyring_read_iterator()
440 ctx->count += sizeof(key->serial); keyring_read_iterator()
445 * Read a list of key IDs from the keyring's contents in binary form
448 * from modifying it under us - which could cause us to read key IDs multiple
451 static long keyring_read(const struct key *keyring, keyring_read()
492 struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid, keyring_alloc()
494 unsigned long flags, struct key *dest) keyring_alloc()
496 struct key *keyring; keyring_alloc()
516 bool key_default_cmp(const struct key *key, key_default_cmp() argument
519 return strcmp(key->description, match_data->raw_data) == 0; key_default_cmp()
523 * Iteration function to consider each key found.
528 const struct key *key = keyring_ptr_to_key(object); keyring_search_iterator() local
529 unsigned long kflags = key->flags; keyring_search_iterator()
531 kenter("{%d}", key->serial); keyring_search_iterator()
534 if (key->type != ctx->index_key.type) { keyring_search_iterator()
548 if (key->expiry && ctx->now.tv_sec >= key->expiry) { keyring_search_iterator()
557 if (!ctx->match_data.cmp(key, &ctx->match_data)) { keyring_search_iterator()
562 /* key must have search permissions */ keyring_search_iterator()
564 key_task_permission(make_key_ref(key, ctx->possessed), keyring_search_iterator()
572 /* we set a different error code if we pass a negative key */ keyring_search_iterator()
575 ctx->result = ERR_PTR(key->type_data.reject_error); keyring_search_iterator()
582 ctx->result = make_key_ref(key, ctx->possessed); keyring_search_iterator()
591 * Search inside a keyring for a key. We can search by walking to it
592 * directly based on its index-key or we can iterate over the entire
595 static int search_keyring(struct key *keyring, struct keyring_search_context *ctx) search_keyring()
612 static bool search_nested_keyrings(struct key *keyring, search_nested_keyrings()
616 struct key *keyring; search_nested_keyrings()
624 struct key *key; search_nested_keyrings() local
732 key = keyring_ptr_to_key(ptr); search_nested_keyrings()
744 key_task_permission(make_key_ref(key, ctx->possessed), search_nested_keyrings()
755 keyring = key; search_nested_keyrings()
787 * matching key. search_nested_keyrings()
806 key = key_ref_to_ptr(ctx->result); search_nested_keyrings()
807 key_check(key); search_nested_keyrings()
809 key->last_used_at = ctx->now.tv_sec; search_nested_keyrings()
819 * keyring_search_aux - Search a keyring tree for a key matching some criteria
823 * Search the supplied keyring tree for a key that matches the criteria given.
828 * addition, the LSM gets to forbid keyring searches and key matches.
835 * match function may use any attributes of a key that it wishes to to
836 * determine the match. Normally the match function from the key type would be
839 * RCU can be used to prevent the keyring key lists from disappearing without
842 * Returns a pointer to the found key and increments the key usage count if
848 * @keyring_ref is propagated to the returned key reference.
853 struct key *keyring; keyring_search_aux()
881 * keyring_search - Search the supplied keyring tree for a matching key
902 key_ref_t key; keyring_search() local
911 key = keyring_search_aux(keyring, &ctx); keyring_search()
915 return key; keyring_search()
920 * Search the given keyring for a key that might be updated.
926 * Returns a pointer to the found key with usage count incremented if
931 * to the returned key reference.
936 struct key *keyring, *key; find_key_to_update() local
954 key = keyring_ptr_to_key(object); find_key_to_update()
955 if (key->flags & ((1 << KEY_FLAG_INVALIDATED) | find_key_to_update()
960 __key_get(key); find_key_to_update()
961 kleave(" = {%d}", key->serial); find_key_to_update()
962 return make_key_ref(key, is_key_possessed(keyring_ref)); find_key_to_update()
974 * incremented on success. -ENOKEY is returned if a key could not be found.
976 struct key *find_keyring_by_name(const char *name, bool skip_perm_check) find_keyring_by_name()
978 struct key *keyring; find_keyring_by_name()
1029 const struct key *key = keyring_ptr_to_key(object); keyring_detect_cycle_iterator() local
1031 kenter("{%d}", key->serial); keyring_detect_cycle_iterator()
1033 /* We might get a keyring with matching index-key that is nonetheless a keyring_detect_cycle_iterator()
1035 if (key != ctx->match_data.raw_data) keyring_detect_cycle_iterator()
1049 static int keyring_detect_cycle(struct key *A, struct key *B) keyring_detect_cycle()
1069 * Preallocate memory so that a key can be linked into to a keyring.
1071 int __key_link_begin(struct key *keyring,
1099 /* Create an edit script that will insert/replace the key in the
1142 int __key_link_check_live_key(struct key *keyring, struct key *key) __key_link_check_live_key() argument
1144 if (key->type == &key_type_keyring) __key_link_check_live_key()
1147 return keyring_detect_cycle(keyring, key); __key_link_check_live_key()
1152 * Link a key into to a keyring.
1155 * already extant link to matching key if there is one, so that each keyring
1156 * holds at most one link to any given key of a particular type+description
1159 void __key_link(struct key *key, struct assoc_array_edit **_edit) __key_link() argument
1161 __key_get(key); __key_link()
1162 assoc_array_insert_set_object(*_edit, keyring_key_to_ptr(key)); __key_link()
1168 * Finish linking a key into to a keyring.
1172 void __key_link_end(struct key *keyring,
1195 * key_link - Link a key to a keyring
1197 * @key: The key to link to.
1199 * Make a link in a keyring to a key, such that the keyring holds a reference
1200 * on that key and the key can potentially be found by searching that keyring.
1203 * of the user's key data quota to hold the link.
1207 * full, -EDQUOT if there is insufficient key data quota remaining to add
1211 * be made (the keyring should have Write permission and the key Link
1214 int key_link(struct key *keyring, struct key *key) key_link() argument
1222 key_check(key); key_link()
1225 !test_bit(KEY_FLAG_TRUSTED, &key->flags)) key_link()
1228 ret = __key_link_begin(keyring, &key->index_key, &edit); key_link()
1231 ret = __key_link_check_live_key(keyring, key); key_link()
1233 __key_link(key, &edit); key_link()
1234 __key_link_end(keyring, &key->index_key, edit); key_link()
1243 * key_unlink - Unlink the first link to a key from a keyring.
1245 * @key: The key the link is to.
1247 * Remove a link from a keyring to a key.
1252 * the key isn't linked to by the keyring or -ENOMEM if there's insufficient
1257 * required on the key).
1259 int key_unlink(struct key *keyring, struct key *key) key_unlink() argument
1265 key_check(key); key_unlink()
1273 &key->index_key); key_unlink()
1300 int keyring_clear(struct key *keyring) keyring_clear()
1328 * This is called with the key sem write-locked.
1330 static void keyring_revoke(struct key *keyring) keyring_revoke()
1344 struct key *key = keyring_ptr_to_key(object); keyring_gc_select_iterator() local
1347 if (key_is_dead(key, *limit)) keyring_gc_select_iterator()
1349 key_get(key); keyring_gc_select_iterator()
1355 const struct key *key = keyring_ptr_to_key(object); keyring_gc_check_iterator() local
1358 key_check(key); keyring_gc_check_iterator()
1359 return key_is_dead(key, *limit); keyring_gc_check_iterator()
1365 * Not called with any locks held. The keyring's key struct will not be
1368 void keyring_gc(struct key *keyring, time_t limit) keyring_gc()
H A Dtrusted.h54 pr_info("trusted_key: sealing key type %d\n", o->keytype); dump_options()
55 pr_info("trusted_key: sealing key handle %0X\n", o->keyhandle); dump_options()
65 print_hex_dump(KERN_INFO, "key ", DUMP_PREFIX_NONE, dump_payload()
66 16, 1, p->key, p->key_len, 0); dump_payload()
75 print_hex_dump(KERN_INFO, "trusted-key: handle ", DUMP_PREFIX_NONE, dump_sess()
77 pr_info("trusted-key: secret:\n"); dump_sess()
80 pr_info("trusted-key: enonce:\n"); dump_sess()
89 pr_info("\ntrusted-key: tpm buffer\n"); dump_tpm_buf()
/linux-4.1.27/security/selinux/ss/
H A Davtab.c70 struct avtab_key *key, struct avtab_datum *datum) avtab_insert_node()
76 newnode->key = *key; avtab_insert_node()
94 static int avtab_insert(struct avtab *h, struct avtab_key *key, struct avtab_datum *datum) avtab_insert() argument
98 u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); avtab_insert()
103 hvalue = avtab_hash(key, h->mask); avtab_insert()
107 if (key->source_type == cur->key.source_type && avtab_insert()
108 key->target_type == cur->key.target_type && avtab_insert()
109 key->target_class == cur->key.target_class && avtab_insert()
110 (specified & cur->key.specified)) avtab_insert()
112 if (key->source_type < cur->key.source_type) avtab_insert()
114 if (key->source_type == cur->key.source_type && avtab_insert()
115 key->target_type < cur->key.target_type) avtab_insert()
117 if (key->source_type == cur->key.source_type && avtab_insert()
118 key->target_type == cur->key.target_type && avtab_insert()
119 key->target_class < cur->key.target_class) avtab_insert()
123 newnode = avtab_insert_node(h, hvalue, prev, cur, key, datum); avtab_insert()
131 * key/specified mask into the table, as needed by the conditional avtab.
135 avtab_insert_nonunique(struct avtab *h, struct avtab_key *key, struct avtab_datum *datum) avtab_insert_nonunique() argument
139 u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); avtab_insert_nonunique()
143 hvalue = avtab_hash(key, h->mask); avtab_insert_nonunique()
147 if (key->source_type == cur->key.source_type && avtab_insert_nonunique()
148 key->target_type == cur->key.target_type && avtab_insert_nonunique()
149 key->target_class == cur->key.target_class && avtab_insert_nonunique()
150 (specified & cur->key.specified)) avtab_insert_nonunique()
152 if (key->source_type < cur->key.source_type) avtab_insert_nonunique()
154 if (key->source_type == cur->key.source_type && avtab_insert_nonunique()
155 key->target_type < cur->key.target_type) avtab_insert_nonunique()
157 if (key->source_type == cur->key.source_type && avtab_insert_nonunique()
158 key->target_type == cur->key.target_type && avtab_insert_nonunique()
159 key->target_class < cur->key.target_class) avtab_insert_nonunique()
162 return avtab_insert_node(h, hvalue, prev, cur, key, datum); avtab_insert_nonunique()
165 struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key) avtab_search() argument
169 u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); avtab_search()
174 hvalue = avtab_hash(key, h->mask); avtab_search()
177 if (key->source_type == cur->key.source_type && avtab_search()
178 key->target_type == cur->key.target_type && avtab_search()
179 key->target_class == cur->key.target_class && avtab_search()
180 (specified & cur->key.specified)) avtab_search()
183 if (key->source_type < cur->key.source_type) avtab_search()
185 if (key->source_type == cur->key.source_type && avtab_search()
186 key->target_type < cur->key.target_type) avtab_search()
188 if (key->source_type == cur->key.source_type && avtab_search()
189 key->target_type == cur->key.target_type && avtab_search()
190 key->target_class < cur->key.target_class) avtab_search()
201 avtab_search_node(struct avtab *h, struct avtab_key *key) avtab_search_node() argument
205 u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); avtab_search_node()
210 hvalue = avtab_hash(key, h->mask); avtab_search_node()
213 if (key->source_type == cur->key.source_type && avtab_search_node()
214 key->target_type == cur->key.target_type && avtab_search_node()
215 key->target_class == cur->key.target_class && avtab_search_node()
216 (specified & cur->key.specified)) avtab_search_node()
219 if (key->source_type < cur->key.source_type) avtab_search_node()
221 if (key->source_type == cur->key.source_type && avtab_search_node()
222 key->target_type < cur->key.target_type) avtab_search_node()
224 if (key->source_type == cur->key.source_type && avtab_search_node()
225 key->target_type == cur->key.target_type && avtab_search_node()
226 key->target_class < cur->key.target_class) avtab_search_node()
242 if (node->key.source_type == cur->key.source_type && avtab_search_node_next()
243 node->key.target_type == cur->key.target_type && avtab_search_node_next()
244 node->key.target_class == cur->key.target_class && avtab_search_node_next()
245 (specified & cur->key.specified)) avtab_search_node_next()
248 if (node->key.source_type < cur->key.source_type) avtab_search_node_next()
250 if (node->key.source_type == cur->key.source_type && avtab_search_node_next()
251 node->key.target_type < cur->key.target_type) avtab_search_node_next()
253 if (node->key.source_type == cur->key.source_type && avtab_search_node_next()
254 node->key.target_type == cur->key.target_type && avtab_search_node_next()
255 node->key.target_class < cur->key.target_class) avtab_search_node_next()
374 struct avtab_key key; avtab_read_item() local
379 memset(&key, 0, sizeof(struct avtab_key)); avtab_read_item()
402 key.source_type = (u16)val; avtab_read_item()
403 if (key.source_type != val) { avtab_read_item()
408 key.target_type = (u16)val; avtab_read_item()
409 if (key.target_type != val) { avtab_read_item()
414 key.target_class = (u16)val; avtab_read_item()
415 if (key.target_class != val) { avtab_read_item()
435 key.specified = spec_order[i] | enabled; avtab_read_item()
437 rc = insertf(a, &key, &datum, p); avtab_read_item()
457 key.source_type = le16_to_cpu(buf16[items++]); avtab_read_item()
458 key.target_type = le16_to_cpu(buf16[items++]); avtab_read_item()
459 key.target_class = le16_to_cpu(buf16[items++]); avtab_read_item()
460 key.specified = le16_to_cpu(buf16[items++]); avtab_read_item()
462 if (!policydb_type_isvalid(pol, key.source_type) || avtab_read_item()
463 !policydb_type_isvalid(pol, key.target_type) || avtab_read_item()
464 !policydb_class_isvalid(pol, key.target_class)) { avtab_read_item()
471 if (key.specified & spec_order[i]) avtab_read_item()
485 if ((key.specified & AVTAB_TYPE) && avtab_read_item()
490 return insertf(a, &key, &datum, p); avtab_read_item()
549 buf16[0] = cpu_to_le16(cur->key.source_type); avtab_write_item()
550 buf16[1] = cpu_to_le16(cur->key.target_type); avtab_write_item()
551 buf16[2] = cpu_to_le16(cur->key.target_class); avtab_write_item()
552 buf16[3] = cpu_to_le16(cur->key.specified); avtab_write_item()
68 avtab_insert_node(struct avtab *h, int hvalue, struct avtab_node *prev, struct avtab_node *cur, struct avtab_key *key, struct avtab_datum *datum) avtab_insert_node() argument
H A Dhashtab.c12 struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void *key), hashtab_create() argument
39 int hashtab_insert(struct hashtab *h, void *key, void *datum) hashtab_insert() argument
49 hvalue = h->hash_value(h, key); hashtab_insert()
52 while (cur && h->keycmp(h, key, cur->key) > 0) { hashtab_insert()
57 if (cur && (h->keycmp(h, key, cur->key) == 0)) hashtab_insert()
63 newnode->key = key; hashtab_insert()
77 void *hashtab_search(struct hashtab *h, const void *key) hashtab_search() argument
85 hvalue = h->hash_value(h, key); hashtab_search()
87 while (cur && h->keycmp(h, key, cur->key) > 0) hashtab_search()
90 if (cur == NULL || (h->keycmp(h, key, cur->key) != 0)) hashtab_search()
134 ret = apply(cur->key, cur->datum, args); hashtab_map()
H A Dhashtab.h3 * key values and datum values. The type of the key values
5 * functions for hash computation and key comparison are
16 void *key; member in struct:hashtab_node
25 u32 (*hash_value)(struct hashtab *h, const void *key);
28 /* key comparison function */
42 struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void *key),
47 * Inserts the specified (key, datum) pair into the specified hash table.
50 * -EEXIST if there is already an entry with the same key,
57 * Searches for the entry with the specified key in the hash table.
59 * Returns NULL if no entry has the specified key or
70 * Applies the specified apply function to (key,datum,args)
H A Dsymtab.c11 static unsigned int symhash(struct hashtab *h, const void *key) symhash() argument
18 keyp = key; symhash()
/linux-4.1.27/security/integrity/
H A Ddigsig_asymmetric.c17 #include <linux/key-type.h>
24 * Request an asymmetric key.
26 static struct key *request_asymmetric_key(struct key *keyring, uint32_t keyid) request_asymmetric_key()
28 struct key *key; request_asymmetric_key() local
33 pr_debug("key search: \"%s\"\n", name); request_asymmetric_key()
41 key = ERR_CAST(kref); request_asymmetric_key()
43 key = key_ref_to_ptr(kref); request_asymmetric_key()
45 key = request_key(&key_type_asymmetric, name, NULL); request_asymmetric_key()
48 if (IS_ERR(key)) { request_asymmetric_key()
49 pr_err_ratelimited("Request for unknown key '%s' err %ld\n", request_asymmetric_key()
50 name, PTR_ERR(key)); request_asymmetric_key()
51 switch (PTR_ERR(key)) { request_asymmetric_key()
58 return key; request_asymmetric_key()
62 pr_debug("%s() = 0 [%x]\n", __func__, key_serial(key)); request_asymmetric_key()
64 return key; request_asymmetric_key()
67 int asymmetric_verify(struct key *keyring, const char *sig, asymmetric_verify()
72 struct key *key; asymmetric_verify() local
86 key = request_asymmetric_key(keyring, __be32_to_cpu(hdr->keyid)); asymmetric_verify()
87 if (IS_ERR(key)) asymmetric_verify()
88 return PTR_ERR(key); asymmetric_verify()
99 ret = verify_signature(key, &pks); asymmetric_verify()
102 key_put(key); asymmetric_verify()
H A Ddigsig.c19 #include <linux/key-type.h>
24 static struct key *keyring[INTEGRITY_KEYRING_MAX];
90 key_ref_t key; integrity_load_x509() local
101 key = key_create_or_update(make_key_ref(keyring[id], 1), integrity_load_x509()
109 if (IS_ERR(key)) { integrity_load_x509()
110 rc = PTR_ERR(key); integrity_load_x509()
115 key_ref_to_ptr(key)->description, path); integrity_load_x509()
116 key_ref_put(key); integrity_load_x509()
/linux-4.1.27/drivers/s390/crypto/
H A Dzcrypt_cca_key.h36 * mapping for the cca private ME key token.
40 * mapping for the cca key token header
75 * In a private key, the modulus doesn't appear in the public
86 unsigned short modulus_byte_len; /* In a private key, this is 0 */
90 * mapping for the cca private CRT key 'token'
127 * Set up private key fields of a type6 MEX message.
128 * Note that all numerics in the key token are big-endian,
129 * while the entries in the key block header are little-endian.
132 * @p: pointer to memory area for the key
134 * Returns the size of the key area or -EFAULT
160 } __attribute__((packed)) *key = p; zcrypt_type6_mex_key_de() local
163 memset(key, 0, sizeof(*key)); zcrypt_type6_mex_key_de()
166 key->t6_hdr.blen = cpu_to_be16(0x189); zcrypt_type6_mex_key_de()
167 key->t6_hdr.ulen = cpu_to_be16(0x189 - 2); zcrypt_type6_mex_key_de()
169 key->t6_hdr.blen = cpu_to_le16(0x189); zcrypt_type6_mex_key_de()
170 key->t6_hdr.ulen = cpu_to_le16(0x189 - 2); zcrypt_type6_mex_key_de()
172 key->pvtMeHdr = static_pvt_me_hdr; zcrypt_type6_mex_key_de()
173 key->pvtMeSec = static_pvt_me_sec; zcrypt_type6_mex_key_de()
174 key->pubMeSec = static_pub_me_sec; zcrypt_type6_mex_key_de()
176 * In a private key, the modulus doesn't appear in the public zcrypt_type6_mex_key_de()
180 memcpy(key->exponent, pk_exponent, 3); zcrypt_type6_mex_key_de()
182 /* key parameter block */ zcrypt_type6_mex_key_de()
183 temp = key->pvtMeSec.exponent + zcrypt_type6_mex_key_de()
184 sizeof(key->pvtMeSec.exponent) - mex->inputdatalength; zcrypt_type6_mex_key_de()
189 temp = key->pvtMeSec.modulus + zcrypt_type6_mex_key_de()
190 sizeof(key->pvtMeSec.modulus) - mex->inputdatalength; zcrypt_type6_mex_key_de()
193 key->pubMeSec.modulus_bit_len = 8 * mex->inputdatalength; zcrypt_type6_mex_key_de()
194 return sizeof(*key); zcrypt_type6_mex_key_de()
198 * Set up private key fields of a type6 MEX message. The _pad variant
200 * Note that all numerics in the key token are big-endian,
201 * while the entries in the key block header are little-endian.
204 * @p: pointer to memory area for the key
206 * Returns the size of the key area or -EFAULT
222 } __attribute__((packed)) *key = p; zcrypt_type6_mex_key_en() local
226 memset(key, 0, sizeof(*key)); zcrypt_type6_mex_key_en()
228 key->pubHdr = static_pub_hdr; zcrypt_type6_mex_key_en()
229 key->pubSec = static_pub_sec; zcrypt_type6_mex_key_en()
231 /* key parameter block */ zcrypt_type6_mex_key_en()
232 temp = key->exponent; zcrypt_type6_mex_key_en()
247 key->pubSec.modulus_bit_len = 8 * mex->inputdatalength; zcrypt_type6_mex_key_en()
248 key->pubSec.modulus_byte_len = mex->inputdatalength; zcrypt_type6_mex_key_en()
249 key->pubSec.exponent_len = mex->inputdatalength - i; zcrypt_type6_mex_key_en()
250 key->pubSec.section_length = sizeof(key->pubSec) + zcrypt_type6_mex_key_en()
252 key->pubHdr.token_length = zcrypt_type6_mex_key_en()
253 key->pubSec.section_length + sizeof(key->pubHdr); zcrypt_type6_mex_key_en()
255 key->t6_hdr.ulen = cpu_to_be16(key->pubHdr.token_length + 4); zcrypt_type6_mex_key_en()
256 key->t6_hdr.blen = cpu_to_be16(key->pubHdr.token_length + 6); zcrypt_type6_mex_key_en()
258 key->t6_hdr.ulen = cpu_to_le16(key->pubHdr.token_length + 4); zcrypt_type6_mex_key_en()
259 key->t6_hdr.blen = cpu_to_le16(key->pubHdr.token_length + 6); zcrypt_type6_mex_key_en()
261 return sizeof(*key) + 2*mex->inputdatalength - i; zcrypt_type6_mex_key_en()
265 * Set up private key fields of a type6 CRT message.
266 * Note that all numerics in the key token are big-endian,
267 * while the entries in the key block header are little-endian.
270 * @p: pointer to memory area for the key
272 * Returns the size of the key area or -EFAULT
288 } __attribute__((packed)) *key = p; zcrypt_type6_crt_key() local
292 memset(key, 0, sizeof(*key)); zcrypt_type6_crt_key()
298 size = sizeof(*key) + key_len + sizeof(*pub) + 3; zcrypt_type6_crt_key()
300 /* parameter block.key block */ zcrypt_type6_crt_key()
302 key->t6_hdr.blen = cpu_to_be16(size); zcrypt_type6_crt_key()
303 key->t6_hdr.ulen = cpu_to_be16(size - 2); zcrypt_type6_crt_key()
305 key->t6_hdr.blen = cpu_to_le16(size); zcrypt_type6_crt_key()
306 key->t6_hdr.ulen = cpu_to_le16(size - 2); zcrypt_type6_crt_key()
309 /* key token header */ zcrypt_type6_crt_key()
310 key->token.token_identifier = CCA_TKN_HDR_ID_EXT; zcrypt_type6_crt_key()
311 key->token.token_length = size - 6; zcrypt_type6_crt_key()
314 key->pvt.section_identifier = CCA_PVT_EXT_CRT_SEC_ID_PVT; zcrypt_type6_crt_key()
315 key->pvt.section_length = sizeof(key->pvt) + key_len; zcrypt_type6_crt_key()
316 key->pvt.key_format = CCA_PVT_EXT_CRT_SEC_FMT_CL; zcrypt_type6_crt_key()
317 key->pvt.key_use_flags[0] = CCA_PVT_USAGE_ALL; zcrypt_type6_crt_key()
318 key->pvt.p_len = key->pvt.dp_len = key->pvt.u_len = long_len; zcrypt_type6_crt_key()
319 key->pvt.q_len = key->pvt.dq_len = short_len; zcrypt_type6_crt_key()
320 key->pvt.mod_len = crt->inputdatalength; zcrypt_type6_crt_key()
321 key->pvt.pad_len = pad_len; zcrypt_type6_crt_key()
323 /* key parts */ zcrypt_type6_crt_key()
324 if (copy_from_user(key->key_parts, crt->np_prime, long_len) || zcrypt_type6_crt_key()
325 copy_from_user(key->key_parts + long_len, zcrypt_type6_crt_key()
327 copy_from_user(key->key_parts + long_len + short_len, zcrypt_type6_crt_key()
329 copy_from_user(key->key_parts + 2*long_len + short_len, zcrypt_type6_crt_key()
331 copy_from_user(key->key_parts + 2*long_len + 2*short_len, zcrypt_type6_crt_key()
334 memset(key->key_parts + 3*long_len + 2*short_len + pad_len, zcrypt_type6_crt_key()
336 pub = (struct cca_public_sec *)(key->key_parts + key_len); zcrypt_type6_crt_key()
340 * In a private key, the modulus doesn't appear in the public zcrypt_type6_crt_key()
/linux-4.1.27/include/keys/
H A Dasymmetric-subtype.h1 /* Asymmetric public-key cryptography key subtype
31 /* Describe a key of this subtype for /proc/keys */
32 void (*describe)(const struct key *key, struct seq_file *m);
34 /* Destroy a key of this subtype */
37 /* Verify the signature on a key of this subtype (optional) */
38 int (*verify_signature)(const struct key *key,
43 * asymmetric_key_subtype - Get the subtype from an asymmetric key
44 * @key: The key of interest.
46 * Retrieves and returns the subtype pointer of the asymmetric key from the
47 * type-specific data attached to the key.
50 struct asymmetric_key_subtype *asymmetric_key_subtype(const struct key *key) asymmetric_key_subtype() argument
52 return key->type_data.p[0]; asymmetric_key_subtype()
H A Dceph-type.h4 #include <linux/key.h>
H A Duser-type.h1 /* user-type.h: User-defined key type
15 #include <linux/key.h>
20 * the payload for a key of type "user" or "logon"
21 * - once filled in and attached to a key:
23 * - the payload must be read with RCU procedures or with the key semaphore
25 * - the payload may only be replaced with the key semaphore write-locked
26 * - the key's data length is the size of the actual data, not including the
42 extern int user_update(struct key *key, struct key_preparsed_payload *prep);
43 extern void user_revoke(struct key *key);
44 extern void user_destroy(struct key *key);
45 extern void user_describe(const struct key *user, struct seq_file *m);
46 extern long user_read(const struct key *key,
H A Dbig_key-type.h1 /* Big capacity key type.
15 #include <linux/key-type.h>
21 extern void big_key_revoke(struct key *key);
22 extern void big_key_destroy(struct key *key);
23 extern void big_key_describe(const struct key *big_key, struct seq_file *m);
24 extern long big_key_read(const struct key *key, char __user *buffer, size_t buflen);
H A Dsystem_keyring.h17 #include <linux/key.h>
19 extern struct key *system_trusted_keyring; get_system_trusted_keyring()
20 static inline struct key *get_system_trusted_keyring(void) get_system_trusted_keyring()
25 static inline struct key *get_system_trusted_keyring(void) get_system_trusted_keyring()
H A Dasymmetric-parser.h1 /* Asymmetric public-key cryptography data parser
18 * Key data parser. Called during key instantiation.
25 /* Attempt to parse a key from the data blob passed to add_key() or
27 * that the caller can optionally use for the key.
H A Dencrypted-type.h18 #include <linux/key.h>
24 char *master_desc; /* datablob: master key name */
25 char *datalen; /* datablob: decrypted key length */
31 unsigned short encrypted_key_format; /* encrypted key format */
H A Ddns_resolver-type.h1 /* DNS resolver key type
15 #include <linux/key-type.h>
H A Dkeyring-type.h1 /* Keyring key type
15 #include <linux/key.h>
H A Dasymmetric-type.h1 /* Asymmetric Public-key cryptography key type interface
17 #include <linux/key-type.h>
22 * Identifiers for an asymmetric key ID. We have three ways of looking up a
23 * key derived from an X.509 certificate:
35 * We could also support an PGP key identifier, which is just a SHA1 sum of the
36 * public key and certain parameters, but since we don't support PGP keys at
H A Drxrpc-type.h1 /* RxRPC key type
15 #include <linux/key.h>
18 * key type for AF_RXRPC keys
22 extern struct key *rxrpc_get_null_key(const char *);
25 * RxRPC key for Kerberos IV (type-2 security)
31 u32 kvno; /* key version number */
32 u8 primary_flag; /* T if key for primary cell for this user */
34 u8 session_key[8]; /* DES session key */
62 * RxRPC key for Kerberos V (type-5 security)
87 * list of tokens attached to an rxrpc key
99 * structure of raw payloads passed to add_key() or instantiate key
111 * AF_RXRPC key payload derived from XDR format
121 #define AFSTOKEN_GK_KEY_MAX 64 /* max GSSAPI key size */
H A Dtrusted-type.h13 #include <linux/key.h>
25 unsigned char key[MAX_KEY_SIZE + 1]; member in struct:trusted_key_payload
/linux-4.1.27/fs/nilfs2/
H A Ddirect.c37 nilfs_direct_get_ptr(const struct nilfs_bmap *direct, __u64 key) nilfs_direct_get_ptr() argument
39 return le64_to_cpu(*(nilfs_direct_dptrs(direct) + key)); nilfs_direct_get_ptr()
43 __u64 key, __u64 ptr) nilfs_direct_set_ptr()
45 *(nilfs_direct_dptrs(direct) + key) = cpu_to_le64(ptr); nilfs_direct_set_ptr()
49 __u64 key, int level, __u64 *ptrp) nilfs_direct_lookup()
53 if (key > NILFS_DIRECT_KEY_MAX || level != 1) nilfs_direct_lookup()
55 ptr = nilfs_direct_get_ptr(direct, key); nilfs_direct_lookup()
64 __u64 key, __u64 *ptrp, nilfs_direct_lookup_contig()
72 if (key > NILFS_DIRECT_KEY_MAX) nilfs_direct_lookup_contig()
74 ptr = nilfs_direct_get_ptr(direct, key); nilfs_direct_lookup_contig()
86 maxblocks = min_t(unsigned, maxblocks, NILFS_DIRECT_KEY_MAX - key + 1); nilfs_direct_lookup_contig()
88 (ptr2 = nilfs_direct_get_ptr(direct, key + cnt)) != nilfs_direct_lookup_contig()
105 nilfs_direct_find_target_v(const struct nilfs_bmap *direct, __u64 key) nilfs_direct_find_target_v() argument
109 ptr = nilfs_bmap_find_target_seq(direct, key); nilfs_direct_find_target_v()
118 static int nilfs_direct_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr) nilfs_direct_insert() argument
125 if (key > NILFS_DIRECT_KEY_MAX) nilfs_direct_insert()
127 if (nilfs_direct_get_ptr(bmap, key) != NILFS_BMAP_INVALID_PTR) nilfs_direct_insert()
131 req.bpr_ptr = nilfs_direct_find_target_v(bmap, key); nilfs_direct_insert()
141 nilfs_direct_set_ptr(bmap, key, req.bpr_ptr); nilfs_direct_insert()
147 nilfs_bmap_set_target_v(bmap, key, req.bpr_ptr); nilfs_direct_insert()
154 static int nilfs_direct_delete(struct nilfs_bmap *bmap, __u64 key) nilfs_direct_delete() argument
160 if (key > NILFS_DIRECT_KEY_MAX || nilfs_direct_delete()
161 nilfs_direct_get_ptr(bmap, key) == NILFS_BMAP_INVALID_PTR) nilfs_direct_delete()
165 req.bpr_ptr = nilfs_direct_get_ptr(bmap, key); nilfs_direct_delete()
170 nilfs_direct_set_ptr(bmap, key, NILFS_BMAP_INVALID_PTR); nilfs_direct_delete()
179 __u64 key; nilfs_direct_seek_key() local
181 for (key = start; key <= NILFS_DIRECT_KEY_MAX; key++) { nilfs_direct_seek_key()
182 if (nilfs_direct_get_ptr(direct, key) != nilfs_direct_seek_key()
184 *keyp = key; nilfs_direct_seek_key()
193 __u64 key, lastkey; nilfs_direct_last_key() local
196 for (key = NILFS_DIRECT_KEY_MIN; key <= NILFS_DIRECT_KEY_MAX; key++) nilfs_direct_last_key()
197 if (nilfs_direct_get_ptr(direct, key) != nilfs_direct_last_key()
199 lastkey = key; nilfs_direct_last_key()
209 static int nilfs_direct_check_insert(const struct nilfs_bmap *bmap, __u64 key) nilfs_direct_check_insert() argument
211 return key > NILFS_DIRECT_KEY_MAX; nilfs_direct_check_insert()
217 __u64 key; nilfs_direct_gather_data() local
224 for (key = 0; key < nitems; key++) { nilfs_direct_gather_data()
225 ptr = nilfs_direct_get_ptr(direct, key); nilfs_direct_gather_data()
227 keys[n] = key; nilfs_direct_gather_data()
236 __u64 key, __u64 *keys, __u64 *ptrs, int n) nilfs_direct_delete_and_convert()
244 ret = bmap->b_ops->bop_delete(bmap, key); nilfs_direct_delete_and_convert()
256 dptrs[i] = (i != key) ? nilfs_direct_delete_and_convert()
273 __u64 key; nilfs_direct_propagate() local
281 key = nilfs_bmap_data_get_key(bmap, bh); nilfs_direct_propagate()
282 ptr = nilfs_direct_get_ptr(bmap, key); nilfs_direct_propagate()
292 nilfs_direct_set_ptr(bmap, key, newreq.pr_entry_nr); nilfs_direct_propagate()
300 __u64 key, __u64 ptr, nilfs_direct_assign_v()
314 binfo->bi_v.bi_blkoff = cpu_to_le64(key); nilfs_direct_assign_v()
320 __u64 key, __u64 ptr, nilfs_direct_assign_p()
325 nilfs_direct_set_ptr(direct, key, blocknr); nilfs_direct_assign_p()
327 binfo->bi_dat.bi_blkoff = cpu_to_le64(key); nilfs_direct_assign_p()
338 __u64 key; nilfs_direct_assign() local
341 key = nilfs_bmap_data_get_key(bmap, *bh); nilfs_direct_assign()
342 if (unlikely(key > NILFS_DIRECT_KEY_MAX)) { nilfs_direct_assign()
343 printk(KERN_CRIT "%s: invalid key: %llu\n", __func__, nilfs_direct_assign()
344 (unsigned long long)key); nilfs_direct_assign()
347 ptr = nilfs_direct_get_ptr(bmap, key); nilfs_direct_assign()
355 nilfs_direct_assign_v(bmap, key, ptr, bh, blocknr, binfo) : nilfs_direct_assign()
356 nilfs_direct_assign_p(bmap, key, ptr, bh, blocknr, binfo); nilfs_direct_assign()
42 nilfs_direct_set_ptr(struct nilfs_bmap *direct, __u64 key, __u64 ptr) nilfs_direct_set_ptr() argument
48 nilfs_direct_lookup(const struct nilfs_bmap *direct, __u64 key, int level, __u64 *ptrp) nilfs_direct_lookup() argument
63 nilfs_direct_lookup_contig(const struct nilfs_bmap *direct, __u64 key, __u64 *ptrp, unsigned maxblocks) nilfs_direct_lookup_contig() argument
235 nilfs_direct_delete_and_convert(struct nilfs_bmap *bmap, __u64 key, __u64 *keys, __u64 *ptrs, int n) nilfs_direct_delete_and_convert() argument
299 nilfs_direct_assign_v(struct nilfs_bmap *direct, __u64 key, __u64 ptr, struct buffer_head **bh, sector_t blocknr, union nilfs_binfo *binfo) nilfs_direct_assign_v() argument
319 nilfs_direct_assign_p(struct nilfs_bmap *direct, __u64 key, __u64 ptr, struct buffer_head **bh, sector_t blocknr, union nilfs_binfo *binfo) nilfs_direct_assign_p() argument
H A Dbmap.c58 * @key: key
60 * @ptrp: place to store the value associated to @key
62 * Description: nilfs_bmap_lookup_at_level() finds a record whose key
63 * matches @key in the block at @level of the bmap.
65 * Return Value: On success, 0 is returned and the record associated with @key
73 * %-ENOENT - A record associated with @key does not exist.
75 int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level, nilfs_bmap_lookup_at_level() argument
82 ret = bmap->b_ops->bop_lookup(bmap, key, level, ptrp); nilfs_bmap_lookup_at_level()
99 int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp, nilfs_bmap_lookup_contig() argument
105 ret = bmap->b_ops->bop_lookup_contig(bmap, key, ptrp, maxblocks); nilfs_bmap_lookup_contig()
111 static int nilfs_bmap_do_insert(struct nilfs_bmap *bmap, __u64 key, __u64 ptr) nilfs_bmap_do_insert() argument
118 ret = bmap->b_ops->bop_check_insert(bmap, key); nilfs_bmap_do_insert()
125 bmap, key, ptr, keys, ptrs, n); nilfs_bmap_do_insert()
134 return bmap->b_ops->bop_insert(bmap, key, ptr); nilfs_bmap_do_insert()
138 * nilfs_bmap_insert - insert a new key-record pair into a bmap
140 * @key: key
143 * Description: nilfs_bmap_insert() inserts the new key-record pair specified
144 * by @key and @rec into @bmap.
153 * %-EEXIST - A record associated with @key already exist.
155 int nilfs_bmap_insert(struct nilfs_bmap *bmap, __u64 key, unsigned long rec) nilfs_bmap_insert() argument
160 ret = nilfs_bmap_do_insert(bmap, key, rec); nilfs_bmap_insert()
166 static int nilfs_bmap_do_delete(struct nilfs_bmap *bmap, __u64 key) nilfs_bmap_do_delete() argument
173 ret = bmap->b_ops->bop_check_delete(bmap, key); nilfs_bmap_do_delete()
180 bmap, key, keys, ptrs, n); nilfs_bmap_do_delete()
189 return bmap->b_ops->bop_delete(bmap, key); nilfs_bmap_do_delete()
193 * nilfs_bmap_seek_key - seek a valid entry and return its key
195 * @start: start key number
196 * @keyp: place to store valid key
198 * Description: nilfs_bmap_seek_key() seeks a valid key on @bmap
237 * nilfs_bmap_delete - delete a key-record pair from a bmap
239 * @key: key
241 * Description: nilfs_bmap_delete() deletes the key-record pair specified by
242 * @key from @bmap.
251 * %-ENOENT - A record associated with @key does not exist.
253 int nilfs_bmap_delete(struct nilfs_bmap *bmap, __u64 key) nilfs_bmap_delete() argument
258 ret = nilfs_bmap_do_delete(bmap, key); nilfs_bmap_delete()
264 static int nilfs_bmap_do_truncate(struct nilfs_bmap *bmap, __u64 key) nilfs_bmap_do_truncate() argument
276 while (key <= lastkey) { nilfs_bmap_do_truncate()
291 * nilfs_bmap_truncate - truncate a bmap to a specified key
293 * @key: key
295 * Description: nilfs_bmap_truncate() removes key-record pairs whose keys are
296 * greater than or equal to @key from @bmap.
305 int nilfs_bmap_truncate(struct nilfs_bmap *bmap, __u64 key) nilfs_bmap_truncate() argument
310 ret = nilfs_bmap_do_truncate(bmap, key); nilfs_bmap_truncate()
404 * @key: key
407 * Description: nilfs_bmap_mark() marks the block specified by @key and @level
417 int nilfs_bmap_mark(struct nilfs_bmap *bmap, __u64 key, int level) nilfs_bmap_mark() argument
425 ret = bmap->b_ops->bop_mark(bmap, key, level); nilfs_bmap_mark()
459 __u64 key; nilfs_bmap_data_get_key() local
461 key = page_index(bh->b_page) << (PAGE_CACHE_SHIFT - nilfs_bmap_data_get_key()
464 key++; nilfs_bmap_data_get_key()
466 return key; nilfs_bmap_data_get_key()
469 __u64 nilfs_bmap_find_target_seq(const struct nilfs_bmap *bmap, __u64 key) nilfs_bmap_find_target_seq() argument
473 diff = key - bmap->b_last_allocated_key; nilfs_bmap_find_target_seq()
/linux-4.1.27/net/mac80211/
H A Dkey.c36 * each station key also belongs to that interface.
39 * that are implemented in software, for each key the hardware is asked
40 * to enable that key for offloading but if it cannot do that the key is
43 * There is currently no way of knowing whether a key is handled in SW
46 * All key management is internally protected by a mutex. Within all
47 * other parts of mac80211, key references are, just as STA structure
49 * unprotected, namely the key->sta dereferences within the hardware
51 * remove the key which waits for an RCU grace period.
87 * 1. SKB resize was skipped because no key was added but just before increment_tailroom_need_count()
88 * the xmit key is added and SW encryption kicks off. increment_tailroom_need_count()
91 * just before xmit one of the key is deleted and SW encryption kicks increment_tailroom_need_count()
125 static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) ieee80211_key_enable_hw_accel() argument
133 if (key->flags & KEY_FLAG_TAINTED) { ieee80211_key_enable_hw_accel()
134 /* If we get here, it's during resume and the key is ieee80211_key_enable_hw_accel()
141 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; ieee80211_key_enable_hw_accel()
145 if (!key->local->ops->set_key) ieee80211_key_enable_hw_accel()
148 assert_key_lock(key->local); ieee80211_key_enable_hw_accel()
150 sta = key->sta; ieee80211_key_enable_hw_accel()
156 if (sta && !(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE) && ieee80211_key_enable_hw_accel()
157 !(key->local->hw.flags & IEEE80211_HW_SUPPORTS_PER_STA_GTK)) ieee80211_key_enable_hw_accel()
163 sdata = key->sdata; ieee80211_key_enable_hw_accel()
169 if (!(key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE)) ieee80211_key_enable_hw_accel()
173 ret = drv_set_key(key->local, SET_KEY, sdata, ieee80211_key_enable_hw_accel()
174 sta ? &sta->sta : NULL, &key->conf); ieee80211_key_enable_hw_accel()
177 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; ieee80211_key_enable_hw_accel()
179 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || ieee80211_key_enable_hw_accel()
180 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) ieee80211_key_enable_hw_accel()
183 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && ieee80211_key_enable_hw_accel()
184 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); ieee80211_key_enable_hw_accel()
191 "failed to set key (%d, %pM) to hardware (%d)\n", ieee80211_key_enable_hw_accel()
192 key->conf.keyidx, ieee80211_key_enable_hw_accel()
196 switch (key->conf.cipher) { ieee80211_key_enable_hw_accel()
211 if (key->local->hw.flags & IEEE80211_HW_SW_CRYPTO_CONTROL) ieee80211_key_enable_hw_accel()
219 static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) ieee80211_key_disable_hw_accel() argument
227 if (!key || !key->local->ops->set_key) ieee80211_key_disable_hw_accel()
230 assert_key_lock(key->local); ieee80211_key_disable_hw_accel()
232 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) ieee80211_key_disable_hw_accel()
235 sta = key->sta; ieee80211_key_disable_hw_accel()
236 sdata = key->sdata; ieee80211_key_disable_hw_accel()
238 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || ieee80211_key_disable_hw_accel()
239 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) ieee80211_key_disable_hw_accel()
242 ret = drv_set_key(key->local, DISABLE_KEY, sdata, ieee80211_key_disable_hw_accel()
243 sta ? &sta->sta : NULL, &key->conf); ieee80211_key_disable_hw_accel()
247 "failed to remove key (%d, %pM) from hardware (%d)\n", ieee80211_key_disable_hw_accel()
248 key->conf.keyidx, ieee80211_key_disable_hw_accel()
251 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; ieee80211_key_disable_hw_accel()
257 struct ieee80211_key *key = NULL; __ieee80211_set_default_key() local
262 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); __ieee80211_set_default_key()
265 rcu_assign_pointer(sdata->default_unicast_key, key); __ieee80211_set_default_key()
270 rcu_assign_pointer(sdata->default_multicast_key, key); __ieee80211_set_default_key()
286 struct ieee80211_key *key = NULL; __ieee80211_set_default_mgmt_key() local
292 key = key_mtx_dereference(sdata->local, sdata->keys[idx]); __ieee80211_set_default_mgmt_key()
294 rcu_assign_pointer(sdata->default_mgmt_key, key); __ieee80211_set_default_mgmt_key()
379 struct ieee80211_key *key; ieee80211_key_alloc() local
385 key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL); ieee80211_key_alloc()
386 if (!key) ieee80211_key_alloc()
391 * key to the hardware if possible. ieee80211_key_alloc()
393 key->conf.flags = 0; ieee80211_key_alloc()
394 key->flags = 0; ieee80211_key_alloc()
396 key->conf.cipher = cipher; ieee80211_key_alloc()
397 key->conf.keyidx = idx; ieee80211_key_alloc()
398 key->conf.keylen = key_len; ieee80211_key_alloc()
402 key->conf.iv_len = IEEE80211_WEP_IV_LEN; ieee80211_key_alloc()
403 key->conf.icv_len = IEEE80211_WEP_ICV_LEN; ieee80211_key_alloc()
406 key->conf.iv_len = IEEE80211_TKIP_IV_LEN; ieee80211_key_alloc()
407 key->conf.icv_len = IEEE80211_TKIP_ICV_LEN; ieee80211_key_alloc()
410 key->u.tkip.rx[i].iv32 = ieee80211_key_alloc()
412 key->u.tkip.rx[i].iv16 = ieee80211_key_alloc()
416 spin_lock_init(&key->u.tkip.txlock); ieee80211_key_alloc()
419 key->conf.iv_len = IEEE80211_CCMP_HDR_LEN; ieee80211_key_alloc()
420 key->conf.icv_len = IEEE80211_CCMP_MIC_LEN; ieee80211_key_alloc()
424 key->u.ccmp.rx_pn[i][j] = ieee80211_key_alloc()
428 * Initialize AES key state here as an optimization so that ieee80211_key_alloc()
431 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( ieee80211_key_alloc()
433 if (IS_ERR(key->u.ccmp.tfm)) { ieee80211_key_alloc()
434 err = PTR_ERR(key->u.ccmp.tfm); ieee80211_key_alloc()
435 kfree(key); ieee80211_key_alloc()
440 key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN; ieee80211_key_alloc()
441 key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN; ieee80211_key_alloc()
444 key->u.ccmp.rx_pn[i][j] = ieee80211_key_alloc()
446 /* Initialize AES key state here as an optimization so that ieee80211_key_alloc()
449 key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt( ieee80211_key_alloc()
451 if (IS_ERR(key->u.ccmp.tfm)) { ieee80211_key_alloc()
452 err = PTR_ERR(key->u.ccmp.tfm); ieee80211_key_alloc()
453 kfree(key); ieee80211_key_alloc()
459 key->conf.iv_len = 0; ieee80211_key_alloc()
461 key->conf.icv_len = sizeof(struct ieee80211_mmie); ieee80211_key_alloc()
463 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); ieee80211_key_alloc()
466 key->u.aes_cmac.rx_pn[j] = ieee80211_key_alloc()
469 * Initialize AES key state here as an optimization so that ieee80211_key_alloc()
472 key->u.aes_cmac.tfm = ieee80211_key_alloc()
474 if (IS_ERR(key->u.aes_cmac.tfm)) { ieee80211_key_alloc()
475 err = PTR_ERR(key->u.aes_cmac.tfm); ieee80211_key_alloc()
476 kfree(key); ieee80211_key_alloc()
482 key->conf.iv_len = 0; ieee80211_key_alloc()
483 key->conf.icv_len = sizeof(struct ieee80211_mmie_16); ieee80211_key_alloc()
486 key->u.aes_gmac.rx_pn[j] = ieee80211_key_alloc()
488 /* Initialize AES key state here as an optimization so that ieee80211_key_alloc()
491 key->u.aes_gmac.tfm = ieee80211_key_alloc()
493 if (IS_ERR(key->u.aes_gmac.tfm)) { ieee80211_key_alloc()
494 err = PTR_ERR(key->u.aes_gmac.tfm); ieee80211_key_alloc()
495 kfree(key); ieee80211_key_alloc()
501 key->conf.iv_len = IEEE80211_GCMP_HDR_LEN; ieee80211_key_alloc()
502 key->conf.icv_len = IEEE80211_GCMP_MIC_LEN; ieee80211_key_alloc()
505 key->u.gcmp.rx_pn[i][j] = ieee80211_key_alloc()
507 /* Initialize AES key state here as an optimization so that ieee80211_key_alloc()
510 key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data, ieee80211_key_alloc()
512 if (IS_ERR(key->u.gcmp.tfm)) { ieee80211_key_alloc()
513 err = PTR_ERR(key->u.gcmp.tfm); ieee80211_key_alloc()
514 kfree(key); ieee80211_key_alloc()
523 key->conf.iv_len = cs->hdr_len; ieee80211_key_alloc()
524 key->conf.icv_len = cs->mic_len; ieee80211_key_alloc()
527 key->u.gen.rx_pn[i][j] = ieee80211_key_alloc()
529 key->flags |= KEY_FLAG_CIPHER_SCHEME; ieee80211_key_alloc()
532 memcpy(key->conf.key, key_data, key_len); ieee80211_key_alloc()
533 INIT_LIST_HEAD(&key->list); ieee80211_key_alloc()
535 return key; ieee80211_key_alloc()
538 static void ieee80211_key_free_common(struct ieee80211_key *key) ieee80211_key_free_common() argument
540 switch (key->conf.cipher) { ieee80211_key_free_common()
543 ieee80211_aes_key_free(key->u.ccmp.tfm); ieee80211_key_free_common()
547 ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); ieee80211_key_free_common()
551 ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm); ieee80211_key_free_common()
555 ieee80211_aes_gcm_key_free(key->u.gcmp.tfm); ieee80211_key_free_common()
558 kzfree(key); ieee80211_key_free_common()
561 static void __ieee80211_key_destroy(struct ieee80211_key *key, __ieee80211_key_destroy() argument
564 if (key->local) __ieee80211_key_destroy()
565 ieee80211_key_disable_hw_accel(key); __ieee80211_key_destroy()
567 if (key->local) { __ieee80211_key_destroy()
568 struct ieee80211_sub_if_data *sdata = key->sdata; __ieee80211_key_destroy()
570 ieee80211_debugfs_key_remove(key); __ieee80211_key_destroy()
582 ieee80211_key_free_common(key); __ieee80211_key_destroy()
585 static void ieee80211_key_destroy(struct ieee80211_key *key, ieee80211_key_destroy() argument
588 if (!key) ieee80211_key_destroy()
593 * this key before we free/remove it. ieee80211_key_destroy()
597 __ieee80211_key_destroy(key, delay_tailroom); ieee80211_key_destroy()
600 void ieee80211_key_free_unused(struct ieee80211_key *key) ieee80211_key_free_unused() argument
602 WARN_ON(key->sdata || key->local); ieee80211_key_free_unused()
603 ieee80211_key_free_common(key); ieee80211_key_free_unused()
606 int ieee80211_key_link(struct ieee80211_key *key, ieee80211_key_link() argument
615 pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE; ieee80211_key_link()
616 idx = key->conf.keyidx; ieee80211_key_link()
617 key->local = sdata->local; ieee80211_key_link()
618 key->sdata = sdata; ieee80211_key_link()
619 key->sta = sta; ieee80211_key_link()
632 ieee80211_key_replace(sdata, sta, pairwise, old_key, key); ieee80211_key_link()
635 ieee80211_debugfs_key_add(key); ieee80211_key_link()
638 ret = ieee80211_key_enable_hw_accel(key); ieee80211_key_link()
640 ieee80211_key_free(key, true); ieee80211_key_link()
650 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom) ieee80211_key_free() argument
652 if (!key) ieee80211_key_free()
656 * Replace key with nothingness if it was ever used. ieee80211_key_free()
658 if (key->sdata) ieee80211_key_free()
659 ieee80211_key_replace(key->sdata, key->sta, ieee80211_key_free()
660 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, ieee80211_key_free()
661 key, NULL); ieee80211_key_free()
662 ieee80211_key_destroy(key, delay_tailroom); ieee80211_key_free()
667 struct ieee80211_key *key; ieee80211_enable_keys() local
686 list_for_each_entry(key, &sdata->key_list, list) { ieee80211_enable_keys()
688 ieee80211_key_enable_hw_accel(key); ieee80211_enable_keys()
715 struct ieee80211_key_conf *key, ieee80211_iter_keys()
720 struct ieee80211_key *key, *tmp; ieee80211_iter_keys() local
728 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) ieee80211_iter_keys()
730 key->sta ? &key->sta->sta : NULL, ieee80211_iter_keys()
731 &key->conf, iter_data); ieee80211_iter_keys()
734 list_for_each_entry_safe(key, tmp, ieee80211_iter_keys()
737 key->sta ? &key->sta->sta : NULL, ieee80211_iter_keys()
738 &key->conf, iter_data); ieee80211_iter_keys()
747 struct ieee80211_key *key, *tmp; ieee80211_free_keys_iface() local
755 list_for_each_entry_safe(key, tmp, &sdata->key_list, list) { ieee80211_free_keys_iface()
756 ieee80211_key_replace(key->sdata, key->sta, ieee80211_free_keys_iface()
757 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, ieee80211_free_keys_iface()
758 key, NULL); ieee80211_free_keys_iface()
759 list_add_tail(&key->list, keys); ieee80211_free_keys_iface()
771 struct ieee80211_key *key, *tmp; ieee80211_free_keys() local
787 list_for_each_entry_safe(key, tmp, &keys, list) ieee80211_free_keys()
788 __ieee80211_key_destroy(key, false); ieee80211_free_keys()
816 struct ieee80211_key *key; ieee80211_free_sta_keys() local
821 key = key_mtx_dereference(local, sta->gtk[i]); ieee80211_free_sta_keys()
822 if (!key) ieee80211_free_sta_keys()
824 ieee80211_key_replace(key->sdata, key->sta, ieee80211_free_sta_keys()
825 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, ieee80211_free_sta_keys()
826 key, NULL); ieee80211_free_sta_keys()
827 __ieee80211_key_destroy(key, true); ieee80211_free_sta_keys()
831 key = key_mtx_dereference(local, sta->ptk[i]); ieee80211_free_sta_keys()
832 if (!key) ieee80211_free_sta_keys()
834 ieee80211_key_replace(key->sdata, key->sta, ieee80211_free_sta_keys()
835 key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE, ieee80211_free_sta_keys()
836 key, NULL); ieee80211_free_sta_keys()
837 __ieee80211_key_destroy(key, true); ieee80211_free_sta_keys()
853 * and then new keys are installed. The first new key causes the ieee80211_delayed_tailroom_dec()
857 * key removal for a while, so if we roam the value is larger than ieee80211_delayed_tailroom_dec()
887 struct ieee80211_key *key; ieee80211_get_key_tx_seq() local
893 key = container_of(keyconf, struct ieee80211_key, conf); ieee80211_get_key_tx_seq()
895 switch (key->conf.cipher) { ieee80211_get_key_tx_seq()
897 seq->tkip.iv32 = key->u.tkip.tx.iv32; ieee80211_get_key_tx_seq()
898 seq->tkip.iv16 = key->u.tkip.tx.iv16; ieee80211_get_key_tx_seq()
902 pn64 = atomic64_read(&key->u.ccmp.tx_pn); ieee80211_get_key_tx_seq()
912 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn); ieee80211_get_key_tx_seq()
922 pn64 = atomic64_read(&key->u.aes_gmac.tx_pn); ieee80211_get_key_tx_seq()
932 pn64 = atomic64_read(&key->u.gcmp.tx_pn); ieee80211_get_key_tx_seq()
949 struct ieee80211_key *key; ieee80211_get_key_rx_seq() local
952 key = container_of(keyconf, struct ieee80211_key, conf); ieee80211_get_key_rx_seq()
954 switch (key->conf.cipher) { ieee80211_get_key_rx_seq()
958 seq->tkip.iv32 = key->u.tkip.rx[tid].iv32; ieee80211_get_key_rx_seq()
959 seq->tkip.iv16 = key->u.tkip.rx[tid].iv16; ieee80211_get_key_rx_seq()
966 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; ieee80211_get_key_rx_seq()
968 pn = key->u.ccmp.rx_pn[tid]; ieee80211_get_key_rx_seq()
975 pn = key->u.aes_cmac.rx_pn; ieee80211_get_key_rx_seq()
982 pn = key->u.aes_gmac.rx_pn; ieee80211_get_key_rx_seq()
990 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; ieee80211_get_key_rx_seq()
992 pn = key->u.gcmp.rx_pn[tid]; ieee80211_get_key_rx_seq()
1002 struct ieee80211_key *key; ieee80211_set_key_tx_seq() local
1005 key = container_of(keyconf, struct ieee80211_key, conf); ieee80211_set_key_tx_seq()
1007 switch (key->conf.cipher) { ieee80211_set_key_tx_seq()
1009 key->u.tkip.tx.iv32 = seq->tkip.iv32; ieee80211_set_key_tx_seq()
1010 key->u.tkip.tx.iv16 = seq->tkip.iv16; ieee80211_set_key_tx_seq()
1020 atomic64_set(&key->u.ccmp.tx_pn, pn64); ieee80211_set_key_tx_seq()
1030 atomic64_set(&key->u.aes_cmac.tx_pn, pn64); ieee80211_set_key_tx_seq()
1040 atomic64_set(&key->u.aes_gmac.tx_pn, pn64); ieee80211_set_key_tx_seq()
1050 atomic64_set(&key->u.gcmp.tx_pn, pn64); ieee80211_set_key_tx_seq()
1062 struct ieee80211_key *key; ieee80211_set_key_rx_seq() local
1065 key = container_of(keyconf, struct ieee80211_key, conf); ieee80211_set_key_rx_seq()
1067 switch (key->conf.cipher) { ieee80211_set_key_rx_seq()
1071 key->u.tkip.rx[tid].iv32 = seq->tkip.iv32; ieee80211_set_key_rx_seq()
1072 key->u.tkip.rx[tid].iv16 = seq->tkip.iv16; ieee80211_set_key_rx_seq()
1079 pn = key->u.ccmp.rx_pn[IEEE80211_NUM_TIDS]; ieee80211_set_key_rx_seq()
1081 pn = key->u.ccmp.rx_pn[tid]; ieee80211_set_key_rx_seq()
1088 pn = key->u.aes_cmac.rx_pn; ieee80211_set_key_rx_seq()
1095 pn = key->u.aes_gmac.rx_pn; ieee80211_set_key_rx_seq()
1103 pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS]; ieee80211_set_key_rx_seq()
1105 pn = key->u.gcmp.rx_pn[tid]; ieee80211_set_key_rx_seq()
1117 struct ieee80211_key *key; ieee80211_remove_key() local
1119 key = container_of(keyconf, struct ieee80211_key, conf); ieee80211_remove_key()
1121 assert_key_lock(key->local); ieee80211_remove_key()
1124 * if key was uploaded, we assume the driver will/has remove(d) ieee80211_remove_key()
1127 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { ieee80211_remove_key()
1128 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; ieee80211_remove_key()
1130 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || ieee80211_remove_key()
1131 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) ieee80211_remove_key()
1132 increment_tailroom_need_count(key->sdata); ieee80211_remove_key()
1135 ieee80211_key_free(key, false); ieee80211_remove_key()
1145 struct ieee80211_key *key; ieee80211_gtk_rekey_add() local
1154 key = ieee80211_key_alloc(keyconf->cipher, keyconf->keyidx, ieee80211_gtk_rekey_add()
1155 keyconf->keylen, keyconf->key, ieee80211_gtk_rekey_add()
1157 if (IS_ERR(key)) ieee80211_gtk_rekey_add()
1158 return ERR_CAST(key); ieee80211_gtk_rekey_add()
1161 key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; ieee80211_gtk_rekey_add()
1163 err = ieee80211_key_link(key, sdata, NULL); ieee80211_gtk_rekey_add()
1167 return &key->conf; ieee80211_gtk_rekey_add()
710 ieee80211_iter_keys(struct ieee80211_hw *hw, struct ieee80211_vif *vif, void (*iter)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key, void *data), void *iter_data) ieee80211_iter_keys() argument
H A Ddebugfs_key.h5 void ieee80211_debugfs_key_add(struct ieee80211_key *key);
6 void ieee80211_debugfs_key_remove(struct ieee80211_key *key);
12 void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key,
15 static inline void ieee80211_debugfs_key_add(struct ieee80211_key *key) ieee80211_debugfs_key_add() argument
17 static inline void ieee80211_debugfs_key_remove(struct ieee80211_key *key) ieee80211_debugfs_key_remove() argument
28 static inline void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, ieee80211_debugfs_key_sta_del() argument
H A Ddebugfs_key.c14 #include "key.h"
23 struct ieee80211_key *key = file->private_data; \
25 format_string, key->prop); \
69 struct ieee80211_key *key = file->private_data; key_algorithm_read() local
70 u32 c = key->conf.cipher; key_algorithm_read()
84 struct ieee80211_key *key = file->private_data; key_tx_spec_read() local
86 switch (key->conf.cipher) { key_tx_spec_read()
93 key->u.tkip.tx.iv32, key_tx_spec_read()
94 key->u.tkip.tx.iv16); key_tx_spec_read()
98 pn = atomic64_read(&key->u.ccmp.tx_pn); key_tx_spec_read()
105 pn = atomic64_read(&key->u.aes_cmac.tx_pn); key_tx_spec_read()
112 pn = atomic64_read(&key->u.aes_gmac.tx_pn); key_tx_spec_read()
119 pn = atomic64_read(&key->u.gcmp.tx_pn); key_tx_spec_read()
134 struct ieee80211_key *key = file->private_data; key_rx_spec_read() local
139 switch (key->conf.cipher) { key_rx_spec_read()
148 key->u.tkip.rx[i].iv32, key_rx_spec_read()
149 key->u.tkip.rx[i].iv16); key_rx_spec_read()
155 rpn = key->u.ccmp.rx_pn[i]; key_rx_spec_read()
165 rpn = key->u.aes_cmac.rx_pn; key_rx_spec_read()
174 rpn = key->u.aes_gmac.rx_pn; key_rx_spec_read()
184 rpn = key->u.gcmp.rx_pn[i]; key_rx_spec_read()
202 struct ieee80211_key *key = file->private_data; key_replays_read() local
206 switch (key->conf.cipher) { key_replays_read()
209 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays); key_replays_read()
214 key->u.aes_cmac.replays); key_replays_read()
219 key->u.aes_gmac.replays); key_replays_read()
223 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.gcmp.replays); key_replays_read()
235 struct ieee80211_key *key = file->private_data; key_icverrors_read() local
239 switch (key->conf.cipher) { key_icverrors_read()
243 key->u.aes_cmac.icverrors); key_icverrors_read()
248 key->u.aes_gmac.icverrors); key_icverrors_read()
260 struct ieee80211_key *key = file->private_data; key_mic_failures_read() local
264 if (key->conf.cipher != WLAN_CIPHER_SUITE_TKIP) key_mic_failures_read()
267 len = scnprintf(buf, sizeof(buf), "%u\n", key->u.tkip.mic_failures); key_mic_failures_read()
276 struct ieee80211_key *key = file->private_data; key_key_read() local
277 int i, bufsize = 2 * key->conf.keylen + 2; key_key_read()
285 for (i = 0; i < key->conf.keylen; i++) key_key_read()
286 p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]); key_key_read()
292 KEY_OPS(key); variable
295 debugfs_create_file(#name, 0400, key->debugfs.dir, \
296 key, &key_##name##_ops);
298 void ieee80211_debugfs_key_add(struct ieee80211_key *key) ieee80211_debugfs_key_add() argument
304 if (!key->local->debugfs.keys) ieee80211_debugfs_key_add()
308 key->debugfs.cnt = keycount; ieee80211_debugfs_key_add()
310 key->debugfs.dir = debugfs_create_dir(buf, ieee80211_debugfs_key_add()
311 key->local->debugfs.keys); ieee80211_debugfs_key_add()
313 if (!key->debugfs.dir) ieee80211_debugfs_key_add()
316 sta = key->sta; ieee80211_debugfs_key_add()
320 key->debugfs.stalink = ieee80211_debugfs_key_add()
321 debugfs_create_symlink("station", key->debugfs.dir, buf); ieee80211_debugfs_key_add()
335 DEBUGFS_ADD(key); ieee80211_debugfs_key_add()
339 void ieee80211_debugfs_key_remove(struct ieee80211_key *key) ieee80211_debugfs_key_remove() argument
341 if (!key) ieee80211_debugfs_key_remove()
344 debugfs_remove_recursive(key->debugfs.dir); ieee80211_debugfs_key_remove()
345 key->debugfs.dir = NULL; ieee80211_debugfs_key_remove()
351 struct ieee80211_key *key; ieee80211_debugfs_key_update_default() local
362 key = key_mtx_dereference(sdata->local, ieee80211_debugfs_key_update_default()
364 sprintf(buf, "../keys/%d", key->debugfs.cnt); ieee80211_debugfs_key_update_default()
374 key = key_mtx_dereference(sdata->local, ieee80211_debugfs_key_update_default()
376 sprintf(buf, "../keys/%d", key->debugfs.cnt); ieee80211_debugfs_key_update_default()
386 struct ieee80211_key *key; ieee80211_debugfs_key_add_mgmt_default() local
391 key = key_mtx_dereference(sdata->local, ieee80211_debugfs_key_add_mgmt_default()
393 if (key) { ieee80211_debugfs_key_add_mgmt_default()
394 sprintf(buf, "../keys/%d", key->debugfs.cnt); ieee80211_debugfs_key_add_mgmt_default()
411 void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, ieee80211_debugfs_key_sta_del() argument
414 debugfs_remove(key->debugfs.stalink); ieee80211_debugfs_key_sta_del()
415 key->debugfs.stalink = NULL; ieee80211_debugfs_key_sta_del()
H A Dtkip.c18 #include "key.h"
145 u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key) ieee80211_tkip_add_iv() argument
147 lockdep_assert_held(&key->u.tkip.txlock); ieee80211_tkip_add_iv()
149 pos = write_tkip_iv(pos, key->u.tkip.tx.iv16); ieee80211_tkip_add_iv()
150 *pos++ = (key->conf.keyidx << 6) | (1 << 5) /* Ext IV */; ieee80211_tkip_add_iv()
151 put_unaligned_le32(key->u.tkip.tx.iv32, pos); ieee80211_tkip_add_iv()
155 static void ieee80211_compute_tkip_p1k(struct ieee80211_key *key, u32 iv32) ieee80211_compute_tkip_p1k() argument
157 struct ieee80211_sub_if_data *sdata = key->sdata; ieee80211_compute_tkip_p1k()
158 struct tkip_ctx *ctx = &key->u.tkip.tx; ieee80211_compute_tkip_p1k()
159 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; ieee80211_compute_tkip_p1k()
161 lockdep_assert_held(&key->u.tkip.txlock); ieee80211_compute_tkip_p1k()
177 struct ieee80211_key *key = (struct ieee80211_key *) ieee80211_get_tkip_p1k_iv() local
179 struct tkip_ctx *ctx = &key->u.tkip.tx; ieee80211_get_tkip_p1k_iv()
181 spin_lock_bh(&key->u.tkip.txlock); ieee80211_get_tkip_p1k_iv()
182 ieee80211_compute_tkip_p1k(key, iv32); ieee80211_get_tkip_p1k_iv()
184 spin_unlock_bh(&key->u.tkip.txlock); ieee80211_get_tkip_p1k_iv()
191 const u8 *tk = &keyconf->key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; ieee80211_get_tkip_rx_p1k()
202 struct ieee80211_key *key = (struct ieee80211_key *) ieee80211_get_tkip_p2k() local
204 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; ieee80211_get_tkip_p2k()
205 struct tkip_ctx *ctx = &key->u.tkip.tx; ieee80211_get_tkip_p2k()
211 spin_lock(&key->u.tkip.txlock); ieee80211_get_tkip_p2k()
212 ieee80211_compute_tkip_p1k(key, iv32); ieee80211_get_tkip_p2k()
214 spin_unlock(&key->u.tkip.txlock); ieee80211_get_tkip_p2k()
219 * Encrypt packet payload with TKIP using @key. @pos is a pointer to the
226 struct ieee80211_key *key, ieee80211_tkip_encrypt_data()
232 ieee80211_get_tkip_p2k(&key->conf, skb, rc4key); ieee80211_tkip_encrypt_data()
238 /* Decrypt packet payload with TKIP using @key. @pos is a pointer to the
243 struct ieee80211_key *key, ieee80211_tkip_decrypt_data()
252 const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; ieee80211_tkip_decrypt_data()
265 if ((keyid >> 6) != key->conf.keyidx) ieee80211_tkip_decrypt_data()
268 if (key->u.tkip.rx[queue].state != TKIP_STATE_NOT_INIT && ieee80211_tkip_decrypt_data()
269 (iv32 < key->u.tkip.rx[queue].iv32 || ieee80211_tkip_decrypt_data()
270 (iv32 == key->u.tkip.rx[queue].iv32 && ieee80211_tkip_decrypt_data()
271 iv16 <= key->u.tkip.rx[queue].iv16))) ieee80211_tkip_decrypt_data()
276 key->u.tkip.rx[queue].state = TKIP_STATE_PHASE1_HW_UPLOADED; ieee80211_tkip_decrypt_data()
280 if (key->u.tkip.rx[queue].state == TKIP_STATE_NOT_INIT || ieee80211_tkip_decrypt_data()
281 key->u.tkip.rx[queue].iv32 != iv32) { ieee80211_tkip_decrypt_data()
283 tkip_mixing_phase1(tk, &key->u.tkip.rx[queue], ta, iv32); ieee80211_tkip_decrypt_data()
285 if (key->local->ops->update_tkip_key && ieee80211_tkip_decrypt_data()
286 key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && ieee80211_tkip_decrypt_data()
287 key->u.tkip.rx[queue].state != TKIP_STATE_PHASE1_HW_UPLOADED) { ieee80211_tkip_decrypt_data()
288 struct ieee80211_sub_if_data *sdata = key->sdata; ieee80211_tkip_decrypt_data()
291 sdata = container_of(key->sdata->bss, ieee80211_tkip_decrypt_data()
293 drv_update_tkip_key(key->local, sdata, &key->conf, key->sta, ieee80211_tkip_decrypt_data()
294 iv32, key->u.tkip.rx[queue].p1k); ieee80211_tkip_decrypt_data()
295 key->u.tkip.rx[queue].state = TKIP_STATE_PHASE1_HW_UPLOADED; ieee80211_tkip_decrypt_data()
298 tkip_mixing_phase2(tk, &key->u.tkip.rx[queue], iv16, rc4key); ieee80211_tkip_decrypt_data()
305 * key information after MIC verification. It is possible ieee80211_tkip_decrypt_data()
225 ieee80211_tkip_encrypt_data(struct crypto_cipher *tfm, struct ieee80211_key *key, struct sk_buff *skb, u8 *payload, size_t payload_len) ieee80211_tkip_encrypt_data() argument
242 ieee80211_tkip_decrypt_data(struct crypto_cipher *tfm, struct ieee80211_key *key, u8 *payload, size_t payload_len, u8 *ta, u8 *ra, int only_iv, int queue, u32 *out_iv32, u16 *out_iv16) ieee80211_tkip_decrypt_data() argument
H A Dtkip.h14 #include "key.h"
16 u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key);
19 struct ieee80211_key *key,
30 struct ieee80211_key *key,
H A Dwpa.c32 u8 *data, *key, *mic; ieee80211_tx_h_michael_mic_add() local
41 if (!tx->key || tx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP || ieee80211_tx_h_michael_mic_add()
60 !(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) { ieee80211_tx_h_michael_mic_add()
76 key = &tx->key->conf.key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]; ieee80211_tx_h_michael_mic_add()
78 michael_mic(key, hdr, data, data_len, mic); ieee80211_tx_h_michael_mic_add()
89 u8 *data, *key = NULL; ieee80211_rx_h_michael_mic_verify() local
106 * the IV with the key index. In this case we have solely rely ieee80211_rx_h_michael_mic_verify()
114 if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key && ieee80211_rx_h_michael_mic_verify()
115 rx->key->conf.cipher == WLAN_CIPHER_SUITE_TKIP) ieee80211_rx_h_michael_mic_verify()
126 if (!rx->key || rx->key->conf.cipher != WLAN_CIPHER_SUITE_TKIP || ieee80211_rx_h_michael_mic_verify()
130 if (rx->sdata->vif.type == NL80211_IFTYPE_AP && rx->key->conf.keyidx) { ieee80211_rx_h_michael_mic_verify()
153 key = &rx->key->conf.key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]; ieee80211_rx_h_michael_mic_verify()
154 michael_mic(key, hdr, data, data_len, mic); ieee80211_rx_h_michael_mic_verify()
162 /* update IV in key information to be able to detect replays */ ieee80211_rx_h_michael_mic_verify()
163 rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip_iv32; ieee80211_rx_h_michael_mic_verify()
164 rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip_iv16; ieee80211_rx_h_michael_mic_verify()
169 rx->key->u.tkip.mic_failures++; ieee80211_rx_h_michael_mic_verify()
173 * In some cases the key can be unset - e.g. a multicast packet, in ieee80211_rx_h_michael_mic_verify()
174 * a driver that supports HW encryption. Send up the key idx only if ieee80211_rx_h_michael_mic_verify()
175 * the key is set. ieee80211_rx_h_michael_mic_verify()
178 rx->key ? rx->key->conf.keyidx : -1, ieee80211_rx_h_michael_mic_verify()
187 struct ieee80211_key *key = tx->key; tkip_encrypt_skb() local
222 spin_lock(&key->u.tkip.txlock); tkip_encrypt_skb()
223 key->u.tkip.tx.iv16++; tkip_encrypt_skb()
224 if (key->u.tkip.tx.iv16 == 0) tkip_encrypt_skb()
225 key->u.tkip.tx.iv32++; tkip_encrypt_skb()
226 pos = ieee80211_tkip_add_iv(pos, key); tkip_encrypt_skb()
227 spin_unlock(&key->u.tkip.txlock); tkip_encrypt_skb()
237 key, skb, pos, len); tkip_encrypt_skb()
262 struct ieee80211_key *key = rx->key; ieee80211_crypto_tkip_decrypt() local
288 key, skb->data + hdrlen, ieee80211_crypto_tkip_decrypt()
402 struct ieee80211_key *key = tx->key; ccmp_encrypt_skb() local
447 pn64 = atomic64_inc_return(&key->u.ccmp.tx_pn); ccmp_encrypt_skb()
456 ccmp_pn2hdr(pos, pn, key->conf.keyidx); ccmp_encrypt_skb()
464 ieee80211_aes_ccm_encrypt(key->u.ccmp.tfm, b_0, aad, pos, len, ccmp_encrypt_skb()
494 struct ieee80211_key *key = rx->key; ieee80211_crypto_ccmp_decrypt() local
523 if (memcmp(pn, key->u.ccmp.rx_pn[queue], IEEE80211_CCMP_PN_LEN) <= 0) { ieee80211_crypto_ccmp_decrypt()
524 key->u.ccmp.replays++; ieee80211_crypto_ccmp_decrypt()
535 key->u.ccmp.tfm, b_0, aad, ieee80211_crypto_ccmp_decrypt()
542 memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN); ieee80211_crypto_ccmp_decrypt()
627 struct ieee80211_key *key = tx->key; gcmp_encrypt_skb() local
673 pn64 = atomic64_inc_return(&key->u.gcmp.tx_pn); gcmp_encrypt_skb()
682 gcmp_pn2hdr(pos, pn, key->conf.keyidx); gcmp_encrypt_skb()
690 ieee80211_aes_gcm_encrypt(key->u.gcmp.tfm, j_0, aad, pos, len, gcmp_encrypt_skb()
716 struct ieee80211_key *key = rx->key; ieee80211_crypto_gcmp_decrypt() local
746 if (memcmp(pn, key->u.gcmp.rx_pn[queue], IEEE80211_GCMP_PN_LEN) <= 0) { ieee80211_crypto_gcmp_decrypt()
747 key->u.gcmp.replays++; ieee80211_crypto_gcmp_decrypt()
758 key->u.gcmp.tfm, j_0, aad, ieee80211_crypto_gcmp_decrypt()
765 memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN); ieee80211_crypto_gcmp_decrypt()
781 struct ieee80211_key *key = tx->key; ieee80211_crypto_cs_encrypt() local
784 u8 *pos, iv_len = key->conf.iv_len; ieee80211_crypto_cs_encrypt()
822 struct ieee80211_key *key = rx->key; ieee80211_crypto_cs_decrypt() local
857 rx_pn = key->u.gen.rx_pn[qos_tid]; ieee80211_crypto_cs_decrypt()
919 struct ieee80211_key *key = tx->key; ieee80211_crypto_aes_cmac_encrypt() local
940 mmie->key_id = cpu_to_le16(key->conf.keyidx); ieee80211_crypto_aes_cmac_encrypt()
943 pn64 = atomic64_inc_return(&key->u.aes_cmac.tx_pn); ieee80211_crypto_aes_cmac_encrypt()
952 ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad, ieee80211_crypto_aes_cmac_encrypt()
963 struct ieee80211_key *key = tx->key; ieee80211_crypto_aes_cmac_256_encrypt() local
984 mmie->key_id = cpu_to_le16(key->conf.keyidx); ieee80211_crypto_aes_cmac_256_encrypt()
987 pn64 = atomic64_inc_return(&key->u.aes_cmac.tx_pn); ieee80211_crypto_aes_cmac_256_encrypt()
995 ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad, ieee80211_crypto_aes_cmac_256_encrypt()
1006 struct ieee80211_key *key = rx->key; ieee80211_crypto_aes_cmac_decrypt() local
1027 if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) { ieee80211_crypto_aes_cmac_decrypt()
1028 key->u.aes_cmac.replays++; ieee80211_crypto_aes_cmac_decrypt()
1035 ieee80211_aes_cmac(key->u.aes_cmac.tfm, aad, ieee80211_crypto_aes_cmac_decrypt()
1038 key->u.aes_cmac.icverrors++; ieee80211_crypto_aes_cmac_decrypt()
1043 memcpy(key->u.aes_cmac.rx_pn, ipn, 6); ieee80211_crypto_aes_cmac_decrypt()
1056 struct ieee80211_key *key = rx->key; ieee80211_crypto_aes_cmac_256_decrypt() local
1077 if (memcmp(ipn, key->u.aes_cmac.rx_pn, 6) <= 0) { ieee80211_crypto_aes_cmac_256_decrypt()
1078 key->u.aes_cmac.replays++; ieee80211_crypto_aes_cmac_256_decrypt()
1085 ieee80211_aes_cmac_256(key->u.aes_cmac.tfm, aad, ieee80211_crypto_aes_cmac_256_decrypt()
1088 key->u.aes_cmac.icverrors++; ieee80211_crypto_aes_cmac_256_decrypt()
1093 memcpy(key->u.aes_cmac.rx_pn, ipn, 6); ieee80211_crypto_aes_cmac_256_decrypt()
1106 struct ieee80211_key *key = tx->key; ieee80211_crypto_aes_gmac_encrypt() local
1129 mmie->key_id = cpu_to_le16(key->conf.keyidx); ieee80211_crypto_aes_gmac_encrypt()
1132 pn64 = atomic64_inc_return(&key->u.aes_gmac.tx_pn); ieee80211_crypto_aes_gmac_encrypt()
1143 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, ieee80211_crypto_aes_gmac_encrypt()
1155 struct ieee80211_key *key = rx->key; ieee80211_crypto_aes_gmac_decrypt() local
1176 if (memcmp(ipn, key->u.aes_gmac.rx_pn, 6) <= 0) { ieee80211_crypto_aes_gmac_decrypt()
1177 key->u.aes_gmac.replays++; ieee80211_crypto_aes_gmac_decrypt()
1188 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, ieee80211_crypto_aes_gmac_decrypt()
1192 key->u.aes_gmac.icverrors++; ieee80211_crypto_aes_gmac_decrypt()
1197 memcpy(key->u.aes_gmac.rx_pn, ipn, 6); ieee80211_crypto_aes_gmac_decrypt()
1219 if (tx->key->flags & KEY_FLAG_CIPHER_SCHEME) { ieee80211_crypto_hw_encrypt()
H A Dkey.h28 * enum ieee80211_internal_key_flags - internal key flags
30 * @KEY_FLAG_UPLOADED_TO_HARDWARE: Indicates that this key is present
33 * @KEY_FLAG_CIPHER_SCHEME: This key is for a hardware cipher scheme
63 /* protected by key mutex */
123 /* number of times this key has been used */
135 * key config, must be last because it contains key
147 * Insert a key into data structures (sdata, sta if necessary)
148 * to make it used, free old key. On failure, also free the new key.
150 int ieee80211_key_link(struct ieee80211_key *key,
153 void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom);
154 void ieee80211_key_free_unused(struct ieee80211_key *key);
H A Dmichael.c30 static void michael_mic_hdr(struct michael_mic_ctx *mctx, const u8 *key, michael_mic_hdr() argument
42 mctx->l = get_unaligned_le32(key); michael_mic_hdr()
43 mctx->r = get_unaligned_le32(key + 4); michael_mic_hdr()
56 void michael_mic(const u8 *key, struct ieee80211_hdr *hdr, michael_mic() argument
63 michael_mic_hdr(&mctx, key, hdr); michael_mic()
H A Dwep.c61 * key scheduling algorithm of RC4. At least IVs (KeyByte + 3, ieee80211_wep_weak_iv()
120 struct ieee80211_key *key) ieee80211_wep_remove_iv()
131 /* Perform WEP encryption using given key. data buffer must have tailroom
159 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
163 const u8 *key, int keylen, int keyidx) ieee80211_wep_encrypt()
178 /* Prepend 24-bit IV to RC4 key */ ieee80211_wep_encrypt()
181 /* Copy rest of the WEP key (the secret part) */ ieee80211_wep_encrypt()
182 memcpy(rc4key + 3, key, keylen); ieee80211_wep_encrypt()
192 /* Perform WEP decryption using given key. data buffer includes encrypted
227 struct ieee80211_key *key) ieee80211_wep_decrypt()
248 if (!key || keyidx != key->conf.keyidx) ieee80211_wep_decrypt()
251 klen = 3 + key->conf.keylen; ieee80211_wep_decrypt()
253 /* Prepend 24-bit IV to RC4 key */ ieee80211_wep_decrypt()
256 /* Copy rest of the WEP key (the secret part) */ ieee80211_wep_decrypt()
257 memcpy(rc4key + 3, key->conf.key, key->conf.keylen); ieee80211_wep_decrypt()
288 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) ieee80211_crypto_wep_decrypt()
294 ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key); ieee80211_crypto_wep_decrypt()
309 if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, wep_encrypt_skb()
310 tx->key->conf.keylen, wep_encrypt_skb()
311 tx->key->conf.keyidx)) wep_encrypt_skb()
316 tx->key->conf.keylen, wep_encrypt_skb()
317 tx->key->conf.keyidx)) wep_encrypt_skb()
118 ieee80211_wep_remove_iv(struct ieee80211_local *local, struct sk_buff *skb, struct ieee80211_key *key) ieee80211_wep_remove_iv() argument
161 ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, const u8 *key, int keylen, int keyidx) ieee80211_wep_encrypt() argument
225 ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb, struct ieee80211_key *key) ieee80211_wep_decrypt() argument
/linux-4.1.27/drivers/staging/vt6656/
H A Dkey.c20 * File: key.c
35 #include "key.h"
51 struct ieee80211_key_conf *key, u32 key_type, u32 mode, vnt_set_keymode()
59 u8 key_inx = key->keyidx; vnt_set_keymode()
72 key->hw_key_idx = i; vnt_set_keymode()
73 entry = key->hw_key_idx; vnt_set_keymode()
82 /* default key last entry */ vnt_set_keymode()
84 key->hw_key_idx = entry; vnt_set_keymode()
98 /* Don't save entry for pairwise key for station mode */ vnt_set_keymode()
110 if (key->keylen == WLAN_KEY_LEN_WEP40) vnt_set_keymode()
111 key->key[15] &= 0x7f; vnt_set_keymode()
112 if (key->keylen == WLAN_KEY_LEN_WEP104) vnt_set_keymode()
113 key->key[15] |= 0x80; vnt_set_keymode()
116 vnt_mac_set_keyentry(priv, key_mode, entry, key_inx, bssid, key->key); vnt_set_keymode()
122 struct ieee80211_vif *vif, struct ieee80211_key_conf *key) vnt_set_keys()
133 switch (key->cipher) { vnt_set_keys()
144 vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY, vnt_set_keys()
147 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
151 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; vnt_set_keys()
152 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
163 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
167 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { vnt_set_keys()
168 vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE, vnt_set_keys()
171 vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY, vnt_set_keys()
174 vnt_set_keymode(hw, (u8 *)conf->bssid, key, vnt_set_keys() local
50 vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr, struct ieee80211_key_conf *key, u32 key_type, u32 mode, bool onfly_latch) vnt_set_keymode() argument
121 vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct ieee80211_vif *vif, struct ieee80211_key_conf *key) vnt_set_keys() argument
H A DMakefile13 key.o \
/linux-4.1.27/drivers/crypto/vmx/
H A Daesp8-ppc.h7 u8 key[AES_MAX_KEYLENGTH]; member in struct:aes_key
12 struct aes_key *key);
14 struct aes_key *key);
15 void aes_p8_encrypt(const u8 *in, u8 *out, const struct aes_key *key);
16 void aes_p8_decrypt(const u8 *in, u8 *out,const struct aes_key *key);
18 const struct aes_key *key, u8 *iv, const int enc);
20 size_t len, const struct aes_key *key, const u8 *iv);
H A Daesp8-ppc.pl62 my ($zero,$in0,$in1,$key,$rcon,$mask,$tmp)=map("v$_",(0..6));
115 lvsr $key,0,r9 # borrow $key
121 le?vxor $key,$key,$mask # adjust for byte swap
124 vperm $in0,$in0,$in1,$key # align [and byte swap in LE]
142 vperm $key,$in0,$in0,$mask # rotate-n-splat
147 vcipherlast $key,$key,$rcon
157 vxor $in0,$in0,$key
162 vperm $key,$in0,$in0,$mask # rotate-n-splat
167 vcipherlast $key,$key,$rcon
177 vxor $in0,$in0,$key
179 vperm $key,$in0,$in0,$mask # rotate-n-splat
184 vcipherlast $key,$key,$rcon
193 vxor $in0,$in0,$key
214 vperm $in1,$in1,$tmp,$key # align [and byte swap in LE]
215 vspltisb $key,8 # borrow $key
217 vsububm $mask,$mask,$key # adjust the mask
220 vperm $key,$in1,$in1,$mask # roate-n-splat
222 vcipherlast $key,$key,$rcon
236 vxor $in0,$in0,$key
237 vxor $in1,$in1,$key
240 vperm $key,$in1,$in1,$mask # rotate-n-splat
245 vcipherlast $key,$key,$rcon
266 vxor $in0,$in0,$key
267 vxor $in1,$in1,$key
290 vperm $in1,$in1,$tmp,$key # align [and byte swap in LE]
294 vperm $key,$in1,$in1,$mask # rotate-n-splat
299 vcipherlast $key,$key,$rcon
309 vxor $in0,$in0,$key
318 vspltw $key,$in0,3 # just splat
320 vsbox $key,$key
328 vxor $in1,$in1,$key
359 subi $inp,$out,240 # first round key
361 add $out,$inp,$cnt # last round key
400 my ($inp,$out,$key,$rounds,$idx)=map("r$_",(3..7));
404 lwz $rounds,240($key)
419 lvx v1,0,$key
420 ?lvsl v5,0,$key # keyperm
422 lvx v2,$idx,$key
425 ?vperm v1,v1,v2,v5 # align round key
428 lvx v1,$idx,$key
435 lvx v2,$idx,$key
439 lvx v1,$idx,$key
445 lvx v2,$idx,$key
475 my ($inp,$out,$len,$key,$ivp,$enc,$rounds,$idx)=map("r$_",(3..10));
500 ?lvsl $keyperm,0,$key # prepare for unaligned key
501 lwz $rounds,240($key)
526 lvx $rndkey0,0,$key
528 lvx $rndkey1,$idx,$key
532 lvx $rndkey0,$idx,$key
539 lvx $rndkey1,$idx,$key
543 lvx $rndkey0,$idx,$key
549 lvx $rndkey1,$idx,$key
574 lvx $rndkey0,0,$key
576 lvx $rndkey1,$idx,$key
580 lvx $rndkey0,$idx,$key
586 lvx $rndkey1,$idx,$key
590 lvx $rndkey0,$idx,$key
596 lvx $rndkey1,$idx,$key
697 lvx $rndkey0,$x00,$key # load key schedule
698 lvx v30,$x10,$key
699 addi $key,$key,0x20
700 lvx v31,$x00,$key
707 lvx v30,$x10,$key
708 addi $key,$key,0x20
711 lvx v31,$x00,$key
716 lvx v26,$x10,$key
718 lvx v27,$x20,$key
721 lvx v28,$x30,$key
725 lvx v29,$x40,$key
727 lvx v30,$x50,$key
729 lvx v31,$x60,$key
731 lvx $out0,$x70,$key # borrow $out0
862 vxor $ivec,$ivec,v31 # xor with last round key
1009 vxor $ivec,$ivec,v31 # last round key
1230 my ($inp,$out,$len,$key,$ivp,$x10,$rounds,$idx)=map("r$_",(3..10));
1258 ?lvsl $keyperm,0,$key # prepare for unaligned key
1259 lwz $rounds,240($key)
1279 lvx $rndkey0,0,$key
1281 lvx $rndkey1,$idx,$key
1285 lvx $rndkey0,$idx,$key
1293 lvx $rndkey1,$idx,$key
1297 lvx $rndkey0,$idx,$key
1309 lvx $rndkey1,$idx,$key
1313 lvx $rndkey0,0,$key
1314 vxor $dat,$dat,$rndkey1 # last round key
1317 lvx $rndkey1,$idx,$key
1325 lvx $rndkey0,$idx,$key
1400 lvx $rndkey0,$x00,$key # load key schedule
1401 lvx v30,$x10,$key
1402 addi $key,$key,0x20
1403 lvx v31,$x00,$key
1410 lvx v30,$x10,$key
1411 addi $key,$key,0x20
1414 lvx v31,$x00,$key
1419 lvx v26,$x10,$key
1421 lvx v27,$x20,$key
1424 lvx v28,$x30,$key
1428 lvx v29,$x40,$key
1430 lvx v30,$x50,$key
1432 lvx v31,$x60,$key
1434 lvx $out0,$x70,$key # borrow $out0
1577 vxor $in0,$in0,v31 # xor with last round key
/linux-4.1.27/crypto/asymmetric_keys/
H A Dpublic_key.c1 /* In-software asymmetric public-key crypto subtype
46 * Provide a part of a description of the key for /proc/keys.
48 static void public_key_describe(const struct key *asymmetric_key, public_key_describe()
51 struct public_key *key = asymmetric_key->payload.data; public_key_describe() local
53 if (key) public_key_describe()
55 pkey_id_type_name[key->id_type], key->algo->name); public_key_describe()
59 * Destroy a public key algorithm key.
63 struct public_key *key = payload; public_key_destroy() local
66 if (key) { public_key_destroy()
67 for (i = 0; i < ARRAY_SIZE(key->mpi); i++) public_key_destroy()
68 mpi_free(key->mpi[i]); public_key_destroy()
69 kfree(key); public_key_destroy()
75 * Verify a signature using a public key.
111 static int public_key_verify_signature_2(const struct key *key, public_key_verify_signature_2() argument
114 const struct public_key *pk = key->payload.data; public_key_verify_signature_2()
119 * Public key algorithm asymmetric key subtype
H A Dpkcs7_trust.c18 #include <linux/key.h>
28 struct key *trust_keyring) pkcs7_validate_trust_one()
32 struct key *key; pkcs7_validate_trust_one() local
57 key = x509_request_asymmetric_key(trust_keyring, x509->id, pkcs7_validate_trust_one()
59 if (!IS_ERR(key)) { pkcs7_validate_trust_one()
65 pr_devel("sinfo %u: Cert %u as key %x\n", pkcs7_validate_trust_one()
66 sinfo->index, x509->index, key_serial(key)); pkcs7_validate_trust_one()
69 if (key == ERR_PTR(-ENOMEM)) pkcs7_validate_trust_one()
89 key = x509_request_asymmetric_key(trust_keyring, last->akid_skid, pkcs7_validate_trust_one()
91 if (!IS_ERR(key)) { pkcs7_validate_trust_one()
93 pr_devel("sinfo %u: Root cert %u signer is key %x\n", pkcs7_validate_trust_one()
94 sinfo->index, x509->index, key_serial(key)); pkcs7_validate_trust_one()
97 if (PTR_ERR(key) != -ENOKEY) pkcs7_validate_trust_one()
98 return PTR_ERR(key); pkcs7_validate_trust_one()
101 /* As a last resort, see if we have a trusted public key that matches pkcs7_validate_trust_one()
104 key = x509_request_asymmetric_key(trust_keyring, pkcs7_validate_trust_one()
107 if (!IS_ERR(key)) { pkcs7_validate_trust_one()
108 pr_devel("sinfo %u: Direct signer is key %x\n", pkcs7_validate_trust_one()
109 sinfo->index, key_serial(key)); pkcs7_validate_trust_one()
113 if (PTR_ERR(key) != -ENOKEY) pkcs7_validate_trust_one()
114 return PTR_ERR(key); pkcs7_validate_trust_one()
120 ret = verify_signature(key, sig); pkcs7_validate_trust_one()
121 trusted = test_bit(KEY_FLAG_TRUSTED, &key->flags); pkcs7_validate_trust_one()
122 key_put(key); pkcs7_validate_trust_one()
155 * key, or:
169 struct key *trust_keyring, pkcs7_validate_trust()
H A Dsignature.c1 /* Signature verification with an asymmetric key
22 * verify_signature - Initiate the use of an asymmetric key to verify a signature
23 * @key: The asymmetric key to verify against
28 int verify_signature(const struct key *key, verify_signature() argument
36 if (key->type != &key_type_asymmetric) verify_signature()
38 subtype = asymmetric_key_subtype(key); verify_signature()
40 !key->payload.data) verify_signature()
45 ret = subtype->verify_signature(key, sig); verify_signature()
H A Dasymmetric_keys.h1 /* Internal definitions for asymmetric key type
18 const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key) asymmetric_key_ids() argument
20 return key->type_data.p[1]; asymmetric_key_ids()
H A Dasymmetric_type.c1 /* Asymmetric public-key cryptography key type
27 * asymmetric_key_generate_id: Construct an asymmetric key ID
33 * Construct an asymmetric key ID from a pair of binary blobs.
55 * @kid_1, @kid_2: The key IDs to compare
71 * @kid_1, @kid_2: The key IDs to compare
86 * asymmetric_match_key_ids - Search asymmetric key IDs
87 * @kids: The list of key IDs to check
88 * @match_id: The key ID we're looking for
117 * asymmetric_key_hex_to_key_id - Convert a hex string into a key ID.
147 static bool asymmetric_key_cmp(const struct key *key, asymmetric_key_cmp() argument
150 const struct asymmetric_key_ids *kids = asymmetric_key_ids(key); asymmetric_key_cmp()
160 static bool asymmetric_key_cmp_partial(const struct key *key, asymmetric_key_cmp_partial() argument
163 const struct asymmetric_key_ids *kids = asymmetric_key_ids(key); asymmetric_key_cmp_partial()
172 * the default will be an exact match on the key description.
174 * There are some specifiers for matching key IDs rather than by the key
177 * "id:<id>" - find a key by partial match on any available ID
178 * "ex:<id>" - find a key by exact match on any available ID
181 * the key is hashed according to its description.
188 bool (*cmp)(const struct key *, const struct key_match_data *) = asymmetric_key_match_preparse()
228 * Describe the asymmetric key
230 static void asymmetric_key_describe(const struct key *key, struct seq_file *m) asymmetric_key_describe() argument
232 const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); asymmetric_key_describe()
233 const struct asymmetric_key_ids *kids = asymmetric_key_ids(key); asymmetric_key_describe()
238 seq_puts(m, key->description); asymmetric_key_describe()
242 subtype->describe(key, m); asymmetric_key_describe()
257 /* put something here to indicate the key's capabilities */ asymmetric_key_describe()
266 * We also generate a proposed description from the contents of the key that
267 * can be used to name the key if the user doesn't want to provide one.
322 * dispose of the data dangling from the corpse of a asymmetric key
324 static void asymmetric_key_destroy(struct key *key) asymmetric_key_destroy() argument
326 struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key); asymmetric_key_destroy()
327 struct asymmetric_key_ids *kids = key->type_data.p[1]; asymmetric_key_destroy()
330 subtype->destroy(key->payload.data); asymmetric_key_destroy()
332 key->type_data.p[0] = NULL; asymmetric_key_destroy()
339 key->type_data.p[1] = NULL; asymmetric_key_destroy()
356 * register_asymmetric_key_parser - Register a asymmetric key blob parser
368 pr_err("Asymmetric key parser '%s' already registered\n", register_asymmetric_key_parser()
377 pr_notice("Asymmetric key parser '%s' registered\n", parser->name); register_asymmetric_key_parser()
387 * unregister_asymmetric_key_parser - Unregister a asymmetric key blob parser
396 pr_notice("Asymmetric key parser '%s' unregistered\n", parser->name); unregister_asymmetric_key_parser()
H A Dx509_public_key.c1 /* Instantiate a public key crypto key from an X.509 Certificate
55 ca_keyid = p; /* owner key 'id:xxxxxx' */ ca_keys_setup()
66 * x509_request_asymmetric_key - Request a key by X.509 certificate params.
68 * @kid: The key ID.
71 * Find a key in the given keyring by subject name and key ID. These might,
72 * for instance, be the issuer name and the authority key ID of an X.509
75 struct key *x509_request_asymmetric_key(struct key *keyring, x509_request_asymmetric_key()
79 key_ref_t key; x509_request_asymmetric_key() local
100 key = keyring_search(make_key_ref(keyring, 1), x509_request_asymmetric_key()
102 if (IS_ERR(key)) x509_request_asymmetric_key()
103 pr_debug("Request for key '%s' err %ld\n", id, PTR_ERR(key)); x509_request_asymmetric_key()
106 if (IS_ERR(key)) { x509_request_asymmetric_key()
107 switch (PTR_ERR(key)) { x509_request_asymmetric_key()
114 return ERR_CAST(key); x509_request_asymmetric_key()
119 key_serial(key_ref_to_ptr(key))); x509_request_asymmetric_key()
120 return key_ref_to_ptr(key); x509_request_asymmetric_key()
191 * Check the signature on a certificate using the provided public key
214 * those is the signing key and validates the new certificate, then mark the
222 struct key *trust_keyring) x509_validate_trust()
224 struct key *key; x509_validate_trust() local
233 key = x509_request_asymmetric_key(trust_keyring, cert->akid_skid, x509_validate_trust()
235 if (!IS_ERR(key)) { x509_validate_trust()
237 || test_bit(KEY_FLAG_BUILTIN, &key->flags)) x509_validate_trust()
238 ret = x509_check_signature(key->payload.data, cert); x509_validate_trust()
239 key_put(key); x509_validate_trust()
245 * Attempt to parse a data blob for a key as an X509 certificate.
282 /* Check the signature on the key if it appears to be self-signed */ x509_key_preparse()
H A Dpublic_key.h1 /* Public key algorithm internals
19 * Public key algorithm definition.
23 u8 n_pub_mpi; /* Number of MPIs in public key */
24 u8 n_sec_mpi; /* Number of MPIs in secret key */
26 int (*verify_signature)(const struct public_key *key,
/linux-4.1.27/drivers/staging/vt6655/
H A Dkey.c20 * File: key.c
31 #include "key.h"
45 struct ieee80211_key_conf *key, u32 key_type, u32 mode, vnt_set_keymode()
53 u8 key_inx = key->keyidx; vnt_set_keymode()
66 key->hw_key_idx = i; vnt_set_keymode()
67 entry = key->hw_key_idx; vnt_set_keymode()
76 /* default key last entry */ vnt_set_keymode()
78 key->hw_key_idx = entry; vnt_set_keymode()
101 if (key->keylen == WLAN_KEY_LEN_WEP40) vnt_set_keymode()
102 key->key[15] &= 0x7f; vnt_set_keymode()
103 if (key->keylen == WLAN_KEY_LEN_WEP104) vnt_set_keymode()
104 key->key[15] |= 0x80; vnt_set_keymode()
108 bssid, (u32 *)key->key, priv->byLocalID); vnt_set_keymode()
114 struct ieee80211_vif *vif, struct ieee80211_key_conf *key) vnt_set_keys()
126 switch (key->cipher) { vnt_set_keys()
138 key, VNT_KEY_DEFAULTKEY, KEY_CTL_WEP, true); vnt_set_keys()
140 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
144 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; vnt_set_keys()
145 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
153 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; vnt_set_keys()
156 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { vnt_set_keys()
158 key, VNT_KEY_PAIRWISE, key_dec_mode, true); vnt_set_keys()
161 key, VNT_KEY_DEFAULTKEY, key_dec_mode, true); vnt_set_keys()
164 key, VNT_KEY_GROUP_ADDRESS, key_dec_mode, true); vnt_set_keys() local
44 vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr, struct ieee80211_key_conf *key, u32 key_type, u32 mode, bool onfly_latch) vnt_set_keymode() argument
113 vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct ieee80211_vif *vif, struct ieee80211_key_conf *key) vnt_set_keys() argument
H A DMakefile15 key.o \
/linux-4.1.27/fs/cachefiles/
H A Dkey.c30 * turn the raw key into something cooked
31 * - the raw key should include the length in the two bytes at the front
32 * - the key may be up to 514 bytes in length (including the length word)
35 * - need to cut the cooked key into 252 char lengths (189 raw bytes)
41 char *key; cachefiles_cook_key() local
66 /* calculate the maximum length of the cooked key */ cachefiles_cook_key()
81 key = kmalloc(max, cachefiles_gfp); cachefiles_cook_key()
82 if (!key) cachefiles_cook_key()
87 /* build the cooked key */ cachefiles_cook_key()
88 sprintf(key, "@%02x%c+", (unsigned) csum, 0); cachefiles_cook_key()
96 key[len + 1] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
98 key[len] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
104 key[len++] = '\0'; cachefiles_cook_key()
106 key[len++] = '+'; cachefiles_cook_key()
110 key[len++] = *raw++; cachefiles_cook_key()
123 key[len++] = '\0'; cachefiles_cook_key()
125 key[len++] = '+'; cachefiles_cook_key()
135 key[len++] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
137 key[len++] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
139 key[len++] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
141 key[len++] = cachefiles_charmap[acc & 63]; cachefiles_cook_key()
153 key[mark] = type; cachefiles_cook_key()
154 key[len++] = 0; cachefiles_cook_key()
155 key[len] = 0; cachefiles_cook_key()
157 _leave(" = %p %d", key, len); cachefiles_cook_key()
158 return key; cachefiles_cook_key()
H A DMakefile9 key.o \
/linux-4.1.27/kernel/
H A Djump_label.c38 if (jea->key < jeb->key) jump_label_cmp()
41 if (jea->key > jeb->key) jump_label_cmp()
57 static void jump_label_update(struct static_key *key, int enable);
59 void static_key_slow_inc(struct static_key *key) static_key_slow_inc() argument
62 if (atomic_inc_not_zero(&key->enabled)) static_key_slow_inc()
66 if (atomic_read(&key->enabled) == 0) { static_key_slow_inc()
67 if (!jump_label_get_branch_default(key)) static_key_slow_inc()
68 jump_label_update(key, JUMP_LABEL_ENABLE); static_key_slow_inc()
70 jump_label_update(key, JUMP_LABEL_DISABLE); static_key_slow_inc()
72 atomic_inc(&key->enabled); static_key_slow_inc()
77 static void __static_key_slow_dec(struct static_key *key, __static_key_slow_dec() argument
80 if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex)) { __static_key_slow_dec()
81 WARN(atomic_read(&key->enabled) < 0, __static_key_slow_dec()
87 atomic_inc(&key->enabled); __static_key_slow_dec()
90 if (!jump_label_get_branch_default(key)) __static_key_slow_dec()
91 jump_label_update(key, JUMP_LABEL_DISABLE); __static_key_slow_dec()
93 jump_label_update(key, JUMP_LABEL_ENABLE); __static_key_slow_dec()
100 struct static_key_deferred *key = jump_label_update_timeout() local
102 __static_key_slow_dec(&key->key, 0, NULL); jump_label_update_timeout()
105 void static_key_slow_dec(struct static_key *key) static_key_slow_dec() argument
108 __static_key_slow_dec(key, 0, NULL); static_key_slow_dec()
112 void static_key_slow_dec_deferred(struct static_key_deferred *key) static_key_slow_dec_deferred() argument
115 __static_key_slow_dec(&key->key, key->timeout, &key->work); static_key_slow_dec_deferred()
119 void jump_label_rate_limit(struct static_key_deferred *key, jump_label_rate_limit() argument
123 key->timeout = rl; jump_label_rate_limit()
124 INIT_DELAYED_WORK(&key->work, jump_label_update_timeout); jump_label_rate_limit()
164 static void __jump_label_update(struct static_key *key, __jump_label_update() argument
169 (entry->key == (jump_label_t)(unsigned long)key); __jump_label_update()
181 static enum jump_label_type jump_label_type(struct static_key *key) jump_label_type() argument
183 bool true_branch = jump_label_get_branch_default(key); jump_label_type()
184 bool state = static_key_enabled(key); jump_label_type()
196 struct static_key *key = NULL; jump_label_init() local
205 iterk = (struct static_key *)(unsigned long)iter->key; jump_label_init()
207 if (iterk == key) jump_label_init()
210 key = iterk; jump_label_init()
212 * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH. jump_label_init()
214 *((unsigned long *)&key->entries) += (unsigned long)iter; jump_label_init()
216 key->next = NULL; jump_label_init()
246 static void __jump_label_mod_update(struct static_key *key, int enable) __jump_label_mod_update() argument
248 struct static_key_mod *mod = key->next; __jump_label_mod_update()
253 __jump_label_update(key, mod->entries, __jump_label_mod_update()
288 struct static_key *key = NULL; jump_label_add_module() local
300 iterk = (struct static_key *)(unsigned long)iter->key; jump_label_add_module()
301 if (iterk == key) jump_label_add_module()
304 key = iterk; jump_label_add_module()
305 if (__module_address(iter->key) == mod) { jump_label_add_module()
307 * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH. jump_label_add_module()
309 *((unsigned long *)&key->entries) += (unsigned long)iter; jump_label_add_module()
310 key->next = NULL; jump_label_add_module()
318 jlm->next = key->next; jump_label_add_module()
319 key->next = jlm; jump_label_add_module()
321 if (jump_label_type(key) == JUMP_LABEL_ENABLE) jump_label_add_module()
322 __jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE); jump_label_add_module()
333 struct static_key *key = NULL; jump_label_del_module() local
337 if (iter->key == (jump_label_t)(unsigned long)key) jump_label_del_module()
340 key = (struct static_key *)(unsigned long)iter->key; jump_label_del_module()
342 if (__module_address(iter->key) == mod) jump_label_del_module()
345 prev = &key->next; jump_label_del_module()
346 jlm = key->next; jump_label_del_module()
442 static void jump_label_update(struct static_key *key, int enable) jump_label_update() argument
445 struct jump_entry *entry = jump_label_get_entries(key); jump_label_update()
448 struct module *mod = __module_address((unsigned long)key); jump_label_update()
450 __jump_label_mod_update(key, enable); jump_label_update()
457 __jump_label_update(key, entry, stop, enable); jump_label_update()
H A Dsystem_keyring.c21 struct key *system_trusted_keyring;
57 key_ref_t key; load_system_certificate_list() local
79 key = key_create_or_update(make_key_ref(system_trusted_keyring, 1), load_system_certificate_list()
88 if (IS_ERR(key)) { load_system_certificate_list()
90 PTR_ERR(key)); load_system_certificate_list()
92 set_bit(KEY_FLAG_BUILTIN, &key_ref_to_ptr(key)->flags); load_system_certificate_list()
94 key_ref_to_ptr(key)->description); load_system_certificate_list()
95 key_ref_put(key); load_system_certificate_list()
H A Dmodule_signing.c31 u8 algo; /* Public-key crypto algorithm [enum pkey_algo] */
35 u8 key_id_len; /* Length of key identifier */
131 * Request an asymmetric key.
133 static struct key *request_asymmetric_key(const char *signer, size_t signer_len, request_asymmetric_key()
136 key_ref_t key; request_asymmetric_key() local
161 key = keyring_search(make_key_ref(system_trusted_keyring, 1), request_asymmetric_key()
163 if (IS_ERR(key)) request_asymmetric_key()
164 pr_warn("Request for unknown module key '%s' err %ld\n", request_asymmetric_key()
165 id, PTR_ERR(key)); request_asymmetric_key()
168 if (IS_ERR(key)) { request_asymmetric_key()
169 switch (PTR_ERR(key)) { request_asymmetric_key()
176 return ERR_CAST(key); request_asymmetric_key()
180 pr_devel("<==%s() = 0 [%x]\n", __func__, key_serial(key_ref_to_ptr(key))); request_asymmetric_key()
181 return key_ref_to_ptr(key); request_asymmetric_key()
191 struct key *key; mod_verify_sig() local
224 key = request_asymmetric_key(sig, ms.signer_len, mod_verify_sig()
226 if (IS_ERR(key)) mod_verify_sig()
227 return PTR_ERR(key); mod_verify_sig()
240 ret = verify_signature(key, pks); mod_verify_sig()
247 key_put(key); mod_verify_sig()
/linux-4.1.27/net/openvswitch/
H A Dflow.c248 static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key) parse_ipv6hdr() argument
266 key->ip.proto = NEXTHDR_NONE; parse_ipv6hdr()
267 key->ip.tos = ipv6_get_dsfield(nh); parse_ipv6hdr()
268 key->ip.ttl = nh->hop_limit; parse_ipv6hdr()
269 key->ipv6.label = *(__be32 *)nh & htonl(IPV6_FLOWINFO_FLOWLABEL); parse_ipv6hdr()
270 key->ipv6.addr.src = nh->saddr; parse_ipv6hdr()
271 key->ipv6.addr.dst = nh->daddr; parse_ipv6hdr()
279 key->ip.frag = OVS_FRAG_TYPE_LATER; parse_ipv6hdr()
281 key->ip.frag = OVS_FRAG_TYPE_FIRST; parse_ipv6hdr()
283 key->ip.frag = OVS_FRAG_TYPE_NONE; parse_ipv6hdr()
288 key->ip.proto = nexthdr; parse_ipv6hdr()
298 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key) parse_vlan() argument
314 key->eth.tci = qp->tci | htons(VLAN_TAG_PRESENT); parse_vlan()
358 static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key, parse_icmpv6() argument
366 key->tp.src = htons(icmp->icmp6_type); parse_icmpv6()
367 key->tp.dst = htons(icmp->icmp6_code); parse_icmpv6()
368 memset(&key->ipv6.nd, 0, sizeof(key->ipv6.nd)); parse_icmpv6()
387 key->ipv6.nd.target = nd->target; parse_icmpv6()
405 if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll))) parse_icmpv6()
407 ether_addr_copy(key->ipv6.nd.sll, parse_icmpv6()
411 if (unlikely(!is_zero_ether_addr(key->ipv6.nd.tll))) parse_icmpv6()
413 ether_addr_copy(key->ipv6.nd.tll, parse_icmpv6()
425 memset(&key->ipv6.nd.target, 0, sizeof(key->ipv6.nd.target)); parse_icmpv6()
426 memset(key->ipv6.nd.sll, 0, sizeof(key->ipv6.nd.sll)); parse_icmpv6()
427 memset(key->ipv6.nd.tll, 0, sizeof(key->ipv6.nd.tll)); parse_icmpv6()
433 * key_extract - extracts a flow key from an Ethernet frame.
436 * @key: output flow key
449 * - skb->transport_header: If key->eth.type is ETH_P_IP or ETH_P_IPV6
452 * For other key->eth.type values it is left untouched.
454 static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) key_extract() argument
460 key->tp.flags = 0; key_extract()
468 ether_addr_copy(key->eth.src, eth->h_source); key_extract()
469 ether_addr_copy(key->eth.dst, eth->h_dest); key_extract()
476 key->eth.tci = 0; key_extract()
478 key->eth.tci = htons(skb->vlan_tci); key_extract()
480 if (unlikely(parse_vlan(skb, key))) key_extract()
483 key->eth.type = parse_ethertype(skb); key_extract()
484 if (unlikely(key->eth.type == htons(0))) key_extract()
492 if (key->eth.type == htons(ETH_P_IP)) { key_extract()
498 memset(&key->ip, 0, sizeof(key->ip)); key_extract()
499 memset(&key->ipv4, 0, sizeof(key->ipv4)); key_extract()
508 key->ipv4.addr.src = nh->saddr; key_extract()
509 key->ipv4.addr.dst = nh->daddr; key_extract()
511 key->ip.proto = nh->protocol; key_extract()
512 key->ip.tos = nh->tos; key_extract()
513 key->ip.ttl = nh->ttl; key_extract()
517 key->ip.frag = OVS_FRAG_TYPE_LATER; key_extract()
522 key->ip.frag = OVS_FRAG_TYPE_FIRST; key_extract()
524 key->ip.frag = OVS_FRAG_TYPE_NONE; key_extract()
527 if (key->ip.proto == IPPROTO_TCP) { key_extract()
530 key->tp.src = tcp->source; key_extract()
531 key->tp.dst = tcp->dest; key_extract()
532 key->tp.flags = TCP_FLAGS_BE16(tcp); key_extract()
534 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
537 } else if (key->ip.proto == IPPROTO_UDP) { key_extract()
540 key->tp.src = udp->source; key_extract()
541 key->tp.dst = udp->dest; key_extract()
543 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
545 } else if (key->ip.proto == IPPROTO_SCTP) { key_extract()
548 key->tp.src = sctp->source; key_extract()
549 key->tp.dst = sctp->dest; key_extract()
551 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
553 } else if (key->ip.proto == IPPROTO_ICMP) { key_extract()
559 key->tp.src = htons(icmp->type); key_extract()
560 key->tp.dst = htons(icmp->code); key_extract()
562 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
566 } else if (key->eth.type == htons(ETH_P_ARP) || key_extract()
567 key->eth.type == htons(ETH_P_RARP)) { key_extract()
581 key->ip.proto = ntohs(arp->ar_op); key_extract()
583 key->ip.proto = 0; key_extract()
585 memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src)); key_extract()
586 memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst)); key_extract()
587 ether_addr_copy(key->ipv4.arp.sha, arp->ar_sha); key_extract()
588 ether_addr_copy(key->ipv4.arp.tha, arp->ar_tha); key_extract()
590 memset(&key->ip, 0, sizeof(key->ip)); key_extract()
591 memset(&key->ipv4, 0, sizeof(key->ipv4)); key_extract()
593 } else if (eth_p_mpls(key->eth.type)) { key_extract()
612 memcpy(&key->mpls.top_lse, &lse, MPLS_HLEN); key_extract()
620 } else if (key->eth.type == htons(ETH_P_IPV6)) { key_extract()
623 nh_len = parse_ipv6hdr(skb, key); key_extract()
625 memset(&key->ip, 0, sizeof(key->ip)); key_extract()
626 memset(&key->ipv6.addr, 0, sizeof(key->ipv6.addr)); key_extract()
636 if (key->ip.frag == OVS_FRAG_TYPE_LATER) key_extract()
639 key->ip.frag = OVS_FRAG_TYPE_FIRST; key_extract()
642 if (key->ip.proto == NEXTHDR_TCP) { key_extract()
645 key->tp.src = tcp->source; key_extract()
646 key->tp.dst = tcp->dest; key_extract()
647 key->tp.flags = TCP_FLAGS_BE16(tcp); key_extract()
649 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
651 } else if (key->ip.proto == NEXTHDR_UDP) { key_extract()
654 key->tp.src = udp->source; key_extract()
655 key->tp.dst = udp->dest; key_extract()
657 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
659 } else if (key->ip.proto == NEXTHDR_SCTP) { key_extract()
662 key->tp.src = sctp->source; key_extract()
663 key->tp.dst = sctp->dest; key_extract()
665 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
667 } else if (key->ip.proto == NEXTHDR_ICMP) { key_extract()
669 error = parse_icmpv6(skb, key, nh_len); key_extract()
673 memset(&key->tp, 0, sizeof(key->tp)); key_extract()
680 int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key) ovs_flow_key_update() argument
682 return key_extract(skb, key); ovs_flow_key_update()
686 struct sk_buff *skb, struct sw_flow_key *key) ovs_flow_key_extract()
690 memcpy(&key->tun_key, &tun_info->tunnel, sizeof(key->tun_key)); ovs_flow_key_extract()
695 > sizeof(key->tun_opts)); ovs_flow_key_extract()
696 memcpy(TUN_METADATA_OPTS(key, tun_info->options_len), ovs_flow_key_extract()
698 key->tun_opts_len = tun_info->options_len; ovs_flow_key_extract()
700 key->tun_opts_len = 0; ovs_flow_key_extract()
703 key->tun_opts_len = 0; ovs_flow_key_extract()
704 memset(&key->tun_key, 0, sizeof(key->tun_key)); ovs_flow_key_extract()
707 key->phy.priority = skb->priority; ovs_flow_key_extract()
708 key->phy.in_port = OVS_CB(skb)->input_vport->port_no; ovs_flow_key_extract()
709 key->phy.skb_mark = skb->mark; ovs_flow_key_extract()
710 key->ovs_flow_hash = 0; ovs_flow_key_extract()
711 key->recirc_id = 0; ovs_flow_key_extract()
713 return key_extract(skb, key); ovs_flow_key_extract()
718 struct sw_flow_key *key, bool log) ovs_flow_key_extract_userspace()
722 memset(key, 0, OVS_SW_FLOW_KEY_METADATA_SIZE); ovs_flow_key_extract_userspace()
725 err = ovs_nla_get_flow_metadata(attr, key, log); ovs_flow_key_extract_userspace()
729 return key_extract(skb, key); ovs_flow_key_extract_userspace()
685 ovs_flow_key_extract(const struct ovs_tunnel_info *tun_info, struct sk_buff *skb, struct sw_flow_key *key) ovs_flow_key_extract() argument
716 ovs_flow_key_extract_userspace(const struct nlattr *attr, struct sk_buff *skb, struct sw_flow_key *key, bool log) ovs_flow_key_extract_userspace() argument
H A Dactions.c44 struct sw_flow_key *key,
95 const struct sw_flow_key *key, add_deferred_actions()
106 da->pkt_key = *key; add_deferred_actions()
112 static void invalidate_flow_key(struct sw_flow_key *key) invalidate_flow_key() argument
114 key->eth.type = htons(0); invalidate_flow_key()
117 static bool is_flow_key_valid(const struct sw_flow_key *key) is_flow_key_valid() argument
119 return !!key->eth.type; is_flow_key_valid()
122 static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, push_mpls() argument
154 invalidate_flow_key(key); push_mpls()
158 static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, pop_mpls() argument
184 invalidate_flow_key(key); pop_mpls()
217 static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) pop_vlan() argument
223 invalidate_flow_key(key); pop_vlan()
225 key->eth.tci = 0; pop_vlan()
229 static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key, push_vlan() argument
233 invalidate_flow_key(key); push_vlan()
235 key->eth.tci = vlan->vlan_tci; push_vlan()
253 const struct ovs_key_ethernet *key, set_eth_addr()
264 ether_addr_copy_masked(eth_hdr(skb)->h_source, key->eth_src, set_eth_addr()
266 ether_addr_copy_masked(eth_hdr(skb)->h_dest, key->eth_dst, set_eth_addr()
368 const struct ovs_key_ipv4 *key, set_ipv4()
387 new_addr = MASKED(nh->saddr, key->ipv4_src, mask->ipv4_src); set_ipv4()
395 new_addr = MASKED(nh->daddr, key->ipv4_dst, mask->ipv4_dst); set_ipv4()
403 ipv4_change_dsfield(nh, ~mask->ipv4_tos, key->ipv4_tos); set_ipv4()
407 set_ip_ttl(skb, nh, key->ipv4_ttl, mask->ipv4_ttl); set_ipv4()
420 const struct ovs_key_ipv6 *key, set_ipv6()
441 mask_ipv6_addr(saddr, key->ipv6_src, mask->ipv6_src, masked); set_ipv6()
444 set_ipv6_addr(skb, key->ipv6_proto, saddr, masked, set_ipv6()
457 mask_ipv6_addr(daddr, key->ipv6_dst, mask->ipv6_dst, masked); set_ipv6()
466 set_ipv6_addr(skb, key->ipv6_proto, daddr, masked, set_ipv6()
473 ipv6_change_dsfield(nh, ~mask->ipv6_tclass, key->ipv6_tclass); set_ipv6()
477 set_ipv6_fl(nh, ntohl(key->ipv6_label), set_ipv6()
483 SET_MASKED(nh->hop_limit, key->ipv6_hlimit, mask->ipv6_hlimit); set_ipv6()
498 const struct ovs_key_udp *key, set_udp()
512 src = MASKED(uh->source, key->udp_src, mask->udp_src); set_udp()
513 dst = MASKED(uh->dest, key->udp_dst, mask->udp_dst); set_udp()
540 const struct ovs_key_tcp *key, set_tcp()
553 src = MASKED(th->source, key->tcp_src, mask->tcp_src); set_tcp()
558 dst = MASKED(th->dest, key->tcp_dst, mask->tcp_dst); set_tcp()
569 const struct ovs_key_sctp *key, set_sctp()
585 sh->source = MASKED(sh->source, key->sctp_src, mask->sctp_src); set_sctp()
586 sh->dest = MASKED(sh->dest, key->sctp_dst, mask->sctp_dst); set_sctp()
611 struct sw_flow_key *key, const struct nlattr *attr) output_userspace()
653 return ovs_dp_upcall(dp, skb, key, &upcall); output_userspace()
657 struct sw_flow_key *key, const struct nlattr *attr) sample()
691 return output_userspace(dp, skb, key, a); sample()
698 if (!add_deferred_actions(skb, key, a)) { sample()
708 static void execute_hash(struct sk_buff *skb, struct sw_flow_key *key, execute_hash() argument
720 key->ovs_flow_hash = hash; execute_hash()
801 struct sw_flow_key *key, execute_recirc()
806 if (!is_flow_key_valid(key)) { execute_recirc()
809 err = ovs_flow_key_update(skb, key); execute_recirc()
813 BUG_ON(!is_flow_key_valid(key)); execute_recirc()
828 da = add_deferred_actions(skb, key, NULL); execute_recirc()
844 struct sw_flow_key *key, do_execute_actions()
875 output_userspace(dp, skb, key, a); do_execute_actions()
879 execute_hash(skb, key, a); do_execute_actions()
883 err = push_mpls(skb, key, nla_data(a)); do_execute_actions()
887 err = pop_mpls(skb, key, nla_get_be16(a)); do_execute_actions()
891 err = push_vlan(skb, key, nla_data(a)); do_execute_actions()
895 err = pop_vlan(skb, key); do_execute_actions()
899 err = execute_recirc(dp, skb, key, a, rem); do_execute_actions()
910 err = execute_set_action(skb, key, nla_data(a)); do_execute_actions()
915 err = execute_masked_set_action(skb, key, nla_data(a)); do_execute_actions()
919 err = sample(dp, skb, key, a); do_execute_actions()
949 struct sw_flow_key *key = &da->pkt_key; process_deferred_actions() local
953 do_execute_actions(dp, skb, key, actions, process_deferred_actions()
956 ovs_dp_process_packet(skb, key); process_deferred_actions()
966 struct sw_flow_key *key) ovs_execute_actions()
973 err = do_execute_actions(dp, skb, key, ovs_execute_actions()
94 add_deferred_actions(struct sk_buff *skb, const struct sw_flow_key *key, const struct nlattr *attr) add_deferred_actions() argument
252 set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_ethernet *key, const struct ovs_key_ethernet *mask) set_eth_addr() argument
367 set_ipv4(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_ipv4 *key, const struct ovs_key_ipv4 *mask) set_ipv4() argument
419 set_ipv6(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_ipv6 *key, const struct ovs_key_ipv6 *mask) set_ipv6() argument
497 set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_udp *key, const struct ovs_key_udp *mask) set_udp() argument
539 set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_tcp *key, const struct ovs_key_tcp *mask) set_tcp() argument
568 set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key, const struct ovs_key_sctp *key, const struct ovs_key_sctp *mask) set_sctp() argument
610 output_userspace(struct datapath *dp, struct sk_buff *skb, struct sw_flow_key *key, const struct nlattr *attr) output_userspace() argument
656 sample(struct datapath *dp, struct sk_buff *skb, struct sw_flow_key *key, const struct nlattr *attr) sample() argument
800 execute_recirc(struct datapath *dp, struct sk_buff *skb, struct sw_flow_key *key, const struct nlattr *a, int rem) execute_recirc() argument
843 do_execute_actions(struct datapath *dp, struct sk_buff *skb, struct sw_flow_key *key, const struct nlattr *attr, int len) do_execute_actions() argument
964 ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, const struct sw_flow_actions *acts, struct sw_flow_key *key) ovs_execute_actions() argument
/linux-4.1.27/tools/perf/arch/x86/util/
H A Dkvm-stat.c20 struct event_key *key) mmio_event_get_key()
22 key->key = perf_evsel__intval(evsel, sample, "gpa"); mmio_event_get_key()
23 key->info = perf_evsel__intval(evsel, sample, "type"); mmio_event_get_key()
31 struct perf_sample *sample, struct event_key *key) mmio_event_begin()
40 mmio_event_get_key(evsel, sample, key); mmio_event_begin()
48 struct event_key *key) mmio_event_end()
57 mmio_event_get_key(evsel, sample, key); mmio_event_end()
65 struct event_key *key, mmio_event_decode_key()
69 (unsigned long)key->key, mmio_event_decode_key()
70 key->info == KVM_TRACE_MMIO_WRITE ? "W" : "R"); mmio_event_decode_key()
83 struct event_key *key) ioport_event_get_key()
85 key->key = perf_evsel__intval(evsel, sample, "port"); ioport_event_get_key()
86 key->info = perf_evsel__intval(evsel, sample, "rw"); ioport_event_get_key()
91 struct event_key *key) ioport_event_begin()
94 ioport_event_get_key(evsel, sample, key); ioport_event_begin()
103 struct event_key *key __maybe_unused) ioport_event_end()
109 struct event_key *key, ioport_event_decode_key()
113 (unsigned long long)key->key, ioport_event_decode_key()
114 key->info ? "POUT" : "PIN"); ioport_event_decode_key()
19 mmio_event_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) mmio_event_get_key() argument
30 mmio_event_begin(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) mmio_event_begin() argument
47 mmio_event_end(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) mmio_event_end() argument
64 mmio_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, struct event_key *key, char *decode) mmio_event_decode_key() argument
81 ioport_event_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) ioport_event_get_key() argument
89 ioport_event_begin(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) ioport_event_begin() argument
108 ioport_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused, struct event_key *key, char *decode) ioport_event_decode_key() argument
/linux-4.1.27/drivers/gpu/drm/
H A Ddrm_hashtab.c59 void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key) drm_ht_verbose_list() argument
66 hashed_key = hash_long(key, ht->order); drm_ht_verbose_list()
67 DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); drm_ht_verbose_list()
70 DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); drm_ht_verbose_list()
74 unsigned long key) drm_ht_find_key()
80 hashed_key = hash_long(key, ht->order); drm_ht_find_key()
83 if (entry->key == key) hlist_for_each_entry()
85 if (entry->key > key) hlist_for_each_entry()
92 unsigned long key) drm_ht_find_key_rcu()
98 hashed_key = hash_long(key, ht->order); drm_ht_find_key_rcu()
101 if (entry->key == key) hlist_for_each_entry_rcu()
103 if (entry->key > key) hlist_for_each_entry_rcu()
115 unsigned long key = item->key; drm_ht_insert_item() local
117 hashed_key = hash_long(key, ht->order); drm_ht_insert_item()
121 if (entry->key == key) hlist_for_each_entry()
123 if (entry->key > key) hlist_for_each_entry()
137 * Just insert an item and return any "bits" bit key that hasn't been
151 item->key = (unshifted_key << shift) + add; drm_ht_just_insert_please()
158 DRM_ERROR("Available key bit space exhausted\n"); drm_ht_just_insert_please()
165 int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, drm_ht_find_item() argument
170 list = drm_ht_find_key_rcu(ht, key); drm_ht_find_item()
179 int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) drm_ht_remove_key() argument
183 list = drm_ht_find_key(ht, key); drm_ht_remove_key()
73 drm_ht_find_key(struct drm_open_hash *ht, unsigned long key) drm_ht_find_key() argument
91 drm_ht_find_key_rcu(struct drm_open_hash *ht, unsigned long key) drm_ht_find_key_rcu() argument
/linux-4.1.27/drivers/macintosh/
H A Dvia-pmu-event.h6 extern void via_pmu_event(int key, int down);
/linux-4.1.27/tools/perf/arch/s390/util/
H A Dkvm-stat.c23 struct event_key *key) event_icpt_insn_get_key()
28 key->key = icpt_insn_decoder(insn); event_icpt_insn_get_key()
29 key->exit_reasons = sie_icpt_insn_codes; event_icpt_insn_get_key()
34 struct event_key *key) event_sigp_get_key()
36 key->key = perf_evsel__intval(evsel, sample, "order_code"); event_sigp_get_key()
37 key->exit_reasons = sie_sigp_order_codes; event_sigp_get_key()
42 struct event_key *key) event_diag_get_key()
44 key->key = perf_evsel__intval(evsel, sample, "code"); event_diag_get_key()
45 key->exit_reasons = sie_diagnose_codes; event_diag_get_key()
50 struct event_key *key) event_icpt_prog_get_key()
52 key->key = perf_evsel__intval(evsel, sample, "code"); event_icpt_prog_get_key()
53 key->exit_reasons = sie_icpt_prog_codes; event_icpt_prog_get_key()
21 event_icpt_insn_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) event_icpt_insn_get_key() argument
32 event_sigp_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) event_sigp_get_key() argument
40 event_diag_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) event_diag_get_key() argument
48 event_icpt_prog_get_key(struct perf_evsel *evsel, struct perf_sample *sample, struct event_key *key) event_icpt_prog_get_key() argument
/linux-4.1.27/include/crypto/
H A Dtwofish.h12 /* Structure for an expanded Twofish key. s contains the key-dependent
20 int __twofish_setkey(struct twofish_ctx *ctx, const u8 *key,
22 int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len);
H A Dpublic_key.h1 /* Asymmetric public-key algorithm definitions
30 /* asymmetric key implementation supports only up to SHA224 */
34 PKEY_ID_PGP, /* OpenPGP generated key ID */
42 * Cryptographic data for the public-key subtype of the asymmetric key type.
44 * Note that this may include private part of the key as well as the public
62 MPI y; /* DSA public-key value = g^x mod p */
78 * Public key cryptography signature data
98 struct key;
99 extern int verify_signature(const struct key *key,
103 extern struct key *x509_request_asymmetric_key(struct key *keyring,
H A Dblowfish.h20 int blowfish_setkey(struct crypto_tfm *tfm, const u8 *key,
H A Dcast6.h17 int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key,
19 int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
H A Dserpent.h20 int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key,
22 int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen);
/linux-4.1.27/drivers/input/
H A Dsparse-keymap.c29 struct key_entry *key; sparse_keymap_get_key_index() local
32 for (key = dev->keycode; key->type != KE_END; key++) { sparse_keymap_get_key_index()
33 if (key->type == KE_KEY) { sparse_keymap_get_key_index()
34 if (key == k) sparse_keymap_get_key_index()
46 struct key_entry *key; sparse_keymap_entry_by_index() local
49 for (key = dev->keycode; key->type != KE_END; key++) sparse_keymap_entry_by_index()
50 if (key->type == KE_KEY) sparse_keymap_entry_by_index()
52 return key; sparse_keymap_entry_by_index()
68 struct key_entry *key; sparse_keymap_entry_from_scancode() local
70 for (key = dev->keycode; key->type != KE_END; key++) sparse_keymap_entry_from_scancode()
71 if (code == key->code) sparse_keymap_entry_from_scancode()
72 return key; sparse_keymap_entry_from_scancode()
89 struct key_entry *key; sparse_keymap_entry_from_keycode() local
91 for (key = dev->keycode; key->type != KE_END; key++) sparse_keymap_entry_from_keycode()
92 if (key->type == KE_KEY && keycode == key->keycode) sparse_keymap_entry_from_keycode()
93 return key; sparse_keymap_entry_from_keycode()
102 struct key_entry *key; sparse_keymap_locate() local
106 key = sparse_keymap_entry_by_index(dev, ke->index); sparse_keymap_locate()
108 key = sparse_keymap_entry_from_scancode(dev, scancode); sparse_keymap_locate()
110 key = NULL; sparse_keymap_locate()
112 return key; sparse_keymap_locate()
118 const struct key_entry *key; sparse_keymap_getkeycode() local
121 key = sparse_keymap_locate(dev, ke); sparse_keymap_getkeycode()
122 if (key && key->type == KE_KEY) { sparse_keymap_getkeycode()
123 ke->keycode = key->keycode; sparse_keymap_getkeycode()
126 sparse_keymap_get_key_index(dev, key); sparse_keymap_getkeycode()
127 ke->len = sizeof(key->code); sparse_keymap_getkeycode()
128 memcpy(ke->scancode, &key->code, sizeof(key->code)); sparse_keymap_getkeycode()
140 struct key_entry *key; sparse_keymap_setkeycode() local
143 key = sparse_keymap_locate(dev, ke); sparse_keymap_setkeycode()
144 if (key && key->type == KE_KEY) { sparse_keymap_setkeycode()
145 *old_keycode = key->keycode; sparse_keymap_setkeycode()
146 key->keycode = ke->keycode; sparse_keymap_setkeycode()
262 * sparse_keymap_report_entry - report event corresponding to given key entry
264 * @ke: key entry describing event
323 /* Report an unknown key event as a debugging aid */ sparse_keymap_report_event()
/linux-4.1.27/arch/sparc/include/asm/
H A Djump_label.h10 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
19 : : "i" (key) : : l_yes); arch_static_branch()
30 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/arch/arm/include/asm/
H A Djump_label.h16 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
23 : : "i" (key) : : l_yes); arch_static_branch()
35 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/net/mac802154/
H A Dllsec.c26 static void llsec_key_put(struct mac802154_llsec_key *key);
50 struct ieee802154_llsec_key_entry *key, *kn; mac802154_llsec_destroy() local
68 list_for_each_entry_safe(key, kn, &sec->table.keys, list) { mac802154_llsec_destroy()
71 mkey = container_of(key->key, struct mac802154_llsec_key, key); mac802154_llsec_destroy()
72 list_del(&key->list); mac802154_llsec_destroy()
74 kfree(key); mac802154_llsec_destroy()
122 struct mac802154_llsec_key *key; llsec_key_alloc() local
125 key = kzalloc(sizeof(*key), GFP_KERNEL); llsec_key_alloc()
126 if (!key) llsec_key_alloc()
129 kref_init(&key->ref); llsec_key_alloc()
130 key->key = *template; llsec_key_alloc()
132 BUILD_BUG_ON(ARRAY_SIZE(authsizes) != ARRAY_SIZE(key->tfm)); llsec_key_alloc()
134 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) { llsec_key_alloc()
135 key->tfm[i] = crypto_alloc_aead("ccm(aes)", 0, llsec_key_alloc()
137 if (IS_ERR(key->tfm[i])) llsec_key_alloc()
139 if (crypto_aead_setkey(key->tfm[i], template->key, llsec_key_alloc()
142 if (crypto_aead_setauthsize(key->tfm[i], authsizes[i])) llsec_key_alloc()
146 key->tfm0 = crypto_alloc_blkcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC); llsec_key_alloc()
147 if (IS_ERR(key->tfm0)) llsec_key_alloc()
150 if (crypto_blkcipher_setkey(key->tfm0, template->key, llsec_key_alloc()
154 return key; llsec_key_alloc()
157 crypto_free_blkcipher(key->tfm0); llsec_key_alloc()
159 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) llsec_key_alloc()
160 if (key->tfm[i]) llsec_key_alloc()
161 crypto_free_aead(key->tfm[i]); llsec_key_alloc()
163 kfree(key); llsec_key_alloc()
169 struct mac802154_llsec_key *key; llsec_key_release() local
172 key = container_of(ref, struct mac802154_llsec_key, ref); llsec_key_release()
174 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) llsec_key_release()
175 crypto_free_aead(key->tfm[i]); llsec_key_release()
177 crypto_free_blkcipher(key->tfm0); llsec_key_release()
178 kfree(key); llsec_key_release()
182 llsec_key_get(struct mac802154_llsec_key *key) llsec_key_get() argument
184 kref_get(&key->ref); llsec_key_get()
185 return key; llsec_key_get()
188 static void llsec_key_put(struct mac802154_llsec_key *key) llsec_key_put() argument
190 kref_put(&key->ref, llsec_key_release); llsec_key_put()
219 const struct ieee802154_llsec_key *key) mac802154_llsec_key_add()
224 if (!(key->frame_types & (1 << IEEE802154_FC_TYPE_MAC_CMD)) && mac802154_llsec_key_add()
225 key->cmd_frame_ids) mac802154_llsec_key_add()
232 if (memcmp(pos->key->key, key->key, mac802154_llsec_key_add()
236 mkey = container_of(pos->key, struct mac802154_llsec_key, key); mac802154_llsec_key_add()
238 /* Don't allow multiple instances of the same AES key to have mac802154_llsec_key_add()
242 if (pos->key->frame_types != key->frame_types || mac802154_llsec_key_add()
243 pos->key->cmd_frame_ids != key->cmd_frame_ids) mac802154_llsec_key_add()
254 mkey = llsec_key_alloc(key); mac802154_llsec_key_add()
262 new->key = &mkey->key; mac802154_llsec_key_add()
274 const struct ieee802154_llsec_key_id *key) mac802154_llsec_key_del()
281 mkey = container_of(pos->key, struct mac802154_llsec_key, key); mac802154_llsec_key_del()
283 if (llsec_key_id_equal(&pos->id, key)) { mac802154_llsec_key_del()
314 u32 key = llsec_dev_hash_short(short_addr, pan_id); llsec_dev_find_short() local
316 hash_for_each_possible_rcu(sec->devices_short, dev, bucket_s, key) { llsec_dev_find_short()
329 u64 key = llsec_dev_hash_long(hwaddr); llsec_dev_find_long() local
331 hash_for_each_possible_rcu(sec->devices_hw, dev, bucket_hw, key) { llsec_dev_find_long()
410 const struct ieee802154_llsec_key_id *key) llsec_devkey_find()
415 if (!llsec_key_id_equal(key, &devkey->key_id)) llsec_devkey_find()
427 const struct ieee802154_llsec_device_key *key) mac802154_llsec_devkey_add()
437 if (llsec_devkey_find(dev, &key->key_id)) mac802154_llsec_devkey_add()
444 devkey->devkey = *key; mac802154_llsec_devkey_add()
451 const struct ieee802154_llsec_device_key *key) mac802154_llsec_devkey_del()
461 devkey = llsec_devkey_find(dev, &key->key_id); mac802154_llsec_devkey_del()
554 struct mac802154_llsec_key *key; llsec_lookup_key() local
569 if (!(key_entry->key->frame_types & BIT(hdr->fc.type))) llsec_lookup_key()
594 key = container_of(key_entry->key, struct mac802154_llsec_key, key); llsec_lookup_key()
597 return llsec_key_get(key); llsec_lookup_key()
617 struct mac802154_llsec_key *key) llsec_do_encrypt_unauth()
622 .tfm = key->tfm0, llsec_do_encrypt_unauth()
633 llsec_tfm_by_len(struct mac802154_llsec_key *key, int authlen) llsec_tfm_by_len() argument
637 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) llsec_tfm_by_len()
638 if (crypto_aead_authsize(key->tfm[i]) == authlen) llsec_tfm_by_len()
639 return key->tfm[i]; llsec_tfm_by_len()
647 struct mac802154_llsec_key *key) llsec_do_encrypt_auth()
658 req = aead_request_alloc(llsec_tfm_by_len(key, authlen), GFP_ATOMIC); llsec_do_encrypt_auth()
697 struct mac802154_llsec_key *key) llsec_do_encrypt()
700 return llsec_do_encrypt_unauth(skb, sec, hdr, key); llsec_do_encrypt()
702 return llsec_do_encrypt_auth(skb, sec, hdr, key); llsec_do_encrypt()
709 struct mac802154_llsec_key *key; mac802154_llsec_encrypt() local
736 key = llsec_lookup_key(sec, &hdr, &hdr.dest, NULL); mac802154_llsec_encrypt()
737 if (!key) { mac802154_llsec_encrypt()
750 llsec_key_put(key); mac802154_llsec_encrypt()
764 rc = llsec_do_encrypt(skb, sec, &hdr, key); mac802154_llsec_encrypt()
765 llsec_key_put(key); mac802154_llsec_encrypt()
788 u32 key = llsec_dev_hash_short(devaddr.short_addr, llsec_lookup_dev() local
792 bucket_s, key) { llsec_lookup_dev()
798 u64 key = llsec_dev_hash_long(devaddr.extended_addr); llsec_lookup_dev() local
801 bucket_hw, key) { llsec_lookup_dev()
832 struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt_unauth()
839 .tfm = key->tfm0, llsec_do_decrypt_unauth()
856 struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt_auth()
867 req = aead_request_alloc(llsec_tfm_by_len(key, authlen), GFP_ATOMIC); llsec_do_decrypt_auth()
904 struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt()
907 return llsec_do_decrypt_unauth(skb, sec, hdr, key, dev_addr); llsec_do_decrypt()
909 return llsec_do_decrypt_auth(skb, sec, hdr, key, dev_addr); llsec_do_decrypt()
984 struct mac802154_llsec_key *key; mac802154_llsec_decrypt() local
1008 key = llsec_lookup_key(sec, &hdr, &hdr.source, &key_id); mac802154_llsec_decrypt()
1009 if (!key) { mac802154_llsec_decrypt()
1047 err = llsec_do_decrypt(skb, sec, &hdr, key, dev_addr); mac802154_llsec_decrypt()
1048 llsec_key_put(key); mac802154_llsec_decrypt()
1052 llsec_key_put(key); mac802154_llsec_decrypt()
217 mac802154_llsec_key_add(struct mac802154_llsec *sec, const struct ieee802154_llsec_key_id *id, const struct ieee802154_llsec_key *key) mac802154_llsec_key_add() argument
273 mac802154_llsec_key_del(struct mac802154_llsec *sec, const struct ieee802154_llsec_key_id *key) mac802154_llsec_key_del() argument
409 llsec_devkey_find(struct mac802154_llsec_device *dev, const struct ieee802154_llsec_key_id *key) llsec_devkey_find() argument
425 mac802154_llsec_devkey_add(struct mac802154_llsec *sec, __le64 dev_addr, const struct ieee802154_llsec_device_key *key) mac802154_llsec_devkey_add() argument
449 mac802154_llsec_devkey_del(struct mac802154_llsec *sec, __le64 dev_addr, const struct ieee802154_llsec_device_key *key) mac802154_llsec_devkey_del() argument
615 llsec_do_encrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key) llsec_do_encrypt_unauth() argument
645 llsec_do_encrypt_auth(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key) llsec_do_encrypt_auth() argument
694 llsec_do_encrypt(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key) llsec_do_encrypt() argument
830 llsec_do_decrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt_unauth() argument
854 llsec_do_decrypt_auth(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt_auth() argument
902 llsec_do_decrypt(struct sk_buff *skb, const struct mac802154_llsec *sec, const struct ieee802154_hdr *hdr, struct mac802154_llsec_key *key, __le64 dev_addr) llsec_do_decrypt() argument
/linux-4.1.27/drivers/net/wireless/ath/
H A Dkey.c36 #define IEEE80211_WEP_NKID 4 /* number of key ids */
105 * Not setting this bit allows the hardware to use the key ath_hw_keysetmac()
165 ath_dbg(common, ANY, "WEP key length %u too small\n", ath_hw_set_keycache_entry()
203 * Write inverted key[47:0] first to avoid Michael MIC errors ath_hw_set_keycache_entry()
205 * The correct key will be written in the end once everything ath_hw_set_keycache_entry()
211 /* Write key[95:48] */ ath_hw_set_keycache_entry()
215 /* Write key[127:96] and key type */ ath_hw_set_keycache_entry()
224 * TKIP uses two key cache entries: ath_hw_set_keycache_entry()
225 * Michael MIC TX/RX keys in the same key cache entry ath_hw_set_keycache_entry()
227 * key0 [31:0] = RX key [31:0] ath_hw_set_keycache_entry()
228 * key1 [15:0] = TX key [31:16] ath_hw_set_keycache_entry()
230 * key2 [31:0] = RX key [63:32] ath_hw_set_keycache_entry()
231 * key3 [15:0] = TX key [15:0] ath_hw_set_keycache_entry()
233 * key4 [31:0] = TX key [63:32] ath_hw_set_keycache_entry()
262 * TKIP uses four key cache entries (two for group ath_hw_set_keycache_entry()
264 * Michael MIC TX/RX keys are in different key cache ath_hw_set_keycache_entry()
267 * key0 [31:0] = TX/RX MIC key [31:0] ath_hw_set_keycache_entry()
269 * key2 [31:0] = TX/RX MIC key [63:32] ath_hw_set_keycache_entry()
284 /* Write MIC key[31:0] */ ath_hw_set_keycache_entry()
288 /* Write MIC key[63:32] */ ath_hw_set_keycache_entry()
307 * Write the correct (un-inverted) key[47:0] last to enable ath_hw_set_keycache_entry()
318 /* Write key[47:0] */ ath_hw_set_keycache_entry()
322 /* Write key[95:48] */ ath_hw_set_keycache_entry()
326 /* Write key[127:96] and key type */ ath_hw_set_keycache_entry()
339 static int ath_setkey_tkip(struct ath_common *common, u16 keyix, const u8 *key, ath_setkey_tkip() argument
346 key_txmic = key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY; ath_setkey_tkip()
347 key_rxmic = key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY; ath_setkey_tkip()
351 * Group key installation - only two key cache entries are used ath_setkey_tkip()
352 * regardless of splitmic capability since group key is only ath_setkey_tkip()
365 /* TX and RX keys share the same key cache entry. */ ath_setkey_tkip()
371 /* Separate key cache entries for TX and RX */ ath_setkey_tkip()
373 /* TX key goes at first index, RX key at +32. */ ath_setkey_tkip()
382 /* XXX delete tx key on failure? */ ath_setkey_tkip()
393 continue; /* At least one part of TKIP key allocated */ ath_reserve_key_cache_slot_tkip()
397 continue; /* At least one part of TKIP key allocated */ ath_reserve_key_cache_slot_tkip()
399 /* Found a free slot for a TKIP key */ ath_reserve_key_cache_slot_tkip()
463 return i; /* Found a free slot for a key */ ath_reserve_key_cache_slot()
476 struct ieee80211_key_conf *key) ath_key_config()
486 switch (key->cipher) { ath_key_config()
504 hk.kv_len = key->keylen; ath_key_config()
505 if (key->keylen) ath_key_config()
506 memcpy(hk.kv_val, key->key, key->keylen); ath_key_config()
508 if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { ath_key_config()
514 idx = ath_reserve_key_cache_slot(common, key->cipher); ath_key_config()
518 idx = key->keyidx; ath_key_config()
524 idx = ath_reserve_key_cache_slot(common, key->cipher); ath_key_config()
527 idx = key->keyidx; ath_key_config()
530 } else if (key->keyidx) { ath_key_config()
536 /* Only keyidx 0 should be used with unicast key, but ath_key_config()
538 idx = key->keyidx; ath_key_config()
546 idx = ath_reserve_key_cache_slot(common, key->cipher); ath_key_config()
550 return -ENOSPC; /* no free key cache entries */ ath_key_config()
552 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) ath_key_config()
553 ret = ath_setkey_tkip(common, idx, key->key, &hk, mac, ath_key_config()
562 if (key->cipher == WLAN_CIPHER_SUITE_CCMP) ath_key_config()
565 if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { ath_key_config()
584 void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key) ath_key_delete() argument
586 ath_hw_keyreset(common, key->hw_key_idx); ath_key_delete()
587 if (key->hw_key_idx < IEEE80211_WEP_NKID) ath_key_delete()
590 clear_bit(key->hw_key_idx, common->keymap); ath_key_delete()
591 clear_bit(key->hw_key_idx, common->ccmp_keymap); ath_key_delete()
592 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) ath_key_delete()
595 clear_bit(key->hw_key_idx + 64, common->keymap); ath_key_delete()
597 clear_bit(key->hw_key_idx, common->tkip_keymap); ath_key_delete()
598 clear_bit(key->hw_key_idx + 64, common->tkip_keymap); ath_key_delete()
601 ath_hw_keyreset(common, key->hw_key_idx + 32); ath_key_delete()
602 clear_bit(key->hw_key_idx + 32, common->keymap); ath_key_delete()
603 clear_bit(key->hw_key_idx + 64 + 32, common->keymap); ath_key_delete()
605 clear_bit(key->hw_key_idx + 32, common->tkip_keymap); ath_key_delete()
606 clear_bit(key->hw_key_idx + 64 + 32, common->tkip_keymap); ath_key_delete()
473 ath_key_config(struct ath_common *common, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) ath_key_config() argument
/linux-4.1.27/net/wireless/
H A Dlib80211_crypt_ccmp.c43 u8 key[CCMP_TK_LEN]; member in struct:lib80211_ccmp_data
184 struct lib80211_ccmp_data *key = priv; lib80211_ccmp_hdr() local
192 memcpy(aeskey, key->key, CCMP_TK_LEN); lib80211_ccmp_hdr()
200 key->tx_pn[i]++; lib80211_ccmp_hdr()
201 if (key->tx_pn[i] != 0) lib80211_ccmp_hdr()
206 *pos++ = key->tx_pn[5]; lib80211_ccmp_hdr()
207 *pos++ = key->tx_pn[4]; lib80211_ccmp_hdr()
209 *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */ ; lib80211_ccmp_hdr()
210 *pos++ = key->tx_pn[3]; lib80211_ccmp_hdr()
211 *pos++ = key->tx_pn[2]; lib80211_ccmp_hdr()
212 *pos++ = key->tx_pn[1]; lib80211_ccmp_hdr()
213 *pos++ = key->tx_pn[0]; lib80211_ccmp_hdr()
220 struct lib80211_ccmp_data *key = priv; lib80211_ccmp_encrypt() local
224 u8 *b0 = key->tx_b0; lib80211_ccmp_encrypt()
225 u8 *b = key->tx_b; lib80211_ccmp_encrypt()
226 u8 *e = key->tx_e; lib80211_ccmp_encrypt()
227 u8 *s0 = key->tx_s0; lib80211_ccmp_encrypt()
239 ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); lib80211_ccmp_encrypt()
248 lib80211_ccmp_aes_encrypt(key->tfm, b, b); lib80211_ccmp_encrypt()
252 lib80211_ccmp_aes_encrypt(key->tfm, b0, e); lib80211_ccmp_encrypt()
287 struct lib80211_ccmp_data *key = priv; lib80211_ccmp_decrypt() local
290 u8 *b0 = key->rx_b0; lib80211_ccmp_decrypt()
291 u8 *b = key->rx_b; lib80211_ccmp_decrypt()
292 u8 *a = key->rx_a; lib80211_ccmp_decrypt()
299 key->dot11RSNAStatsCCMPFormatErrors++; lib80211_ccmp_decrypt()
309 key->dot11RSNAStatsCCMPFormatErrors++; lib80211_ccmp_decrypt()
313 if (key->key_idx != keyidx) { lib80211_ccmp_decrypt()
315 "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv); lib80211_ccmp_decrypt()
318 if (!key->key_set) { lib80211_ccmp_decrypt()
319 net_dbg_ratelimited("CCMP: received packet from %pM with keyid=%d that does not have a configured key\n", lib80211_ccmp_decrypt()
332 if (ccmp_replay_check(pn, key->rx_pn)) { lib80211_ccmp_decrypt()
336 key->rx_pn[0], key->rx_pn[1], key->rx_pn[2], lib80211_ccmp_decrypt()
337 key->rx_pn[3], key->rx_pn[4], key->rx_pn[5], lib80211_ccmp_decrypt()
340 key->dot11RSNAStatsCCMPReplays++; lib80211_ccmp_decrypt()
344 ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); lib80211_ccmp_decrypt()
355 lib80211_ccmp_aes_encrypt(key->tfm, b0, b); lib80211_ccmp_decrypt()
359 lib80211_ccmp_aes_encrypt(key->tfm, a, a); lib80211_ccmp_decrypt()
366 key->dot11RSNAStatsCCMPDecryptErrors++; lib80211_ccmp_decrypt()
370 memcpy(key->rx_pn, pn, CCMP_PN_LEN); lib80211_ccmp_decrypt()
380 static int lib80211_ccmp_set_key(void *key, int len, u8 * seq, void *priv) lib80211_ccmp_set_key() argument
391 memcpy(data->key, key, CCMP_TK_LEN); lib80211_ccmp_set_key()
401 crypto_cipher_setkey(data->tfm, data->key, CCMP_TK_LEN); lib80211_ccmp_set_key()
410 static int lib80211_ccmp_get_key(void *key, int len, u8 * seq, void *priv) lib80211_ccmp_get_key() argument
419 memcpy(key, data->key, CCMP_TK_LEN); lib80211_ccmp_get_key()
438 "key[%d] alg=CCMP key_set=%d " lib80211_ccmp_print_stats()
H A Dlib80211_crypt_wep.c35 u8 key[WEP_KEY_LEN + 1]; member in struct:lib80211_wep_data
90 /* Add WEP IV/key info to a frame that has at least 4 bytes of headroom */ lib80211_wep_build_iv()
92 u8 *key, int keylen, void *priv) lib80211_wep_build_iv()
109 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key lib80211_wep_build_iv()
118 /* Prepend 24-bit IV to RC4 key and TX frame */ lib80211_wep_build_iv()
131 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
140 u8 key[WEP_KEY_LEN + 3]; lib80211_wep_encrypt() local
150 /* Copy the IV into the first 3 bytes of the key */ lib80211_wep_encrypt()
151 skb_copy_from_linear_data_offset(skb, hdr_len, key, 3); lib80211_wep_encrypt()
153 /* Copy rest of the WEP key (the secret part) */ lib80211_wep_encrypt()
154 memcpy(key + 3, wep->key, wep->key_len); lib80211_wep_encrypt()
168 crypto_blkcipher_setkey(wep->tx_tfm, key, klen); lib80211_wep_encrypt()
185 u8 key[WEP_KEY_LEN + 3]; lib80211_wep_decrypt() local
193 key[0] = *pos++; lib80211_wep_decrypt()
194 key[1] = *pos++; lib80211_wep_decrypt()
195 key[2] = *pos++; lib80211_wep_decrypt()
202 /* Copy rest of the WEP key (the secret part) */ lib80211_wep_decrypt()
203 memcpy(key + 3, wep->key, wep->key_len); lib80211_wep_decrypt()
208 crypto_blkcipher_setkey(wep->rx_tfm, key, klen); lib80211_wep_decrypt()
231 static int lib80211_wep_set_key(void *key, int len, u8 * seq, void *priv) lib80211_wep_set_key() argument
238 memcpy(wep->key, key, len); lib80211_wep_set_key()
244 static int lib80211_wep_get_key(void *key, int len, u8 * seq, void *priv) lib80211_wep_get_key() argument
251 memcpy(key, wep->key, wep->key_len); lib80211_wep_get_key()
259 seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len); lib80211_wep_print_stats()
91 lib80211_wep_build_iv(struct sk_buff *skb, int hdr_len, u8 *key, int keylen, void *priv) lib80211_wep_build_iv() argument
/linux-4.1.27/fs/btrfs/
H A Dorphan.c26 struct btrfs_key key; btrfs_insert_orphan_item() local
29 key.objectid = BTRFS_ORPHAN_OBJECTID; btrfs_insert_orphan_item()
30 key.type = BTRFS_ORPHAN_ITEM_KEY; btrfs_insert_orphan_item()
31 key.offset = offset; btrfs_insert_orphan_item()
37 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); btrfs_insert_orphan_item()
47 struct btrfs_key key; btrfs_del_orphan_item() local
50 key.objectid = BTRFS_ORPHAN_OBJECTID; btrfs_del_orphan_item()
51 key.type = BTRFS_ORPHAN_ITEM_KEY; btrfs_del_orphan_item()
52 key.offset = offset; btrfs_del_orphan_item()
58 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); btrfs_del_orphan_item()
H A Dexport.c65 struct btrfs_key key; btrfs_get_dentry() local
72 key.objectid = root_objectid; btrfs_get_dentry()
73 key.type = BTRFS_ROOT_ITEM_KEY; btrfs_get_dentry()
74 key.offset = (u64)-1; btrfs_get_dentry()
78 root = btrfs_read_fs_root_no_name(fs_info, &key); btrfs_get_dentry()
84 key.objectid = objectid; btrfs_get_dentry()
85 key.type = BTRFS_INODE_ITEM_KEY; btrfs_get_dentry()
86 key.offset = 0; btrfs_get_dentry()
88 inode = btrfs_iget(sb, &key, root, NULL); btrfs_get_dentry()
160 struct btrfs_key key; btrfs_get_parent() local
169 key.objectid = root->root_key.objectid; btrfs_get_parent()
170 key.type = BTRFS_ROOT_BACKREF_KEY; btrfs_get_parent()
171 key.offset = (u64)-1; btrfs_get_parent()
174 key.objectid = btrfs_ino(dir); btrfs_get_parent()
175 key.type = BTRFS_INODE_REF_KEY; btrfs_get_parent()
176 key.offset = (u64)-1; btrfs_get_parent()
179 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); btrfs_get_parent()
193 if (found_key.objectid != key.objectid || found_key.type != key.type) { btrfs_get_parent()
201 key.objectid = btrfs_root_ref_dirid(leaf, ref); btrfs_get_parent()
203 key.objectid = found_key.offset; btrfs_get_parent()
208 return btrfs_get_dentry(root->fs_info->sb, key.objectid, btrfs_get_parent()
212 key.type = BTRFS_INODE_ITEM_KEY; btrfs_get_parent()
213 key.offset = 0; btrfs_get_parent()
214 return d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL)); btrfs_get_parent()
231 struct btrfs_key key; btrfs_get_name() local
250 key.objectid = BTRFS_I(inode)->root->root_key.objectid; btrfs_get_name()
251 key.type = BTRFS_ROOT_BACKREF_KEY; btrfs_get_name()
252 key.offset = (u64)-1; btrfs_get_name()
255 key.objectid = ino; btrfs_get_name()
256 key.offset = btrfs_ino(dir); btrfs_get_name()
257 key.type = BTRFS_INODE_REF_KEY; btrfs_get_name()
260 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); btrfs_get_name()
H A Duuid-tree.c26 static void btrfs_uuid_to_key(u8 *uuid, u8 type, struct btrfs_key *key) btrfs_uuid_to_key() argument
28 key->type = type; btrfs_uuid_to_key()
29 key->objectid = get_unaligned_le64(uuid); btrfs_uuid_to_key()
30 key->offset = get_unaligned_le64(uuid + sizeof(u64)); btrfs_uuid_to_key()
43 struct btrfs_key key; btrfs_uuid_tree_lookup() local
56 btrfs_uuid_to_key(uuid, type, &key); btrfs_uuid_tree_lookup()
57 ret = btrfs_search_slot(NULL, uuid_root, &key, path, 0, 0); btrfs_uuid_tree_lookup()
99 struct btrfs_key key; btrfs_uuid_tree_add() local
114 btrfs_uuid_to_key(uuid, type, &key); btrfs_uuid_tree_add()
122 ret = btrfs_insert_empty_item(trans, uuid_root, path, &key, btrfs_uuid_tree_add()
142 ret, (unsigned long long)key.objectid, btrfs_uuid_tree_add()
143 (unsigned long long)key.offset, type); btrfs_uuid_tree_add()
163 struct btrfs_key key; btrfs_uuid_tree_rem() local
177 btrfs_uuid_to_key(uuid, type, &key); btrfs_uuid_tree_rem()
185 ret = btrfs_search_slot(trans, uuid_root, &key, path, -1, 1); btrfs_uuid_tree_rem()
263 struct btrfs_key key; btrfs_uuid_tree_iterate() local
277 key.objectid = 0; btrfs_uuid_tree_iterate()
278 key.type = 0; btrfs_uuid_tree_iterate()
279 key.offset = 0; btrfs_uuid_tree_iterate()
282 ret = btrfs_search_forward(root, &key, path, 0); btrfs_uuid_tree_iterate()
293 btrfs_item_key_to_cpu(leaf, &key, slot); btrfs_uuid_tree_iterate()
295 if (key.type != BTRFS_UUID_KEY_SUBVOL && btrfs_uuid_tree_iterate()
296 key.type != BTRFS_UUID_KEY_RECEIVED_SUBVOL) btrfs_uuid_tree_iterate()
311 put_unaligned_le64(key.objectid, uuid); btrfs_uuid_tree_iterate()
312 put_unaligned_le64(key.offset, uuid + sizeof(u64)); btrfs_uuid_tree_iterate()
316 ret = check_func(fs_info, uuid, key.type, subid_cpu); btrfs_uuid_tree_iterate()
321 ret = btrfs_uuid_iter_rem(root, uuid, key.type, btrfs_uuid_tree_iterate()
H A Droot-tree.c68 * btrfs_find_root - lookup the root by the key.
70 * search_key: the key to search
73 * root_key: the reak key of the tree we look for
76 * of the search key, just lookup the root with the highest offset for a
94 if (search_key->offset != -1ULL) { /* the search key is exact */ btrfs_find_root()
136 *root, struct btrfs_key *key, struct btrfs_root_item btrfs_update_root()
150 ret = btrfs_search_slot(trans, root, key, path, 0, 1); btrfs_update_root()
158 btrfs_crit(root->fs_info, "unable to update root key %llu %u %llu", btrfs_update_root()
159 key->objectid, key->type, key->offset); btrfs_update_root()
175 ret = btrfs_search_slot(trans, root, key, path, btrfs_update_root()
189 key, sizeof(*item)); btrfs_update_root()
213 struct btrfs_key *key, struct btrfs_root_item *item) btrfs_insert_root()
219 return btrfs_insert_item(trans, root, key, item, sizeof(*item)); btrfs_insert_root()
226 struct btrfs_key key; btrfs_find_orphan_roots() local
240 key.objectid = BTRFS_ORPHAN_OBJECTID; btrfs_find_orphan_roots()
241 key.type = BTRFS_ORPHAN_ITEM_KEY; btrfs_find_orphan_roots()
242 key.offset = 0; btrfs_find_orphan_roots()
248 ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0); btrfs_find_orphan_roots()
264 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); btrfs_find_orphan_roots()
267 if (key.objectid != BTRFS_ORPHAN_OBJECTID || btrfs_find_orphan_roots()
268 key.type != BTRFS_ORPHAN_ITEM_KEY) btrfs_find_orphan_roots()
271 root_key.objectid = key.offset; btrfs_find_orphan_roots()
272 key.offset++; btrfs_find_orphan_roots()
326 /* drop the root item for 'key' from 'root' */ btrfs_del_root()
328 struct btrfs_key *key) btrfs_del_root()
336 ret = btrfs_search_slot(trans, root, key, path, -1, 1); btrfs_del_root()
357 struct btrfs_key key; btrfs_del_root_ref() local
366 key.objectid = root_id; btrfs_del_root_ref()
367 key.type = BTRFS_ROOT_BACKREF_KEY; btrfs_del_root_ref()
368 key.offset = ref_id; btrfs_del_root_ref()
370 ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1); btrfs_del_root_ref()
391 if (key.type == BTRFS_ROOT_BACKREF_KEY) { btrfs_del_root_ref()
393 key.objectid = ref_id; btrfs_del_root_ref()
394 key.type = BTRFS_ROOT_REF_KEY; btrfs_del_root_ref()
395 key.offset = root_id; btrfs_del_root_ref()
424 struct btrfs_key key; btrfs_add_root_ref() local
435 key.objectid = root_id; btrfs_add_root_ref()
436 key.type = BTRFS_ROOT_BACKREF_KEY; btrfs_add_root_ref()
437 key.offset = ref_id; btrfs_add_root_ref()
439 ret = btrfs_insert_empty_item(trans, tree_root, path, &key, btrfs_add_root_ref()
456 if (key.type == BTRFS_ROOT_BACKREF_KEY) { btrfs_add_root_ref()
458 key.objectid = ref_id; btrfs_add_root_ref()
459 key.type = BTRFS_ROOT_REF_KEY; btrfs_add_root_ref()
460 key.offset = root_id; btrfs_add_root_ref()
135 btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key, struct btrfs_root_item *item) btrfs_update_root() argument
212 btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key, struct btrfs_root_item *item) btrfs_insert_root() argument
327 btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_key *key) btrfs_del_root() argument
H A Dtree-defrag.c28 * Read all the leaves and try to get key order to
36 struct btrfs_key key; btrfs_defrag_leaves() local
80 memset(&key, 0, sizeof(key)); btrfs_defrag_leaves()
82 memcpy(&key, &root->defrag_progress, sizeof(key)); btrfs_defrag_leaves()
87 ret = btrfs_search_forward(root, &key, path, min_trans); btrfs_defrag_leaves()
95 wret = btrfs_search_slot(trans, root, &key, path, 0, 1); btrfs_defrag_leaves()
106 next_key_ret = btrfs_find_next_key(root, path, &key, 1, btrfs_defrag_leaves()
117 memcpy(&root->defrag_progress, &key, sizeof(key)); btrfs_defrag_leaves()
H A Dinode-item.c104 struct btrfs_key key; btrfs_lookup_inode_extref() local
107 key.objectid = inode_objectid; btrfs_lookup_inode_extref()
108 key.type = BTRFS_INODE_EXTREF_KEY; btrfs_lookup_inode_extref()
109 key.offset = btrfs_extref_hash(ref_objectid, name, name_len); btrfs_lookup_inode_extref()
111 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); btrfs_lookup_inode_extref()
128 struct btrfs_key key; btrfs_del_inode_extref() local
137 key.objectid = inode_objectid; btrfs_del_inode_extref()
138 key.type = BTRFS_INODE_EXTREF_KEY; btrfs_del_inode_extref()
139 key.offset = btrfs_extref_hash(ref_objectid, name, name_len); btrfs_del_inode_extref()
147 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); btrfs_del_inode_extref()
199 struct btrfs_key key; btrfs_del_inode_ref() local
210 key.objectid = inode_objectid; btrfs_del_inode_ref()
211 key.offset = ref_objectid; btrfs_del_inode_ref()
212 key.type = BTRFS_INODE_REF_KEY; btrfs_del_inode_ref()
220 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); btrfs_del_inode_ref()
280 struct btrfs_key key; btrfs_insert_inode_extref() local
284 key.objectid = inode_objectid; btrfs_insert_inode_extref()
285 key.type = BTRFS_INODE_EXTREF_KEY; btrfs_insert_inode_extref()
286 key.offset = btrfs_extref_hash(ref_objectid, name, name_len); btrfs_insert_inode_extref()
293 ret = btrfs_insert_empty_item(trans, root, path, &key, btrfs_insert_inode_extref()
332 struct btrfs_key key; btrfs_insert_inode_ref() local
338 key.objectid = inode_objectid; btrfs_insert_inode_ref()
339 key.offset = ref_objectid; btrfs_insert_inode_ref()
340 key.type = BTRFS_INODE_REF_KEY; btrfs_insert_inode_ref()
348 ret = btrfs_insert_empty_item(trans, root, path, &key, btrfs_insert_inode_ref()
405 struct btrfs_key key; btrfs_insert_empty_inode() local
407 key.objectid = objectid; btrfs_insert_empty_inode()
408 key.type = BTRFS_INODE_ITEM_KEY; btrfs_insert_empty_inode()
409 key.offset = 0; btrfs_insert_empty_inode()
411 ret = btrfs_insert_empty_item(trans, root, path, &key, btrfs_insert_empty_inode()
H A Ddir-item.c77 struct btrfs_key key, location; btrfs_insert_xattr_item() local
84 key.objectid = objectid; btrfs_insert_xattr_item()
85 key.type = BTRFS_XATTR_ITEM_KEY; btrfs_insert_xattr_item()
86 key.offset = btrfs_name_hash(name, name_len); btrfs_insert_xattr_item()
89 dir_item = insert_with_overflow(trans, root, path, &key, data_size, btrfs_insert_xattr_item()
115 * 'location' is the key to stuff into the directory item, 'type' is the
131 struct btrfs_key key; btrfs_insert_dir_item() local
135 key.objectid = btrfs_ino(dir); btrfs_insert_dir_item()
136 key.type = BTRFS_DIR_ITEM_KEY; btrfs_insert_dir_item()
137 key.offset = btrfs_name_hash(name, name_len); btrfs_insert_dir_item()
147 dir_item = insert_with_overflow(trans, root, path, &key, data_size, btrfs_insert_dir_item()
198 struct btrfs_key key; btrfs_lookup_dir_item() local
202 key.objectid = dir; btrfs_lookup_dir_item()
203 key.type = BTRFS_DIR_ITEM_KEY; btrfs_lookup_dir_item()
205 key.offset = btrfs_name_hash(name, name_len); btrfs_lookup_dir_item()
207 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); btrfs_lookup_dir_item()
220 struct btrfs_key key; btrfs_check_dir_item_collision() local
232 key.objectid = dir; btrfs_check_dir_item_collision()
233 key.type = BTRFS_DIR_ITEM_KEY; btrfs_check_dir_item_collision()
234 key.offset = btrfs_name_hash(name, name_len); btrfs_check_dir_item_collision()
236 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); btrfs_check_dir_item_collision()
291 struct btrfs_key key; btrfs_lookup_dir_index_item() local
295 key.objectid = dir; btrfs_lookup_dir_index_item()
296 key.type = BTRFS_DIR_INDEX_KEY; btrfs_lookup_dir_index_item()
297 key.offset = objectid; btrfs_lookup_dir_index_item()
299 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); btrfs_lookup_dir_index_item()
314 struct btrfs_key key; btrfs_search_dir_index_item() local
318 key.objectid = dirid; btrfs_search_dir_index_item()
319 key.type = BTRFS_DIR_INDEX_KEY; btrfs_search_dir_index_item()
320 key.offset = 0; btrfs_search_dir_index_item()
322 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); btrfs_search_dir_index_item()
341 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); btrfs_search_dir_index_item()
342 if (key.objectid != dirid || key.type != BTRFS_DIR_INDEX_KEY) btrfs_search_dir_index_item()
361 struct btrfs_key key; btrfs_lookup_xattr() local
365 key.objectid = dir; btrfs_lookup_xattr()
366 key.type = BTRFS_XATTR_ITEM_KEY; btrfs_lookup_xattr()
367 key.offset = btrfs_name_hash(name, name_len); btrfs_lookup_xattr()
368 ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); btrfs_lookup_xattr()
H A Dprint-tree.c63 struct btrfs_disk_key key; print_extent_item() local
94 btrfs_tree_block_key(eb, info, &key); print_extent_item()
95 printk(KERN_INFO "\t\ttree block key (%llu %u %llu) " print_extent_item()
97 btrfs_disk_key_objectid(&key), key.type, print_extent_item()
98 btrfs_disk_key_offset(&key), print_extent_item()
185 struct btrfs_key key; btrfs_print_leaf() local
197 btrfs_item_key_to_cpu(l, &key, i); btrfs_print_leaf()
198 type = key.type; btrfs_print_leaf()
199 printk(KERN_INFO "\titem %d key (%llu %u %llu) itemoff %d " btrfs_print_leaf()
201 i, key.objectid, type, key.offset, btrfs_print_leaf()
316 struct btrfs_key key; btrfs_print_tree() local
331 btrfs_node_key_to_cpu(c, &key, i); btrfs_print_tree()
333 i, key.objectid, key.type, key.offset, btrfs_print_tree()
/linux-4.1.27/crypto/
H A Dcast6_generic.c101 static inline void W(u32 *key, unsigned int i) W() argument
104 key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]); W()
105 key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]); W()
106 key[4] ^= F3(key[5], Tr[i % 4][2], Tm[i][2]); W()
107 key[3] ^= F1(key[4], Tr[i % 4][3], Tm[i][3]); W()
108 key[2] ^= F2(key[3], Tr[i % 4][4], Tm[i][4]); W()
109 key[1] ^= F3(key[2], Tr[i % 4][5], Tm[i][5]); W()
110 key[0] ^= F1(key[1], Tr[i % 4][6], Tm[i][6]); W()
111 key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); W()
118 u32 key[8]; __cast6_setkey() local
119 __be32 p_key[8]; /* padded key */ __cast6_setkey()
129 key[0] = be32_to_cpu(p_key[0]); /* A */ __cast6_setkey()
130 key[1] = be32_to_cpu(p_key[1]); /* B */ __cast6_setkey()
131 key[2] = be32_to_cpu(p_key[2]); /* C */ __cast6_setkey()
132 key[3] = be32_to_cpu(p_key[3]); /* D */ __cast6_setkey()
133 key[4] = be32_to_cpu(p_key[4]); /* E */ __cast6_setkey()
134 key[5] = be32_to_cpu(p_key[5]); /* F */ __cast6_setkey()
135 key[6] = be32_to_cpu(p_key[6]); /* G */ __cast6_setkey()
136 key[7] = be32_to_cpu(p_key[7]); /* H */ __cast6_setkey()
139 W(key, 2 * i); __cast6_setkey()
140 W(key, 2 * i + 1); __cast6_setkey()
142 c->Kr[i][0] = key[0] & 0x1f; __cast6_setkey()
143 c->Kr[i][1] = key[2] & 0x1f; __cast6_setkey()
144 c->Kr[i][2] = key[4] & 0x1f; __cast6_setkey()
145 c->Kr[i][3] = key[6] & 0x1f; __cast6_setkey()
147 c->Km[i][0] = key[7]; __cast6_setkey()
148 c->Km[i][1] = key[5]; __cast6_setkey()
149 c->Km[i][2] = key[3]; __cast6_setkey()
150 c->Km[i][3] = key[1]; __cast6_setkey()
157 int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) cast6_setkey() argument
159 return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen, cast6_setkey()
/linux-4.1.27/arch/x86/include/asm/
H A Djump_label.h19 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
27 : : "i" (key) : : l_yes); arch_static_branch()
42 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/arch/s390/include/asm/
H A Djump_label.h15 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
22 : : "X" (key) : : label); arch_static_branch()
33 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/fs/afs/
H A Dsecurity.c21 * get a key
23 struct key *afs_request_key(struct afs_cell *cell) afs_request_key()
25 struct key *key; afs_request_key() local
29 _debug("key %s", cell->anonymous_key->description); afs_request_key()
30 key = request_key(&key_type_rxrpc, cell->anonymous_key->description, afs_request_key()
32 if (IS_ERR(key)) { afs_request_key()
33 if (PTR_ERR(key) != -ENOKEY) { afs_request_key()
34 _leave(" = %ld", PTR_ERR(key)); afs_request_key()
35 return key; afs_request_key()
43 _leave(" = {%x} [auth]", key_serial(key)); afs_request_key()
44 return key; afs_request_key()
60 key_put(permits->permits[loop].key); afs_zap_permits()
65 * dispose of a permits list in which all the key pointers have been copied
84 struct key *key) afs_get_auth_inode()
95 auth_inode = afs_iget(vnode->vfs_inode.i_sb, key, afs_get_auth_inode()
127 * for the key used to access it
129 void afs_cache_permit(struct afs_vnode *vnode, struct key *key, long acl_order) afs_cache_permit() argument
137 vnode->fid.vid, vnode->fid.vnode, key_serial(key), acl_order); afs_cache_permit()
139 auth_vnode = afs_get_auth_inode(vnode, key); afs_cache_permit()
166 if (key == vnode->volume->cell->anonymous_key) afs_cache_permit()
178 if (permit->key == key) { afs_cache_permit()
196 _debug("key %x access %x", afs_cache_permit()
197 key_serial(key), vnode->status.caller_access); afs_cache_permit()
199 permits->permits[count].key = key_get(key); afs_cache_permit()
217 static int afs_check_permit(struct afs_vnode *vnode, struct key *key, afs_check_permit() argument
227 vnode->fid.vid, vnode->fid.vnode, key_serial(key)); afs_check_permit()
229 auth_vnode = afs_get_auth_inode(vnode, key); afs_check_permit()
239 if (key == auth_vnode->volume->cell->anonymous_key) { afs_check_permit()
250 if (permit->key == key) { afs_check_permit()
268 ret = afs_vnode_fetch_status(vnode, auth_vnode, key); afs_check_permit()
292 struct key *key; afs_permission() local
301 key = afs_request_key(vnode->volume->cell); afs_permission()
302 if (IS_ERR(key)) { afs_permission()
303 _leave(" = %ld [key]", PTR_ERR(key)); afs_permission()
304 return PTR_ERR(key); afs_permission()
310 ret = afs_vnode_fetch_status(vnode, NULL, key); afs_permission()
317 ret = afs_check_permit(vnode, key, &access); afs_permission()
352 key_put(key); afs_permission()
360 key_put(key); afs_permission()
83 afs_get_auth_inode(struct afs_vnode *vnode, struct key *key) afs_get_auth_inode() argument
H A Dfile.c63 * open an AFS file or directory and attach a key to it
68 struct key *key; afs_open() local
73 key = afs_request_key(vnode->volume->cell); afs_open()
74 if (IS_ERR(key)) { afs_open()
75 _leave(" = %ld [key]", PTR_ERR(key)); afs_open()
76 return PTR_ERR(key); afs_open()
79 ret = afs_validate(vnode, key); afs_open()
85 file->private_data = key; afs_open()
91 * release an AFS file or directory and discard its key
123 * read page from file, directory or symlink, given a key to use
129 struct key *key = data; afs_page_filler() local
134 _enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index); afs_page_filler()
172 ret = afs_vnode_fetch_data(vnode, key, offset, len, page); afs_page_filler()
212 * read page from file, directory or symlink, given a file to nominate the key
217 struct key *key; afs_readpage() local
221 key = file->private_data; afs_readpage()
222 ASSERT(key != NULL); afs_readpage()
223 ret = afs_page_filler(key, page); afs_readpage()
226 key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell); afs_readpage()
227 if (IS_ERR(key)) { afs_readpage()
228 ret = PTR_ERR(key); afs_readpage()
230 ret = afs_page_filler(key, page); afs_readpage()
231 key_put(key); afs_readpage()
243 struct key *key = file->private_data; afs_readpages() local
248 key_serial(key), mapping->host->i_ino, nr_pages); afs_readpages()
250 ASSERT(key != NULL); afs_readpages()
291 ret = read_cache_pages(mapping, pages, afs_page_filler, key); afs_readpages()
H A Ddir.c191 struct key *key) afs_dir_get_page()
196 page = read_cache_page(dir->i_mapping, index, afs_page_filler, key); afs_dir_get_page()
322 struct key *key) afs_dir_iterate()
347 page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key); afs_dir_iterate()
427 struct afs_fid *fid, struct key *key) afs_do_lookup()
440 ret = afs_dir_iterate(dir, &cookie.ctx, key); afs_do_lookup()
462 int ret, struct dentry *dentry, struct inode *dir, struct key *key, afs_try_auto_mntpt()
470 ret, dentry, dentry, vnode->fid.vid, vnode->fid.vnode, key); afs_try_auto_mntpt()
476 inode = afs_iget_autocell(dir, devname, strlen(devname), key); afs_try_auto_mntpt()
500 struct key *key; afs_lookup() local
520 key = afs_request_key(vnode->volume->cell); afs_lookup()
521 if (IS_ERR(key)) { afs_lookup()
522 _leave(" = %ld [key]", PTR_ERR(key)); afs_lookup()
523 return ERR_CAST(key); afs_lookup()
526 ret = afs_validate(vnode, key); afs_lookup()
528 key_put(key); afs_lookup()
533 ret = afs_do_lookup(dir, dentry, &fid, key); afs_lookup()
535 inode = afs_try_auto_mntpt(ret, dentry, dir, key, &fid); afs_lookup()
537 key_put(key); afs_lookup()
542 key_put(key); afs_lookup()
554 inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL); afs_lookup()
555 key_put(key); afs_lookup()
582 struct key *key; afs_d_revalidate() local
598 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell); afs_d_revalidate()
599 if (IS_ERR(key)) afs_d_revalidate()
600 key = NULL; afs_d_revalidate()
608 afs_validate(dir, key); afs_d_revalidate()
622 ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key); afs_d_revalidate()
674 key_put(key); afs_d_revalidate()
687 key_put(key); afs_d_revalidate()
738 struct key *key; afs_mkdir() local
746 key = afs_request_key(dvnode->volume->cell); afs_mkdir()
747 if (IS_ERR(key)) { afs_mkdir()
748 ret = PTR_ERR(key); afs_mkdir()
753 ret = afs_vnode_create(dvnode, key, dentry->d_name.name, afs_mkdir()
758 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb); afs_mkdir()
779 key_put(key); afs_mkdir()
786 key_put(key); afs_mkdir()
799 struct key *key; afs_rmdir() local
807 key = afs_request_key(dvnode->volume->cell); afs_rmdir()
808 if (IS_ERR(key)) { afs_rmdir()
809 ret = PTR_ERR(key); afs_rmdir()
813 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true); afs_rmdir()
824 key_put(key); afs_rmdir()
829 key_put(key); afs_rmdir()
841 struct key *key; afs_unlink() local
853 key = afs_request_key(dvnode->volume->cell); afs_unlink()
854 if (IS_ERR(key)) { afs_unlink()
855 ret = PTR_ERR(key); afs_unlink()
863 ret = afs_validate(vnode, key); afs_unlink()
868 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false); afs_unlink()
888 ret = afs_validate(vnode, key); afs_unlink()
892 key_put(key); afs_unlink()
897 key_put(key); afs_unlink()
915 struct key *key; afs_create() local
923 key = afs_request_key(dvnode->volume->cell); afs_create()
924 if (IS_ERR(key)) { afs_create()
925 ret = PTR_ERR(key); afs_create()
930 ret = afs_vnode_create(dvnode, key, dentry->d_name.name, afs_create()
935 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb); afs_create()
956 key_put(key); afs_create()
963 key_put(key); afs_create()
977 struct key *key; afs_link() local
988 key = afs_request_key(dvnode->volume->cell); afs_link()
989 if (IS_ERR(key)) { afs_link()
990 ret = PTR_ERR(key); afs_link()
994 ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name); afs_link()
1000 key_put(key); afs_link()
1005 key_put(key); afs_link()
1023 struct key *key; afs_symlink() local
1036 key = afs_request_key(dvnode->volume->cell); afs_symlink()
1037 if (IS_ERR(key)) { afs_symlink()
1038 ret = PTR_ERR(key); afs_symlink()
1042 ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content, afs_symlink()
1047 inode = afs_iget(dir->i_sb, key, &fid, &status, NULL); afs_symlink()
1068 key_put(key); afs_symlink()
1075 key_put(key); afs_symlink()
1089 struct key *key; afs_rename() local
1102 key = afs_request_key(orig_dvnode->volume->cell); afs_rename()
1103 if (IS_ERR(key)) { afs_rename()
1104 ret = PTR_ERR(key); afs_rename()
1108 ret = afs_vnode_rename(orig_dvnode, new_dvnode, key, afs_rename()
1113 key_put(key); afs_rename()
1118 key_put(key); afs_rename()
190 afs_dir_get_page(struct inode *dir, unsigned long index, struct key *key) afs_dir_get_page() argument
321 afs_dir_iterate(struct inode *dir, struct dir_context *ctx, struct key *key) afs_dir_iterate() argument
426 afs_do_lookup(struct inode *dir, struct dentry *dentry, struct afs_fid *fid, struct key *key) afs_do_lookup() argument
461 afs_try_auto_mntpt( int ret, struct dentry *dentry, struct inode *dir, struct key *key, struct afs_fid *fid) afs_try_auto_mntpt() argument
H A Dvnode.c265 struct afs_vnode *auth_vnode, struct key *key) afs_vnode_fetch_status()
360 ret = afs_fs_fetch_file_status(server, key, vnode, NULL, afs_vnode_fetch_status()
369 afs_cache_permit(vnode, key, acl_order); afs_vnode_fetch_status()
395 int afs_vnode_fetch_data(struct afs_vnode *vnode, struct key *key, afs_vnode_fetch_data() argument
406 key_serial(key)); afs_vnode_fetch_data()
423 ret = afs_fs_fetch_data(server, key, vnode, offset, length, afs_vnode_fetch_data()
450 int afs_vnode_create(struct afs_vnode *vnode, struct key *key, afs_vnode_create() argument
463 key_serial(key), afs_vnode_create()
479 ret = afs_fs_create(server, key, vnode, name, mode, newfid, afs_vnode_create()
508 int afs_vnode_remove(struct afs_vnode *vnode, struct key *key, const char *name, afs_vnode_remove() argument
519 key_serial(key), afs_vnode_remove()
535 ret = afs_fs_remove(server, key, vnode, name, isdir, afs_vnode_remove()
564 struct key *key, const char *name) afs_vnode_link()
578 key_serial(key), afs_vnode_link()
597 ret = afs_fs_link(server, key, dvnode, vnode, name, afs_vnode_link()
631 int afs_vnode_symlink(struct afs_vnode *vnode, struct key *key, afs_vnode_symlink() argument
645 key_serial(key), afs_vnode_symlink()
661 ret = afs_fs_symlink(server, key, vnode, name, content, afs_vnode_symlink()
692 struct key *key, afs_vnode_rename()
708 key_serial(key), afs_vnode_rename()
731 ret = afs_fs_rename(server, key, orig_dvnode, orig_name, afs_vnode_rename()
781 key_serial(wb->key), afs_vnode_store_data()
824 int afs_vnode_setattr(struct afs_vnode *vnode, struct key *key, afs_vnode_setattr() argument
835 key_serial(key)); afs_vnode_setattr()
850 ret = afs_fs_setattr(server, key, vnode, attr, &afs_sync_call); afs_vnode_setattr()
876 int afs_vnode_get_volume_status(struct afs_vnode *vnode, struct key *key, afs_vnode_get_volume_status() argument
887 key_serial(key)); afs_vnode_get_volume_status()
897 ret = afs_fs_get_volume_status(server, key, vnode, vs, &afs_sync_call); afs_vnode_get_volume_status()
915 int afs_vnode_set_lock(struct afs_vnode *vnode, struct key *key, afs_vnode_set_lock() argument
926 key_serial(key), type); afs_vnode_set_lock()
936 ret = afs_fs_set_lock(server, key, vnode, type, &afs_sync_call); afs_vnode_set_lock()
954 int afs_vnode_extend_lock(struct afs_vnode *vnode, struct key *key) afs_vnode_extend_lock() argument
964 key_serial(key)); afs_vnode_extend_lock()
974 ret = afs_fs_extend_lock(server, key, vnode, &afs_sync_call); afs_vnode_extend_lock()
992 int afs_vnode_release_lock(struct afs_vnode *vnode, struct key *key) afs_vnode_release_lock() argument
1002 key_serial(key)); afs_vnode_release_lock()
1012 ret = afs_fs_release_lock(server, key, vnode, &afs_sync_call); afs_vnode_release_lock()
264 afs_vnode_fetch_status(struct afs_vnode *vnode, struct afs_vnode *auth_vnode, struct key *key) afs_vnode_fetch_status() argument
563 afs_vnode_link(struct afs_vnode *dvnode, struct afs_vnode *vnode, struct key *key, const char *name) afs_vnode_link() argument
690 afs_vnode_rename(struct afs_vnode *orig_dvnode, struct afs_vnode *new_dvnode, struct key *key, const char *orig_name, const char *new_name) afs_vnode_rename() argument
/linux-4.1.27/fs/nfs/
H A Dfscache.c69 struct nfs_fscache_key *key, *xkey; nfs_fscache_get_super_cookie() local
79 key = kzalloc(sizeof(*key) + ulen, GFP_KERNEL); nfs_fscache_get_super_cookie()
80 if (!key) nfs_fscache_get_super_cookie()
83 key->nfs_client = nfss->nfs_client; nfs_fscache_get_super_cookie()
84 key->key.super.s_flags = sb->s_flags & NFS_MS_MASK; nfs_fscache_get_super_cookie()
85 key->key.nfs_server.flags = nfss->flags; nfs_fscache_get_super_cookie()
86 key->key.nfs_server.rsize = nfss->rsize; nfs_fscache_get_super_cookie()
87 key->key.nfs_server.wsize = nfss->wsize; nfs_fscache_get_super_cookie()
88 key->key.nfs_server.acregmin = nfss->acregmin; nfs_fscache_get_super_cookie()
89 key->key.nfs_server.acregmax = nfss->acregmax; nfs_fscache_get_super_cookie()
90 key->key.nfs_server.acdirmin = nfss->acdirmin; nfs_fscache_get_super_cookie()
91 key->key.nfs_server.acdirmax = nfss->acdirmax; nfs_fscache_get_super_cookie()
92 key->key.nfs_server.fsid = nfss->fsid; nfs_fscache_get_super_cookie()
93 key->key.rpc_auth.au_flavor = nfss->client->cl_auth->au_flavor; nfs_fscache_get_super_cookie()
95 key->key.uniq_len = ulen; nfs_fscache_get_super_cookie()
96 memcpy(key->key.uniquifier, uniq, ulen); nfs_fscache_get_super_cookie()
105 if (key->nfs_client < xkey->nfs_client) nfs_fscache_get_super_cookie()
107 if (key->nfs_client > xkey->nfs_client) nfs_fscache_get_super_cookie()
110 diff = memcmp(&key->key, &xkey->key, sizeof(key->key)); nfs_fscache_get_super_cookie()
116 if (key->key.uniq_len == 0) nfs_fscache_get_super_cookie()
118 diff = memcmp(key->key.uniquifier, nfs_fscache_get_super_cookie()
119 xkey->key.uniquifier, nfs_fscache_get_super_cookie()
120 key->key.uniq_len); nfs_fscache_get_super_cookie()
134 rb_link_node(&key->node, parent, p); nfs_fscache_get_super_cookie()
135 rb_insert_color(&key->node, &nfs_fscache_keys); nfs_fscache_get_super_cookie()
137 nfss->fscache_key = key; nfs_fscache_get_super_cookie()
149 kfree(key); nfs_fscache_get_super_cookie()
H A Ddns_resolve.c74 struct nfs_dns_ent *key; nfs_dns_ent_update() local
77 key = container_of(ckey, struct nfs_dns_ent, h); nfs_dns_ent_update()
79 memcpy(&new->addr, &key->addr, key->addrlen); nfs_dns_ent_update()
80 new->addrlen = key->addrlen; nfs_dns_ent_update()
87 struct nfs_dns_ent *key; nfs_dns_ent_init() local
90 key = container_of(ckey, struct nfs_dns_ent, h); nfs_dns_ent_init()
93 new->hostname = kstrndup(key->hostname, key->namelen, GFP_KERNEL); nfs_dns_ent_init()
95 new->namelen = key->namelen; nfs_dns_ent_init()
125 static unsigned int nfs_dns_hash(const struct nfs_dns_ent *key) nfs_dns_hash() argument
127 return hash_str(key->hostname, NFS_DNS_HASHBITS); nfs_dns_hash()
134 struct nfs_dns_ent *key = container_of(ch, struct nfs_dns_ent, h); nfs_dns_request() local
136 qword_add(bpp, blen, key->hostname); nfs_dns_request()
143 struct nfs_dns_ent *key = container_of(ch, struct nfs_dns_ent, h); nfs_dns_upcall() local
146 ret = nfs_cache_upcall(cd, key->hostname); nfs_dns_upcall()
193 struct nfs_dns_ent *key) nfs_dns_lookup()
198 &key->h, nfs_dns_lookup()
199 nfs_dns_hash(key)); nfs_dns_lookup()
207 struct nfs_dns_ent *key) nfs_dns_update()
212 &new->h, &key->h, nfs_dns_update()
213 nfs_dns_hash(key)); nfs_dns_update()
222 struct nfs_dns_ent key, *item; nfs_dns_parse() local
234 key.addrlen = rpc_pton(cd->net, buf1, len, nfs_dns_parse()
235 (struct sockaddr *)&key.addr, nfs_dns_parse()
236 sizeof(key.addr)); nfs_dns_parse()
242 key.hostname = buf1; nfs_dns_parse()
243 key.namelen = len; nfs_dns_parse()
244 memset(&key.h, 0, sizeof(key.h)); nfs_dns_parse()
250 key.h.expiry_time = ttl + seconds_since_boot(); nfs_dns_parse()
253 item = nfs_dns_lookup(cd, &key); nfs_dns_parse()
257 if (key.addrlen == 0) nfs_dns_parse()
258 set_bit(CACHE_NEGATIVE, &key.h.flags); nfs_dns_parse()
260 item = nfs_dns_update(cd, &key, item); nfs_dns_parse()
271 struct nfs_dns_ent *key, do_cache_lookup()
277 *item = nfs_dns_lookup(cd, key); do_cache_lookup()
287 struct nfs_dns_ent *key, do_cache_lookup_nowait()
292 *item = nfs_dns_lookup(cd, key); do_cache_lookup_nowait()
312 struct nfs_dns_ent *key, do_cache_lookup_wait()
321 ret = do_cache_lookup(cd, key, item, dreq); do_cache_lookup_wait()
325 ret = do_cache_lookup_nowait(cd, key, item); do_cache_lookup_wait()
335 struct nfs_dns_ent key = { nfs_dns_resolve_name() local
343 ret = do_cache_lookup_wait(nn->nfs_dns_resolve, &key, &item); nfs_dns_resolve_name()
192 nfs_dns_lookup(struct cache_detail *cd, struct nfs_dns_ent *key) nfs_dns_lookup() argument
205 nfs_dns_update(struct cache_detail *cd, struct nfs_dns_ent *new, struct nfs_dns_ent *key) nfs_dns_update() argument
270 do_cache_lookup(struct cache_detail *cd, struct nfs_dns_ent *key, struct nfs_dns_ent **item, struct nfs_cache_defer_req *dreq) do_cache_lookup() argument
286 do_cache_lookup_nowait(struct cache_detail *cd, struct nfs_dns_ent *key, struct nfs_dns_ent **item) do_cache_lookup_nowait() argument
311 do_cache_lookup_wait(struct cache_detail *cd, struct nfs_dns_ent *key, struct nfs_dns_ent **item) do_cache_lookup_wait() argument
H A Dfscache-index.c52 * Layout of the key for an NFS server cache object.
65 * Generate a key to describe a server in the main NFS index
66 * - We return the length of the key, or 0 if we can't generate one
74 struct nfs_server_key *key = buffer; nfs_server_get_key() local
77 memset(key, 0, len); nfs_server_get_key()
78 key->nfsversion = clp->rpc_ops->version; nfs_server_get_key()
79 key->family = clp->cl_addr.ss_family; nfs_server_get_key()
83 key->port = sin->sin_port; nfs_server_get_key()
84 key->addr[0].ipv4_addr = sin->sin_addr; nfs_server_get_key()
85 len += sizeof(key->addr[0].ipv4_addr); nfs_server_get_key()
89 key->port = sin6->sin6_port; nfs_server_get_key()
90 key->addr[0].ipv6_addr = sin6->sin6_addr; nfs_server_get_key()
91 len += sizeof(key->addr[0].ipv6_addr); nfs_server_get_key()
116 * Generate a key to describe a superblock key in the main NFS index
121 const struct nfs_fscache_key *key; nfs_super_get_key() local
125 key = nfss->fscache_key; nfs_super_get_key()
126 len = sizeof(key->key) + key->key.uniq_len; nfs_super_get_key()
130 memcpy(buffer, &key->key, sizeof(key->key)); nfs_super_get_key()
131 memcpy(buffer + sizeof(key->key), nfs_super_get_key()
132 key->key.uniquifier, key->key.uniq_len); nfs_super_get_key()
166 * Generate a key to describe an NFS inode in an NFS server's index
174 /* use the inode's NFS filehandle as the key */ nfs_fscache_inode_get_key()
/linux-4.1.27/fs/btrfs/tests/
H A Dextent-buffer-tests.c37 struct btrfs_key key; test_btrfs_split_item() local
64 key.objectid = 0; test_btrfs_split_item()
65 key.type = BTRFS_EXTENT_CSUM_KEY; test_btrfs_split_item()
66 key.offset = 0; test_btrfs_split_item()
68 setup_items_for_insert(root, path, &key, &value_len, value_len, test_btrfs_split_item()
74 key.offset = 3; test_btrfs_split_item()
81 ret = btrfs_split_item(NULL, root, path, &key, 17); test_btrfs_split_item()
88 * Read the first slot, it should have the original key and contain only test_btrfs_split_item()
91 btrfs_item_key_to_cpu(eb, &key, 0); test_btrfs_split_item()
92 if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY || test_btrfs_split_item()
93 key.offset != 0) { test_btrfs_split_item()
94 test_msg("Invalid key at slot 0\n"); test_btrfs_split_item()
116 btrfs_item_key_to_cpu(eb, &key, 1); test_btrfs_split_item()
117 if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY || test_btrfs_split_item()
118 key.offset != 3) { test_btrfs_split_item()
119 test_msg("Invalid key at slot 1\n"); test_btrfs_split_item()
140 key.offset = 1; test_btrfs_split_item()
142 ret = btrfs_split_item(NULL, root, path, &key, 4); test_btrfs_split_item()
148 btrfs_item_key_to_cpu(eb, &key, 0); test_btrfs_split_item()
149 if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY || test_btrfs_split_item()
150 key.offset != 0) { test_btrfs_split_item()
151 test_msg("Invalid key at slot 0\n"); test_btrfs_split_item()
172 btrfs_item_key_to_cpu(eb, &key, 1); test_btrfs_split_item()
173 if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY || test_btrfs_split_item()
174 key.offset != 1) { test_btrfs_split_item()
175 test_msg("Invalid key at slot 1\n"); test_btrfs_split_item()
196 btrfs_item_key_to_cpu(eb, &key, 2); test_btrfs_split_item()
197 if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY || test_btrfs_split_item()
198 key.offset != 3) { test_btrfs_split_item()
199 test_msg("Invalid key at slot 2\n"); test_btrfs_split_item()
H A Dqgroup-tests.c92 struct btrfs_key key; add_tree_ref() local
98 key.objectid = bytenr; add_tree_ref()
99 key.type = BTRFS_EXTENT_ITEM_KEY; add_tree_ref()
100 key.offset = num_bytes; add_tree_ref()
109 ret = btrfs_search_slot(&trans, root, &key, path, 0, 1); add_tree_ref()
122 key.objectid = bytenr; add_tree_ref()
124 key.type = BTRFS_SHARED_BLOCK_REF_KEY; add_tree_ref()
125 key.offset = parent; add_tree_ref()
127 key.type = BTRFS_TREE_BLOCK_REF_KEY; add_tree_ref()
128 key.offset = root_objectid; add_tree_ref()
131 ret = btrfs_insert_empty_item(&trans, root, path, &key, 0); add_tree_ref()
142 struct btrfs_key key; remove_extent_item() local
148 key.objectid = bytenr; remove_extent_item()
149 key.type = BTRFS_EXTENT_ITEM_KEY; remove_extent_item()
150 key.offset = num_bytes; remove_extent_item()
159 ret = btrfs_search_slot(&trans, root, &key, path, -1, 1); remove_extent_item()
161 test_msg("Didn't find our key %d\n", ret); remove_extent_item()
176 struct btrfs_key key; remove_extent_ref() local
182 key.objectid = bytenr; remove_extent_ref()
183 key.type = BTRFS_EXTENT_ITEM_KEY; remove_extent_ref()
184 key.offset = num_bytes; remove_extent_ref()
193 ret = btrfs_search_slot(&trans, root, &key, path, 0, 1); remove_extent_ref()
206 key.objectid = bytenr; remove_extent_ref()
208 key.type = BTRFS_SHARED_BLOCK_REF_KEY; remove_extent_ref()
209 key.offset = parent; remove_extent_ref()
211 key.type = BTRFS_TREE_BLOCK_REF_KEY; remove_extent_ref()
212 key.offset = root_objectid; remove_extent_ref()
215 ret = btrfs_search_slot(&trans, root, &key, path, -1, 1); remove_extent_ref()
/linux-4.1.27/drivers/staging/rtl8192u/ieee80211/
H A Dieee80211_crypt_ccmp.c39 u8 key[CCMP_TK_LEN]; member in struct:ieee80211_ccmp_data
196 struct ieee80211_ccmp_data *key = priv; ieee80211_ccmp_encrypt() local
215 key->tx_pn[i]++; ieee80211_ccmp_encrypt()
216 if (key->tx_pn[i] != 0) ieee80211_ccmp_encrypt()
221 *pos++ = key->tx_pn[5]; ieee80211_ccmp_encrypt()
222 *pos++ = key->tx_pn[4]; ieee80211_ccmp_encrypt()
224 *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */; ieee80211_ccmp_encrypt()
225 *pos++ = key->tx_pn[3]; ieee80211_ccmp_encrypt()
226 *pos++ = key->tx_pn[2]; ieee80211_ccmp_encrypt()
227 *pos++ = key->tx_pn[1]; ieee80211_ccmp_encrypt()
228 *pos++ = key->tx_pn[0]; ieee80211_ccmp_encrypt()
236 u8 *b0 = key->tx_b0; ieee80211_ccmp_encrypt()
237 u8 *b = key->tx_b; ieee80211_ccmp_encrypt()
238 u8 *e = key->tx_e; ieee80211_ccmp_encrypt()
239 u8 *s0 = key->tx_s0; ieee80211_ccmp_encrypt()
244 ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); ieee80211_ccmp_encrypt()
253 ieee80211_ccmp_aes_encrypt(key->tfm, b, b); ieee80211_ccmp_encrypt()
257 ieee80211_ccmp_aes_encrypt(key->tfm, b0, e); ieee80211_ccmp_encrypt()
271 struct ieee80211_ccmp_data *key = priv; ieee80211_ccmp_decrypt() local
278 key->dot11RSNAStatsCCMPFormatErrors++; ieee80211_ccmp_decrypt()
290 key->dot11RSNAStatsCCMPFormatErrors++; ieee80211_ccmp_decrypt()
294 if (key->key_idx != keyidx) { ieee80211_ccmp_decrypt()
296 "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv); ieee80211_ccmp_decrypt()
299 if (!key->key_set) { ieee80211_ccmp_decrypt()
303 " key\n", hdr->addr2, keyidx); ieee80211_ccmp_decrypt()
316 if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) { ieee80211_ccmp_decrypt()
320 hdr->addr2, key->rx_pn, pn); ieee80211_ccmp_decrypt()
322 key->dot11RSNAStatsCCMPReplays++; ieee80211_ccmp_decrypt()
329 u8 *b0 = key->rx_b0; ieee80211_ccmp_decrypt()
330 u8 *b = key->rx_b; ieee80211_ccmp_decrypt()
331 u8 *a = key->rx_a; ieee80211_ccmp_decrypt()
335 ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); ieee80211_ccmp_decrypt()
346 ieee80211_ccmp_aes_encrypt(key->tfm, b0, b); ieee80211_ccmp_decrypt()
350 ieee80211_ccmp_aes_encrypt(key->tfm, a, a); ieee80211_ccmp_decrypt()
359 key->dot11RSNAStatsCCMPDecryptErrors++; ieee80211_ccmp_decrypt()
363 memcpy(key->rx_pn, pn, CCMP_PN_LEN); ieee80211_ccmp_decrypt()
374 static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv) ieee80211_ccmp_set_key() argument
385 memcpy(data->key, key, CCMP_TK_LEN); ieee80211_ccmp_set_key()
395 crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); ieee80211_ccmp_set_key()
405 static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) ieee80211_ccmp_get_key() argument
414 memcpy(key, data->key, CCMP_TK_LEN); ieee80211_ccmp_get_key()
432 p += sprintf(p, "key[%d] alg=CCMP key_set=%d " ieee80211_ccmp_print_stats()
H A Dieee80211_crypt_wep.c32 u8 key[WEP_KEY_LEN + 1]; member in struct:prism2_wep_data
99 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
105 u8 key[WEP_KEY_LEN + 3]; prism2_wep_encrypt() local
126 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key prism2_wep_encrypt()
136 /* Prepend 24-bit IV to RC4 key and TX frame */ prism2_wep_encrypt()
137 *pos++ = key[0] = (wep->iv >> 16) & 0xff; prism2_wep_encrypt()
138 *pos++ = key[1] = (wep->iv >> 8) & 0xff; prism2_wep_encrypt()
139 *pos++ = key[2] = wep->iv & 0xff; prism2_wep_encrypt()
142 /* Copy rest of the WEP key (the secret part) */ prism2_wep_encrypt()
143 memcpy(key + 3, wep->key, wep->key_len); prism2_wep_encrypt()
156 crypto_blkcipher_setkey(wep->tx_tfm, key, klen); prism2_wep_encrypt()
177 u8 key[WEP_KEY_LEN + 3]; prism2_wep_decrypt() local
189 key[0] = *pos++; prism2_wep_decrypt()
190 key[1] = *pos++; prism2_wep_decrypt()
191 key[2] = *pos++; prism2_wep_decrypt()
198 /* Copy rest of the WEP key (the secret part) */ prism2_wep_decrypt()
199 memcpy(key + 3, wep->key, wep->key_len); prism2_wep_decrypt()
206 crypto_blkcipher_setkey(wep->rx_tfm, key, klen); prism2_wep_decrypt()
231 static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) prism2_wep_set_key() argument
238 memcpy(wep->key, key, len); prism2_wep_set_key()
245 static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) prism2_wep_get_key() argument
252 memcpy(key, wep->key, wep->key_len); prism2_wep_get_key()
262 p += sprintf(p, "key[%d] alg=WEP len=%d\n", prism2_wep_print_stats()
H A Dieee80211_wx.c299 int i, key, key_provided, len; ieee80211_wx_set_encode() local
304 key = erq->flags & IW_ENCODE_INDEX; ieee80211_wx_set_encode()
305 if (key) { ieee80211_wx_set_encode()
306 if (key > WEP_KEYS) ieee80211_wx_set_encode()
308 key--; ieee80211_wx_set_encode()
312 key = ieee->tx_keyidx; ieee80211_wx_set_encode()
315 IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? ieee80211_wx_set_encode()
317 crypt = &ieee->crypt[key]; ieee80211_wx_set_encode()
321 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n", ieee80211_wx_set_encode()
322 key); ieee80211_wx_set_encode()
328 * and if no key index was provided, de-init them all */ ieee80211_wx_set_encode()
355 * on this key */ ieee80211_wx_set_encode()
373 new_crypt->priv = new_crypt->ops->init(key); ieee80211_wx_set_encode()
387 /* If a new key was provided, set it up */ ieee80211_wx_set_encode()
390 memcpy(sec.keys[key], keybuf, erq->length); ieee80211_wx_set_encode()
392 memset(sec.keys[key] + erq->length, 0, ieee80211_wx_set_encode()
394 IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", ieee80211_wx_set_encode()
395 key, escape_essid(sec.keys[key], len), ieee80211_wx_set_encode()
397 sec.key_sizes[key] = len; ieee80211_wx_set_encode()
398 (*crypt)->ops->set_key(sec.keys[key], len, NULL, ieee80211_wx_set_encode()
400 sec.flags |= (1 << key); ieee80211_wx_set_encode()
401 /* This ensures a key will be activated if no key is ieee80211_wx_set_encode()
403 if (key == sec.active_key) ieee80211_wx_set_encode()
405 ieee->tx_keyidx = key; ieee80211_wx_set_encode()
408 len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN, ieee80211_wx_set_encode()
411 /* Set a default key of all 0 */ ieee80211_wx_set_encode()
412 printk("Setting key %d to all zero.\n", ieee80211_wx_set_encode()
413 key); ieee80211_wx_set_encode()
415 IEEE80211_DEBUG_WX("Setting key %d to all zero.\n", ieee80211_wx_set_encode()
416 key); ieee80211_wx_set_encode()
417 memset(sec.keys[key], 0, 13); ieee80211_wx_set_encode()
418 (*crypt)->ops->set_key(sec.keys[key], 13, NULL, ieee80211_wx_set_encode()
420 sec.key_sizes[key] = 13; ieee80211_wx_set_encode()
421 sec.flags |= (1 << key); ieee80211_wx_set_encode()
424 /* No key data - just set the default TX key index */ ieee80211_wx_set_encode()
427 "Setting key %d to default Tx key.\n", key); ieee80211_wx_set_encode()
428 ieee->tx_keyidx = key; ieee80211_wx_set_encode()
429 sec.active_key = key; ieee80211_wx_set_encode()
470 int len, key; ieee80211_wx_get_encode() local
478 key = erq->flags & IW_ENCODE_INDEX; ieee80211_wx_get_encode()
479 if (key) { ieee80211_wx_get_encode()
480 if (key > WEP_KEYS) ieee80211_wx_get_encode()
482 key--; ieee80211_wx_get_encode()
484 key = ieee->tx_keyidx; ieee80211_wx_get_encode()
486 crypt = ieee->crypt[key]; ieee80211_wx_get_encode()
487 erq->flags = key + 1; ieee80211_wx_get_encode()
541 //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg); ieee80211_wx_set_encode_ext()
633 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, ieee80211_wx_set_encode_ext()
635 IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); ieee80211_wx_set_encode_ext()
636 printk("key setting failed\n"); ieee80211_wx_set_encode_ext()
649 //memcpy(sec.keys[idx], ext->key, ext->key_len); ieee80211_wx_set_encode_ext()
726 ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, NULL, crypt->priv); ieee80211_wx_get_encode_ext()
/linux-4.1.27/tools/perf/ui/tui/
H A Dutil.c29 int key; popup_menu__run() local
35 key = ui_browser__run(menu, 0); popup_menu__run()
37 switch (key) { popup_menu__run()
40 key = menu->index; popup_menu__run()
46 key = -1; popup_menu__run()
56 return key; popup_menu__run()
75 int x, y, len, key; ui_browser__input_window() local
129 key = ui__getch(delay_secs); ui_browser__input_window()
130 while (key != K_TIMER && key != K_ENTER && key != K_ESC) { ui_browser__input_window()
133 if (key == K_BKSPC) { ui_browser__input_window()
141 buf[len] = key; ui_browser__input_window()
143 SLsmg_write_char(key); ui_browser__input_window()
152 key = K_ENTER; ui_browser__input_window()
156 key = ui__getch(delay_secs); ui_browser__input_window()
161 return key; ui_browser__input_window()
218 return ui__question_window("Help", text, "Press any key...", 0); ui__help_window()
231 int key; __ui__warning() local
233 key = ui__question_window(title, s, "Press any key...", 0); __ui__warning()
235 return key; __ui__warning()
H A Dsetup.c56 int err, key; ui__getch() local
79 key = SLang_getkey(); ui__getch()
80 if (key != K_ESC) ui__getch()
81 return key; ui__getch()
91 SLang_ungetkey(key); ui__getch()
166 "Press any key...", 0); ui__exit()
/linux-4.1.27/drivers/staging/rtl8192e/
H A Drtllib_crypt_ccmp.c35 u8 key[CCMP_TK_LEN]; member in struct:rtllib_ccmp_data
188 struct rtllib_ccmp_data *key = priv; rtllib_ccmp_encrypt() local
206 key->tx_pn[i]++; rtllib_ccmp_encrypt()
207 if (key->tx_pn[i] != 0) rtllib_ccmp_encrypt()
212 *pos++ = key->tx_pn[5]; rtllib_ccmp_encrypt()
213 *pos++ = key->tx_pn[4]; rtllib_ccmp_encrypt()
215 *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */; rtllib_ccmp_encrypt()
216 *pos++ = key->tx_pn[3]; rtllib_ccmp_encrypt()
217 *pos++ = key->tx_pn[2]; rtllib_ccmp_encrypt()
218 *pos++ = key->tx_pn[1]; rtllib_ccmp_encrypt()
219 *pos++ = key->tx_pn[0]; rtllib_ccmp_encrypt()
226 u8 *b0 = key->tx_b0; rtllib_ccmp_encrypt()
227 u8 *b = key->tx_b; rtllib_ccmp_encrypt()
228 u8 *e = key->tx_e; rtllib_ccmp_encrypt()
229 u8 *s0 = key->tx_s0; rtllib_ccmp_encrypt()
233 ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, rtllib_ccmp_encrypt()
243 rtllib_ccmp_aes_encrypt(key->tfm, b, b); rtllib_ccmp_encrypt()
247 rtllib_ccmp_aes_encrypt(key->tfm, b0, e); rtllib_ccmp_encrypt()
261 struct rtllib_ccmp_data *key = priv; rtllib_ccmp_decrypt() local
269 key->dot11RSNAStatsCCMPFormatErrors++; rtllib_ccmp_decrypt()
281 key->dot11RSNAStatsCCMPFormatErrors++; rtllib_ccmp_decrypt()
285 if (key->key_idx != keyidx) { rtllib_ccmp_decrypt()
287 key->key_idx, keyidx, priv); rtllib_ccmp_decrypt()
290 if (!key->key_set) { rtllib_ccmp_decrypt()
292 pr_debug("CCMP: received packet from %pM with keyid=%d that does not have a configured key\n", rtllib_ccmp_decrypt()
305 if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) { rtllib_ccmp_decrypt()
306 key->dot11RSNAStatsCCMPReplays++; rtllib_ccmp_decrypt()
313 u8 *b0 = key->rx_b0; rtllib_ccmp_decrypt()
314 u8 *b = key->rx_b; rtllib_ccmp_decrypt()
315 u8 *a = key->rx_a; rtllib_ccmp_decrypt()
319 ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b); rtllib_ccmp_decrypt()
330 rtllib_ccmp_aes_encrypt(key->tfm, b0, b); rtllib_ccmp_decrypt()
334 rtllib_ccmp_aes_encrypt(key->tfm, a, a); rtllib_ccmp_decrypt()
343 key->dot11RSNAStatsCCMPDecryptErrors++; rtllib_ccmp_decrypt()
347 memcpy(key->rx_pn, pn, CCMP_PN_LEN); rtllib_ccmp_decrypt()
358 static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) rtllib_ccmp_set_key() argument
369 memcpy(data->key, key, CCMP_TK_LEN); rtllib_ccmp_set_key()
379 crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); rtllib_ccmp_set_key()
389 static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv) rtllib_ccmp_get_key() argument
398 memcpy(key, data->key, CCMP_TK_LEN); rtllib_ccmp_get_key()
418 "key[%d] alg=CCMP key_set=%d tx_pn=%pM rx_pn=%pM format_errors=%d replays=%d decrypt_errors=%d\n", rtllib_ccmp_print_stats()
H A Drtllib_crypt_wep.c28 u8 key[WEP_KEY_LEN + 1]; member in struct:prism2_wep_data
92 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
98 u8 key[WEP_KEY_LEN + 3]; prism2_wep_encrypt() local
122 /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key prism2_wep_encrypt()
133 /* Prepend 24-bit IV to RC4 key and TX frame */ prism2_wep_encrypt()
134 *pos++ = key[0] = (wep->iv >> 16) & 0xff; prism2_wep_encrypt()
135 *pos++ = key[1] = (wep->iv >> 8) & 0xff; prism2_wep_encrypt()
136 *pos++ = key[2] = wep->iv & 0xff; prism2_wep_encrypt()
139 /* Copy rest of the WEP key (the secret part) */ prism2_wep_encrypt()
140 memcpy(key + 3, wep->key, wep->key_len); prism2_wep_encrypt()
153 crypto_blkcipher_setkey(wep->tx_tfm, key, klen); prism2_wep_encrypt()
172 u8 key[WEP_KEY_LEN + 3]; prism2_wep_decrypt() local
185 key[0] = *pos++; prism2_wep_decrypt()
186 key[1] = *pos++; prism2_wep_decrypt()
187 key[2] = *pos++; prism2_wep_decrypt()
194 /* Copy rest of the WEP key (the secret part) */ prism2_wep_decrypt()
195 memcpy(key + 3, wep->key, wep->key_len); prism2_wep_decrypt()
202 crypto_blkcipher_setkey(wep->rx_tfm, key, klen); prism2_wep_decrypt()
224 static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) prism2_wep_set_key() argument
231 memcpy(wep->key, key, len); prism2_wep_set_key()
238 static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) prism2_wep_get_key() argument
245 memcpy(key, wep->key, wep->key_len); prism2_wep_get_key()
255 seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len); prism2_wep_print_stats()
H A Drtllib_wx.c311 int i, key, key_provided, len; rtllib_wx_set_encode() local
316 key = erq->flags & IW_ENCODE_INDEX; rtllib_wx_set_encode()
317 if (key) { rtllib_wx_set_encode()
318 if (key > NUM_WEP_KEYS) rtllib_wx_set_encode()
320 key--; rtllib_wx_set_encode()
324 key = ieee->crypt_info.tx_keyidx; rtllib_wx_set_encode()
327 RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? rtllib_wx_set_encode()
329 crypt = &ieee->crypt_info.crypt[key]; rtllib_wx_set_encode()
332 RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n", rtllib_wx_set_encode()
333 key); rtllib_wx_set_encode()
339 * and if no key index was provided, de-init them all rtllib_wx_set_encode()
367 * on this key rtllib_wx_set_encode()
387 new_crypt->priv = new_crypt->ops->init(key); rtllib_wx_set_encode()
401 /* If a new key was provided, set it up */ rtllib_wx_set_encode()
404 memcpy(sec.keys[key], keybuf, erq->length); rtllib_wx_set_encode()
406 memset(sec.keys[key] + erq->length, 0, rtllib_wx_set_encode()
408 RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n", rtllib_wx_set_encode()
409 key, escape_essid(sec.keys[key], len), rtllib_wx_set_encode()
411 sec.key_sizes[key] = len; rtllib_wx_set_encode()
412 (*crypt)->ops->set_key(sec.keys[key], len, NULL, rtllib_wx_set_encode()
414 sec.flags |= (1 << key); rtllib_wx_set_encode()
415 /* This ensures a key will be activated if no key is rtllib_wx_set_encode()
418 if (key == sec.active_key) rtllib_wx_set_encode()
420 ieee->crypt_info.tx_keyidx = key; rtllib_wx_set_encode()
423 len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN, rtllib_wx_set_encode()
426 /* Set a default key of all 0 */ rtllib_wx_set_encode()
427 netdev_info(ieee->dev, "Setting key %d to all zero.\n", rtllib_wx_set_encode()
428 key); rtllib_wx_set_encode()
430 memset(sec.keys[key], 0, 13); rtllib_wx_set_encode()
431 (*crypt)->ops->set_key(sec.keys[key], 13, NULL, rtllib_wx_set_encode()
433 sec.key_sizes[key] = 13; rtllib_wx_set_encode()
434 sec.flags |= (1 << key); rtllib_wx_set_encode()
437 /* No key data - just set the default TX key index */ rtllib_wx_set_encode()
439 RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n", rtllib_wx_set_encode()
440 key); rtllib_wx_set_encode()
441 ieee->crypt_info.tx_keyidx = key; rtllib_wx_set_encode()
442 sec.active_key = key; rtllib_wx_set_encode()
485 int len, key; rtllib_wx_get_encode() local
493 key = erq->flags & IW_ENCODE_INDEX; rtllib_wx_get_encode()
494 if (key) { rtllib_wx_get_encode()
495 if (key > NUM_WEP_KEYS) rtllib_wx_get_encode()
497 key--; rtllib_wx_get_encode()
499 key = ieee->crypt_info.tx_keyidx; rtllib_wx_get_encode()
501 crypt = ieee->crypt_info.crypt[key]; rtllib_wx_get_encode()
503 erq->flags = key + 1; rtllib_wx_get_encode()
641 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, rtllib_wx_set_encode_ext()
643 netdev_info(dev, "key setting failed\n"); rtllib_wx_set_encode_ext()
727 ext->key_len = crypt->ops->get_key(ext->key, SCM_KEY_LEN, rtllib_wx_get_encode_ext()
/linux-4.1.27/drivers/crypto/caam/
H A Dkey_gen.c2 * CAAM/SEC 4.x functions for handling key-generation jobs
31 get a split ipad/opad key
33 Split key generation-----------------------------------------------
36 [01] 0x04000014 key: class2->keyreg len=20
55 dev_err(jrdev, "unable to allocate key input memory\n"); gen_split_key()
62 dev_err(jrdev, "unable to map key input memory\n"); gen_split_key()
69 dev_err(jrdev, "unable to map key output memory\n"); gen_split_key()
80 * do a FIFO_LOAD of zero, this will trigger the internal key expansion gen_split_key()
87 * FIFO_STORE with the explicit split-key content store gen_split_key()
94 print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ", gen_split_key()
109 print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ", gen_split_key()
/linux-4.1.27/tools/perf/util/
H A Dkvm-stat.h13 u64 key; member in struct:event_key
27 struct event_key key; member in struct:kvm_event
40 key_cmp_fun key; member in struct:kvm_event_key
48 struct event_key *key);
55 struct event_key *key);
57 struct perf_sample *sample, struct event_key *key);
59 void (*decode_key)(struct perf_kvm_stat *kvm, struct event_key *key,
112 struct event_key *key);
115 struct event_key *key);
118 struct event_key *key);
120 struct event_key *key,
H A Dpstack.h10 void pstack__remove(struct pstack *pstack, void *key);
11 void pstack__push(struct pstack *pstack, void *key);
H A Dpstack.c38 void pstack__remove(struct pstack *pstack, void *key) pstack__remove() argument
43 if (pstack->entries[i] == key) { pstack__remove()
52 pr_err("%s: %p not on the pstack!\n", __func__, key); pstack__remove()
55 void pstack__push(struct pstack *pstack, void *key) pstack__push() argument
61 pstack->entries[pstack->top++] = key; pstack__push()
/linux-4.1.27/net/ceph/
H A Dcrypto.c8 #include <linux/key-type.h>
19 dst->key = kmemdup(src->key, src->len, GFP_NOFS); ceph_crypto_key_clone()
20 if (!dst->key) ceph_crypto_key_clone()
25 int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end) ceph_crypto_key_encode() argument
27 if (*p + sizeof(u16) + sizeof(key->created) + ceph_crypto_key_encode()
28 sizeof(u16) + key->len > end) ceph_crypto_key_encode()
30 ceph_encode_16(p, key->type); ceph_crypto_key_encode()
31 ceph_encode_copy(p, &key->created, sizeof(key->created)); ceph_crypto_key_encode()
32 ceph_encode_16(p, key->len); ceph_crypto_key_encode()
33 ceph_encode_copy(p, key->key, key->len); ceph_crypto_key_encode()
37 int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end) ceph_crypto_key_decode() argument
39 ceph_decode_need(p, end, 2*sizeof(u16) + sizeof(key->created), bad); ceph_crypto_key_decode()
40 key->type = ceph_decode_16(p); ceph_crypto_key_decode()
41 ceph_decode_copy(p, &key->created, sizeof(key->created)); ceph_crypto_key_decode()
42 key->len = ceph_decode_16(p); ceph_crypto_key_decode()
43 ceph_decode_need(p, end, key->len, bad); ceph_crypto_key_decode()
44 key->key = kmalloc(key->len, GFP_NOFS); ceph_crypto_key_decode()
45 if (!key->key) ceph_crypto_key_decode()
47 ceph_decode_copy(p, key->key, key->len); ceph_crypto_key_decode()
51 dout("failed to decode crypto key\n"); ceph_crypto_key_decode()
55 int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *inkey) ceph_crypto_key_unarmor() argument
73 ret = ceph_crypto_key_decode(key, &p, p + blen); ceph_crypto_key_unarmor()
77 dout("crypto_key_unarmor key %p type %d len %d\n", key, ceph_crypto_key_unarmor()
78 key->type, key->len); ceph_crypto_key_unarmor()
163 static int ceph_aes_encrypt(const void *key, int key_len, ceph_aes_encrypt() argument
191 crypto_blkcipher_setkey((void *)tfm, key, key_len); ceph_aes_encrypt()
197 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, ceph_aes_encrypt()
198 key, key_len, 1); ceph_aes_encrypt()
222 static int ceph_aes_encrypt2(const void *key, int key_len, void *dst, ceph_aes_encrypt2() argument
252 crypto_blkcipher_setkey((void *)tfm, key, key_len); ceph_aes_encrypt2()
258 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, ceph_aes_encrypt2()
259 key, key_len, 1); ceph_aes_encrypt2()
285 static int ceph_aes_decrypt(const void *key, int key_len, ceph_aes_decrypt() argument
309 crypto_blkcipher_setkey((void *)tfm, key, key_len); ceph_aes_decrypt()
315 print_hex_dump(KERN_ERR, "dec key: ", DUMP_PREFIX_NONE, 16, 1, ceph_aes_decrypt()
316 key, key_len, 1); ceph_aes_decrypt()
349 static int ceph_aes_decrypt2(const void *key, int key_len, ceph_aes_decrypt2() argument
375 crypto_blkcipher_setkey((void *)tfm, key, key_len); ceph_aes_decrypt2()
381 print_hex_dump(KERN_ERR, "dec key: ", DUMP_PREFIX_NONE, 16, 1, ceph_aes_decrypt2()
382 key, key_len, 1); ceph_aes_decrypt2()
439 return ceph_aes_decrypt(secret->key, secret->len, dst, ceph_decrypt()
471 return ceph_aes_decrypt2(secret->key, secret->len, ceph_decrypt2()
492 return ceph_aes_encrypt(secret->key, secret->len, dst, ceph_encrypt()
514 return ceph_aes_encrypt2(secret->key, secret->len, dst, dst_len, ceph_encrypt2()
561 static void ceph_key_destroy(struct key *key) ceph_key_destroy() argument
563 struct ceph_crypto_key *ckey = key->payload.data; ceph_key_destroy()
H A Dcrypto.h14 void *key; member in struct:ceph_crypto_key
17 static inline void ceph_crypto_key_destroy(struct ceph_crypto_key *key) ceph_crypto_key_destroy() argument
19 if (key) ceph_crypto_key_destroy()
20 kfree(key->key); ceph_crypto_key_destroy()
25 int ceph_crypto_key_encode(struct ceph_crypto_key *key, void **p, void *end);
26 int ceph_crypto_key_decode(struct ceph_crypto_key *key, void **p, void *end);
27 int ceph_crypto_key_unarmor(struct ceph_crypto_key *key, const char *in);
H A Dceph_common.c8 #include <linux/key.h>
142 if (opt1->key && !opt2->key) ceph_compare_options()
144 if (!opt1->key && opt2->key) ceph_compare_options()
146 if (opt1->key && opt2->key) { ceph_compare_options()
147 if (opt1->key->type != opt2->key->type) ceph_compare_options()
149 if (opt1->key->created.tv_sec != opt2->key->created.tv_sec) ceph_compare_options()
151 if (opt1->key->created.tv_nsec != opt2->key->created.tv_nsec) ceph_compare_options()
153 if (opt1->key->len != opt2->key->len) ceph_compare_options()
155 if (opt1->key->key && !opt2->key->key) ceph_compare_options()
157 if (!opt1->key->key && opt2->key->key) ceph_compare_options()
159 if (opt1->key->key && opt2->key->key) { ceph_compare_options()
160 ret = memcmp(opt1->key->key, opt2->key->key, opt1->key->len); ceph_compare_options()
255 {Opt_key, "key=%s"},
273 if (opt->key) { ceph_destroy_options()
274 ceph_crypto_key_destroy(opt->key); ceph_destroy_options()
275 kfree(opt->key); ceph_destroy_options()
282 /* get secret from key store */ get_secret()
284 struct key *ukey; get_secret()
296 pr_warn("ceph: Mount failed due to key not found: %s\n", get_secret()
300 pr_warn("ceph: Mount failed due to expired key: %s\n", get_secret()
304 pr_warn("ceph: Mount failed due to revoked key: %s\n", get_secret()
308 pr_warn("ceph: Mount failed due to unknown key error %d: %s\n", get_secret()
417 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); ceph_parse_options()
418 if (!opt->key) { ceph_parse_options()
422 err = ceph_crypto_key_unarmor(opt->key, argstr[0].from); ceph_parse_options()
427 opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL); ceph_parse_options()
428 if (!opt->key) { ceph_parse_options()
432 err = get_secret(opt->key, argstr[0].from); ceph_parse_options()
503 if (opt->key) ceph_print_client_options()
/linux-4.1.27/lib/
H A Ddigsig.c23 #include <linux/key.h>
68 * RSA Signature verification with public key
70 static int digsig_verify_rsa(struct key *key, digsig_verify_rsa() argument
86 down_read(&key->sem); digsig_verify_rsa()
87 ukp = key->payload.data; digsig_verify_rsa()
169 up_read(&key->sem); digsig_verify_rsa()
175 * digsig_verify() - digital signature verification with public key
176 * @keyring: keyring to search key in
189 int digsig_verify(struct key *keyring, const char *sig, int siglen, digsig_verify()
196 struct key *key; digsig_verify() local
213 key = ERR_CAST(kref); digsig_verify()
215 key = key_ref_to_ptr(kref); digsig_verify()
217 key = request_key(&key_type_user, name, NULL); digsig_verify()
219 if (IS_ERR(key)) { digsig_verify()
220 pr_err("key not found, id: %s\n", name); digsig_verify()
221 return PTR_ERR(key); digsig_verify()
240 err = digsig_verify_rsa(key, sig + sizeof(*sh), siglen - sizeof(*sh), digsig_verify()
244 key_put(key); digsig_verify()
H A Dbtree.c135 static void dec_key(struct btree_geo *geo, unsigned long *key) dec_key() argument
141 val = key[i]; dec_key()
142 key[i] = val - 1; dec_key()
159 unsigned long *key) setkey()
161 longcpy(bkey(geo, node, n), key, geo->keylen); setkey() local
208 unsigned long *key) btree_last()
219 longcpy(key, bkey(geo, node, 0), geo->keylen); btree_last()
225 unsigned long *key) keycmp()
227 return longcmp(bkey(geo, node, pos), key, geo->keylen); keycmp()
230 static int keyzero(struct btree_geo *geo, unsigned long *key) keyzero() argument
235 if (key[i]) keyzero()
242 unsigned long *key) btree_lookup()
252 if (keycmp(geo, node, i, key) <= 0) btree_lookup()
265 if (keycmp(geo, node, i, key) == 0) btree_lookup()
272 unsigned long *key, void *val) btree_update()
282 if (keycmp(geo, node, i, key) <= 0) btree_update()
295 if (keycmp(geo, node, i, key) == 0) { btree_update()
304 * Usually this function is quite similar to normal lookup. But the key of
305 * a parent node may be smaller than the smallest key of all its siblings.
307 * key smaller than __key, but larger than this parent key exists.
308 * So we set __key to the parent key and retry. We have to use the smallest
309 * such parent key, which is the last parent key we encountered.
316 unsigned long *retry_key = NULL, key[geo->keylen]; btree_get_prev() local
323 longcpy(key, __key, geo->keylen); btree_get_prev()
325 dec_key(geo, key); btree_get_prev()
330 if (keycmp(geo, node, i, key) <= 0) btree_get_prev()
345 if (keycmp(geo, node, i, key) <= 0) { btree_get_prev()
355 longcpy(key, retry_key, geo->keylen); btree_get_prev()
364 unsigned long *key) getpos()
369 if (keycmp(geo, node, i, key) <= 0) getpos()
389 unsigned long *key, int level) find_level()
396 if (keycmp(geo, node, i, key) <= 0) find_level()
400 /* right-most key is too large, update it */ find_level()
401 /* FIXME: If the right-most key on higher levels is find_level()
404 setkey(geo, node, i, key); find_level()
449 unsigned long *key, void *val, int level, btree_insert_level()
463 node = find_level(head, geo, key, level); btree_insert_level()
464 pos = getpos(geo, node, key); btree_insert_level()
467 BUG_ON(pos < fill && keycmp(geo, node, pos, key) == 0); btree_insert_level()
504 setkey(geo, node, pos, key); btree_insert_level()
511 unsigned long *key, void *val, gfp_t gfp) btree_insert()
514 return btree_insert_level(head, geo, key, val, 1, gfp); btree_insert()
519 unsigned long *key, int level); merge()
541 unsigned long *key, int level, unsigned long *child, int fill) rebalance()
551 btree_remove_level(head, geo, key, level + 1); rebalance()
556 parent = find_level(head, geo, key, level + 1); rebalance()
557 i = getpos(geo, parent, key); rebalance()
592 unsigned long *key, int level) btree_remove_level()
605 node = find_level(head, geo, key, level); btree_remove_level()
606 pos = getpos(geo, node, key); btree_remove_level()
608 if ((level == 1) && (keycmp(geo, node, pos, key) != 0)) btree_remove_level()
621 rebalance(head, geo, key, level, node, fill - 1); btree_remove_level()
630 unsigned long *key) btree_remove()
635 return btree_remove_level(head, geo, key, 1); btree_remove()
642 unsigned long key[geo->keylen]; btree_merge() local
661 if (!btree_last(victim, geo, key)) btree_merge()
663 val = btree_lookup(victim, geo, key); btree_merge()
664 err = btree_insert(target, geo, key, val, gfp); btree_merge()
667 /* We must make a copy of the key, as the original will get btree_merge()
669 longcpy(dup, key, geo->keylen); btree_merge()
679 unsigned long *key, size_t index, __btree_for_each()
702 static void empty(void *elem, unsigned long opaque, unsigned long *key, empty() argument
707 void visitorl(void *elem, unsigned long opaque, unsigned long *key, visitorl() argument
712 func(elem, opaque, *key, index); visitorl()
720 u32 *key = (void *)__key; visitor32() local
722 func(elem, opaque, *key, index); visitor32()
730 u64 *key = (void *)__key; visitor64() local
732 func(elem, opaque, *key, index); visitor64()
740 u64 *key = (void *)__key; visitor128() local
742 func(elem, opaque, key[0], key[1], index); visitor128()
749 unsigned long *key, btree_visitor()
767 unsigned long *key, btree_grim_visitor()
158 setkey(struct btree_geo *geo, unsigned long *node, int n, unsigned long *key) setkey() argument
207 btree_last(struct btree_head *head, struct btree_geo *geo, unsigned long *key) btree_last() argument
224 keycmp(struct btree_geo *geo, unsigned long *node, int pos, unsigned long *key) keycmp() argument
241 btree_lookup(struct btree_head *head, struct btree_geo *geo, unsigned long *key) btree_lookup() argument
271 btree_update(struct btree_head *head, struct btree_geo *geo, unsigned long *key, void *val) btree_update() argument
363 getpos(struct btree_geo *geo, unsigned long *node, unsigned long *key) getpos() argument
388 find_level(struct btree_head *head, struct btree_geo *geo, unsigned long *key, int level) find_level() argument
448 btree_insert_level(struct btree_head *head, struct btree_geo *geo, unsigned long *key, void *val, int level, gfp_t gfp) btree_insert_level() argument
510 btree_insert(struct btree_head *head, struct btree_geo *geo, unsigned long *key, void *val, gfp_t gfp) btree_insert() argument
540 rebalance(struct btree_head *head, struct btree_geo *geo, unsigned long *key, int level, unsigned long *child, int fill) rebalance() argument
591 btree_remove_level(struct btree_head *head, struct btree_geo *geo, unsigned long *key, int level) btree_remove_level() argument
629 btree_remove(struct btree_head *head, struct btree_geo *geo, unsigned long *key) btree_remove() argument
676 __btree_for_each(struct btree_head *head, struct btree_geo *geo, unsigned long *node, unsigned long opaque, void (*func)(void *elem, unsigned long opaque, unsigned long *key, size_t index, void *func2), void *func2, int reap, int height, size_t count) __btree_for_each() argument
746 btree_visitor(struct btree_head *head, struct btree_geo *geo, unsigned long opaque, void (*func)(void *elem, unsigned long opaque, unsigned long *key, size_t index, void *func2), void *func2) btree_visitor() argument
764 btree_grim_visitor(struct btree_head *head, struct btree_geo *geo, unsigned long opaque, void (*func)(void *elem, unsigned long opaque, unsigned long *key, size_t index, void *func2), void *func2) btree_grim_visitor() argument
H A Dbsearch.c17 * @key: pointer to item being searched for
27 * Note that the key need not have the same type as the elements in
28 * the array, e.g. key could be a string and the comparison function
30 * the key and elements in the array are of the same type, you can use
33 void *bsearch(const void *key, const void *base, size_t num, size_t size, bsearch() argument
34 int (*cmp)(const void *key, const void *elt)) bsearch()
42 result = cmp(key, base + mid * size); bsearch()
H A Drbtree_test.c11 u32 key; member in struct:test_node
27 u32 key = node->key; insert() local
31 if (key < rb_entry(parent, struct test_node, rb)->key) insert()
70 u32 key = node->key; insert_augmented() local
79 if (key < parent->key) insert_augmented()
99 nodes[i].key = prandom_u32_state(&rnd); init()
145 WARN_ON_ONCE(node->key < prev_key); check()
153 prev_key = node->key; check()
/linux-4.1.27/drivers/staging/lustre/lustre/llite/
H A Dllite_rmtacl.c77 static struct rmtacl_ctl_entry *rce_alloc(pid_t key, int ops) rce_alloc() argument
86 rce->rce_key = key; rce_alloc()
101 pid_t key) __rct_search()
104 struct list_head *head = &rct->rct_entries[rce_hashfunc(key)]; __rct_search()
107 if (rce->rce_key == key) __rct_search()
113 struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key) rct_search() argument
118 rce = __rct_search(rct, key); rct_search()
123 int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops) rct_add() argument
127 rce = rce_alloc(key, ops); rct_add()
132 e = __rct_search(rct, key); rct_add()
134 CWARN("Unexpected stale rmtacl_entry found: [key: %d] [ops: %d]\n", rct_add()
135 (int)key, ops); rct_add()
138 list_add_tail(&rce->rce_list, &rct->rct_entries[rce_hashfunc(key)]); rct_add()
144 int rct_del(struct rmtacl_ctl_table *rct, pid_t key) rct_del() argument
149 rce = __rct_search(rct, key); rct_del()
182 static struct eacl_entry *ee_alloc(pid_t key, struct lu_fid *fid, int type, ee_alloc() argument
192 ee->ee_key = key; ee_alloc()
211 static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key, __et_search_del() argument
215 struct list_head *head = &et->et_entries[ee_hashfunc(key)]; __et_search_del()
219 if (ee->ee_key == key) { list_for_each_entry()
230 struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, et_search_del() argument
236 ee = __et_search_del(et, key, fid, type); et_search_del()
241 void et_search_free(struct eacl_table *et, pid_t key) et_search_free() argument
244 struct list_head *head = &et->et_entries[ee_hashfunc(key)]; et_search_free()
248 if (ee->ee_key == key) et_search_free()
254 int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, ee_add() argument
259 ee = ee_alloc(key, fid, type, header); ee_add()
264 e = __et_search_del(et, key, fid, type); ee_add()
266 CWARN("Unexpected stale eacl_entry found: [key: %d] [fid: " DFID "] [type: %d]\n", ee_add()
267 (int)key, PFID(fid), type); ee_add()
270 list_add_tail(&ee->ee_list, &et->et_entries[ee_hashfunc(key)]); ee_add()
100 __rct_search(struct rmtacl_ctl_table *rct, pid_t key) __rct_search() argument
/linux-4.1.27/drivers/crypto/qat/qat_common/
H A Dqat_crypto.c156 char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES]; qat_crypto_create_instances() local
160 strlcpy(key, ADF_NUM_CY, sizeof(key)); qat_crypto_create_instances()
162 if (adf_cfg_get_param_value(accel_dev, SEC, key, val)) qat_crypto_create_instances()
178 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_BANK_NUM, i); qat_crypto_create_instances()
179 if (adf_cfg_get_param_value(accel_dev, SEC, key, val)) qat_crypto_create_instances()
184 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i); qat_crypto_create_instances()
185 if (adf_cfg_get_param_value(accel_dev, SEC, key, val)) qat_crypto_create_instances()
191 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_SIZE, i); qat_crypto_create_instances()
192 if (adf_cfg_get_param_value(accel_dev, SEC, key, val)) qat_crypto_create_instances()
200 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i); qat_crypto_create_instances()
202 msg_size, key, NULL, 0, &inst->sym_tx)) qat_crypto_create_instances()
205 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_RND_TX, i); qat_crypto_create_instances()
207 msg_size, key, NULL, 0, &inst->rnd_tx)) qat_crypto_create_instances()
211 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i); qat_crypto_create_instances()
213 msg_size, key, NULL, 0, &inst->pke_tx)) qat_crypto_create_instances()
217 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i); qat_crypto_create_instances()
219 msg_size, key, qat_alg_callback, 0, qat_crypto_create_instances()
223 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_RND_RX, i); qat_crypto_create_instances()
225 msg_size, key, qat_alg_callback, 0, qat_crypto_create_instances()
229 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i); qat_crypto_create_instances()
231 msg_size, key, qat_alg_callback, 0, qat_crypto_create_instances()
/linux-4.1.27/arch/sparc/crypto/
H A Daes_glue.c34 void (*encrypt)(const u64 *key, const u32 *input, u32 *output);
35 void (*decrypt)(const u64 *key, const u32 *input, u32 *output);
36 void (*load_encrypt_keys)(const u64 *key);
37 void (*load_decrypt_keys)(const u64 *key);
38 void (*ecb_encrypt)(const u64 *key, const u64 *input, u64 *output,
40 void (*ecb_decrypt)(const u64 *key, const u64 *input, u64 *output,
42 void (*cbc_encrypt)(const u64 *key, const u64 *input, u64 *output,
44 void (*cbc_decrypt)(const u64 *key, const u64 *input, u64 *output,
46 void (*ctr_crypt)(const u64 *key, const u64 *input, u64 *output,
52 u64 key[AES_MAX_KEYLENGTH / sizeof(u64)]; member in struct:crypto_sparc64_aes_ctx
57 extern void aes_sparc64_encrypt_128(const u64 *key, const u32 *input,
59 extern void aes_sparc64_encrypt_192(const u64 *key, const u32 *input,
61 extern void aes_sparc64_encrypt_256(const u64 *key, const u32 *input,
64 extern void aes_sparc64_decrypt_128(const u64 *key, const u32 *input,
66 extern void aes_sparc64_decrypt_192(const u64 *key, const u32 *input,
68 extern void aes_sparc64_decrypt_256(const u64 *key, const u32 *input,
71 extern void aes_sparc64_load_encrypt_keys_128(const u64 *key);
72 extern void aes_sparc64_load_encrypt_keys_192(const u64 *key);
73 extern void aes_sparc64_load_encrypt_keys_256(const u64 *key);
75 extern void aes_sparc64_load_decrypt_keys_128(const u64 *key);
76 extern void aes_sparc64_load_decrypt_keys_192(const u64 *key);
77 extern void aes_sparc64_load_decrypt_keys_256(const u64 *key);
79 extern void aes_sparc64_ecb_encrypt_128(const u64 *key, const u64 *input,
81 extern void aes_sparc64_ecb_encrypt_192(const u64 *key, const u64 *input,
83 extern void aes_sparc64_ecb_encrypt_256(const u64 *key, const u64 *input,
86 extern void aes_sparc64_ecb_decrypt_128(const u64 *key, const u64 *input,
88 extern void aes_sparc64_ecb_decrypt_192(const u64 *key, const u64 *input,
90 extern void aes_sparc64_ecb_decrypt_256(const u64 *key, const u64 *input,
93 extern void aes_sparc64_cbc_encrypt_128(const u64 *key, const u64 *input,
97 extern void aes_sparc64_cbc_encrypt_192(const u64 *key, const u64 *input,
101 extern void aes_sparc64_cbc_encrypt_256(const u64 *key, const u64 *input,
105 extern void aes_sparc64_cbc_decrypt_128(const u64 *key, const u64 *input,
109 extern void aes_sparc64_cbc_decrypt_192(const u64 *key, const u64 *input,
113 extern void aes_sparc64_cbc_decrypt_256(const u64 *key, const u64 *input,
117 extern void aes_sparc64_ctr_crypt_128(const u64 *key, const u64 *input,
120 extern void aes_sparc64_ctr_crypt_192(const u64 *key, const u64 *input,
123 extern void aes_sparc64_ctr_crypt_256(const u64 *key, const u64 *input,
193 aes_sparc64_key_expand((const u32 *)in_key, &ctx->key[0], key_len); aes_set_key()
203 ctx->ops->encrypt(&ctx->key[0], (const u32 *) src, (u32 *) dst); aes_encrypt()
210 ctx->ops->decrypt(&ctx->key[0], (const u32 *) src, (u32 *) dst); aes_decrypt()
227 ctx->ops->load_encrypt_keys(&ctx->key[0]); ecb_encrypt()
232 ctx->ops->ecb_encrypt(&ctx->key[0], ecb_encrypt()
257 ctx->ops->load_decrypt_keys(&ctx->key[0]); ecb_decrypt()
258 key_end = &ctx->key[ctx->expanded_key_length / sizeof(u64)]; ecb_decrypt()
287 ctx->ops->load_encrypt_keys(&ctx->key[0]); cbc_encrypt()
292 ctx->ops->cbc_encrypt(&ctx->key[0], cbc_encrypt()
317 ctx->ops->load_decrypt_keys(&ctx->key[0]); cbc_decrypt()
318 key_end = &ctx->key[ctx->expanded_key_length / sizeof(u64)]; cbc_decrypt()
345 ctx->ops->ecb_encrypt(&ctx->key[0], (const u64 *)ctrblk, ctr_crypt_final()
364 ctx->ops->load_encrypt_keys(&ctx->key[0]); ctr_crypt()
369 ctx->ops->ctr_crypt(&ctx->key[0], ctr_crypt()
H A Dcamellia_glue.c54 extern void camellia_sparc64_crypt(const u64 *key, const u32 *input,
75 extern void camellia_sparc64_load_keys(const u64 *key, unsigned int key_len);
78 const u64 *key);
92 const u64 *key; __ecb_crypt() local
104 key = &ctx->encrypt_key[0]; __ecb_crypt()
106 key = &ctx->decrypt_key[0]; __ecb_crypt()
107 camellia_sparc64_load_keys(key, ctx->key_len); __ecb_crypt()
117 op(src64, dst64, block_len, key); __ecb_crypt()
141 const u64 *key, u64 *iv);
155 const u64 *key; cbc_encrypt() local
166 key = &ctx->encrypt_key[0]; cbc_encrypt()
167 camellia_sparc64_load_keys(key, ctx->key_len); cbc_encrypt()
177 op(src64, dst64, block_len, key, cbc_encrypt()
194 const u64 *key; cbc_decrypt() local
205 key = &ctx->decrypt_key[0]; cbc_decrypt()
206 camellia_sparc64_load_keys(key, ctx->key_len); cbc_decrypt()
216 op(src64, dst64, block_len, key, cbc_decrypt()
/linux-4.1.27/drivers/hid/
H A Dhid-appleir.c47 * 26 00 00 00 00 for key repeat
58 * 26 00 00 00 00 for key repeat
61 * sent after a key is release, which I interpret
74 * 26 87 ee 47 ** for key repeat (** is the code of the key being held)
119 struct timer_list key_up_timer; /* timer for key up */
121 int current_key; /* the currently pressed key */
122 int prev_key_idx; /* key index in a 2 packets message */
128 * The key is coded accross bits 2..9: get_key()
130 * 0x00 or 0x01 ( ) key: 0 -> KEY_RESERVED get_key()
131 * 0x02 or 0x03 ( menu ) key: 1 -> KEY_MENU get_key()
132 * 0x04 or 0x05 ( >" ) key: 2 -> KEY_PLAYPAUSE get_key()
133 * 0x06 or 0x07 ( >> ) key: 3 -> KEY_FORWARD get_key()
134 * 0x08 or 0x09 ( << ) key: 4 -> KEY_BACK get_key()
135 * 0x0a or 0x0b ( + ) key: 5 -> KEY_VOLUMEUP get_key()
136 * 0x0c or 0x0d ( - ) key: 6 -> KEY_VOLUMEDOWN get_key()
137 * 0x0e or 0x0f ( ) key: 7 -> KEY_RESERVED get_key()
138 * 0x50 or 0x51 ( ) key: 8 -> KEY_RESERVED get_key()
139 * 0x52 or 0x53 ( ) key: 9 -> KEY_RESERVED get_key()
140 * 0x54 or 0x55 ( ) key: 10 -> KEY_RESERVED get_key()
141 * 0x56 or 0x57 ( ) key: 11 -> KEY_RESERVED get_key()
142 * 0x58 or 0x59 ( ) key: 12 -> KEY_RESERVED get_key()
143 * 0x5a or 0x5b ( ) key: 13 -> KEY_RESERVED get_key()
144 * 0x5c or 0x5d ( middle ) key: 14 -> KEY_ENTER get_key()
145 * 0x5e or 0x5f ( >" ) key: 15 -> KEY_PLAYPAUSE get_key()
150 int key = (data >> 1) & KEY_MASK; get_key() local
154 key = -key; get_key()
156 return key; get_key()
159 static void key_up(struct hid_device *hid, struct appleir *appleir, int key) key_up() argument
161 input_report_key(appleir->input_dev, key, 0); key_up()
165 static void key_down(struct hid_device *hid, struct appleir *appleir, int key) key_down() argument
167 input_report_key(appleir->input_dev, key, 1); key_down()
207 * If we already have a key down, take it up before marking appleir_raw_event()
224 * Remote doesn't do key up, either pull them up, in appleir_raw_event()
231 /* Remember key for next packet */ appleir_raw_event()
242 * Remote doesn't do key up, either pull them up, in the test appleir_raw_event()
H A Dhid-zydacron.c117 unsigned key; zc_raw_event() local
124 key = zc->last_key[index]; zc_raw_event()
125 if (key) { zc_raw_event()
126 input_event(zc->input_ep81, EV_KEY, key, 0); zc_raw_event()
131 key = 0; zc_raw_event()
137 key = KEY_MODE; zc_raw_event()
141 key = KEY_SCREEN; zc_raw_event()
145 key = KEY_INFO; zc_raw_event()
149 key = KEY_RADIO; zc_raw_event()
154 if (key) { zc_raw_event()
155 input_event(zc->input_ep81, EV_KEY, key, 1); zc_raw_event()
156 zc->last_key[index] = key; zc_raw_event()
/linux-4.1.27/include/linux/platform_data/
H A Dkeypad-pxa27x.h20 * 2. direct_key_map is the key code map for the direct keys, if rotary
21 * encoder(s) are enabled, direct key 0/1(2/3) will be ignored
26 * 4. matrix key and direct key will use the same debounce_interval by
46 /* the key output may be low active */
48 /* give board a chance to choose the start direct key */
63 /* key debounce interval */
H A Dkeypad-ep93xx.h7 #define EP93XX_KEYPAD_DISABLE_3_KEY (1<<0) /* disable 3-key reset */
12 #define EP93XX_KEYPAD_AUTOREPEAT (1<<5) /* enable key autorepeat */
/linux-4.1.27/security/keys/encrypted-keys/
H A Dmasterkey_trusted.c25 * request_trusted_key - request the trusted key
28 * manages both trusted/encrypted key-types, like the encrypted key type
29 * data, trusted key type data is not visible decrypted from userspace.
31 struct key *request_trusted_key(const char *trusted_desc, request_trusted_key()
35 struct key *tkey; request_trusted_key()
43 *master_key = tpayload->key; request_trusted_key()
H A Dencrypted.h7 extern struct key *request_trusted_key(const char *trusted_desc,
10 static inline struct key *request_trusted_key(const char *trusted_desc, request_trusted_key()
21 print_hex_dump(KERN_ERR, "master key: ", DUMP_PREFIX_NONE, 32, 1, dump_master_key()
H A Dencrypted.c27 #include <linux/key-type.h>
103 * valid_ecryptfs_desc - verify the description of a new/loaded encrypted key
105 * The description of a encrypted key with format 'ecryptfs' must contain
114 pr_err("encrypted_key: key description must be %d hexadecimal " valid_ecryptfs_desc()
121 pr_err("encrypted_key: key description must contain " valid_ecryptfs_desc()
131 * valid_master_desc - verify the 'key-type:desc' of a new/updated master-key
133 * key-type:= "trusted:" | "user:"
134 * desc:= master-key description
136 * Verify that 'key-type' is valid and that 'desc' exists. On key update,
137 * only the master key description is permitted to change, not the key-type.
138 * The key-type remains constant.
167 * new [<format>] <master-key name> <decrypted data length>
168 * load [<format>] <master-key name> <decrypted data length>
170 * update <new-master-key name>
214 pr_info("encrypted_key: master key parameter is missing\n"); datablob_parse()
219 pr_info("encrypted_key: master key parameter \'%s\' " datablob_parse()
302 * request_user_key - request the user key
304 * Use a user provided key to encrypt/decrypt an encrypted-key.
306 static struct key *request_user_key(const char *master_desc, u8 **master_key, request_user_key()
310 struct key *ukey; request_user_key()
338 static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen, calc_hmac() argument
350 ret = crypto_shash_setkey(hmacalg, key, keylen); calc_hmac()
375 /* Derive authentication/encryption key from trusted key */ get_derived_key()
404 static int init_blkcipher_desc(struct blkcipher_desc *desc, const u8 *key, init_blkcipher_desc() argument
418 ret = crypto_blkcipher_setkey(desc->tfm, key, key_len); init_blkcipher_desc()
428 static struct key *request_master_key(struct encrypted_key_payload *epayload, request_master_key()
431 struct key *mkey = NULL; request_master_key()
450 pr_info("encrypted_key: key %s not supported", request_master_key()
453 pr_info("encrypted_key: key %s not found", request_master_key()
524 /* verify HMAC before decrypting encrypted key */ datablob_hmac_verify()
597 /* Allocate memory for decrypted key and datablob. */ encrypted_key_alloc()
598 static struct encrypted_key_payload *encrypted_key_alloc(struct key *key, encrypted_key_alloc() argument
635 ret = key_payload_reserve(key, payload_datalen + datablob_len encrypted_key_alloc()
654 struct key *mkey; encrypted_key_decrypt()
700 pr_err("encrypted_key: failed to decrypt key (%d)\n", ret); encrypted_key_decrypt()
736 * encrypted_init - initialize an encrypted key
738 * For a new key, use a random number for both the iv and data
739 * itself. For an old key, decrypt the hex encoded data.
769 * encrypted_instantiate - instantiate an encrypted key
771 * Decrypt an existing encrypted datablob or create a new encrypted key
776 static int encrypted_instantiate(struct key *key, encrypted_instantiate() argument
801 epayload = encrypted_key_alloc(key, format, master_desc, encrypted_instantiate()
807 ret = encrypted_init(epayload, key->description, format, master_desc, encrypted_instantiate()
814 rcu_assign_keypointer(key, epayload); encrypted_instantiate()
830 * encrypted_update - update the master key description
832 * Change the master key description for an existing encrypted key.
834 * master key description.
838 static int encrypted_update(struct key *key, struct key_preparsed_payload *prep) encrypted_update() argument
840 struct encrypted_key_payload *epayload = key->payload.data; encrypted_update()
848 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) encrypted_update()
867 new_epayload = encrypted_key_alloc(key, epayload->format, encrypted_update()
881 rcu_assign_keypointer(key, new_epayload); encrypted_update()
892 * <master-key name> <decrypted data length> <encrypted iv> <encrypted data>
894 * On success, return to userspace the encrypted key datablob size.
896 static long encrypted_read(const struct key *key, char __user *buffer, encrypted_read() argument
900 struct key *mkey; encrypted_read()
908 epayload = rcu_dereference_key(key); encrypted_read()
955 * encrypted_destroy - before freeing the key, clear the decrypted data
957 * Before freeing the key, clear the memory containing the decrypted
958 * key data.
960 static void encrypted_destroy(struct key *key) encrypted_destroy() argument
962 struct encrypted_key_payload *epayload = key->payload.data; encrypted_destroy()
968 kfree(key->payload.data); encrypted_destroy()
/linux-4.1.27/arch/mips/include/asm/
H A Djump_label.h29 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
36 : : "i" (key) : : l_yes); arch_static_branch()
51 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/drivers/staging/wlan-ng/
H A Dp80211wep.c123 int wep_change_key(wlandevice_t *wlandev, int keynum, u8 *key, int keylen) wep_change_key() argument
129 if (key == NULL) wep_change_key()
137 pr_debug("WEP key %d len %d = %*phC\n", keynum, keylen, wep_change_key()
138 8, key); wep_change_key()
142 memcpy(wlandev->wep_keys[keynum], key, keylen); wep_change_key()
155 u8 s[256], key[64], c_crc[4]; wep_decrypt() local
162 /* initialize the first bytes of the key from the IV */ wep_decrypt()
163 key[0] = iv[0]; wep_decrypt()
164 key[1] = iv[1]; wep_decrypt()
165 key[2] = iv[2]; wep_decrypt()
179 /* copy the rest of the key over from the designated key */ wep_decrypt()
180 memcpy(key + 3, wlandev->wep_keys[keyidx], keylen); wep_decrypt()
185 pr_debug("D %d: %*ph (%d %d) %*phC\n", len, 3, key, wep_decrypt()
186 keyidx, keylen, 5, key + 3); wep_decrypt()
194 j = (j + s[i] + key[i % keylen]) & 0xff; wep_decrypt()
232 u8 s[256], key[64]; wep_encrypt() local
238 /* we need to have a real key.. */ wep_encrypt()
252 key[0] = iv[0]; wep_encrypt()
253 key[1] = iv[1]; wep_encrypt()
254 key[2] = iv[2]; wep_encrypt()
256 /* copy the rest of the key over from the designated key */ wep_encrypt()
257 memcpy(key + 3, wlandev->wep_keys[keynum], keylen); wep_encrypt()
263 iv[3], keynum, keylen, 3, key, 5, key + 3); wep_encrypt()
271 j = (j + s[i] + key[i % keylen]) & 0xff; wep_encrypt()
/linux-4.1.27/drivers/staging/skein/
H A Dthreefish_api.h24 threefish_set_key(&key_ctx, THREEFISH_512, key, tweak);
46 * Context for Threefish key and tweak words.
55 u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ member in struct:threefish_key
60 * Set Threefish key and tweak data.
62 * This function sets the key and tweak data for the Threefish cipher of
63 * the given size. The key data must have the same length (number of bits)
67 * Pointer to a Threefish key structure.
71 * Pointer to the key words (word has 64 bits).
83 * state size for this key. The function uses the first @c state_size bits
88 * Pointer to a Threefish key structure.
101 * state size for this key. The function uses the first @c state_size bits
108 * Pointer to a Threefish key structure.
121 * state size for this key. The function uses the first @c state_size bits
126 * Pointer to a Threefish key structure.
139 * state size for this key. The function uses the first @c state_size bits
146 * Pointer to a Threefish key structure.
/linux-4.1.27/arch/arm64/crypto/
H A Daes-ce-cipher.c31 * 128 bit key 10 rounds num_rounds()
32 * 192 bit key 12 rounds num_rounds()
33 * 256 bit key 14 rounds num_rounds()
34 * => n byte key => 6 + (n/4) rounds num_rounds()
50 " ld1 {v1.2d}, [%[key]], #16 ;" aes_cipher_encrypt()
57 " ld1 {v3.2d}, [%[key]], #16 ;" aes_cipher_encrypt()
60 "2: ld1 {v1.2d}, [%[key]], #16 ;" aes_cipher_encrypt()
63 "3: ld1 {v2.2d}, [%[key]], #16 ;" aes_cipher_encrypt()
67 " ld1 {v3.2d}, [%[key]], #16 ;" aes_cipher_encrypt()
74 [key] "=r"(dummy0), aes_cipher_encrypt()
95 " ld1 {v1.2d}, [%[key]], #16 ;" aes_cipher_decrypt()
102 " ld1 {v3.2d}, [%[key]], #16 ;" aes_cipher_decrypt()
105 "2: ld1 {v1.2d}, [%[key]], #16 ;" aes_cipher_decrypt()
108 "3: ld1 {v2.2d}, [%[key]], #16 ;" aes_cipher_decrypt()
112 " ld1 {v3.2d}, [%[key]], #16 ;" aes_cipher_decrypt()
119 [key] "=r"(dummy0), aes_cipher_decrypt()
153 * The AES key schedule round constants ce_aes_expandkey()
H A Dghash-ce-glue.c56 struct ghash_key *key = crypto_shash_ctx(desc->tfm); ghash_update() local
71 pmull_ghash_update(blocks, ctx->digest, src, key, ghash_update()
88 struct ghash_key *key = crypto_shash_ctx(desc->tfm); ghash_final() local
93 pmull_ghash_update(1, ctx->digest, ctx->buf, key, NULL); ghash_final()
106 struct ghash_key *key = crypto_shash_ctx(tfm); ghash_setkey() local
118 key->a = (a << 1) | (b >> 63); ghash_setkey()
119 key->b = (b << 1) | (a >> 63); ghash_setkey()
122 key->b ^= 0xc200000000000000UL; ghash_setkey()
/linux-4.1.27/drivers/crypto/qat/qat_dh895xcc/
H A Dadf_drv.c125 char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES]; adf_dev_configure() local
135 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_BANK_NUM, i); adf_dev_configure()
137 key, (void *)&val, ADF_DEC)) adf_dev_configure()
140 snprintf(key, sizeof(key), ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY, adf_dev_configure()
143 key, (void *)&val, ADF_DEC)) adf_dev_configure()
146 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_SIZE, i); adf_dev_configure()
149 key, (void *)&val, ADF_DEC)) adf_dev_configure()
153 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i); adf_dev_configure()
155 key, (void *)&val, ADF_DEC)) adf_dev_configure()
159 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i); adf_dev_configure()
161 key, (void *)&val, ADF_DEC)) adf_dev_configure()
165 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i); adf_dev_configure()
167 key, (void *)&val, ADF_DEC)) adf_dev_configure()
171 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_RND_TX, i); adf_dev_configure()
173 key, (void *)&val, ADF_DEC)) adf_dev_configure()
177 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i); adf_dev_configure()
179 key, (void *)&val, ADF_DEC)) adf_dev_configure()
183 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i); adf_dev_configure()
185 key, (void *)&val, ADF_DEC)) adf_dev_configure()
189 snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_RND_RX, i); adf_dev_configure()
191 key, (void *)&val, ADF_DEC)) adf_dev_configure()
195 snprintf(key, sizeof(key), ADF_ETRMGR_COALESCE_TIMER_FORMAT, i); adf_dev_configure()
197 key, (void *)&val, ADF_DEC)) adf_dev_configure()
/linux-4.1.27/arch/arm/crypto/
H A Dbsaes-armv7.pl25 # encrypt 19.5 cycles per byte processed with 128-bit key
26 # decrypt 22.1 cycles per byte processed with 128-bit key
27 # key conv. 440 cycles per 128-bit key/0.18 of 8x block
39 # results keep in mind key schedule conversion overhead (see
53 my ($inp,$out,$len,$key)=("r0","r1","r2","r3");
57 my ($key,$rounds,$const)=("r4","r5","r6");
344 vldmia $key!, {@t[0]-@t[3]}
349 vldmia $key!, {@t[0]}
353 vldmia $key!, {@t[1]}
357 vldmia $key!, {@t[2]}
360 vldmia $key!, {@t[3]}
728 vldmia $key!, {@XMM[9]} @ round 0 key
732 veor @XMM[10], @XMM[0], @XMM[9] @ xor with round0 key
784 vldmia $key, {@XMM[8]} @ last round key
823 vldmia $key!, {@XMM[9]} @ round 0 key
828 veor @XMM[10], @XMM[0], @XMM[9] @ xor with round0 key
882 vldmia $key, {@XMM[8]} @ last round key
927 vld1.8 {@XMM[7]}, [$inp]! @ load round 0 key
929 vld1.8 {@XMM[15]}, [$inp]! @ load round 1 key
944 vstmia $out!, {@XMM[7]} @ save round 0 key
962 vld1.8 {@XMM[15]}, [$inp]! @ load next round key
971 vstmia $out!,{@XMM[0]-@XMM[7]} @ write bit-sliced round key
975 @ don't save last round key
992 mov r4,$inp @ pass key
993 mov r12,$out @ pass key schedule
995 veor @XMM[7],@XMM[7],@XMM[15] @ fix up last round key
996 vstmia r12, {@XMM[7]} @ save last round key
1011 mov r4,$key @ pass the key
1040 mov r4,$inp @ pass key
1041 mov r12,$out @ pass key schedule
1044 vstmia r12, {@XMM[15]} @ save last round key
1045 veor @XMM[7], @XMM[7], @XMM[6] @ fix up round 0 key
1061 mov r4,$key @ pass the key
1084 my ($inp,$out,$len,$key, $ivp,$fp,$rounds)=map("r$_",(0..3,8..10));
1116 ldr $rounds, [$key, #240] @ get # of rounds
1118 @ allocate the key schedule on the stack
1119 sub r12, sp, $rounds, lsl#7 @ 128 bytes per inner round key
1120 add r12, #`128-32` @ sifze of bit-slices key schedule
1122 @ populate the key schedule
1123 mov r4, $key @ pass key
1128 vstmia r12, {@XMM[15]} @ save last round key
1129 veor @XMM[7], @XMM[7], @XMM[6] @ fix up round 0 key
1132 ldr r12, [$key, #244]
1136 @ populate the key schedule
1137 str r12, [$key, #244]
1138 mov r4, $key @ pass key
1140 add r12, $key, #248 @ pass key schedule
1142 add r4, $key, #248
1144 vstmia r12, {@XMM[15]} @ save last round key
1145 veor @XMM[7], @XMM[7], @XMM[6] @ fix up round 0 key
1163 mov r4, $keysched @ pass the key
1165 add r4, $key, #248
1207 mov r4, $keysched @ pass the key
1209 add r4, $key, #248
1332 mov r2, $key
1345 .Lcbc_dec_bzero: @ wipe key schedule [if any]
1360 my ($inp,$out,$len,$key, $ctr,$fp,$rounds)=(map("r$_",(0..3,8..10)));
1380 ldr $rounds, [$key, #240] @ get # of rounds
1382 @ allocate the key schedule on the stack
1383 sub r12, sp, $rounds, lsl#7 @ 128 bytes per inner round key
1384 add r12, #`128-32` @ size of bit-sliced key schedule
1386 @ populate the key schedule
1387 mov r4, $key @ pass key
1391 veor @XMM[7],@XMM[7],@XMM[15] @ fix up last round key
1392 vstmia r12, {@XMM[7]} @ save last round key
1396 vldmia $keysched, {@XMM[4]} @ load round0 key
1398 ldr r12, [$key, #244]
1402 @ populate the key schedule
1403 str r12, [$key, #244]
1404 mov r4, $key @ pass key
1406 add r12, $key, #248 @ pass key schedule
1408 veor @XMM[7],@XMM[7],@XMM[15] @ fix up last round key
1409 vstmia r12, {@XMM[7]} @ save last round key
1412 0: add r12, $key, #248
1415 vldmia r12, {@XMM[4]} @ load round0 key
1416 sub sp, #0x10 @ place for adjusted round0 key
1425 vstmia $keysched, {@XMM[4]} @ save adjusted round0 key
1443 vldmia $keysched, {@XMM[9]} @ load round0 key
1445 add r4, $keysched, #0x10 @ pass next round key
1447 add r4, $key, #`248+16`
1525 .Lctr_enc_bzero: @ wipe key schedule [if any]
1546 mov r7, $key
1559 mov r2, r7 @ key
1591 my ($inp,$out,$len,$key,$rounds,$magic,$fp)=(map("r$_",(7..10,1..3)));
1609 mov $key, r3
1626 ldr $rounds, [$key, #240] @ get # of rounds
1629 @ allocate the key schedule on the stack
1630 sub r12, sp, $rounds, lsl#7 @ 128 bytes per inner round key
1631 @ add r12, #`128-32` @ size of bit-sliced key schedule
1634 @ populate the key schedule
1635 mov r4, $key @ pass key
1638 add r12, #0x90 @ pass key schedule
1640 veor @XMM[7], @XMM[7], @XMM[15] @ fix up last round key
1641 vstmia r12, {@XMM[7]} @ save last round key
1643 ldr r12, [$key, #244]
1647 str r12, [$key, #244]
1648 mov r4, $key @ pass key
1650 add r12, $key, #248 @ pass key schedule
1652 veor @XMM[7], @XMM[7], @XMM[15] @ fix up last round key
1701 add r4, sp, #0x90 @ pass key schedule
1703 add r4, $key, #248 @ pass key schedule
1770 add r4, sp, #0x90 @ pass key schedule
1772 add r4, $key, #248 @ pass key schedule
1804 add r4, sp, #0x90 @ pass key schedule
1806 add r4, $key, #248 @ pass key schedule
1841 add r4, sp, #0x90 @ pass key schedule
1843 add r4, $key, #248 @ pass key schedule
1871 add r4, sp, #0x90 @ pass key schedule
1873 add r4, $key, #248 @ pass key schedule
1898 add r4, sp, #0x90 @ pass key schedule
1900 add r4, $key, #248 @ pass key schedule
1924 add r4, sp, #0x90 @ pass key schedule
1926 add r4, $key, #248 @ pass key schedule
1947 mov r2, $key
1979 mov r2, $key
1997 .Lxts_enc_bzero: @ wipe key schedule [if any]
2023 mov $key, r3
2040 ldr $rounds, [$key, #240] @ get # of rounds
2043 @ allocate the key schedule on the stack
2044 sub r12, sp, $rounds, lsl#7 @ 128 bytes per inner round key
2045 @ add r12, #`128-32` @ size of bit-sliced key schedule
2048 @ populate the key schedule
2049 mov r4, $key @ pass key
2052 add r12, #0x90 @ pass key schedule
2056 vstmia r12, {@XMM[15]} @ save last round key
2057 veor @XMM[7], @XMM[7], @XMM[6] @ fix up round 0 key
2060 ldr r12, [$key, #244]
2064 str r12, [$key, #244]
2065 mov r4, $key @ pass key
2067 add r12, $key, #248 @ pass key schedule
2069 add r4, $key, #248
2071 vstmia r12, {@XMM[15]} @ save last round key
2072 veor @XMM[7], @XMM[7], @XMM[6] @ fix up round 0 key
2126 add r4, sp, #0x90 @ pass key schedule
2128 add r4, $key, #248 @ pass key schedule
2195 add r4, sp, #0x90 @ pass key schedule
2197 add r4, $key, #248 @ pass key schedule
2229 add r4, sp, #0x90 @ pass key schedule
2231 add r4, $key, #248 @ pass key schedule
2260 add r4, sp, #0x90 @ pass key schedule
2262 add r4, $key, #248 @ pass key schedule
2290 add r4, sp, #0x90 @ pass key schedule
2292 add r4, $key, #248 @ pass key schedule
2317 add r4, sp, #0x90 @ pass key schedule
2319 add r4, $key, #248 @ pass key schedule
2343 add r4, sp, #0x90 @ pass key schedule
2345 add r4, $key, #248 @ pass key schedule
2366 mov r2, $key
2399 mov r2, $key
2423 mov r2, $key
2440 .Lxts_dec_bzero: @ wipe key schedule [if any]
H A Daes_glue.h17 const int bits, struct AES_KEY *key);
19 const int bits, struct AES_KEY *key);
/linux-4.1.27/net/sunrpc/auth_gss/
H A Dgss_krb5_keys.c197 /* loop encrypting the blocks until enough key bytes are generated */ krb5_derive_key()
214 /* postprocess the key */ krb5_derive_key()
250 static void mit_des_fixup_key_parity(u8 key[8]) mit_des_fixup_key_parity() argument
254 key[i] &= 0xfe; mit_des_fixup_key_parity()
255 key[i] |= 1^parity_char(key[i]); mit_des_fixup_key_parity()
260 * This is the des3 key derivation postprocess function
264 struct xdr_netobj *key) gss_krb5_des3_make_key()
269 if (key->len != 24) { gss_krb5_des3_make_key()
270 dprintk("%s: key->len is %d\n", __func__, key->len); gss_krb5_des3_make_key()
280 8 key bytes, then compute the parity bits. Do this three times. */ gss_krb5_des3_make_key()
283 memcpy(key->data + i*8, randombits->data + i*7, 7); gss_krb5_des3_make_key()
284 key->data[i*8+7] = (((key->data[i*8]&1)<<1) | gss_krb5_des3_make_key()
285 ((key->data[i*8+1]&1)<<2) | gss_krb5_des3_make_key()
286 ((key->data[i*8+2]&1)<<3) | gss_krb5_des3_make_key()
287 ((key->data[i*8+3]&1)<<4) | gss_krb5_des3_make_key()
288 ((key->data[i*8+4]&1)<<5) | gss_krb5_des3_make_key()
289 ((key->data[i*8+5]&1)<<6) | gss_krb5_des3_make_key()
290 ((key->data[i*8+6]&1)<<7)); gss_krb5_des3_make_key()
292 mit_des_fixup_key_parity(key->data + i*8); gss_krb5_des3_make_key()
300 * This is the aes key derivation postprocess function
304 struct xdr_netobj *key) gss_krb5_aes_make_key()
308 if (key->len != 16 && key->len != 32) { gss_krb5_aes_make_key()
309 dprintk("%s: key->len is %d\n", __func__, key->len); gss_krb5_aes_make_key()
317 if (randombits->len != key->len) { gss_krb5_aes_make_key()
318 dprintk("%s: randombits->len is %d, key->len is %d\n", gss_krb5_aes_make_key()
319 __func__, randombits->len, key->len); gss_krb5_aes_make_key()
322 memcpy(key->data, randombits->data, key->len); gss_krb5_aes_make_key()
262 gss_krb5_des3_make_key(const struct gss_krb5_enctype *gk5e, struct xdr_netobj *randombits, struct xdr_netobj *key) gss_krb5_des3_make_key() argument
302 gss_krb5_aes_make_key(const struct gss_krb5_enctype *gk5e, struct xdr_netobj *randombits, struct xdr_netobj *key) gss_krb5_aes_make_key() argument
/linux-4.1.27/drivers/staging/speakup/
H A Dkeyhelp.c65 u_short *p_key = key_data, key; build_key_data() local
102 key = (state_tbl[i] << 8) + ch; build_key_data()
108 *p_key = key; build_key_data()
113 static void say_key(int key) say_key() argument
115 int i, state = key >> 8; say_key()
117 key &= 0xff; say_key()
122 if ((key > 0) && (key <= num_key_names)) say_key()
124 spk_msg_get(MSG_KEYNAMES_START + (key - 1))); say_key()
145 int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) spk_handle_help() argument
187 if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { spk_handle_help()
189 spk_msg_get(MSG_KEYNAMES_START + key-1)); spk_handle_help()
198 kp = spk_our_keys[key]+1; spk_handle_help()
203 key += (state_tbl[i] << 8); spk_handle_help()
204 say_key(key); spk_handle_help()
/linux-4.1.27/arch/powerpc/boot/
H A Dplanetcore.h27 /* Return the value associated with a given key in text,
32 const char *planetcore_get_key(const char *table, const char *key);
33 int planetcore_get_decimal(const char *table, const char *key, u64 *val);
34 int planetcore_get_hex(const char *table, const char *key, u64 *val);
H A Dplanetcore.c20 * a table of key=value strings, separated by newlines.
41 const char *planetcore_get_key(const char *table, const char *key) planetcore_get_key() argument
43 int keylen = strlen(key); planetcore_get_key()
46 if (!strncmp(table, key, keylen) && table[keylen] == '=') planetcore_get_key()
55 int planetcore_get_decimal(const char *table, const char *key, u64 *val) planetcore_get_decimal() argument
57 const char *str = planetcore_get_key(table, key); planetcore_get_decimal()
65 int planetcore_get_hex(const char *table, const char *key, u64 *val) planetcore_get_hex() argument
67 const char *str = planetcore_get_key(table, key); planetcore_get_hex()
/linux-4.1.27/net/sctp/
H A Dauth.c61 void sctp_auth_key_put(struct sctp_auth_bytes *key) sctp_auth_key_put() argument
63 if (!key) sctp_auth_key_put()
66 if (atomic_dec_and_test(&key->refcnt)) { sctp_auth_key_put()
67 kzfree(key); sctp_auth_key_put()
72 /* Create a new key structure of a given length */ sctp_auth_create_key()
75 struct sctp_auth_bytes *key; sctp_auth_create_key() local
81 /* Allocate the shared key */ sctp_auth_create_key()
82 key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); sctp_auth_create_key()
83 if (!key) sctp_auth_create_key()
86 key->len = key_len; sctp_auth_create_key()
87 atomic_set(&key->refcnt, 1); sctp_auth_create_key()
90 return key; sctp_auth_create_key()
93 /* Create a new shared key container with a give key id */ sctp_auth_shkey_create()
98 /* Allocate the shared key container */ sctp_auth_shkey_create()
109 /* Free the shared key structure */ sctp_auth_shkey_free()
113 sctp_auth_key_put(sh_key->key); sctp_auth_shkey_free()
114 sh_key->key = NULL; sctp_auth_shkey_free()
118 /* Destroy the entire key list. This is done during the
142 * This is performed by selecting the numerically smaller key vector...
143 * If the key vectors are equal as numbers but differ in length ...
177 * Create a key vector as described in SCTP-AUTH, Section 6.1
185 * are called the two key vectors.
223 /* Make a key vector based on our local parameters */ sctp_auth_make_local_vector()
235 /* Make a key vector based on peer's parameters */ sctp_auth_make_peer_vector()
247 /* Set the value of the association shared key base on the parameters
249 * From the endpoint pair shared keys and the key vectors the
251 * the numerically smaller key vector and concatenating it to the
252 * endpoint pair shared key, and then concatenating the numerically
253 * larger key vector to that. The result of the concatenation is the
254 * association shared key.
267 if (ep_key->key) sctp_auth_asoc_set_secret()
268 auth_len += ep_key->key->len; sctp_auth_asoc_set_secret()
274 if (ep_key->key) { sctp_auth_asoc_set_secret()
275 memcpy(secret->data, ep_key->key->data, ep_key->key->len); sctp_auth_asoc_set_secret()
276 offset += ep_key->key->len; sctp_auth_asoc_set_secret()
287 /* Create an association shared key. Follow the algorithm
303 /* Now we need to build the key vectors sctp_auth_asoc_create_secret()
312 * are called the two key vectors. sctp_auth_asoc_create_secret()
322 * added to the endpoint shared key. sctp_auth_asoc_create_secret()
324 * This is performed by selecting the numerically smaller key sctp_auth_asoc_create_secret()
326 * key, and then concatenating the numerically larger key sctp_auth_asoc_create_secret()
327 * vector to that. If the key vectors are equal as numbers sctp_auth_asoc_create_secret()
329 * endpoint shared key, followed by the shorter key vector, sctp_auth_asoc_create_secret()
330 * followed by the longer key vector. Otherwise, the key sctp_auth_asoc_create_secret()
332 * endpoint pair key in any order. sctp_auth_asoc_create_secret()
371 new->key = sh_key->key; sctp_auth_asoc_copy_shkeys()
372 sctp_auth_key_hold(new->key); sctp_auth_asoc_copy_shkeys()
384 /* Public interface to create the association shared key.
400 * endpoint pair shared key, we can't compute the sctp_auth_asoc_init_active_key()
402 * For key_id 0, endpoint pair shared key is a NULL key. sctp_auth_asoc_init_active_key()
426 /* Find the endpoint pair shared key based on the key_id */ sctp_auth_get_shkey()
431 struct sctp_shared_key *key; sctp_auth_get_shkey() local
434 key_for_each(key, &asoc->endpoint_shared_keys) { sctp_auth_get_shkey()
435 if (key->key_id == key_id) sctp_auth_get_shkey()
436 return key; sctp_auth_get_shkey()
701 * association key K based on the endpoint pair shared key described by
702 * the shared key identifier. The 'data' used for the computation of
722 * - key id sctp_auth_calculate_hmac()
819 /* Set a new shared key on either endpoint or association. If the
820 * the key with a same ID already exists, replace the key (remove the
821 * old key and add a new one).
828 struct sctp_auth_bytes *key; sctp_auth_set_key() local
832 /* Try to find the given key id to see if sctp_auth_set_key()
833 * we are doing a replace, or adding a new key sctp_auth_set_key()
847 /* If we are not replacing a key id, we need to allocate
848 * a shared key.
857 /* Create a new key data based on the info passed in */
858 key = sctp_auth_create_key(auth_key->sca_keylength, GFP_KERNEL);
859 if (!key)
862 memcpy(key->data, &auth_key->sca_key[0], auth_key->sca_keylength);
865 * key id. If we are adding new key id, add it to the
869 sctp_auth_key_put(cur_key->key);
873 cur_key->key = key;
886 struct sctp_shared_key *key; sctp_auth_set_active_key() local
890 /* The key identifier MUST correst to an existing key */ sctp_auth_set_active_key()
896 key_for_each(key, sh_keys) { key_for_each()
897 if (key->key_id == key_id) { key_for_each()
919 struct sctp_shared_key *key; sctp_auth_del_key_id() local
923 /* The key identifier MUST NOT be the current active key sctp_auth_del_key_id()
924 * The key identifier MUST correst to an existing key sctp_auth_del_key_id()
938 key_for_each(key, sh_keys) { key_for_each()
939 if (key->key_id == key_id) { key_for_each()
948 /* Delete the shared key */
949 list_del_init(&key->key_list);
950 sctp_auth_shkey_free(key);
/linux-4.1.27/include/uapi/linux/netfilter/
H A Dnf_conntrack_tuple_common.h33 __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */ member in struct:nf_conntrack_man_proto::__anon13457
/linux-4.1.27/drivers/tty/
H A Dsysrq.c8 * overhauled to use key registration
84 static void sysrq_handle_loglevel(int key) sysrq_handle_loglevel() argument
88 i = key - '0'; sysrq_handle_loglevel()
101 static void sysrq_handle_SAK(int key) sysrq_handle_SAK() argument
117 static void sysrq_handle_unraw(int key) sysrq_handle_unraw() argument
132 static void sysrq_handle_crash(int key) sysrq_handle_crash() argument
147 static void sysrq_handle_reboot(int key) sysrq_handle_reboot() argument
160 static void sysrq_handle_sync(int key) sysrq_handle_sync() argument
171 static void sysrq_handle_show_timers(int key) sysrq_handle_show_timers() argument
182 static void sysrq_handle_mountro(int key) sysrq_handle_mountro() argument
194 static void sysrq_handle_showlocks(int key) sysrq_handle_showlocks() argument
232 static void sysrq_handle_showallcpus(int key) sysrq_handle_showallcpus() argument
258 static void sysrq_handle_showregs(int key) sysrq_handle_showregs() argument
272 static void sysrq_handle_showstate(int key) sysrq_handle_showstate() argument
284 static void sysrq_handle_showstate_blocked(int key) sysrq_handle_showstate_blocked() argument
298 static void sysrq_ftrace_dump(int key) sysrq_ftrace_dump() argument
312 static void sysrq_handle_showmem(int key) sysrq_handle_showmem() argument
342 static void sysrq_handle_term(int key) sysrq_handle_term() argument
363 static void sysrq_handle_moom(int key) sysrq_handle_moom() argument
375 static void sysrq_handle_thaw(int key) sysrq_handle_thaw() argument
387 static void sysrq_handle_kill(int key) sysrq_handle_kill() argument
399 static void sysrq_handle_unrt(int key) sysrq_handle_unrt() argument
472 static int sysrq_key_table_key2index(int key) sysrq_key_table_key2index() argument
476 if ((key >= '0') && (key <= '9')) sysrq_key_table_key2index()
477 retval = key - '0'; sysrq_key_table_key2index()
478 else if ((key >= 'a') && (key <= 'z')) sysrq_key_table_key2index()
479 retval = key + 10 - 'a'; sysrq_key_table_key2index()
488 struct sysrq_key_op *__sysrq_get_key_op(int key) __sysrq_get_key_op() argument
493 i = sysrq_key_table_key2index(key); __sysrq_get_key_op()
500 static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p) __sysrq_put_key_op() argument
502 int i = sysrq_key_table_key2index(key); __sysrq_put_key_op()
508 void __handle_sysrq(int key, bool check_mask) __handle_sysrq() argument
526 op_p = __sysrq_get_key_op(key); __handle_sysrq()
535 op_p->handler(key); __handle_sysrq()
561 void handle_sysrq(int key) handle_sysrq() argument
564 __handle_sysrq(key, true); handle_sysrq()
609 unsigned short key; sysrq_parse_reset_sequence() local
614 key = sysrq_reset_seq[i]; sysrq_parse_reset_sequence()
616 if (key == KEY_RESERVED || key > KEY_MAX) sysrq_parse_reset_sequence()
619 __set_bit(key, state->reset_keybit); sysrq_parse_reset_sequence()
622 if (test_bit(key, state->key_down)) sysrq_parse_reset_sequence()
659 * Pressing any key _not_ in reset sequence cancels sysrq_detect_reset_sequence()
679 /* key press, not autorepeat */ sysrq_detect_reset_sequence()
690 u32 key; sysrq_of_get_keyreset_config() local
704 of_property_for_each_u32(np, "keyset", prop, p, key) { sysrq_of_get_keyreset_config()
705 if (key == KEY_RESERVED || key > KEY_MAX || sysrq_of_get_keyreset_config()
709 sysrq_reset_seq[sysrq_reset_seq_len++] = (unsigned short)key; sysrq_of_get_keyreset_config()
785 * do not clear key bit it KGDB will end up sending sysrq_handle_keypress()
790 clear_bit(KEY_SYSRQ, sysrq->handle.dev->key); sysrq_handle_keypress()
813 * If we are not suppressing key presses keep track of sysrq_handle_keypress()
925 * keyboards have SysRq key predefined and so user may add it to keymap
1029 static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p, __sysrq_swap_key_ops() argument
1035 if (__sysrq_get_key_op(key) == remove_op_p) { __sysrq_swap_key_ops()
1036 __sysrq_put_key_op(key, insert_op_p); __sysrq_swap_key_ops()
1053 int register_sysrq_key(int key, struct sysrq_key_op *op_p) register_sysrq_key() argument
1055 return __sysrq_swap_key_ops(key, op_p, NULL); register_sysrq_key()
1059 int unregister_sysrq_key(int key, struct sysrq_key_op *op_p) unregister_sysrq_key() argument
1061 return __sysrq_swap_key_ops(key, NULL, op_p); unregister_sysrq_key()
/linux-4.1.27/include/net/
H A Darp.h14 u32 key = *(const u32 *)pkey; arp_hashfn() local
15 u32 val = key ^ hash32_ptr(dev); arp_hashfn()
20 static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) __ipv4_neigh_lookup_noref() argument
22 return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); __ipv4_neigh_lookup_noref()
25 static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) __ipv4_neigh_lookup() argument
30 n = __ipv4_neigh_lookup_noref(dev, key); __ipv4_neigh_lookup()
/linux-4.1.27/net/rxrpc/
H A Dar-key.c1 /* RxRPC key management
18 #include <linux/key-type.h>
33 static void rxrpc_destroy(struct key *);
34 static void rxrpc_destroy_s(struct key *);
35 static void rxrpc_describe(const struct key *, struct seq_file *);
36 static long rxrpc_read(const struct key *, char __user *, size_t);
55 * description and an 8-byte decryption key as the payload
68 * Vet the description for an RxRPC server key
461 /* extract the session key and the encoding type (the tag field -> rxrpc_preparse_xdr_rxk5()
627 * - we ignore the cellname, relying on the key to be correctly named rxrpc_preparse_xdr()
670 * Preparse an rxrpc defined key.
674 * 0 4 key interface version number
677 * 8 4 key expiry time (time_t)
679 * 16 8 session key
682 * if no data is provided, then a no-security key is made
694 /* handle a no-security key */ rxrpc_preparse()
705 /* get the key interface version number */ rxrpc_preparse()
719 /* deal with a version 1 key */ rxrpc_preparse()
803 printk(KERN_ERR "Unknown token type %x on rxrpc key\n", rxrpc_free_token_list()
821 * Preparse a server secret key.
823 * The data should be the 8-byte secret key.
860 * dispose of the data dangling from the corpse of a rxrpc key
862 static void rxrpc_destroy(struct key *key) rxrpc_destroy() argument
864 rxrpc_free_token_list(key->payload.data); rxrpc_destroy()
868 * dispose of the data dangling from the corpse of a rxrpc key
870 static void rxrpc_destroy_s(struct key *key) rxrpc_destroy_s() argument
872 if (key->payload.data) { rxrpc_destroy_s()
873 crypto_free_blkcipher(key->payload.data); rxrpc_destroy_s()
874 key->payload.data = NULL; rxrpc_destroy_s()
879 * describe the rxrpc key
881 static void rxrpc_describe(const struct key *key, struct seq_file *m) rxrpc_describe() argument
883 seq_puts(m, key->description); rxrpc_describe()
887 * grab the security key for a socket
891 struct key *key; rxrpc_request_key() local
909 key = request_key(&key_type_rxrpc, description, NULL); rxrpc_request_key()
910 if (IS_ERR(key)) { rxrpc_request_key()
912 _leave(" = %ld", PTR_ERR(key)); rxrpc_request_key()
913 return PTR_ERR(key); rxrpc_request_key()
916 rx->key = key; rxrpc_request_key()
918 _leave(" = 0 [key %x]", key->serial); rxrpc_request_key()
928 struct key *key; rxrpc_server_keyring() local
946 key = request_key(&key_type_keyring, description, NULL); rxrpc_server_keyring()
947 if (IS_ERR(key)) { rxrpc_server_keyring()
949 _leave(" = %ld", PTR_ERR(key)); rxrpc_server_keyring()
950 return PTR_ERR(key); rxrpc_server_keyring()
953 rx->securities = key; rxrpc_server_keyring()
955 _leave(" = 0 [key %x]", key->serial); rxrpc_server_keyring()
960 * generate a server data key
968 struct key *key; rxrpc_get_server_data_key() local
978 key = key_alloc(&key_type_rxrpc, "x", rxrpc_get_server_data_key()
981 if (IS_ERR(key)) { rxrpc_get_server_data_key()
982 _leave(" = -ENOMEM [alloc %ld]", PTR_ERR(key)); rxrpc_get_server_data_key()
986 _debug("key %d", key_serial(key)); rxrpc_get_server_data_key()
996 ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL); rxrpc_get_server_data_key()
1000 conn->key = key; rxrpc_get_server_data_key()
1001 _leave(" = 0 [%d]", key_serial(key)); rxrpc_get_server_data_key()
1005 key_revoke(key); rxrpc_get_server_data_key()
1006 key_put(key); rxrpc_get_server_data_key()
1013 * rxrpc_get_null_key - Generate a null RxRPC key
1014 * @keyname: The name to give the key.
1016 * Generate a null RxRPC key that can be used to indicate anonymous security is
1019 struct key *rxrpc_get_null_key(const char *keyname) rxrpc_get_null_key()
1022 struct key *key; rxrpc_get_null_key() local
1025 key = key_alloc(&key_type_rxrpc, keyname, rxrpc_get_null_key()
1028 if (IS_ERR(key)) rxrpc_get_null_key()
1029 return key; rxrpc_get_null_key()
1031 ret = key_instantiate_and_link(key, NULL, 0, NULL, NULL); rxrpc_get_null_key()
1033 key_revoke(key); rxrpc_get_null_key()
1034 key_put(key); rxrpc_get_null_key()
1038 return key; rxrpc_get_null_key()
1043 * read the contents of an rxrpc key
1046 static long rxrpc_read(const struct key *key, rxrpc_read() argument
1060 if (memcmp(key->description, "afs@", 4) != 0) rxrpc_read()
1062 cnlen = strlen(key->description + 4); rxrpc_read()
1073 for (token = key->payload.data; token; token = token->next) { rxrpc_read()
1078 toksize += 8 * 4; /* viceid, kvno, key*2, begin, rxrpc_read()
1162 ENCODE_DATA(cnlen, key->description + 4); /* cellname */ rxrpc_read()
1166 for (token = key->payload.data; token; token = token->next) { rxrpc_read()
H A Dar-security.c128 struct key *key = conn->key; rxrpc_init_client_conn_security() local
131 _enter("{%d},{%x}", conn->debug_id, key_serial(key)); rxrpc_init_client_conn_security()
133 if (!key) rxrpc_init_client_conn_security()
136 ret = key_validate(key); rxrpc_init_client_conn_security()
140 if (!key->payload.data) rxrpc_init_client_conn_security()
142 token = key->payload.data; rxrpc_init_client_conn_security()
168 struct key *key; rxrpc_init_server_conn_security() local
213 key = key_ref_to_ptr(kref); rxrpc_init_server_conn_security()
216 conn->server_key = key; rxrpc_init_server_conn_security()
262 key_put(conn->key); rxrpc_clear_conn_security()
/linux-4.1.27/kernel/bpf/
H A Dhashtab.c26 /* each htab element is struct htab_elem + key + value */
31 char key[0] __aligned(8);
98 static inline u32 htab_map_hash(const void *key, u32 key_len) htab_map_hash() argument
100 return jhash(key, key_len, 0); htab_map_hash()
109 void *key, u32 key_size) lookup_elem_raw()
114 if (l->hash == hash && !memcmp(&l->key, key, key_size)) lookup_elem_raw()
121 static void *htab_map_lookup_elem(struct bpf_map *map, void *key) htab_map_lookup_elem() argument
133 hash = htab_map_hash(key, key_size); htab_map_lookup_elem()
137 l = lookup_elem_raw(head, hash, key, key_size); htab_map_lookup_elem()
140 return l->key + round_up(map->key_size, 8); htab_map_lookup_elem()
146 static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key) htab_map_get_next_key() argument
158 hash = htab_map_hash(key, key_size); htab_map_get_next_key()
162 /* lookup the key */ htab_map_get_next_key()
163 l = lookup_elem_raw(head, hash, key, key_size); htab_map_get_next_key()
170 /* key was found, get next key in the same bucket */ htab_map_get_next_key()
176 memcpy(next_key, next_l->key, key_size); htab_map_get_next_key()
194 memcpy(next_key, next_l->key, key_size); htab_map_get_next_key()
204 static int htab_map_update_elem(struct bpf_map *map, void *key, void *value, htab_map_update_elem() argument
227 memcpy(l_new->key, key, key_size); htab_map_update_elem()
228 memcpy(l_new->key + round_up(key_size, 8), value, map->value_size); htab_map_update_elem()
230 l_new->hash = htab_map_hash(l_new->key, key_size); htab_map_update_elem()
237 l_old = lookup_elem_raw(head, l_new->hash, key, key_size); htab_map_update_elem()
240 /* if elem with this 'key' doesn't exist and we've reached htab_map_update_elem()
279 static int htab_map_delete_elem(struct bpf_map *map, void *key) htab_map_delete_elem() argument
292 hash = htab_map_hash(key, key_size); htab_map_delete_elem()
298 l = lookup_elem_raw(head, hash, key, key_size); htab_map_delete_elem()
108 lookup_elem_raw(struct hlist_head *head, u32 hash, void *key, u32 key_size) lookup_elem_raw() argument
H A Dsyscall.c149 void __user *ukey = u64_to_ptr(attr->key); map_lookup_elem()
154 void *key, *value, *ptr; map_lookup_elem() local
165 key = kmalloc(map->key_size, GFP_USER); map_lookup_elem()
166 if (!key) map_lookup_elem()
170 if (copy_from_user(key, ukey, map->key_size) != 0) map_lookup_elem()
179 ptr = map->ops->map_lookup_elem(map, key); map_lookup_elem()
197 kfree(key); map_lookup_elem()
207 void __user *ukey = u64_to_ptr(attr->key); map_update_elem()
212 void *key, *value; map_update_elem() local
223 key = kmalloc(map->key_size, GFP_USER); map_update_elem()
224 if (!key) map_update_elem()
228 if (copy_from_user(key, ukey, map->key_size) != 0) map_update_elem()
244 err = map->ops->map_update_elem(map, key, value, attr->flags); map_update_elem()
250 kfree(key); map_update_elem()
256 #define BPF_MAP_DELETE_ELEM_LAST_FIELD key
260 void __user *ukey = u64_to_ptr(attr->key); map_delete_elem()
264 void *key; map_delete_elem() local
275 key = kmalloc(map->key_size, GFP_USER); map_delete_elem()
276 if (!key) map_delete_elem()
280 if (copy_from_user(key, ukey, map->key_size) != 0) map_delete_elem()
284 err = map->ops->map_delete_elem(map, key); map_delete_elem()
288 kfree(key); map_delete_elem()
299 void __user *ukey = u64_to_ptr(attr->key); map_get_next_key()
304 void *key, *next_key; map_get_next_key() local
315 key = kmalloc(map->key_size, GFP_USER); map_get_next_key()
316 if (!key) map_get_next_key()
320 if (copy_from_user(key, ukey, map->key_size) != 0) map_get_next_key()
329 err = map->ops->map_get_next_key(map, key, next_key); map_get_next_key()
343 kfree(key); map_get_next_key()
/linux-4.1.27/scripts/kconfig/lxdialog/
H A Dmenubox.c189 int key = 0, button = 0, scroll = 0, choice = 0; dialog_menu() local
282 while (key != KEY_ESC) { dialog_menu()
283 key = wgetch(menu); dialog_menu()
285 if (key < 256 && isalpha(key)) dialog_menu()
286 key = tolower(key); dialog_menu()
288 if (strchr("ynmh", key)) dialog_menu()
294 if (key == tolower(item_str()[j])) dialog_menu()
301 if (key == tolower(item_str()[j])) dialog_menu()
308 key == KEY_UP || key == KEY_DOWN || dialog_menu()
309 key == '-' || key == '+' || dialog_menu()
310 key == KEY_PPAGE || key == KEY_NPAGE)) { dialog_menu()
314 if (key == KEY_UP || key == '-') { dialog_menu()
323 } else if (key == KEY_DOWN || key == '+') { dialog_menu()
336 } else if (key == KEY_PPAGE) { dialog_menu()
348 } else if (key == KEY_NPAGE) { dialog_menu()
370 continue; /* wait for another key press */ dialog_menu()
373 switch (key) { dialog_menu()
377 button = ((key == KEY_LEFT ? --button : ++button) < 0) dialog_menu()
399 switch (key) { dialog_menu()
422 key = KEY_ESC; dialog_menu()
425 key = on_key_esc(menu); dialog_menu()
436 return key; /* ESC pressed */ dialog_menu()
H A Dchecklist.c121 int key = 0, button = 0, choice = 0, scroll = 0, max_choice; dialog_checklist() local
208 while (key != KEY_ESC) {
209 key = wgetch(dialog);
213 if (toupper(key) == toupper(item_str()[0]))
217 if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
218 key == '+' || key == '-') {
219 if (key == KEY_UP || key == '-') {
241 continue; /* wait for another key press */
244 } else if (key == KEY_DOWN || key == '+') {
269 continue; /* wait for another key press */
284 continue; /* wait for another key press */
286 switch (key) {
306 button = ((key == KEY_LEFT ? --button : ++button) < 0)
314 key = KEY_ESC;
317 key = on_key_esc(dialog);
331 return key; /* ESC pressed */
/linux-4.1.27/net/dns_resolver/
H A Ddns_key.c49 * Preparse instantiation data for a dns_resolver key.
55 * one to be an option of the form 'key=value'. The actual data of interest is
96 "Empty option to dns_resolver key\n"); dns_resolver_preparse()
110 * that's to be recorded as the result in this key */ dns_resolver_preparse()
131 "Option '%*.*s' to dns_resolver key:" dns_resolver_preparse()
179 static bool dns_resolver_cmp(const struct key *key, dns_resolver_cmp() argument
183 const char *src = key->description, *dsp = match_data->raw_data; dns_resolver_cmp()
222 * Describe a DNS key
224 static void dns_resolver_describe(const struct key *key, struct seq_file *m) dns_resolver_describe() argument
226 int err = key->type_data.x[0]; dns_resolver_describe()
228 seq_puts(m, key->description); dns_resolver_describe()
229 if (key_is_instantiated(key)) { dns_resolver_describe()
233 seq_printf(m, ": %u", key->datalen); dns_resolver_describe()
239 * - the key's semaphore is read-locked
241 static long dns_resolver_read(const struct key *key, dns_resolver_read() argument
244 if (key->type_data.x[0]) dns_resolver_read()
245 return key->type_data.x[0]; dns_resolver_read()
247 return user_read(key, buffer, buflen); dns_resolver_read()
265 struct key *keyring; init_dns_resolver()
/linux-4.1.27/drivers/md/bcache/
H A Dmovinggc.c54 trace_bcache_gc_copy_collision(&io->w->key); write_moving_finish()
71 else if (!KEY_DIRTY(&b->key) && read_moving_endio()
72 ptr_stale(io->op.c, &b->key, 0)) { read_moving_endio()
87 bio->bi_iter.bi_size = KEY_SIZE(&io->w->key) << 9; moving_init()
88 bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&io->w->key), moving_init()
103 io->bio.bio.bi_iter.bi_sector = KEY_START(&io->w->key); write_moving()
107 op->writeback = KEY_DIRTY(&io->w->key); write_moving()
108 op->csum = KEY_CSUM(&io->w->key); write_moving()
110 bkey_copy(&op->replace_key, &io->w->key); write_moving()
124 bch_submit_bbio(bio, io->op.c, &io->w->key, 0); read_moving_submit()
146 if (ptr_stale(c, &w->key, 0)) { read_moving()
152 * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS), read_moving()
159 io->op.inode = KEY_INODE(&w->key); read_moving()
172 trace_bcache_gc_copy(&w->key); read_moving()
/linux-4.1.27/drivers/net/wireless/ipw2x00/
H A Dlibipw_wx.c319 int i, key, key_provided, len; libipw_wx_set_encode() local
325 key = erq->flags & IW_ENCODE_INDEX; libipw_wx_set_encode()
326 if (key) { libipw_wx_set_encode()
327 if (key > WEP_KEYS) libipw_wx_set_encode()
329 key--; libipw_wx_set_encode()
333 key = ieee->crypt_info.tx_keyidx; libipw_wx_set_encode()
336 LIBIPW_DEBUG_WX("Key: %d [%s]\n", key, key_provided ? libipw_wx_set_encode()
339 crypt = &ieee->crypt_info.crypt[key]; libipw_wx_set_encode()
343 LIBIPW_DEBUG_WX("Disabling encryption on key %d.\n", libipw_wx_set_encode()
344 key); libipw_wx_set_encode()
350 * and if no key index was provided, de-init them all */ libipw_wx_set_encode()
377 * on this key */ libipw_wx_set_encode()
396 new_crypt->priv = new_crypt->ops->init(key); libipw_wx_set_encode()
409 /* If a new key was provided, set it up */ libipw_wx_set_encode()
412 memcpy(sec.keys[key], keybuf, erq->length); libipw_wx_set_encode()
414 memset(sec.keys[key] + erq->length, 0, libipw_wx_set_encode()
416 LIBIPW_DEBUG_WX("Setting key %d to '%*pE' (%d:%d bytes)\n", libipw_wx_set_encode()
417 key, len, sec.keys[key], libipw_wx_set_encode()
419 sec.key_sizes[key] = len; libipw_wx_set_encode()
421 (*crypt)->ops->set_key(sec.keys[key], len, NULL, libipw_wx_set_encode()
423 sec.flags |= (1 << key); libipw_wx_set_encode()
424 /* This ensures a key will be activated if no key is libipw_wx_set_encode()
426 if (key == sec.active_key) libipw_wx_set_encode()
431 len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN, libipw_wx_set_encode()
434 /* Set a default key of all 0 */ libipw_wx_set_encode()
435 LIBIPW_DEBUG_WX("Setting key %d to all " libipw_wx_set_encode()
436 "zero.\n", key); libipw_wx_set_encode()
437 memset(sec.keys[key], 0, 13); libipw_wx_set_encode()
438 (*crypt)->ops->set_key(sec.keys[key], 13, NULL, libipw_wx_set_encode()
440 sec.key_sizes[key] = 13; libipw_wx_set_encode()
441 sec.flags |= (1 << key); libipw_wx_set_encode()
444 /* No key data - just set the default TX key index */ libipw_wx_set_encode()
446 LIBIPW_DEBUG_WX("Setting key %d to default Tx " libipw_wx_set_encode()
447 "key.\n", key); libipw_wx_set_encode()
448 ieee->crypt_info.tx_keyidx = key; libipw_wx_set_encode()
449 sec.active_key = key; libipw_wx_set_encode()
467 sec.encode_alg[key] = SEC_ALG_WEP; libipw_wx_set_encode()
481 int len, key; libipw_wx_get_encode() local
487 key = erq->flags & IW_ENCODE_INDEX; libipw_wx_get_encode()
488 if (key) { libipw_wx_get_encode()
489 if (key > WEP_KEYS) libipw_wx_get_encode()
491 key--; libipw_wx_get_encode()
493 key = ieee->crypt_info.tx_keyidx; libipw_wx_get_encode()
495 crypt = ieee->crypt_info.crypt[key]; libipw_wx_get_encode()
496 erq->flags = key + 1; libipw_wx_get_encode()
504 len = sec->key_sizes[key]; libipw_wx_get_encode()
505 memcpy(keybuf, sec->keys[key], len); libipw_wx_get_encode()
637 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, libipw_wx_set_encodeext()
639 LIBIPW_DEBUG_WX("%s: key setting failed\n", dev->name); libipw_wx_set_encodeext()
652 memcpy(sec.keys[idx], ext->key, ext->key_len); libipw_wx_set_encodeext()
723 memcpy(ext->key, sec->keys[idx], ext->key_len); libipw_wx_get_encodeext()
/linux-4.1.27/drivers/infiniband/hw/mthca/
H A Dmthca_mr.c53 __be32 key; member in struct:mthca_mpt_entry
390 static inline u32 tavor_key_to_hw_index(u32 key) tavor_key_to_hw_index() argument
392 return key; tavor_key_to_hw_index()
400 static inline u32 arbel_key_to_hw_index(u32 key) arbel_key_to_hw_index() argument
402 return (key << 24) | (key >> 8); arbel_key_to_hw_index()
413 static inline u32 key_to_hw_index(struct mthca_dev *dev, u32 key) key_to_hw_index() argument
416 return arbel_key_to_hw_index(key); key_to_hw_index()
418 return tavor_key_to_hw_index(key); key_to_hw_index()
421 static inline u32 adjust_key(struct mthca_dev *dev, u32 key) adjust_key() argument
424 return ((key << 20) & 0x800000) | (key & 0x7fffff); adjust_key()
426 return key; adjust_key()
434 u32 key; mthca_mr_alloc() local
440 key = mthca_alloc(&dev->mr_table.mpt_alloc); mthca_mr_alloc()
441 if (key == -1) mthca_mr_alloc()
443 key = adjust_key(dev, key); mthca_mr_alloc()
444 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key); mthca_mr_alloc()
447 err = mthca_table_get(dev, dev->mr_table.mpt_table, key); mthca_mr_alloc()
467 mpt_entry->key = cpu_to_be32(key); mthca_mr_alloc()
492 key & (dev->limits.num_mpts - 1)); mthca_mr_alloc()
505 mthca_table_put(dev, dev->mr_table.mpt_table, key); mthca_mr_alloc()
508 mthca_free(&dev->mr_table.mpt_alloc, key); mthca_mr_alloc()
573 u32 key, idx; mthca_fmr_alloc() local
588 key = mthca_alloc(&dev->mr_table.mpt_alloc); mthca_fmr_alloc()
589 if (key == -1) mthca_fmr_alloc()
591 key = adjust_key(dev, key); mthca_fmr_alloc()
593 idx = key & (dev->limits.num_mpts - 1); mthca_fmr_alloc()
594 mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key); mthca_fmr_alloc()
597 err = mthca_table_get(dev, dev->mr_table.mpt_table, key); mthca_fmr_alloc()
601 mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key, NULL); mthca_fmr_alloc()
637 mpt_entry->key = cpu_to_be32(key); mthca_fmr_alloc()
655 key & (dev->limits.num_mpts - 1)); mthca_fmr_alloc()
671 mthca_table_put(dev, dev->mr_table.mpt_table, key); mthca_fmr_alloc()
674 mthca_free(&dev->mr_table.mpt_alloc, key); mthca_fmr_alloc()
723 u32 key; mthca_tavor_map_phys_fmr() local
732 key = tavor_key_to_hw_index(fmr->ibmr.lkey); mthca_tavor_map_phys_fmr()
733 key += dev->limits.num_mpts; mthca_tavor_map_phys_fmr()
734 fmr->ibmr.lkey = fmr->ibmr.rkey = tavor_hw_index_to_key(key); mthca_tavor_map_phys_fmr()
744 mpt_entry.lkey = cpu_to_be32(key); mthca_tavor_map_phys_fmr()
748 __raw_writel((__force u32) mpt_entry.lkey, &fmr->mem.tavor.mpt->key); mthca_tavor_map_phys_fmr()
763 u32 key; mthca_arbel_map_phys_fmr() local
772 key = arbel_key_to_hw_index(fmr->ibmr.lkey); mthca_arbel_map_phys_fmr()
774 key += SINAI_FMR_KEY_INC; mthca_arbel_map_phys_fmr()
776 key += dev->limits.num_mpts; mthca_arbel_map_phys_fmr()
777 fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key); mthca_arbel_map_phys_fmr()
793 fmr->mem.arbel.mpt->key = cpu_to_be32(key); mthca_arbel_map_phys_fmr()
794 fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); mthca_arbel_map_phys_fmr()
845 mthca_dbg(dev, "Memory key throughput optimization activated.\n"); mthca_init_mr_table()
/linux-4.1.27/arch/x86/boot/
H A Dvideo.c102 int key; get_entry() local
106 key = getchar(); get_entry()
108 if (key == '\b') { get_entry()
113 } else if ((key >= '0' && key <= '9') || get_entry()
114 (key >= 'A' && key <= 'Z') || get_entry()
115 (key >= 'a' && key <= 'z')) { get_entry()
117 entry_buf[len++] = key; get_entry()
118 putchar(key); get_entry()
121 } while (key != '\r'); get_entry()
130 key = entry_buf[i] | 0x20; get_entry()
131 v += (key > '9') ? key-'a'+10 : key-'0'; get_entry()
202 int key; mode_menu() local
210 key = getchar_timeout(); mode_menu()
211 if (key == ' ' || key == 0) mode_menu()
213 if (key == '\r') mode_menu()
/linux-4.1.27/drivers/media/usb/dvb-usb/
H A DcinergyT2-core.c144 u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS; cinergyt2_rc_query() local
149 dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0); cinergyt2_rc_query()
150 if (key[4] == 0xff) { cinergyt2_rc_query()
151 /* key repeat */ cinergyt2_rc_query()
158 deb_rc("repeat key, event %x\n", cinergyt2_rc_query()
163 deb_rc("repeated key (non repeatable)\n"); cinergyt2_rc_query()
169 key[2] = ~key[1]; cinergyt2_rc_query()
170 dvb_usb_nec_rc_key_to_event(d, key, event, state); cinergyt2_rc_query()
171 if (key[0] != 0) { cinergyt2_rc_query()
175 deb_rc("key: %*ph\n", 5, key); cinergyt2_rc_query()
H A Dnova-t-usb2.c72 /* Firmware bug? sometimes, when a new key is pressed, the previous pressed key
77 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom; nova_t_rc_query() local
82 dvb_usb_generic_rw(d,cmd,2,key,5,0); nova_t_rc_query()
85 switch (key[0]) { nova_t_rc_query()
87 raw = ((key[1] << 8) | key[2]) >> 3; nova_t_rc_query()
92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle); nova_t_rc_query()
/linux-4.1.27/fs/xfs/
H A Dxfs_mru_cache.h25 unsigned long key; member in struct:xfs_mru_cache_elem
37 int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key,
40 xfs_mru_cache_remove(struct xfs_mru_cache *mru, unsigned long key);
41 void xfs_mru_cache_delete(struct xfs_mru_cache *mru, unsigned long key);
43 xfs_mru_cache_lookup(struct xfs_mru_cache *mru, unsigned long key);
/linux-4.1.27/net/sched/
H A Dem_u32.c24 struct tc_u32_key *key = (struct tc_u32_key *) em->data; em_u32_match() local
30 ptr += (info->nexthdr & key->offmask); em_u32_match()
33 ptr += key->off; em_u32_match()
38 return !(((*(__be32 *) ptr) ^ key->val) & key->mask); em_u32_match()
/linux-4.1.27/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/
H A DUtil.py35 def add_stats(dict, key, value):
36 if not dict.has_key(key):
37 dict[key] = (value, value, value, 1)
39 min, max, avg, count = dict[key]
45 dict[key] = (min, max, avg, count + 1)
/linux-4.1.27/kernel/sched/
H A Dwait.c14 void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *key) __init_waitqueue_head() argument
17 lockdep_set_class_and_name(&q->lock, key, name); __init_waitqueue_head()
66 int nr_exclusive, int wake_flags, void *key) __wake_up_common()
73 if (curr->func(curr, mode, wake_flags, key) && __wake_up_common()
84 * @key: is directly passed to the wakeup function
90 int nr_exclusive, void *key) __wake_up()
95 __wake_up_common(q, mode, nr_exclusive, 0, key); __wake_up()
109 void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key) __wake_up_locked_key() argument
111 __wake_up_common(q, mode, 1, 0, key); __wake_up_locked_key()
120 * @key: opaque value to be passed to wakeup targets
133 int nr_exclusive, void *key) __wake_up_sync_key()
145 __wake_up_common(q, mode, nr_exclusive, wake_flags, key); __wake_up_sync_key()
263 * @key: key to identify a wait bit queue or %NULL
277 unsigned int mode, void *key) abort_exclusive_wait()
286 __wake_up_locked_key(q, mode, key); abort_exclusive_wait()
291 int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) autoremove_wake_function() argument
293 int ret = default_wake_function(wait, mode, sync, key); autoremove_wake_function()
350 int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key) woken_wake_function() argument
362 return default_wake_function(wait, mode, sync, key); woken_wake_function()
368 struct wait_bit_key *key = arg; wake_bit_function() local
372 if (wait_bit->key.flags != key->flags || wake_bit_function()
373 wait_bit->key.bit_nr != key->bit_nr || wake_bit_function()
374 test_bit(key->bit_nr, key->flags)) wake_bit_function()
377 return autoremove_wake_function(wait, mode, sync, key); wake_bit_function()
394 if (test_bit(q->key.bit_nr, q->key.flags)) __wait_on_bit()
395 ret = (*action)(&q->key); __wait_on_bit()
396 } while (test_bit(q->key.bit_nr, q->key.flags) && !ret); __wait_on_bit()
419 wait.key.timeout = jiffies + timeout; out_of_line_wait_on_bit_timeout()
432 if (!test_bit(q->key.bit_nr, q->key.flags)) __wait_on_bit_lock()
434 ret = action(&q->key); __wait_on_bit_lock()
437 abort_exclusive_wait(wq, &q->wait, mode, &q->key); __wait_on_bit_lock()
439 } while (test_and_set_bit(q->key.bit_nr, q->key.flags)); __wait_on_bit_lock()
457 struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit); __wake_up_bit() local
459 __wake_up(wq, TASK_NORMAL, 1, &key); __wake_up_bit()
513 struct wait_bit_key *key = arg; wake_atomic_t_function() local
516 atomic_t *val = key->flags; wake_atomic_t_function()
518 if (wait_bit->key.flags != key->flags || wake_atomic_t_function()
519 wait_bit->key.bit_nr != key->bit_nr || wake_atomic_t_function()
522 return autoremove_wake_function(wait, mode, sync, key); wake_atomic_t_function()
539 val = q->key.flags; __wait_on_atomic_t()
550 .key = __WAIT_ATOMIC_T_KEY_INITIALIZER(p), \
65 __wake_up_common(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, int wake_flags, void *key) __wake_up_common() argument
89 __wake_up(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, void *key) __wake_up() argument
132 __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr_exclusive, void *key) __wake_up_sync_key() argument
276 abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait, unsigned int mode, void *key) abort_exclusive_wait() argument
/linux-4.1.27/fs/reiserfs/
H A Dprints.c17 static char *reiserfs_cpu_offset(struct cpu_key *key) reiserfs_cpu_offset() argument
19 if (cpu_key_k_type(key) == TYPE_DIRENTRY) reiserfs_cpu_offset()
22 GET_HASH_VALUE(cpu_key_k_offset(key)), reiserfs_cpu_offset()
24 GET_GENERATION_NUMBER(cpu_key_k_offset(key))); reiserfs_cpu_offset()
27 (unsigned long long)cpu_key_k_offset(key)); reiserfs_cpu_offset()
31 static char *le_offset(struct reiserfs_key *key) le_offset() argument
35 version = le_key_version(key); le_offset()
36 if (le_key_k_type(version, key) == TYPE_DIRENTRY) le_offset()
39 GET_HASH_VALUE(le_key_k_offset(version, key)), le_offset()
41 GET_GENERATION_NUMBER(le_key_k_offset(version, key))); le_offset()
44 (unsigned long long)le_key_k_offset(version, key)); le_offset()
48 static char *cpu_type(struct cpu_key *key) cpu_type() argument
50 if (cpu_key_k_type(key) == TYPE_STAT_DATA) cpu_type()
52 if (cpu_key_k_type(key) == TYPE_DIRENTRY) cpu_type()
54 if (cpu_key_k_type(key) == TYPE_DIRECT) cpu_type()
56 if (cpu_key_k_type(key) == TYPE_INDIRECT) cpu_type()
61 static char *le_type(struct reiserfs_key *key) le_type() argument
65 version = le_key_version(key); le_type()
67 if (le_key_k_type(version, key) == TYPE_STAT_DATA) le_type()
69 if (le_key_k_type(version, key) == TYPE_DIRENTRY) le_type()
71 if (le_key_k_type(version, key) == TYPE_DIRECT) le_type()
73 if (le_key_k_type(version, key) == TYPE_INDIRECT) le_type()
79 static void sprintf_le_key(char *buf, struct reiserfs_key *key) sprintf_le_key() argument
81 if (key) sprintf_le_key()
82 sprintf(buf, "[%d %d %s %s]", le32_to_cpu(key->k_dir_id), sprintf_le_key()
83 le32_to_cpu(key->k_objectid), le_offset(key), sprintf_le_key()
84 le_type(key)); sprintf_le_key()
90 static void sprintf_cpu_key(char *buf, struct cpu_key *key) sprintf_cpu_key() argument
92 if (key) sprintf_cpu_key()
93 sprintf(buf, "[%d %d %s %s]", key->on_disk_key.k_dir_id, sprintf_cpu_key()
94 key->on_disk_key.k_objectid, reiserfs_cpu_offset(key), sprintf_cpu_key()
95 cpu_type(key)); sprintf_cpu_key()
182 * out key structure you have to write just:
183 * reiserfs_warning ("bad key %k", key);
185 * printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid,
186 * key->k_offset, key->k_uniqueness);
250 * %k to print little endian key,
251 * %K to print cpu key,
425 struct reiserfs_key *key; print_internal() local
448 for (i = from, key = internal_key(bh, from), dc++; i < to; print_internal()
449 i++, key++, dc++) { print_internal()
450 reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc); print_internal()
499 ("|##| type | key | ilen | free_space | version | loc |\n"); print_leaf()
/linux-4.1.27/arch/powerpc/include/asm/
H A Djump_label.h21 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
28 : : "i" (key) : : l_yes); arch_static_branch()
43 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/arch/arm64/include/asm/
H A Djump_label.h29 static __always_inline bool arch_static_branch(struct static_key *key) arch_static_branch() argument
36 : : "i"(key) : : l_yes); arch_static_branch()
48 jump_label_t key; member in struct:jump_entry
/linux-4.1.27/net/ipv4/netfilter/
H A Dnf_nat_proto_gre.c9 * It has an optional key field, which may help us distinguishing two
15 * field called "CallID", which serves us for the same purpose as the key
48 static u_int16_t key; gre_unique_tuple() local
58 keyptr = &tuple->src.u.gre.key; gre_unique_tuple()
60 keyptr = &tuple->dst.u.gre.key; gre_unique_tuple()
67 min = ntohs(range->min_proto.gre.key); gre_unique_tuple()
68 range_size = ntohs(range->max_proto.gre.key) - min + 1; gre_unique_tuple()
73 for (i = 0; ; ++key) { gre_unique_tuple()
74 *keyptr = htons(min + key % range_size); gre_unique_tuple()
102 /* we only have destination manip of a packet, since 'source key' gre_manip_pkt()
112 pr_debug("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key)); gre_manip_pkt()
113 pgreh->call_id = tuple->dst.u.gre.key; gre_manip_pkt()
/linux-4.1.27/tools/lib/lockdep/include/liblockdep/
H A Dcommon.h30 struct lock_class_key *key; member in struct:lockdep_map
40 struct lock_class_key *key, int subclass);
48 { .name = (_name), .key = (void *)(_key), }
/linux-4.1.27/security/integrity/evm/
H A Devm_secfs.c12 * - Used to signal when key is on keyring
13 * - Get the key and enable EVM
56 * Used to signal that key is on the kernel key ring.
57 * - get the integrity hmac key from the kernel key ring
/linux-4.1.27/drivers/crypto/nx/
H A Dnx_csbcpb.h6 u8 key[32]; member in struct:cop_symcpb_aes_ecb
12 u8 key[32]; member in struct:cop_symcpb_aes_cbc
20 u8 key[32]; member in struct:cop_symcpb_aes_gca
32 u8 key[32]; member in struct:cop_symcpb_aes_gcm
43 u8 key[32]; member in struct:cop_symcpb_aes_ctr
52 u8 key[16]; member in struct:cop_symcpb_aes_cca
62 u8 key[16]; member in struct:cop_symcpb_aes_ccm
73 u8 key[16]; member in struct:cop_symcpb_aes_xcbc
/linux-4.1.27/fs/ext4/
H A Dcrypto_key.c6 * This contains encryption key functions for ext4
32 * ext4_derive_key_aes() - Derive a key using AES-128-ECB
33 * @deriving_key: Encryption key used for derivatio.
34 * @source_key: Source key to which to apply derivation.
35 * @derived_key: Derived key.
88 * ext4_generate_encryption_key() - generates an encryption key
89 * @inode: The inode to generate the encryption key for.
97 struct key *keyring_key = NULL; ext4_generate_encryption_key()
/linux-4.1.27/drivers/power/
H A Dtest_power.c251 char const *key; member in struct:battery_property_map
294 static int map_get_value(struct battery_property_map *map, const char *key, map_get_value() argument
300 strncpy(buf, key, MAX_KEYLENGTH); map_get_value()
307 while (map->key) { map_get_value()
308 if (strncasecmp(map->key, buf, MAX_KEYLENGTH) == 0) map_get_value()
320 while (map->key) { map_get_key()
322 return map->key; map_get_key()
335 static int param_set_ac_online(const char *key, const struct kernel_param *kp) param_set_ac_online() argument
337 ac_online = map_get_value(map_ac_online, key, ac_online); param_set_ac_online()
348 static int param_set_usb_online(const char *key, const struct kernel_param *kp) param_set_usb_online() argument
350 usb_online = map_get_value(map_ac_online, key, usb_online); param_set_usb_online()
361 static int param_set_battery_status(const char *key, param_set_battery_status() argument
364 battery_status = map_get_value(map_status, key, battery_status); param_set_battery_status()
375 static int param_set_battery_health(const char *key, param_set_battery_health() argument
378 battery_health = map_get_value(map_health, key, battery_health); param_set_battery_health()
389 static int param_set_battery_present(const char *key, param_set_battery_present() argument
392 battery_present = map_get_value(map_present, key, battery_present); param_set_battery_present()
404 static int param_set_battery_technology(const char *key, param_set_battery_technology() argument
407 battery_technology = map_get_value(map_technology, key, param_set_battery_technology()
421 static int param_set_battery_capacity(const char *key, param_set_battery_capacity() argument
426 if (1 != sscanf(key, "%d", &tmp)) param_set_battery_capacity()
436 static int param_set_battery_voltage(const char *key, param_set_battery_voltage() argument
441 if (1 != sscanf(key, "%d", &tmp)) param_set_battery_voltage()
/linux-4.1.27/drivers/crypto/
H A Dpadlock-aes.c72 the extended key for a given key_len. */
108 const __le32 *key = (const __le32 *)in_key; aes_set_key() local
119 * If the hardware is capable of generating the extended key aes_set_key()
120 * itself we must supply the plain key for both encryption aes_set_key()
125 ctx->E[0] = le32_to_cpu(key[0]); aes_set_key()
126 ctx->E[1] = le32_to_cpu(key[1]); aes_set_key()
127 ctx->E[2] = le32_to_cpu(key[2]); aes_set_key()
128 ctx->E[3] = le32_to_cpu(key[3]); aes_set_key()
190 static inline void rep_xcrypt_ecb(const u8 *input, u8 *output, void *key, rep_xcrypt_ecb() argument
195 : "d"(control_word), "b"(key), "c"(count)); rep_xcrypt_ecb()
198 static inline u8 *rep_xcrypt_cbc(const u8 *input, u8 *output, void *key, rep_xcrypt_cbc() argument
203 : "d" (control_word), "b" (key), "c" (count)); rep_xcrypt_cbc()
207 static void ecb_crypt_copy(const u8 *in, u8 *out, u32 *key, ecb_crypt_copy() argument
218 rep_xcrypt_ecb(tmp, out, key, cword, count); ecb_crypt_copy()
221 static u8 *cbc_crypt_copy(const u8 *in, u8 *out, u32 *key, cbc_crypt_copy() argument
232 return rep_xcrypt_cbc(tmp, out, key, iv, cword, count); cbc_crypt_copy()
235 static inline void ecb_crypt(const u8 *in, u8 *out, u32 *key, ecb_crypt() argument
242 ecb_crypt_copy(in, out, key, cword, count); ecb_crypt()
246 rep_xcrypt_ecb(in, out, key, cword, count); ecb_crypt()
249 static inline u8 *cbc_crypt(const u8 *in, u8 *out, u32 *key, cbc_crypt() argument
254 return cbc_crypt_copy(in, out, key, iv, cword, count); cbc_crypt()
256 return rep_xcrypt_cbc(in, out, key, iv, cword, count); cbc_crypt()
259 static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key, padlock_xcrypt_ecb() argument
265 ecb_crypt(input, output, key, control_word, count); padlock_xcrypt_ecb()
272 : "d"(control_word), "b"(key), "c"(initial)); padlock_xcrypt_ecb()
276 : "d"(control_word), "b"(key), "c"(count - initial)); padlock_xcrypt_ecb()
279 static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key, padlock_xcrypt_cbc() argument
285 return cbc_crypt(input, output, key, iv, control_word, count); padlock_xcrypt_cbc()
290 : "d" (control_word), "b" (key), "c" (initial)); padlock_xcrypt_cbc()
294 : "d" (control_word), "b" (key), "c" (count-initial)); padlock_xcrypt_cbc()
/linux-4.1.27/drivers/net/wireless/iwlwifi/mvm/
H A Dfw-api-sta.h76 * @STA_FLG_SET_ALL_KEYS: the current key applies to all key IDs
136 * enum iwl_sta_key_flag - key flags for the ADD_STA host command
145 * @STA_KEY_FLG_WEP_KEY_MAP: wep is either a group key (0 - legacy WEP) or from
147 * @STA_KEY_FLG_KEYID_MSK: the index of the key
148 * @STA_KEY_NOT_VALID: key is invalid
149 * @STA_KEY_FLG_WEP_13BYTES: set for 13 bytes WEP key
150 * @STA_KEY_MULTICAST: set for multical key
151 * @STA_KEY_MFP: key is used for Management Frame Protection
174 * @STA_MODIFY_KEY: this command modifies %key
233 * struct iwl_mvm_keyinfo - key information
235 * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
237 * @key_offset: key offset in the fw's key table
238 * @key: 16-byte unicast decryption key
250 u8 key[16]; member in struct:iwl_mvm_keyinfo
316 * struct iwl_mvm_add_sta_key_cmd - add/modify sta key
319 * @key_offset: key offset in key storage
321 * @key: key material data
322 * @key2: key material data
323 * @rx_secur_seq_cnt: RX security sequence counter for the key
324 * @tkip_rx_tsc_byte2: TSC[2] for key mix ph1 detection
331 u8 key[16]; member in struct:iwl_mvm_add_sta_key_cmd
369 * @K1: IGTK master key
370 * @K2: IGTK sub key
391 u8 key[16]; member in struct:iwl_mvm_wep_key

Completed in 7435 milliseconds

1234567891011>>