Lines Matching refs:nonce

247 int bt_mesh_prov_nonce(const uint8_t dhkey[32], const uint8_t prov_salt[16], uint8_t nonce[13])  in bt_mesh_prov_nonce()
254 memcpy(nonce, tmp + 3, 13); in bt_mesh_prov_nonce()
289 static void create_proxy_nonce(uint8_t nonce[13], const uint8_t *pdu, in create_proxy_nonce()
292 memset(nonce, 0, 13); in create_proxy_nonce()
295 nonce[0] = 0x03; in create_proxy_nonce()
298 nonce[2] = pdu[2]; in create_proxy_nonce()
299 nonce[3] = pdu[3]; in create_proxy_nonce()
300 nonce[4] = pdu[4]; in create_proxy_nonce()
303 nonce[5] = pdu[5]; in create_proxy_nonce()
304 nonce[6] = pdu[6]; in create_proxy_nonce()
307 sys_put_be32(iv_index, &nonce[9]); in create_proxy_nonce()
310 static void create_proxy_sol_nonce(uint8_t nonce[13], const uint8_t *pdu) in create_proxy_sol_nonce()
312 memset(nonce, 0, 13); in create_proxy_sol_nonce()
315 nonce[0] = 0x04; in create_proxy_sol_nonce()
318 nonce[2] = pdu[2]; in create_proxy_sol_nonce()
319 nonce[3] = pdu[3]; in create_proxy_sol_nonce()
320 nonce[4] = pdu[4]; in create_proxy_sol_nonce()
323 nonce[5] = pdu[5]; in create_proxy_sol_nonce()
324 nonce[6] = pdu[6]; in create_proxy_sol_nonce()
327 static void create_net_nonce(uint8_t nonce[13], const uint8_t *pdu, in create_net_nonce()
331 nonce[0] = 0x00; in create_net_nonce()
334 nonce[1] = pdu[1]; in create_net_nonce()
337 nonce[2] = pdu[2]; in create_net_nonce()
338 nonce[3] = pdu[3]; in create_net_nonce()
339 nonce[4] = pdu[4]; in create_net_nonce()
342 nonce[5] = pdu[5]; in create_net_nonce()
343 nonce[6] = pdu[6]; in create_net_nonce()
346 nonce[7] = 0U; in create_net_nonce()
347 nonce[8] = 0U; in create_net_nonce()
350 sys_put_be32(iv_index, &nonce[9]); in create_net_nonce()
383 uint8_t nonce[13]; in bt_mesh_net_encrypt() local
391 create_proxy_nonce(nonce, buf->data, iv_index); in bt_mesh_net_encrypt()
394 create_proxy_sol_nonce(nonce, buf->data); in bt_mesh_net_encrypt()
396 create_net_nonce(nonce, buf->data, iv_index); in bt_mesh_net_encrypt()
399 LOG_DBG("Nonce %s", bt_hex(nonce, 13)); in bt_mesh_net_encrypt()
401 err = bt_mesh_ccm_encrypt(key, nonce, &buf->data[7], buf->len - 7, NULL, 0, in bt_mesh_net_encrypt()
414 uint8_t nonce[13]; in bt_mesh_net_decrypt() local
421 create_proxy_nonce(nonce, buf->data, iv_index); in bt_mesh_net_decrypt()
424 create_proxy_sol_nonce(nonce, buf->data); in bt_mesh_net_decrypt()
426 create_net_nonce(nonce, buf->data, iv_index); in bt_mesh_net_decrypt()
429 LOG_DBG("Nonce %s", bt_hex(nonce, 13)); in bt_mesh_net_decrypt()
433 return bt_mesh_ccm_decrypt(key, nonce, &buf->data[7], buf->len - 7, NULL, 0, in bt_mesh_net_decrypt()
437 static void create_app_nonce(uint8_t nonce[13], in create_app_nonce()
441 nonce[0] = 0x02; in create_app_nonce()
443 nonce[0] = 0x01; in create_app_nonce()
446 sys_put_be32((ctx->seq_num | ((uint32_t)ctx->aszmic << 31)), &nonce[1]); in create_app_nonce()
448 sys_put_be16(ctx->src, &nonce[5]); in create_app_nonce()
449 sys_put_be16(ctx->dst, &nonce[7]); in create_app_nonce()
451 sys_put_be32(ctx->iv_index, &nonce[9]); in create_app_nonce()
457 uint8_t nonce[13]; in bt_mesh_app_encrypt() local
465 create_app_nonce(nonce, ctx); in bt_mesh_app_encrypt()
467 LOG_DBG("Nonce %s", bt_hex(nonce, 13)); in bt_mesh_app_encrypt()
469 err = bt_mesh_ccm_encrypt(key, nonce, buf->data, buf->len, ctx->ad, in bt_mesh_app_encrypt()
483 uint8_t nonce[13]; in bt_mesh_app_decrypt() local
488 create_app_nonce(nonce, ctx); in bt_mesh_app_decrypt()
491 LOG_DBG("Nonce %s", bt_hex(nonce, 13)); in bt_mesh_app_decrypt()
493 err = bt_mesh_ccm_decrypt(key, nonce, buf->data, buf->len, ctx->ad, in bt_mesh_app_decrypt()
671 int bt_mesh_prov_decrypt(struct bt_mesh_key *key, uint8_t nonce[13], const uint8_t data[25 + 8], in bt_mesh_prov_decrypt()
676 err = bt_mesh_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8); in bt_mesh_prov_decrypt()
681 int bt_mesh_prov_encrypt(struct bt_mesh_key *key, uint8_t nonce[13], const uint8_t data[25], in bt_mesh_prov_encrypt()
686 err = bt_mesh_ccm_encrypt(key, nonce, data, 25, NULL, 0, out, 8); in bt_mesh_prov_encrypt()