Lines Matching +full:t0 +full:- +full:out

5  * SPDX-License-Identifier: Apache-2.0
82 uint8_t out[16]; in bt_mesh_k2() local
109 err = bt_mesh_aes_cmac_raw_key(t, sg, ARRAY_SIZE(sg), out); in bt_mesh_k2()
114 net_id[0] = out[15] & 0x7f; in bt_mesh_k2()
116 sg[0].data = out; in bt_mesh_k2()
117 sg[0].len = sizeof(out); in bt_mesh_k2()
120 err = bt_mesh_aes_cmac_raw_key(t, sg, ARRAY_SIZE(sg), out); in bt_mesh_k2()
125 err = bt_mesh_key_import(BT_MESH_KEY_TYPE_CCM, out, enc_key); in bt_mesh_k2()
132 err = bt_mesh_aes_cmac_raw_key(t, sg, ARRAY_SIZE(sg), out); in bt_mesh_k2()
137 err = bt_mesh_key_import(BT_MESH_KEY_TYPE_ECB, out, priv_key); in bt_mesh_k2()
148 int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]) in bt_mesh_k3()
170 memcpy(out, tmp + 8, 8); in bt_mesh_k3()
175 int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]) in bt_mesh_k4()
197 out[0] = tmp[15] & BIT_MASK(6); in bt_mesh_k4()
203 uint8_t *p, uint8_t out[32]) in bt_mesh_k5()
213 err = bt_mesh_sha256_hmac_one_raw_key(t, p, strlen(p), out); in bt_mesh_k5()
222 struct bt_mesh_key *out) in bt_mesh_id128() argument
239 err = bt_mesh_key_import(type, k1_out, out); in bt_mesh_id128()
382 uint8_t mic_len = NET_MIC_LEN(buf->data); in bt_mesh_net_encrypt()
388 LOG_DBG("PDU (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); in bt_mesh_net_encrypt()
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()
401 err = bt_mesh_ccm_encrypt(key, nonce, &buf->data[7], buf->len - 7, NULL, 0, in bt_mesh_net_encrypt()
402 &buf->data[7], mic_len); in bt_mesh_net_encrypt()
413 uint8_t mic_len = NET_MIC_LEN(buf->data); in bt_mesh_net_decrypt()
416 LOG_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len)); in bt_mesh_net_decrypt()
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()
431 buf->len -= mic_len; 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()
434 &buf->data[7], mic_len); in bt_mesh_net_decrypt()
440 if (ctx->dev_key) { 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()
461 LOG_DBG("dev_key %u src 0x%04x dst 0x%04x", ctx->dev_key, ctx->src, ctx->dst); in bt_mesh_app_encrypt()
462 LOG_DBG("seq_num 0x%08x iv_index 0x%08x", ctx->seq_num, ctx->iv_index); in bt_mesh_app_encrypt()
463 LOG_DBG("Clear: %s", bt_hex(buf->data, buf->len)); in bt_mesh_app_encrypt()
469 err = bt_mesh_ccm_encrypt(key, nonce, buf->data, buf->len, ctx->ad, in bt_mesh_app_encrypt()
470 ctx->ad ? 16 : 0, buf->data, in bt_mesh_app_encrypt()
471 APP_MIC_LEN(ctx->aszmic)); in bt_mesh_app_encrypt()
473 net_buf_simple_add(buf, APP_MIC_LEN(ctx->aszmic)); in bt_mesh_app_encrypt()
474 LOG_DBG("Encr: %s", bt_hex(buf->data, buf->len)); in bt_mesh_app_encrypt()
481 struct net_buf_simple *buf, struct net_buf_simple *out) in bt_mesh_app_decrypt() argument
486 LOG_DBG("EncData (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); in bt_mesh_app_decrypt()
493 err = bt_mesh_ccm_decrypt(key, nonce, buf->data, buf->len, ctx->ad, in bt_mesh_app_decrypt()
494 ctx->ad ? 16 : 0, out->data, in bt_mesh_app_decrypt()
495 APP_MIC_LEN(ctx->aszmic)); in bt_mesh_app_decrypt()
497 net_buf_simple_add(out, buf->len); in bt_mesh_app_decrypt()
503 /* reversed, 8-bit, poly=0x07 */
550 while (data_len--) { in bt_mesh_fcs_calc()
554 LOG_DBG("fcs 0x%02x", 0xff - fcs); in bt_mesh_fcs_calc()
556 return 0xff - fcs; in bt_mesh_fcs_calc()
561 const uint8_t *data = buf->data; in bt_mesh_fcs_check()
562 uint16_t data_len = buf->len; in bt_mesh_fcs_check()
565 while (data_len--) { in bt_mesh_fcs_check()
625 return -EINVAL; in bt_mesh_prov_conf_salt()
643 return -EINVAL; in bt_mesh_prov_conf_key()
668 return -EINVAL; in bt_mesh_prov_conf()
672 uint8_t out[25]) in bt_mesh_prov_decrypt()
676 err = bt_mesh_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8); in bt_mesh_prov_decrypt()
682 uint8_t out[25 + 8]) in bt_mesh_prov_encrypt()
686 err = bt_mesh_ccm_encrypt(key, nonce, data, 25, NULL, 0, out, 8); in bt_mesh_prov_encrypt()
716 const uint8_t random[13], uint8_t out[5]) in private_beacon_obf()
733 out[i] = data[i] ^ salt[i]; in private_beacon_obf()
752 /* T0 = e(PBK, b0) */ in private_beacon_auth()
759 /* T1 = e(PBK, P ^ T0) */ in private_beacon_auth()
790 const uint8_t data[5], const uint8_t expected_auth[8], uint8_t out[5]) in bt_mesh_beacon_decrypt()
797 err = private_beacon_obf(pbk, data, random, out); in bt_mesh_beacon_decrypt()
802 err = private_beacon_auth(pbk, out, random, auth); in bt_mesh_beacon_decrypt()
807 LOG_DBG("0x%02x, 0x%08x", out[0], sys_get_be32(&out[1])); in bt_mesh_beacon_decrypt()
812 return -EBADMSG; in bt_mesh_beacon_decrypt()