Lines Matching defs:cose
240 dump_cose(cose_encrypt0_t *cose, const char *message) {
242 (void)cose;
250 cose_get_alg_name(cose->alg, buffer, sizeof(buffer)));
251 oscore_log_hex_value(COAP_LOG_OSCORE, "key", &cose->key);
252 oscore_log_hex_value(COAP_LOG_OSCORE, "partial_iv", &cose->partial_iv);
253 oscore_log_hex_value(COAP_LOG_OSCORE, "key_id", &cose->key_id);
254 oscore_log_hex_value(COAP_LOG_OSCORE, "kid_context", &cose->kid_context);
257 &cose->oscore_option);
258 oscore_log_hex_value(COAP_LOG_OSCORE, "nonce", &cose->nonce);
259 oscore_log_hex_value(COAP_LOG_OSCORE, "external_aad", &cose->external_aad);
260 oscore_log_hex_value(COAP_LOG_OSCORE, "aad", &cose->aad);
293 cose_encrypt0_t cose[1];
323 cose_encrypt0_init(cose); /* clears cose memory */
347 cose_encrypt0_set_partial_iv(cose, association->partial_iv);
348 cose_encrypt0_set_aad(cose, association->aad);
351 cose_encrypt0_set_alg(cose, osc_ctx->aead_alg);
368 cose_encrypt0_set_partial_iv(cose, &partial_iv);
372 cose_encrypt0_set_kid_context(cose, osc_ctx->id_context);
374 cose_encrypt0_set_key_id(cose, snd_ctx->sender_id);
391 oscore_generate_nonce(cose, osc_ctx, nonce_buffer, 13);
392 cose_encrypt0_set_nonce(cose, &nonce);
408 cose_encrypt0_set_nonce(cose, association->nonce);
413 /* cose is modified for encode option in response message */
416 cose_encrypt0_set_key_id(cose, NULL);
418 cose_encrypt0_set_partial_iv(cose, NULL);
421 cose_encrypt0_set_kid_context(cose, kid_context);
424 oscore_encode_option_value(oscore_option, sizeof(oscore_option), cose,
429 cose_encrypt0_set_key_id(cose, rcp_ctx->recipient_id);
430 cose_encrypt0_set_partial_iv(cose, association->partial_iv);
433 cose_encrypt0_set_kid_context(cose, osc_ctx->id_context);
440 * partial_iv (cose partial_iv)
441 * kid_context (cose kid_context)
442 * key_id (cose key_id)
447 * request_kid (request key_id using cose)
448 * request_piv (request partial_iv using cose)
455 * request_kid (request key_id using cose)
456 * request_piv (request partial_iv using cose)
470 cose,
476 cose_encrypt0_set_external_aad(cose, &external_aad);
485 cose_encrypt0_set_aad(cose, &aad);
586 cose_encrypt0_set_key(cose, snd_ctx->sender_key);
587 cose_encrypt0_set_plaintext(cose, plain_pdu->token, plain_pdu->used_size);
588 dump_cose(cose, "Pre encrypt");
593 ciphertext_len = cose_encrypt0_encrypt(cose,
659 coap_new_bin_const(cose->nonce.s, cose->nonce.length);
663 association->aad = coap_new_bin_const(cose->aad.s, cose->aad.length);
668 coap_new_bin_const(cose->partial_iv.s, cose->partial_iv.length);
691 &cose->aad,
692 &cose->nonce,
693 &cose->partial_iv,
779 cose_encrypt0_t cose[1];
826 cose_encrypt0_init(cose); /* clear cose memory */
894 if (oscore_decode_option_value(osc_value, osc_size, cose) == 0) {
906 cose->key_id,
907 &cose->kid_context,
911 if (cose->kid_context.length > 0) {
916 cose->key_id,
920 ptr = cose->kid_context.s;
921 length = cose->kid_context.length;
930 cose_encrypt0_set_kid_context(cose, (coap_bin_const_t *)&kid_context);
934 coap_bin_const_t *kc = coap_new_bin_const(cose->kid_context.s,
935 cose->kid_context.length);
949 &cose->key_id,
950 &cose->kid_context);
969 oscore_log_hex_value(COAP_LOG_OSCORE, "key_id", &cose->key_id);
970 oscore_log_hex_value(COAP_LOG_OSCORE, "kid_context", &cose->kid_context);
992 !oscore_validate_sender_seq(rcp_ctx, cose)) {
1005 coap_decode_var_bytes8(cose->partial_iv.s, cose->partial_iv.length);
1013 if (oscore_decode_option_value(osc_value, osc_size, cose) == 0) {
1028 const uint8_t *ptr = cose->kid_context.s;
1029 size_t length = cose->kid_context.length;
1037 cose_encrypt0_set_kid_context(cose, &kid_context);
1039 if (ptr && !coap_binary_equal(osc_ctx->id_context, &cose->kid_context)) {
1042 coap_binary_t *kc = coap_new_binary(cose->kid_context.length +
1052 memcpy(kc->s, cose->kid_context.s, cose->kid_context.length);
1053 memcpy(&kc->s[cose->kid_context.length],
1075 cose_encrypt0_set_alg(cose, osc_ctx->aead_alg);
1084 * request_kid (request key_id using cose)
1085 * request_piv (request partial_iv using cose)
1092 * request_kid (request key_id using cose)
1093 * request_piv (request partial_iv using cose)
1106 cose,
1112 cose_encrypt0_set_external_aad(cose, &external_aad);
1121 cose_encrypt0_set_aad(cose, &aad);
1134 oscore_generate_nonce(cose, osc_ctx, nonce_buffer, 13);
1135 cose_encrypt0_set_nonce(cose, &nonce);
1144 coap_new_bin_const(cose->nonce.s, cose->nonce.length);
1149 coap_new_bin_const(cose->partial_iv.s, cose->partial_iv.length);
1153 association->aad = coap_new_bin_const(cose->aad.s, cose->aad.length);
1161 &cose->aad,
1162 &cose->nonce,
1163 &cose->partial_iv,
1175 cose_encrypt0_set_key_id(cose, rcp_ctx->recipient_id);
1176 if (cose->partial_iv.length == 0) {
1177 cose_encrypt0_set_partial_iv(cose, association->partial_iv);
1178 cose_encrypt0_set_nonce(cose, association->nonce);
1183 !oscore_validate_sender_seq(rcp_ctx, cose)) {
1188 coap_decode_var_bytes8(cose->partial_iv.s, cose->partial_iv.length);
1201 oscore_generate_nonce(cose, osc_ctx, nonce_buffer, 13);
1204 cose_encrypt0_set_nonce(cose, &nonce);
1207 dump_cose(cose, "!req post set nonce");
1215 * request_kid (request key_id using cose)
1216 * request_piv (request partial_iv using cose)
1223 * request_kid (request key_id using cose)
1224 * request_piv (request partial_iv using cose)
1235 cose_encrypt0_set_key_id(cose, snd_ctx->sender_id);
1236 cose_encrypt0_set_partial_iv(cose, association->partial_iv);
1238 dump_cose(cose, "!req pre aad");
1242 cose,
1248 cose_encrypt0_set_external_aad(cose, &external_aad);
1257 cose_encrypt0_set_aad(cose, &aad);
1259 dump_cose(cose, "!req post set aad");
1284 cose_encrypt0_set_key(cose, rcp_ctx->recipient_key);
1285 cose_encrypt0_set_ciphertext(cose, st_encrypt, encrypt_len);
1287 tag_len = cose_tag_len(cose->alg);
1313 dump_cose(cose, "Pre decrypt");
1315 cose_encrypt0_decrypt(cose, plain_pdu->token, encrypt_len - tag_len);
1343 coap_new_binary(sizeof(session->oscore_r2) + cose->kid_context.length);
1357 cose->kid_context.s,
1358 cose->kid_context.length);
1398 coap_binary_t *kc = coap_new_binary(cose->kid_context.length + 8);
1407 memcpy(kc->s, cose->kid_context.s, cose->kid_context.length);
1408 coap_prng(&kc->s[cose->kid_context.length], 8);
1437 if (!oscore_validate_sender_seq(rcp_ctx, cose)) {
1491 bias = cose->partial_iv.length > 3 ? cose->partial_iv.length - 3 : 0;
1492 len = cose->partial_iv.length > 3 ? 3 : cose->partial_iv.length;
1498 cose->partial_iv.s ? &cose->partial_iv.s[bias] : NULL)) {
1784 /* Naming as per https://www.iana.org/assignments/cose/cose.xhtml#algorithms */