Lines Matching refs:key

161 	struct tipc_aead_key *key;  member
209 struct tipc_key key; member
375 rc = crypto_rng_get_bytes(crypto_default_rng, skey->key, in tipc_aead_key_generate()
427 kfree_sensitive(aead->key); in tipc_aead_free()
557 err |= crypto_aead_setkey(tfm, ukey->key, keylen); in tipc_aead_init()
592 bin2hex(tmp->hint, ukey->key + keylen - TIPC_AEAD_HINT_LEN, in tipc_aead_init()
599 tmp->key = kmemdup(ukey, tipc_aead_key_size(ukey), GFP_KERNEL); in tipc_aead_init()
600 if (!tmp->key) { in tipc_aead_init()
604 memcpy(&tmp->salt, ukey->key + keylen, TIPC_AES_GCM_SALT_SIZE); in tipc_aead_init()
1076 ehdr->rx_key_active = (__rx) ? __rx->key.active : 0; in tipc_ehdr_build()
1104 struct tipc_key old = c->key; in tipc_crypto_key_set_state()
1107 c->key.keys = ((new_passive & KEY_MASK) << (KEY_BITS * 2)) | in tipc_crypto_key_set_state()
1112 tipc_key_change_dump(old, c->key, buf), in tipc_crypto_key_set_state()
1160 struct tipc_key key; in tipc_crypto_key_attach() local
1165 key = c->key; in tipc_crypto_key_attach()
1170 if (key.active && key.passive) in tipc_crypto_key_attach()
1172 if (key.pending) { in tipc_crypto_key_attach()
1173 if (tipc_aead_users(c->aead[key.pending]) > 0) in tipc_crypto_key_attach()
1177 new_key = key.pending; in tipc_crypto_key_attach()
1180 if (key.active && pos != key_next(key.active)) { in tipc_crypto_key_attach()
1181 key.passive = pos; in tipc_crypto_key_attach()
1184 } else if (!key.active && !key.passive) { in tipc_crypto_key_attach()
1185 key.pending = pos; in tipc_crypto_key_attach()
1190 key.pending = key_next(key.active ?: key.passive); in tipc_crypto_key_attach()
1191 new_key = key.pending; in tipc_crypto_key_attach()
1198 if (likely(c->key.keys != key.keys)) in tipc_crypto_key_attach()
1199 tipc_crypto_key_set_state(c, key.passive, key.active, in tipc_crypto_key_attach()
1200 key.pending); in tipc_crypto_key_attach()
1260 struct tipc_key key; in tipc_crypto_key_try_align() local
1266 key = rx->key; in tipc_crypto_key_try_align()
1267 if (key.pending == new_pending) { in tipc_crypto_key_try_align()
1271 if (key.active) in tipc_crypto_key_try_align()
1273 if (!key.pending) in tipc_crypto_key_try_align()
1275 if (tipc_aead_users(rx->aead[key.pending]) > 0) in tipc_crypto_key_try_align()
1279 tmp1 = tipc_aead_rcu_ptr(rx->aead[key.pending], &rx->lock); in tipc_crypto_key_try_align()
1282 rcu_assign_pointer(rx->aead[key.pending], NULL); in tipc_crypto_key_try_align()
1285 if (key.passive) { in tipc_crypto_key_try_align()
1286 tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock)); in tipc_crypto_key_try_align()
1287 x = (key.passive - key.pending + new_pending) % KEY_MAX; in tipc_crypto_key_try_align()
1298 pr_info_ratelimited("%s: key[%d] -> key[%d]\n", rx->name, key.pending, in tipc_crypto_key_try_align()
1326 struct tipc_key key = tx->key; in tipc_crypto_key_pick_tx() local
1346 k = (i == 0) ? key.pending : in tipc_crypto_key_pick_tx()
1347 ((i == 1) ? key.active : key.passive); in tipc_crypto_key_pick_tx()
1415 if (tx->key.keys && in tipc_crypto_key_synch()
1431 if (tx->key.keys && in tipc_crypto_key_synch()
1451 struct tipc_key key; in tipc_crypto_key_revoke() local
1454 key = tx->key; in tipc_crypto_key_revoke()
1455 WARN_ON(!key.active || tx_key != key.active); in tipc_crypto_key_revoke()
1458 tipc_crypto_key_set_state(tx, key.passive, 0, key.pending); in tipc_crypto_key_revoke()
1459 tipc_crypto_key_detach(tx->aead[key.active], &tx->lock); in tipc_crypto_key_revoke()
1555 struct tipc_key key; in tipc_crypto_timeout() local
1560 key = tx->key; in tipc_crypto_timeout()
1561 if (key.active && tipc_aead_users(tx->aead[key.active]) > 0) in tipc_crypto_timeout()
1563 if (!key.pending || tipc_aead_users(tx->aead[key.pending]) <= 0) in tipc_crypto_timeout()
1568 tipc_crypto_key_set_state(tx, key.passive, key.pending, 0); in tipc_crypto_timeout()
1569 if (key.active) in tipc_crypto_timeout()
1570 tipc_crypto_key_detach(tx->aead[key.active], &tx->lock); in tipc_crypto_timeout()
1572 pr_info("%s: key[%d] is activated\n", tx->name, key.pending); in tipc_crypto_timeout()
1579 key = rx->key; in tipc_crypto_timeout()
1580 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) <= 0) in tipc_crypto_timeout()
1583 if (key.active) in tipc_crypto_timeout()
1584 key.passive = key.active; in tipc_crypto_timeout()
1585 key.active = key.pending; in tipc_crypto_timeout()
1587 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1589 pr_info("%s: key[%d] is activated\n", rx->name, key.pending); in tipc_crypto_timeout()
1594 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) > -10) in tipc_crypto_timeout()
1597 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1598 tipc_crypto_key_detach(rx->aead[key.pending], &rx->lock); in tipc_crypto_timeout()
1599 pr_debug("%s: key[%d] is removed\n", rx->name, key.pending); in tipc_crypto_timeout()
1604 if (!key.active) in tipc_crypto_timeout()
1607 tipc_aead_users(rx->aead[key.active]) > 0) in tipc_crypto_timeout()
1610 if (key.pending) in tipc_crypto_timeout()
1611 key.passive = key.active; in tipc_crypto_timeout()
1613 key.pending = key.active; in tipc_crypto_timeout()
1615 tipc_crypto_key_set_state(rx, key.passive, 0, key.pending); in tipc_crypto_timeout()
1616 tipc_aead_users_set(rx->aead[key.pending], 0); in tipc_crypto_timeout()
1617 pr_debug("%s: key[%d] is deactivated\n", rx->name, key.active); in tipc_crypto_timeout()
1622 if (!key.passive) in tipc_crypto_timeout()
1625 tipc_aead_users(rx->aead[key.passive]) > -10) in tipc_crypto_timeout()
1628 tipc_crypto_key_set_state(rx, 0, key.active, key.pending); in tipc_crypto_timeout()
1629 tipc_crypto_key_detach(rx->aead[key.passive], &rx->lock); in tipc_crypto_timeout()
1630 pr_debug("%s: key[%d] is freed\n", rx->name, key.passive); in tipc_crypto_timeout()
1697 struct tipc_key key = tx->key; in tipc_crypto_xmit() local
1709 if (unlikely(key.pending)) { in tipc_crypto_xmit()
1710 tx_key = key.pending; in tipc_crypto_xmit()
1711 if (!tx->key_master && !key.active) in tipc_crypto_xmit()
1717 key.pending); in tipc_crypto_xmit()
1728 if (!key.active) in tipc_crypto_xmit()
1752 if (likely(key.active)) { in tipc_crypto_xmit()
1753 tx_key = key.active; in tipc_crypto_xmit()
1820 struct tipc_key key; in tipc_crypto_rcv() local
1833 key = rx->key; in tipc_crypto_rcv()
1834 if (tx_key == key.active || tx_key == key.pending || in tipc_crypto_rcv()
1835 tx_key == key.passive) in tipc_crypto_rcv()
1882 tx_key, rx->key.keys); in tipc_crypto_rcv()
1967 if (rx->key.passive && ehdr->tx_key == rx->key.passive) in tipc_crypto_rcv_complete()
2082 struct tipc_key key = c->key; in tipc_crypto_key_dump() local
2097 if (k == key.passive) in tipc_crypto_key_dump()
2099 else if (k == key.active) in tipc_crypto_key_dump()
2101 else if (k == key.pending) in tipc_crypto_key_dump()
2131 struct tipc_key *key = &old; in tipc_key_change_dump() local
2139 if (k == key->passive) in tipc_key_change_dump()
2141 else if (k == key->active) in tipc_key_change_dump()
2143 else if (k == key->pending) in tipc_key_change_dump()
2150 if (key != &new) { in tipc_key_change_dump()
2152 key = &new; in tipc_key_change_dump()
2200 int tipc_crypto_key_distr(struct tipc_crypto *tx, u8 key, in tipc_crypto_key_distr() argument
2210 if (key) { in tipc_crypto_key_distr()
2212 aead = tipc_aead_get(tx->aead[key]); in tipc_crypto_key_distr()
2214 rc = tipc_crypto_key_xmit(tx->net, aead->key, in tipc_crypto_key_distr()
2263 memcpy(data + TIPC_AEAD_ALG_NAME + sizeof(__be32), skey->key, in tipc_crypto_key_xmit()
2312 if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) { in tipc_crypto_key_rcv()
2328 memcpy(skey->key, data + TIPC_AEAD_ALG_NAME + sizeof(__be32), in tipc_crypto_key_rcv()
2362 u8 key; in tipc_crypto_work_rx() local
2370 key = tx->key.pending ?: tx->key.active; in tipc_crypto_work_rx()
2371 rc = tipc_crypto_key_distr(tx, key, rx->node); in tipc_crypto_work_rx()
2374 tx->name, key, tipc_node_get_id_str(rx->node), in tipc_crypto_work_rx()
2449 struct tipc_key key = tx->key; in tipc_crypto_work_tx() local
2453 if (unlikely(key.pending)) in tipc_crypto_work_tx()
2458 aead = rcu_dereference(tx->aead[key.active ?: KEY_MASTER]); in tipc_crypto_work_tx()
2466 skey = kmemdup(aead->key, tipc_aead_key_size(aead->key), GFP_ATOMIC); in tipc_crypto_work_tx()