From f1443b420dd56fdbf58d65faa636cebc1f064083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20R=C3=B8nningstad?= Date: Wed, 10 Jan 2024 13:51:59 +0100 Subject: [PATCH] Adapt to changes in name generation in zcbor 0.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øyvind Rønningstad --- src/edhoc/cert.c | 38 ++++++++--------- src/edhoc/edhoc_cose.c | 30 +++++++------- src/edhoc/hkdf_info.c | 10 ++--- src/edhoc/initiator.c | 52 +++++++++++------------ src/edhoc/plaintext_decode.c | 78 +++++++++++++++++------------------ src/edhoc/plaintext_encode.c | 4 +- src/edhoc/responder.c | 58 +++++++++++++------------- src/edhoc/retrieve_cred.c | 32 +++++++------- src/edhoc/th.c | 18 ++++---- src/oscore/aad.c | 20 ++++----- src/oscore/oscore_cose.c | 12 +++--- src/oscore/oscore_hkdf_info.c | 26 ++++++------ 12 files changed, 189 insertions(+), 189 deletions(-) diff --git a/src/edhoc/cert.c b/src/edhoc/cert.c index 54b4ca06..fa266320 100644 --- a/src/edhoc/cert.c +++ b/src/edhoc/cert.c @@ -255,36 +255,36 @@ enum err cert_c509_verify(struct const_byte_array *cert, TRY_EXPECT(cbor_decode_cert(cert->ptr, cert->len, &c, &decode_len), 0); PRINT_MSG("CBOR certificate parsed.\n"); - PRINTF("Certificate type: %d\n", c._cert_type); - PRINT_ARRAY("issuer", c._cert_issuer.value, - (uint32_t)c._cert_issuer.len); - PRINTF("validity_not_before: %d\n", c._cert_validity_not_before); - PRINTF("validity_not_after: %d\n", c._cert_validity_not_after); - PRINT_ARRAY("subject", c._cert_subject.value, - (uint32_t)c._cert_subject.len); - PRINT_ARRAY("PK", c._cert_pk.value, (uint32_t)c._cert_pk.len); - PRINTF("extensions: %d\n", c._cert_extensions); + PRINTF("Certificate type: %d\n", c.cert_type); + PRINT_ARRAY("issuer", c.cert_issuer.value, + (uint32_t)c.cert_issuer.len); + PRINTF("validity_not_before: %d\n", c.cert_validity_not_before); + PRINTF("validity_not_after: %d\n", c.cert_validity_not_after); + PRINT_ARRAY("subject", c.cert_subject.value, + (uint32_t)c.cert_subject.len); + PRINT_ARRAY("PK", c.cert_pk.value, (uint32_t)c.cert_pk.len); + PRINTF("extensions: %d\n", c.cert_extensions); PRINTF("issuer_signature_algorithm: %d\n", - c._cert_issuer_signature_algorithm); - PRINT_ARRAY("Signature", c._cert_signature.value, - (uint32_t)c._cert_signature.len); + c.cert_issuer_signature_algorithm); + PRINT_ARRAY("Signature", c.cert_signature.value, + (uint32_t)c.cert_signature.len); /*get the CA's public key*/ struct byte_array root_pk; - TRY(ca_pk_get(cred_array, c._cert_issuer.value, &root_pk)); + TRY(ca_pk_get(cred_array, c.cert_issuer.value, &root_pk)); /*verify the certificates signature*/ struct const_byte_array m = BYTE_ARRAY_INIT( - cert->ptr, cert->len - 2 - (uint32_t)c._cert_signature.len); + cert->ptr, cert->len - 2 - (uint32_t)c.cert_signature.len); struct const_byte_array sgn = BYTE_ARRAY_INIT( - c._cert_signature.value, (uint32_t)c._cert_signature.len); + c.cert_signature.value, (uint32_t)c.cert_signature.len); - TRY(verify((enum sign_alg)c._cert_issuer_signature_algorithm, &root_pk, + TRY(verify((enum sign_alg)c.cert_issuer_signature_algorithm, &root_pk, &m, &sgn, verified)); - TRY(_memcpy_s(pk->ptr, pk->len, c._cert_pk.value, - (uint32_t)c._cert_pk.len)); - pk->len = (uint32_t)c._cert_pk.len; + TRY(_memcpy_s(pk->ptr, pk->len, c.cert_pk.value, + (uint32_t)c.cert_pk.len)); + pk->len = (uint32_t)c.cert_pk.len; return ok; } diff --git a/src/edhoc/edhoc_cose.c b/src/edhoc/edhoc_cose.c index dff00f68..674abea1 100644 --- a/src/edhoc/edhoc_cose.c +++ b/src/edhoc/edhoc_cose.c @@ -25,11 +25,11 @@ enum err cose_enc_structure_encode(const struct byte_array *context, { struct edhoc_enc_structure enc_structure; - enc_structure._edhoc_enc_structure_context.value = context->ptr; - enc_structure._edhoc_enc_structure_context.len = context->len; - enc_structure._edhoc_enc_structure_external_aad.value = + enc_structure.edhoc_enc_structure_context.value = context->ptr; + enc_structure.edhoc_enc_structure_context.len = context->len; + enc_structure.edhoc_enc_structure_external_aad.value = external_aad->ptr; - enc_structure._edhoc_enc_structure_external_aad.len = external_aad->len; + enc_structure.edhoc_enc_structure_external_aad.len = external_aad->len; /* NULL protected with zero size is acceptable from EDHOC point of view, * but CBOR encoder does not accept NULL as input argument. @@ -44,15 +44,15 @@ enum err cose_enc_structure_encode(const struct byte_array *context, if (0 != protected->len) { return wrong_parameter; } else { - enc_structure._edhoc_enc_structure_protected.value = + enc_structure.edhoc_enc_structure_protected.value = (const uint8_t *)&dummy_buffer; } } else { - enc_structure._edhoc_enc_structure_protected.value = + enc_structure.edhoc_enc_structure_protected.value = protected->ptr; } - enc_structure._edhoc_enc_structure_protected.len = protected->len; + enc_structure.edhoc_enc_structure_protected.len = protected->len; size_t payload_len_out; TRY_EXPECT(cbor_encode_edhoc_enc_structure(out->ptr, out->len, @@ -71,14 +71,14 @@ enum err cose_sig_structure_encode(const struct byte_array *context, { struct sig_structure sig_structure; - sig_structure._sig_structure_context.value = context->ptr; - sig_structure._sig_structure_context.len = context->len; - sig_structure._sig_structure_protected.value = protected->ptr; - sig_structure._sig_structure_protected.len = protected->len; - sig_structure._sig_structure_external_aad.value = external_aad->ptr; - sig_structure._sig_structure_external_aad.len = external_aad->len; - sig_structure._sig_structure_payload.value = payload->ptr; - sig_structure._sig_structure_payload.len = payload->len; + sig_structure.sig_structure_context.value = context->ptr; + sig_structure.sig_structure_context.len = context->len; + sig_structure.sig_structure_protected.value = protected->ptr; + sig_structure.sig_structure_protected.len = protected->len; + sig_structure.sig_structure_external_aad.value = external_aad->ptr; + sig_structure.sig_structure_external_aad.len = external_aad->len; + sig_structure.sig_structure_payload.value = payload->ptr; + sig_structure.sig_structure_payload.len = payload->len; size_t payload_len_out; TRY_EXPECT(cbor_encode_sig_structure(out->ptr, out->len, &sig_structure, diff --git a/src/edhoc/hkdf_info.c b/src/edhoc/hkdf_info.c index 049c3ab0..fadbe339 100644 --- a/src/edhoc/hkdf_info.c +++ b/src/edhoc/hkdf_info.c @@ -24,7 +24,7 @@ enum err create_hkdf_info(uint8_t label, struct byte_array *context, { struct info info; - info._info_label = label; + info.info_label = label; /* NULL context with zero size is acceptable from EDHOC point of view, * but CBOR encoder does not accept NULL as input argument. @@ -39,16 +39,16 @@ enum err create_hkdf_info(uint8_t label, struct byte_array *context, if (0 != context->len) { return wrong_parameter; } else { - info._info_context.value = + info.info_context.value = (const uint8_t *)&dummy_buffer; } } else { - info._info_context.value = context->ptr; + info.info_context.value = context->ptr; } - info._info_context.len = context->len; + info.info_context.len = context->len; - info._info_length = okm_len; + info.info_length = okm_len; size_t payload_len_out = 0; TRY_EXPECT(cbor_encode_info(out->ptr, out->len, &info, diff --git a/src/edhoc/initiator.c b/src/edhoc/initiator.c index d47f0144..64a882d8 100644 --- a/src/edhoc/initiator.c +++ b/src/edhoc/initiator.c @@ -55,23 +55,23 @@ static inline enum err msg2_parse(struct byte_array *msg2, struct m2 m; TRY_EXPECT(cbor_decode_m2(msg2->ptr, msg2->len, &m, &decode_len), 0); - TRY(_memcpy_s(g_y->ptr, g_y->len, m._m2_G_Y_CIPHERTEXT_2.value, + TRY(_memcpy_s(g_y->ptr, g_y->len, m.m2_G_Y_CIPHERTEXT_2.value, g_y->len)); PRINT_ARRAY("g_y", g_y->ptr, g_y->len); TRY(_memcpy_s(ciphertext2->ptr, ciphertext2->len, - m._m2_G_Y_CIPHERTEXT_2.value + g_y->len, - (uint32_t)(m._m2_G_Y_CIPHERTEXT_2.len - g_y->len))); + m.m2_G_Y_CIPHERTEXT_2.value + g_y->len, + (uint32_t)(m.m2_G_Y_CIPHERTEXT_2.len - g_y->len))); - ciphertext2->len = (uint32_t)m._m2_G_Y_CIPHERTEXT_2.len - g_y->len; + ciphertext2->len = (uint32_t)m.m2_G_Y_CIPHERTEXT_2.len - g_y->len; PRINT_ARRAY("ciphertext2", ciphertext2->ptr, ciphertext2->len); - if (m._m2_C_R_choice == _m2_C_R_int) { - TRY(encode_int(&m._m2_C_R_int, 1, c_r)); + if (m.m2_C_R_choice == m2_C_R_int_c) { + TRY(encode_int(&m.m2_C_R_int, 1, c_r)); } else { - TRY(_memcpy_s(c_r->ptr, c_r->len, m._m2_C_R_bstr.value, - (uint32_t)m._m2_C_R_bstr.len)); - c_r->len = (uint32_t)m._m2_C_R_bstr.len; + TRY(_memcpy_s(c_r->ptr, c_r->len, m.m2_C_R_bstr.value, + (uint32_t)m.m2_C_R_bstr.len)); + c_r->len = (uint32_t)m.m2_C_R_bstr.len; } PRINT_ARRAY("C_R_raw", c_r->ptr, c_r->len); @@ -84,46 +84,46 @@ enum err msg1_gen(const struct edhoc_initiator_context *c, struct message_1 m1; /*METHOD_CORR*/ - m1._message_1_METHOD = (int32_t)c->method; + m1.message_1_METHOD = (int32_t)c->method; /*SUITES_I*/ if (c->suites_i.len == 1) { /* only one suite, encode into int */ - m1._message_1_SUITES_I_choice = _message_1_SUITES_I_int; - m1._message_1_SUITES_I_int = c->suites_i.ptr[0]; + m1.message_1_SUITES_I_choice = message_1_SUITES_I_int_c; + m1.message_1_SUITES_I_int = c->suites_i.ptr[0]; } else if (c->suites_i.len > 1) { /* more than one suites, encode into array */ - m1._message_1_SUITES_I_choice = _SUITES_I__suite; - m1._SUITES_I__suite_suite_count = c->suites_i.len; + m1.message_1_SUITES_I_choice = SUITES_I_suite_l_c; + m1.SUITES_I_suite_l_suite_count = c->suites_i.len; for (uint32_t i = 0; i < c->suites_i.len; i++) { - m1._SUITES_I__suite_suite[i] = c->suites_i.ptr[i]; + m1.SUITES_I_suite_l_suite[i] = c->suites_i.ptr[i]; } } /* G_X ephemeral public key */ - m1._message_1_G_X.value = c->g_x.ptr; - m1._message_1_G_X.len = c->g_x.len; + m1.message_1_G_X.value = c->g_x.ptr; + m1.message_1_G_X.len = c->g_x.len; /* C_I connection ID of the initiator*/ PRINT_ARRAY("C_I", c->c_i.ptr, c->c_i.len); if (c->c_i.len == 1 && ((0x00 <= c->c_i.ptr[0] && c->c_i.ptr[0] < 0x18) || (0x1F < c->c_i.ptr[0] && c->c_i.ptr[0] <= 0x37))) { - m1._message_1_C_I_choice = _message_1_C_I_int; - TRY(decode_int(&c->c_i, &m1._message_1_C_I_int)); + m1.message_1_C_I_choice = message_1_C_I_int_c; + TRY(decode_int(&c->c_i, &m1.message_1_C_I_int)); } else { - m1._message_1_C_I_choice = _message_1_C_I_bstr; - m1._message_1_C_I_bstr.value = c->c_i.ptr; - m1._message_1_C_I_bstr.len = c->c_i.len; + m1.message_1_C_I_choice = message_1_C_I_bstr_c; + m1.message_1_C_I_bstr.value = c->c_i.ptr; + m1.message_1_C_I_bstr.len = c->c_i.len; } if (c->ead_1.len != 0) { /* ead_1 unprotected opaque auxiliary data */ - m1._message_1_ead_1.value = c->ead_1.ptr; - m1._message_1_ead_1.len = c->ead_1.len; - m1._message_1_ead_1_present = true; + m1.message_1_ead_1.value = c->ead_1.ptr; + m1.message_1_ead_1.len = c->ead_1.len; + m1.message_1_ead_1_present = true; } else { - m1._message_1_ead_1_present = false; + m1.message_1_ead_1_present = false; } size_t payload_len_out; diff --git a/src/edhoc/plaintext_decode.c b/src/edhoc/plaintext_decode.c index 34f50a18..ac5b8081 100644 --- a/src/edhoc/plaintext_decode.c +++ b/src/edhoc/plaintext_decode.c @@ -44,24 +44,24 @@ static enum err id_cred_x_encode(enum id_cred_x_label label, int algo, switch (label) { case kid: //todo update that to v15 - map._id_cred_x_map_kid_present = true; - map._id_cred_x_map_kid._id_cred_x_map_kid_choice = - _id_cred_x_map_kid_int; - map._id_cred_x_map_kid._id_cred_x_map_kid_int = + map.id_cred_x_map_kid_present = true; + map.id_cred_x_map_kid.id_cred_x_map_kid_choice = + id_cred_x_map_kid_int_c; + map.id_cred_x_map_kid.id_cred_x_map_kid_int = *((const int32_t *)id); break; case x5chain: - map._id_cred_x_map_x5chain_present = true; - map._id_cred_x_map_x5chain._id_cred_x_map_x5chain.value = id; - map._id_cred_x_map_x5chain._id_cred_x_map_x5chain.len = id_len; + map.id_cred_x_map_x5chain_present = true; + map.id_cred_x_map_x5chain.id_cred_x_map_x5chain.value = id; + map.id_cred_x_map_x5chain.id_cred_x_map_x5chain.len = id_len; break; case x5t: - map._id_cred_x_map_x5t_present = true; - map._id_cred_x_map_x5t._id_cred_x_map_x5t_alg_choice = - _id_cred_x_map_x5t_alg_int; - map._id_cred_x_map_x5t._id_cred_x_map_x5t_alg_int = algo; - map._id_cred_x_map_x5t._id_cred_x_map_x5t_hash.value = id; - map._id_cred_x_map_x5t._id_cred_x_map_x5t_hash.len = id_len; + map.id_cred_x_map_x5t_present = true; + map.id_cred_x_map_x5t.id_cred_x_map_x5t_alg_choice = + id_cred_x_map_x5t_alg_int_c; + map.id_cred_x_map_x5t.id_cred_x_map_x5t_alg_int = algo; + map.id_cred_x_map_x5t.id_cred_x_map_x5t_hash.value = id; + map.id_cred_x_map_x5t.id_cred_x_map_x5t_hash.len = id_len; break; default: break; @@ -86,55 +86,55 @@ enum err plaintext_split(struct byte_array *ptxt, struct byte_array *id_cred_x, 0); /*ID_CRED_x*/ - if (p._plaintext_ID_CRED_x_choice == _plaintext_ID_CRED_x__map) { - if (p._plaintext_ID_CRED_x__map._map_x5chain_present) { + if (p.plaintext_ID_CRED_x_choice == plaintext_ID_CRED_x_map_m_c) { + if (p.plaintext_ID_CRED_x_map_m.map_x5chain_present) { PRINT_MSG( "ID_CRED of the other party has label x5chain\n"); TRY(id_cred_x_encode( x5chain, 0, - p._plaintext_ID_CRED_x__map._map_x5chain - ._map_x5chain.value, - (uint32_t)p._plaintext_ID_CRED_x__map - ._map_x5chain._map_x5chain.len, + p.plaintext_ID_CRED_x_map_m.map_x5chain + .map_x5chain.value, + (uint32_t)p.plaintext_ID_CRED_x_map_m + .map_x5chain.map_x5chain.len, id_cred_x)); } - if (p._plaintext_ID_CRED_x__map._map_x5t_present) { + if (p.plaintext_ID_CRED_x_map_m.map_x5t_present) { PRINT_MSG("ID_CRED of the other party has label x5t\n"); TRY(id_cred_x_encode( x5t, - p._plaintext_ID_CRED_x__map._map_x5t - ._map_x5t_alg_int, - p._plaintext_ID_CRED_x__map._map_x5t - ._map_x5t_hash.value, - (uint32_t)p._plaintext_ID_CRED_x__map._map_x5t - ._map_x5t_hash.len, + p.plaintext_ID_CRED_x_map_m.map_x5t + .map_x5t_alg_int, + p.plaintext_ID_CRED_x_map_m.map_x5t + .map_x5t_hash.value, + (uint32_t)p.plaintext_ID_CRED_x_map_m.map_x5t + .map_x5t_hash.len, id_cred_x)); } } else { /*Note that if ID_CRED_x contains a single 'kid' parameter, i.e., ID_CRED_R = { 4 : kid_x }, only the byte string kid_x is conveyed in the plaintext encoded as a bstr or int*/ - if (p._plaintext_ID_CRED_x_choice == - _plaintext_ID_CRED_x__map) { + if (p.plaintext_ID_CRED_x_choice == + plaintext_ID_CRED_x_map_m_c) { TRY(id_cred_x_encode( - kid, 0, p._plaintext_ID_CRED_x_bstr.value, - (uint32_t)p._plaintext_ID_CRED_x_bstr.len, + kid, 0, p.plaintext_ID_CRED_x_bstr.value, + (uint32_t)p.plaintext_ID_CRED_x_bstr.len, id_cred_x)); } else { - int _kid = p._plaintext_ID_CRED_x_int; + int _kid = p.plaintext_ID_CRED_x_int; TRY(id_cred_x_encode(kid, 0, &_kid, 1, id_cred_x)); } } TRY(_memcpy_s(sign_or_mac->ptr, sign_or_mac->len, - p._plaintext_SGN_or_MAC_x.value, - (uint32_t)p._plaintext_SGN_or_MAC_x.len)); - sign_or_mac->len = (uint32_t)p._plaintext_SGN_or_MAC_x.len; - - if (p._plaintext_AD_x_present == true) { - TRY(_memcpy_s(ad->ptr, ad->len, p._plaintext_AD_x.value, - (uint32_t)p._plaintext_AD_x.len)); - ad->len = (uint32_t)p._plaintext_AD_x.len; + p.plaintext_SGN_or_MAC_x.value, + (uint32_t)p.plaintext_SGN_or_MAC_x.len)); + sign_or_mac->len = (uint32_t)p.plaintext_SGN_or_MAC_x.len; + + if (p.plaintext_AD_x_present == true) { + TRY(_memcpy_s(ad->ptr, ad->len, p.plaintext_AD_x.value, + (uint32_t)p.plaintext_AD_x.len)); + ad->len = (uint32_t)p.plaintext_AD_x.len; } else { if (ad->len) { ad->len = 0; diff --git a/src/edhoc/plaintext_encode.c b/src/edhoc/plaintext_encode.c index 8993210f..511ddbaa 100644 --- a/src/edhoc/plaintext_encode.c +++ b/src/edhoc/plaintext_encode.c @@ -32,11 +32,11 @@ enum err id_cred2kid(const struct byte_array *id_cred, struct byte_array *kid) &decode_len), 0); - if (map._id_cred_x_map_kid_present) { + if (map.id_cred_x_map_kid_present) { TRY_EXPECT( cbor_encode_int_type_i( kid->ptr, kid->len, - &map._id_cred_x_map_kid._id_cred_x_map_kid_int, + &map.id_cred_x_map_kid.id_cred_x_map_kid_int, &payload_len_out), ZCBOR_SUCCESS); kid->len = (uint32_t)payload_len_out; diff --git a/src/edhoc/responder.c b/src/edhoc/responder.c index 3377b924..b5855a81 100644 --- a/src/edhoc/responder.c +++ b/src/edhoc/responder.c @@ -65,57 +65,57 @@ msg1_parse(struct byte_array *msg1, enum method_type *method, 0); /*METHOD*/ - if ((m._message_1_METHOD > INITIATOR_SDHK_RESPONDER_SDHK) || - (m._message_1_METHOD < INITIATOR_SK_RESPONDER_SK)) { + if ((m.message_1_METHOD > INITIATOR_SDHK_RESPONDER_SDHK) || + (m.message_1_METHOD < INITIATOR_SK_RESPONDER_SK)) { return wrong_parameter; } - *method = (enum method_type)m._message_1_METHOD; + *method = (enum method_type)m.message_1_METHOD; PRINTF("msg1 METHOD: %d\n", (int)*method); /*SUITES_I*/ - if (m._message_1_SUITES_I_choice == _message_1_SUITES_I_int) { + if (m.message_1_SUITES_I_choice == message_1_SUITES_I_int_c) { /*the initiator supports only one suite*/ - suites_i->ptr[0] = (uint8_t)m._message_1_SUITES_I_int; + suites_i->ptr[0] = (uint8_t)m.message_1_SUITES_I_int; suites_i->len = 1; } else { - if (0 == m._SUITES_I__suite_suite_count) { + if (0 == m.SUITES_I_suite_l_suite_count) { return suites_i_list_empty; } /*the initiator supports more than one suite*/ - if (m._SUITES_I__suite_suite_count > suites_i->len) { + if (m.SUITES_I_suite_l_suite_count > suites_i->len) { return suites_i_list_to_long; } - for (i = 0; i < m._SUITES_I__suite_suite_count; i++) { - suites_i->ptr[i] = (uint8_t)m._SUITES_I__suite_suite[i]; + for (i = 0; i < m.SUITES_I_suite_l_suite_count; i++) { + suites_i->ptr[i] = (uint8_t)m.SUITES_I_suite_l_suite[i]; } - suites_i->len = (uint32_t)m._SUITES_I__suite_suite_count; + suites_i->len = (uint32_t)m.SUITES_I_suite_l_suite_count; } PRINT_ARRAY("msg1 SUITES_I", suites_i->ptr, suites_i->len); /*G_X*/ - TRY(_memcpy_s(g_x->ptr, g_x->len, m._message_1_G_X.value, - (uint32_t)m._message_1_G_X.len)); - g_x->len = (uint32_t)m._message_1_G_X.len; + TRY(_memcpy_s(g_x->ptr, g_x->len, m.message_1_G_X.value, + (uint32_t)m.message_1_G_X.len)); + g_x->len = (uint32_t)m.message_1_G_X.len; PRINT_ARRAY("msg1 G_X", g_x->ptr, g_x->len); /*C_I*/ - if (m._message_1_C_I_choice == _message_1_C_I_int) { - c_i->ptr[0] = (uint8_t)m._message_1_C_I_int; + if (m.message_1_C_I_choice == message_1_C_I_int_c) { + c_i->ptr[0] = (uint8_t)m.message_1_C_I_int; c_i->len = 1; } else { - TRY(_memcpy_s(c_i->ptr, c_i->len, m._message_1_C_I_bstr.value, - (uint32_t)m._message_1_C_I_bstr.len)); - c_i->len = (uint32_t)m._message_1_C_I_bstr.len; + TRY(_memcpy_s(c_i->ptr, c_i->len, m.message_1_C_I_bstr.value, + (uint32_t)m.message_1_C_I_bstr.len)); + c_i->len = (uint32_t)m.message_1_C_I_bstr.len; } PRINT_ARRAY("msg1 C_I_raw", c_i->ptr, c_i->len); /*ead_1*/ - if (m._message_1_ead_1_present) { - TRY(_memcpy_s(ead1->ptr, ead1->len, m._message_1_ead_1.value, - (uint32_t)m._message_1_ead_1.len)); - ead1->len = (uint32_t)m._message_1_ead_1.len; + if (m.message_1_ead_1_present) { + TRY(_memcpy_s(ead1->ptr, ead1->len, m.message_1_ead_1.value, + (uint32_t)m.message_1_ead_1.len)); + ead1->len = (uint32_t)m.message_1_ead_1.len; PRINT_ARRAY("msg1 ead_1", ead1->ptr, ead1->len); } return ok; @@ -165,19 +165,19 @@ static inline enum err msg2_encode(const struct byte_array *g_y, ciphertext_2->len); /*Encode g_y_ciphertext_2*/ - m._m2_G_Y_CIPHERTEXT_2.value = g_y_ciphertext_2.ptr; - m._m2_G_Y_CIPHERTEXT_2.len = g_y_ciphertext_2.len; + m.m2_G_Y_CIPHERTEXT_2.value = g_y_ciphertext_2.ptr; + m.m2_G_Y_CIPHERTEXT_2.len = g_y_ciphertext_2.len; /*Encode C_R*/ PRINT_ARRAY("C_R", c_r->ptr, c_r->len); if (c_r->len == 1 && (c_r->ptr[0] < 0x18 || (0x1F < c_r->ptr[0] && c_r->ptr[0] <= 0x37))) { - m._m2_C_R_choice = _m2_C_R_int; - TRY(decode_int(c_r, &m._m2_C_R_int)); + m.m2_C_R_choice = m2_C_R_int_c; + TRY(decode_int(c_r, &m.m2_C_R_int)); } else { - m._m2_C_R_choice = _m2_C_R_bstr; - m._m2_C_R_bstr.value = c_r->ptr; - m._m2_C_R_bstr.len = c_r->len; + m.m2_C_R_choice = m2_C_R_bstr_c; + m.m2_C_R_bstr.value = c_r->ptr; + m.m2_C_R_bstr.len = c_r->len; } TRY_EXPECT(cbor_encode_m2(msg2->ptr, msg2->len, &m, &payload_len_out), diff --git a/src/edhoc/retrieve_cred.c b/src/edhoc/retrieve_cred.c index 1bd82463..ddb72bef 100644 --- a/src/edhoc/retrieve_cred.c +++ b/src/edhoc/retrieve_cred.c @@ -156,48 +156,48 @@ enum err retrieve_cred(bool static_dh_auth, struct cred_array *cred_array, 0); /*the cred should be locally available on the device if kid, x5u, x5t, c5u, c5t is used*/ - if (map._id_cred_x_map_kid_present || map._id_cred_x_map_x5u_present || - map._id_cred_x_map_x5t_present || map._id_cred_x_map_c5u_present || - map._id_cred_x_map_c5t_present) { + if (map.id_cred_x_map_kid_present || map.id_cred_x_map_x5u_present || + map.id_cred_x_map_x5t_present || map.id_cred_x_map_c5u_present || + map.id_cred_x_map_c5t_present) { TRY(get_local_cred(static_dh_auth, cred_array, id_cred, cred, pk, g)); return ok; } /*x5chain*/ - else if (map._id_cred_x_map_x5chain_present) { + else if (map.id_cred_x_map_x5chain_present) { struct const_byte_array cert = BYTE_ARRAY_INIT( - map._id_cred_x_map_x5chain._id_cred_x_map_x5chain.value, - (uint32_t)map._id_cred_x_map_x5chain - ._id_cred_x_map_x5chain.len); + map.id_cred_x_map_x5chain.id_cred_x_map_x5chain.value, + (uint32_t)map.id_cred_x_map_x5chain + .id_cred_x_map_x5chain.len); TRY(verify_cert2cred(static_dh_auth, cred_array, x5chain, &cert, cred, pk, g)); return ok; } /*x5bag*/ - else if (map._id_cred_x_map_x5bag_present) { + else if (map.id_cred_x_map_x5bag_present) { struct const_byte_array cert = BYTE_ARRAY_INIT( - map._id_cred_x_map_x5bag._id_cred_x_map_x5bag.value, - (uint32_t)map._id_cred_x_map_x5bag._id_cred_x_map_x5bag + map.id_cred_x_map_x5bag.id_cred_x_map_x5bag.value, + (uint32_t)map.id_cred_x_map_x5bag.id_cred_x_map_x5bag .len); TRY(verify_cert2cred(static_dh_auth, cred_array, x5bag, &cert, cred, pk, g)); return ok; } /*c5c*/ - else if (map._id_cred_x_map_c5c_present) { + else if (map.id_cred_x_map_c5c_present) { struct const_byte_array cert = BYTE_ARRAY_INIT( - map._id_cred_x_map_c5c._id_cred_x_map_c5c.value, - (uint32_t)map._id_cred_x_map_c5c._id_cred_x_map_c5c.len); + map.id_cred_x_map_c5c.id_cred_x_map_c5c.value, + (uint32_t)map.id_cred_x_map_c5c.id_cred_x_map_c5c.len); TRY(verify_cert2cred(static_dh_auth, cred_array, c5c, &cert, cred, pk, g)); return ok; } /*c5b*/ - else if (map._id_cred_x_map_c5b_present) { + else if (map.id_cred_x_map_c5b_present) { struct const_byte_array cert = BYTE_ARRAY_INIT( - map._id_cred_x_map_c5b._id_cred_x_map_c5b.value, - (uint32_t)map._id_cred_x_map_c5b._id_cred_x_map_c5b.len); + map.id_cred_x_map_c5b.id_cred_x_map_c5b.value, + (uint32_t)map.id_cred_x_map_c5b.id_cred_x_map_c5b.len); TRY(verify_cert2cred(static_dh_auth, cred_array, c5b, &cert, cred, pk, g)); return ok; diff --git a/src/edhoc/th.c b/src/edhoc/th.c index e7419ae0..f0baa447 100644 --- a/src/edhoc/th.c +++ b/src/edhoc/th.c @@ -42,22 +42,22 @@ static inline enum err th2_input_encode(struct byte_array *hash_msg1, struct th2 th2; /*Encode hash_msg1*/ - th2._th2_hash_msg1.value = hash_msg1->ptr; - th2._th2_hash_msg1.len = hash_msg1->len; + th2.th2_hash_msg1.value = hash_msg1->ptr; + th2.th2_hash_msg1.len = hash_msg1->len; /*Encode G_Y*/ - th2._th2_G_Y.value = g_y->ptr; - th2._th2_G_Y.len = g_y->len; + th2.th2_G_Y.value = g_y->ptr; + th2.th2_G_Y.len = g_y->len; /*Encode C_R as int or byte*/ if (c_r->len == 1 && (c_r->ptr[0] < 0x18 || (0x1F < c_r->ptr[0] && c_r->ptr[0] <= 0x37))) { - th2._th2_C_R_choice = _th2_C_R_int; - TRY(decode_int(c_r, &th2._th2_C_R_int)); + th2.th2_C_R_choice = th2_C_R_int_c; + TRY(decode_int(c_r, &th2.th2_C_R_int)); } else { - th2._th2_C_R_choice = _th2_C_R_bstr; - th2._th2_C_R_bstr.value = c_r->ptr; - th2._th2_C_R_bstr.len = c_r->len; + th2.th2_C_R_choice = th2_C_R_bstr_c; + th2.th2_C_R_bstr.value = c_r->ptr; + th2.th2_C_R_bstr.len = c_r->len; } TRY_EXPECT(cbor_encode_th2(th2_input->ptr, th2_input->len, &th2, &payload_len_out), diff --git a/src/oscore/aad.c b/src/oscore/aad.c index e3008f09..fff1c686 100644 --- a/src/oscore/aad.c +++ b/src/oscore/aad.c @@ -26,14 +26,14 @@ enum err create_aad(struct o_coap_option *options, uint16_t opt_num, { struct aad_array aad_array; - aad_array._aad_array_oscore_version = 1; - aad_array._aad_array_algorithms_alg_aead_choice = - _aad_array_algorithms_alg_aead_int; - aad_array._aad_array_algorithms_alg_aead_int = (int32_t)aead_alg; - aad_array._aad_array_request_kid.value = kid->ptr; - aad_array._aad_array_request_kid.len = kid->len; - aad_array._aad_array_request_piv.value = piv->ptr; - aad_array._aad_array_request_piv.len = piv->len; + aad_array.aad_array_oscore_version = 1; + aad_array.aad_array_algorithms_alg_aead_choice = + aad_array_algorithms_alg_aead_int_c; + aad_array.aad_array_algorithms_alg_aead_int = (int32_t)aead_alg; + aad_array.aad_array_request_kid.value = kid->ptr; + aad_array.aad_array_request_kid.len = kid->len; + aad_array.aad_array_request_piv.value = piv->ptr; + aad_array.aad_array_request_piv.len = piv->len; PRINT_ARRAY("request_piv", piv->ptr, piv->len); PRINT_ARRAY("request_kid", kid->ptr, kid->len); @@ -43,8 +43,8 @@ enum err create_aad(struct o_coap_option *options, uint16_t opt_num, * If at some later time I options are defined this implementation * must be extended here. */ - aad_array._aad_array_options.len = 0; - aad_array._aad_array_options.value = NULL; + aad_array.aad_array_options.len = 0; + aad_array.aad_array_options.value = NULL; size_t payload_len_out; TRY_EXPECT(cbor_encode_aad_array(out->ptr, out->len, &aad_array, diff --git a/src/oscore/oscore_cose.c b/src/oscore/oscore_cose.c index cbaa313b..98aa21c0 100644 --- a/src/oscore/oscore_cose.c +++ b/src/oscore/oscore_cose.c @@ -37,14 +37,14 @@ static enum err create_enc_structure(struct byte_array *external_aad, struct oscore_enc_structure enc_structure; uint8_t context[] = { "Encrypt0" }; - enc_structure._oscore_enc_structure_context.value = context; - enc_structure._oscore_enc_structure_context.len = + enc_structure.oscore_enc_structure_context.value = context; + enc_structure.oscore_enc_structure_context.len = (uint32_t)strlen((char *)context); - enc_structure._oscore_enc_structure_protected.value = NULL; - enc_structure._oscore_enc_structure_protected.len = 0; - enc_structure._oscore_enc_structure_external_aad.value = + enc_structure.oscore_enc_structure_protected.value = NULL; + enc_structure.oscore_enc_structure_protected.len = 0; + enc_structure.oscore_enc_structure_external_aad.value = external_aad->ptr; - enc_structure._oscore_enc_structure_external_aad.len = + enc_structure.oscore_enc_structure_external_aad.len = external_aad->len; size_t payload_len_out = 0; diff --git a/src/oscore/oscore_hkdf_info.c b/src/oscore/oscore_hkdf_info.c index 24cbe29b..e29847ae 100644 --- a/src/oscore/oscore_hkdf_info.c +++ b/src/oscore/oscore_hkdf_info.c @@ -57,25 +57,25 @@ enum err oscore_create_hkdf_info(struct byte_array *id, break; } - info_struct._oscore_info_id.value = id->ptr; - info_struct._oscore_info_id.len = id->len; + info_struct.oscore_info_id.value = id->ptr; + info_struct.oscore_info_id.len = id->len; if (id_context->len == 0) { - info_struct._oscore_info_id_context_choice = - _oscore_info_id_context_nil; + info_struct.oscore_info_id_context_choice = + oscore_info_id_context_nil_c; } else { - info_struct._oscore_info_id_context_choice = - _oscore_info_id_context_bstr; - info_struct._oscore_info_id_context_bstr.value = + info_struct.oscore_info_id_context_choice = + oscore_info_id_context_bstr_c; + info_struct.oscore_info_id_context_bstr.value = id_context->ptr; - info_struct._oscore_info_id_context_bstr.len = id_context->len; + info_struct.oscore_info_id_context_bstr.len = id_context->len; } - info_struct._oscore_info_alg_aead_choice = _oscore_info_alg_aead_int; - info_struct._oscore_info_alg_aead_int = (int32_t)aead_alg; + info_struct.oscore_info_alg_aead_choice = oscore_info_alg_aead_int_c; + info_struct.oscore_info_alg_aead_int = (int32_t)aead_alg; - info_struct._oscore_info_type.value = (uint8_t *)type_enc; - info_struct._oscore_info_type.len = (uint32_t)strlen(type_enc); - info_struct._oscore_info_L = len; + info_struct.oscore_info_type.value = (uint8_t *)type_enc; + info_struct.oscore_info_type.len = (uint32_t)strlen(type_enc); + info_struct.oscore_info_L = len; size_t payload_len_out;