Lines Matching refs:sec_ctx
25 int ieee802154_security_setup_session(struct ieee802154_security_ctx *sec_ctx, uint8_t level, in ieee802154_security_setup_session() argument
43 sec_ctx->level = level; in ieee802154_security_setup_session()
58 sec_ctx->enc.mode_params.ccm_info.tag_len = authtag_len; in ieee802154_security_setup_session()
59 sec_ctx->dec.mode_params.ccm_info.tag_len = authtag_len; in ieee802154_security_setup_session()
61 memcpy(sec_ctx->key, key, key_len); in ieee802154_security_setup_session()
62 sec_ctx->key_len = key_len; in ieee802154_security_setup_session()
63 sec_ctx->key_mode = key_mode; in ieee802154_security_setup_session()
65 sec_ctx->enc.key.bit_stream = sec_ctx->key; in ieee802154_security_setup_session()
66 sec_ctx->enc.keylen = sec_ctx->key_len; in ieee802154_security_setup_session()
68 sec_ctx->dec.key.bit_stream = sec_ctx->key; in ieee802154_security_setup_session()
69 sec_ctx->dec.keylen = sec_ctx->key_len; in ieee802154_security_setup_session()
71 ret = cipher_begin_session(sec_ctx->enc.device, &sec_ctx->enc, CRYPTO_CIPHER_ALGO_AES, in ieee802154_security_setup_session()
79 ret = cipher_begin_session(sec_ctx->dec.device, &sec_ctx->dec, CRYPTO_CIPHER_ALGO_AES, in ieee802154_security_setup_session()
83 cipher_free_session(sec_ctx->enc.device, &sec_ctx->enc); in ieee802154_security_setup_session()
91 void ieee802154_security_teardown_session(struct ieee802154_security_ctx *sec_ctx) in ieee802154_security_teardown_session() argument
93 if (sec_ctx->level == IEEE802154_SECURITY_LEVEL_NONE) { in ieee802154_security_teardown_session()
97 cipher_free_session(sec_ctx->enc.device, &sec_ctx->enc); in ieee802154_security_teardown_session()
98 cipher_free_session(sec_ctx->dec.device, &sec_ctx->dec); in ieee802154_security_teardown_session()
99 sec_ctx->level = IEEE802154_SECURITY_LEVEL_NONE; in ieee802154_security_teardown_session()
131 bool ieee802154_decrypt_auth(struct ieee802154_security_ctx *sec_ctx, uint8_t *frame, in ieee802154_decrypt_auth() argument
141 if (!sec_ctx || sec_ctx->level == IEEE802154_SECURITY_LEVEL_NONE) { in ieee802154_decrypt_auth()
145 level = sec_ctx->level; in ieee802154_decrypt_auth()
154 ret = cipher_ccm_op(&sec_ctx->dec, &apkt, nonce); in ieee802154_decrypt_auth()
164 bool ieee802154_encrypt_auth(struct ieee802154_security_ctx *sec_ctx, uint8_t *frame, in ieee802154_encrypt_auth() argument
174 if (!sec_ctx || sec_ctx->level == IEEE802154_SECURITY_LEVEL_NONE) { in ieee802154_encrypt_auth()
178 level = sec_ctx->level; in ieee802154_encrypt_auth()
185 if (sec_ctx->frame_counter == 0xffffffff) { in ieee802154_encrypt_auth()
192 sys_put_be32(sec_ctx->frame_counter, &nonce[8]); in ieee802154_encrypt_auth()
197 ret = cipher_ccm_op(&sec_ctx->enc, &apkt, nonce); in ieee802154_encrypt_auth()
200 payload_len, sec_ctx->frame_counter); in ieee802154_encrypt_auth()
204 sec_ctx->frame_counter++; in ieee802154_encrypt_auth()
209 int ieee802154_security_init(struct ieee802154_security_ctx *sec_ctx) in ieee802154_security_init() argument
213 (void)memset(&sec_ctx->enc, 0, sizeof(struct cipher_ctx)); in ieee802154_security_init()
214 (void)memset(&sec_ctx->dec, 0, sizeof(struct cipher_ctx)); in ieee802154_security_init()
221 sec_ctx->enc.flags = crypto_query_hwcaps(dev); in ieee802154_security_init()
222 sec_ctx->dec.flags = crypto_query_hwcaps(dev); in ieee802154_security_init()
224 sec_ctx->enc.mode_params.ccm_info.nonce_len = 13U; in ieee802154_security_init()
225 sec_ctx->dec.mode_params.ccm_info.nonce_len = 13U; in ieee802154_security_init()
227 sec_ctx->enc.device = dev; in ieee802154_security_init()
228 sec_ctx->dec.device = dev; in ieee802154_security_init()