edhoc 1.0.5 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/crypto.d.ts +9 -2
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +112 -84
- package/dist/edhoc.d.ts +31 -9
- package/dist/edhoc.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/dist/credentials.d.ts +0 -16
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js +0 -84
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* \file edhoc_message_4.c
|
|
3
3
|
* \author Kamil Kielbasa
|
|
4
4
|
* \brief EDHOC message 4 compose & process.
|
|
5
|
-
* \version 0.
|
|
6
|
-
* \date 2024-
|
|
5
|
+
* \version 0.6
|
|
6
|
+
* \date 2024-08-05
|
|
7
7
|
*
|
|
8
8
|
* \copyright Copyright (c) 2024
|
|
9
9
|
*
|
|
@@ -286,32 +286,30 @@ static int prepare_plaintext_4(const struct edhoc_context *ctx, uint8_t *ptxt,
|
|
|
286
286
|
|
|
287
287
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
288
288
|
|
|
289
|
-
struct
|
|
289
|
+
struct plaintext_4 ead_4 = { .plaintext_4_present = false };
|
|
290
290
|
|
|
291
|
-
if (ARRAY_SIZE(ead_4.
|
|
291
|
+
if (ARRAY_SIZE(ead_4.plaintext_4.EAD_4) < ctx->nr_of_ead_tokens)
|
|
292
292
|
return EDHOC_ERROR_BUFFER_TOO_SMALL;
|
|
293
293
|
|
|
294
294
|
if (0 != ctx->nr_of_ead_tokens) {
|
|
295
|
-
ead_4.
|
|
296
|
-
ead_4.
|
|
295
|
+
ead_4.plaintext_4_present = true;
|
|
296
|
+
ead_4.plaintext_4.EAD_4_count = ctx->nr_of_ead_tokens;
|
|
297
297
|
|
|
298
298
|
for (size_t i = 0; i < ctx->nr_of_ead_tokens; ++i) {
|
|
299
|
-
ead_4.
|
|
299
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_label =
|
|
300
300
|
ctx->ead_token[i].label;
|
|
301
|
-
ead_4.
|
|
302
|
-
._ead_x_ead_value.value =
|
|
301
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_value.value =
|
|
303
302
|
ctx->ead_token[i].value;
|
|
304
|
-
ead_4.
|
|
303
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_value.len =
|
|
305
304
|
ctx->ead_token[i].value_len;
|
|
306
|
-
ead_4.
|
|
307
|
-
._ead_x_ead_value_present =
|
|
305
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_value_present =
|
|
308
306
|
(NULL != ctx->ead_token[i].value);
|
|
309
307
|
}
|
|
310
308
|
} else {
|
|
311
|
-
ead_4.
|
|
309
|
+
ead_4.plaintext_4_present = false;
|
|
312
310
|
}
|
|
313
311
|
|
|
314
|
-
ret =
|
|
312
|
+
ret = cbor_encode_plaintext_4(ptxt, ptxt_size, &ead_4, ptxt_len);
|
|
315
313
|
|
|
316
314
|
if (EDHOC_SUCCESS != ret)
|
|
317
315
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
@@ -347,7 +345,7 @@ static int compute_key_iv_aad(const struct edhoc_context *ctx, uint8_t *key,
|
|
|
347
345
|
const struct edhoc_cipher_suite csuite =
|
|
348
346
|
ctx->csuite[ctx->chosen_csuite_idx];
|
|
349
347
|
|
|
350
|
-
uint8_t key_id[
|
|
348
|
+
uint8_t key_id[CONFIG_LIBEDHOC_KEY_ID_LEN] = { 0 };
|
|
351
349
|
struct info input_info = { 0 };
|
|
352
350
|
|
|
353
351
|
/* Calculate struct info cbor overhead. */
|
|
@@ -356,26 +354,26 @@ static int compute_key_iv_aad(const struct edhoc_context *ctx, uint8_t *key,
|
|
|
356
354
|
len += ctx->th_len + cbor_bstr_overhead(ctx->th_len);
|
|
357
355
|
len += cbor_int_mem_req((int32_t)csuite.aead_key_length);
|
|
358
356
|
|
|
359
|
-
|
|
360
|
-
memset(info, 0,
|
|
357
|
+
VLA_ALLOC(uint8_t, info, len);
|
|
358
|
+
memset(info, 0, VLA_SIZEOF(info));
|
|
361
359
|
|
|
362
360
|
/* Generate K_3. */
|
|
363
361
|
input_info = (struct info){
|
|
364
|
-
.
|
|
365
|
-
.
|
|
366
|
-
.
|
|
367
|
-
.
|
|
362
|
+
.info_label = EDHOC_EXTRACT_PRK_INFO_LABEL_K_4,
|
|
363
|
+
.info_context.value = ctx->th,
|
|
364
|
+
.info_context.len = ctx->th_len,
|
|
365
|
+
.info_length = (uint32_t)csuite.aead_key_length,
|
|
368
366
|
};
|
|
369
367
|
|
|
370
|
-
memset(info, 0,
|
|
368
|
+
memset(info, 0, VLA_SIZEOF(info));
|
|
371
369
|
len = 0;
|
|
372
|
-
ret = cbor_encode_info(info,
|
|
370
|
+
ret = cbor_encode_info(info, VLA_SIZE(info), &input_info, &len);
|
|
373
371
|
|
|
374
372
|
if (ZCBOR_SUCCESS != ret)
|
|
375
373
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
376
374
|
|
|
377
|
-
ret = ctx->keys.
|
|
378
|
-
|
|
375
|
+
ret = ctx->keys.import_key(ctx->user_ctx, EDHOC_KT_EXPAND, ctx->prk,
|
|
376
|
+
ctx->prk_len, key_id);
|
|
379
377
|
|
|
380
378
|
if (EDHOC_SUCCESS != ret)
|
|
381
379
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
@@ -390,21 +388,21 @@ static int compute_key_iv_aad(const struct edhoc_context *ctx, uint8_t *key,
|
|
|
390
388
|
|
|
391
389
|
/* Generate IV_3. */
|
|
392
390
|
input_info = (struct info){
|
|
393
|
-
.
|
|
394
|
-
.
|
|
395
|
-
.
|
|
396
|
-
.
|
|
391
|
+
.info_label = EDHOC_EXTRACT_PRK_INFO_LABEL_IV_4,
|
|
392
|
+
.info_context.value = ctx->th,
|
|
393
|
+
.info_context.len = ctx->th_len,
|
|
394
|
+
.info_length = (uint32_t)csuite.aead_iv_length,
|
|
397
395
|
};
|
|
398
396
|
|
|
399
|
-
memset(info, 0,
|
|
397
|
+
memset(info, 0, VLA_SIZEOF(info));
|
|
400
398
|
len = 0;
|
|
401
|
-
ret = cbor_encode_info(info,
|
|
399
|
+
ret = cbor_encode_info(info, VLA_SIZE(info), &input_info, &len);
|
|
402
400
|
|
|
403
401
|
if (ZCBOR_SUCCESS != ret)
|
|
404
402
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
405
403
|
|
|
406
|
-
ret = ctx->keys.
|
|
407
|
-
|
|
404
|
+
ret = ctx->keys.import_key(ctx->user_ctx, EDHOC_KT_EXPAND, ctx->prk,
|
|
405
|
+
ctx->prk_len, key_id);
|
|
408
406
|
|
|
409
407
|
if (EDHOC_SUCCESS != ret)
|
|
410
408
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
@@ -418,10 +416,10 @@ static int compute_key_iv_aad(const struct edhoc_context *ctx, uint8_t *key,
|
|
|
418
416
|
|
|
419
417
|
/* Generate AAD_3. */
|
|
420
418
|
struct enc_structure cose_enc_0 = {
|
|
421
|
-
.
|
|
422
|
-
.
|
|
423
|
-
.
|
|
424
|
-
.
|
|
419
|
+
.enc_structure_protected.value = NULL,
|
|
420
|
+
.enc_structure_protected.len = 0,
|
|
421
|
+
.enc_structure_external_aad.value = ctx->th,
|
|
422
|
+
.enc_structure_external_aad.len = ctx->th_len,
|
|
425
423
|
};
|
|
426
424
|
|
|
427
425
|
len = 0;
|
|
@@ -442,9 +440,9 @@ static int compute_ciphertext(const struct edhoc_context *ctx,
|
|
|
442
440
|
{
|
|
443
441
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
444
442
|
|
|
445
|
-
uint8_t key_id[
|
|
446
|
-
ret = ctx->keys.
|
|
447
|
-
|
|
443
|
+
uint8_t key_id[CONFIG_LIBEDHOC_KEY_ID_LEN] = { 0 };
|
|
444
|
+
ret = ctx->keys.import_key(ctx->user_ctx, EDHOC_KT_ENCRYPT, key,
|
|
445
|
+
key_len, key_id);
|
|
448
446
|
|
|
449
447
|
if (EDHOC_SUCCESS != ret)
|
|
450
448
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
@@ -516,9 +514,9 @@ static int decrypt_ciphertext(const struct edhoc_context *ctx,
|
|
|
516
514
|
{
|
|
517
515
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
518
516
|
|
|
519
|
-
uint8_t key_id[
|
|
520
|
-
ret = ctx->keys.
|
|
521
|
-
|
|
517
|
+
uint8_t key_id[CONFIG_LIBEDHOC_KEY_ID_LEN] = { 0 };
|
|
518
|
+
ret = ctx->keys.import_key(ctx->user_ctx, EDHOC_KT_DECRYPT, key,
|
|
519
|
+
key_len, key_id);
|
|
522
520
|
|
|
523
521
|
if (EDHOC_SUCCESS != ret)
|
|
524
522
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
@@ -545,20 +543,20 @@ static int parse_plaintext(struct edhoc_context *ctx, const uint8_t *ptxt,
|
|
|
545
543
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
546
544
|
|
|
547
545
|
size_t len = 0;
|
|
548
|
-
struct
|
|
549
|
-
ret =
|
|
546
|
+
struct plaintext_4 ead_4 = { 0 };
|
|
547
|
+
ret = cbor_decode_plaintext_4(ptxt, ptxt_len, &ead_4, &len);
|
|
550
548
|
|
|
551
549
|
if (ZCBOR_SUCCESS != ret)
|
|
552
550
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
553
551
|
|
|
554
|
-
ctx->nr_of_ead_tokens = ead_4.
|
|
555
|
-
for (size_t i = 0; i < ead_4.
|
|
552
|
+
ctx->nr_of_ead_tokens = ead_4.plaintext_4.EAD_4_count;
|
|
553
|
+
for (size_t i = 0; i < ead_4.plaintext_4.EAD_4_count; ++i) {
|
|
556
554
|
ctx->ead_token[i].label =
|
|
557
|
-
ead_4.
|
|
558
|
-
ctx->ead_token[i].value =
|
|
559
|
-
|
|
555
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_label;
|
|
556
|
+
ctx->ead_token[i].value =
|
|
557
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_value.value;
|
|
560
558
|
ctx->ead_token[i].value_len =
|
|
561
|
-
ead_4.
|
|
559
|
+
ead_4.plaintext_4.EAD_4[i].ead_y_ead_value.len;
|
|
562
560
|
}
|
|
563
561
|
|
|
564
562
|
return EDHOC_SUCCESS;
|
|
@@ -590,6 +588,8 @@ int edhoc_message_4_compose(struct edhoc_context *ctx, uint8_t *msg_4,
|
|
|
590
588
|
|
|
591
589
|
ctx->status = EDHOC_SM_ABORTED;
|
|
592
590
|
ctx->error_code = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
591
|
+
ctx->message = EDHOC_MSG_4;
|
|
592
|
+
ctx->role = EDHOC_RESPONDER;
|
|
593
593
|
|
|
594
594
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
595
595
|
|
|
@@ -599,7 +599,7 @@ int edhoc_message_4_compose(struct edhoc_context *ctx, uint8_t *msg_4,
|
|
|
599
599
|
|
|
600
600
|
/* 2. Compose EAD_4 if present. */
|
|
601
601
|
if (NULL != ctx->ead.compose && 0 != ARRAY_SIZE(ctx->ead_token) - 1) {
|
|
602
|
-
ret = ctx->ead.compose(ctx->user_ctx,
|
|
602
|
+
ret = ctx->ead.compose(ctx->user_ctx, ctx->message,
|
|
603
603
|
ctx->ead_token,
|
|
604
604
|
ARRAY_SIZE(ctx->ead_token) - 1,
|
|
605
605
|
&ctx->nr_of_ead_tokens);
|
|
@@ -633,11 +633,11 @@ int edhoc_message_4_compose(struct edhoc_context *ctx, uint8_t *msg_4,
|
|
|
633
633
|
if (EDHOC_SUCCESS != ret)
|
|
634
634
|
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
635
635
|
|
|
636
|
-
|
|
637
|
-
memset(plaintext, 0,
|
|
636
|
+
VLA_ALLOC(uint8_t, plaintext, plaintext_len);
|
|
637
|
+
memset(plaintext, 0, VLA_SIZEOF(plaintext));
|
|
638
638
|
|
|
639
639
|
/* 3b. Prepare plaintext (PLAINTEXT_4). */
|
|
640
|
-
ret = prepare_plaintext_4(ctx, plaintext,
|
|
640
|
+
ret = prepare_plaintext_4(ctx, plaintext, VLA_SIZE(plaintext),
|
|
641
641
|
&plaintext_len);
|
|
642
642
|
|
|
643
643
|
if (EDHOC_SUCCESS != ret)
|
|
@@ -648,36 +648,37 @@ int edhoc_message_4_compose(struct edhoc_context *ctx, uint8_t *msg_4,
|
|
|
648
648
|
plaintext_len);
|
|
649
649
|
|
|
650
650
|
/* 4. Compute K_4, IV_4 and AAD_4. */
|
|
651
|
-
|
|
652
|
-
memset(key, 0,
|
|
651
|
+
VLA_ALLOC(uint8_t, key, csuite.aead_key_length);
|
|
652
|
+
memset(key, 0, VLA_SIZEOF(key));
|
|
653
653
|
|
|
654
|
-
|
|
655
|
-
memset(iv, 0,
|
|
654
|
+
VLA_ALLOC(uint8_t, iv, csuite.aead_iv_length);
|
|
655
|
+
memset(iv, 0, VLA_SIZEOF(iv));
|
|
656
656
|
|
|
657
657
|
const size_t aad_len = compute_aad_4_len(ctx);
|
|
658
|
-
|
|
659
|
-
memset(aad, 0,
|
|
658
|
+
VLA_ALLOC(uint8_t, aad, aad_len);
|
|
659
|
+
memset(aad, 0, VLA_SIZEOF(aad));
|
|
660
660
|
|
|
661
|
-
ret = compute_key_iv_aad(ctx, key,
|
|
662
|
-
|
|
661
|
+
ret = compute_key_iv_aad(ctx, key, VLA_SIZE(key), iv, VLA_SIZE(iv), aad,
|
|
662
|
+
VLA_SIZE(aad));
|
|
663
663
|
|
|
664
664
|
if (EDHOC_SUCCESS != ret)
|
|
665
665
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
666
666
|
|
|
667
667
|
if (NULL != ctx->logger) {
|
|
668
|
-
ctx->logger(ctx->user_ctx, "K_4", key,
|
|
669
|
-
ctx->logger(ctx->user_ctx, "IV_4", iv,
|
|
670
|
-
ctx->logger(ctx->user_ctx, "AAD_4", aad,
|
|
668
|
+
ctx->logger(ctx->user_ctx, "K_4", key, VLA_SIZE(key));
|
|
669
|
+
ctx->logger(ctx->user_ctx, "IV_4", iv, VLA_SIZE(iv));
|
|
670
|
+
ctx->logger(ctx->user_ctx, "AAD_4", aad, VLA_SIZE(aad));
|
|
671
671
|
}
|
|
672
672
|
|
|
673
673
|
/* 5. Compute ciphertext. */
|
|
674
674
|
size_t ciphertext_len = 0;
|
|
675
|
-
|
|
676
|
-
|
|
675
|
+
VLA_ALLOC(uint8_t, ciphertext,
|
|
676
|
+
VLA_SIZE(plaintext) + csuite.aead_tag_length);
|
|
677
|
+
memset(ciphertext, 0, VLA_SIZEOF(ciphertext));
|
|
677
678
|
|
|
678
|
-
ret = compute_ciphertext(ctx, key,
|
|
679
|
-
|
|
680
|
-
ciphertext,
|
|
679
|
+
ret = compute_ciphertext(ctx, key, VLA_SIZE(key), iv, VLA_SIZE(iv), aad,
|
|
680
|
+
VLA_SIZE(aad), plaintext, plaintext_len,
|
|
681
|
+
ciphertext, VLA_SIZE(ciphertext),
|
|
681
682
|
&ciphertext_len);
|
|
682
683
|
|
|
683
684
|
if (EDHOC_SUCCESS != ret)
|
|
@@ -727,6 +728,8 @@ int edhoc_message_4_process(struct edhoc_context *ctx, const uint8_t *msg_4,
|
|
|
727
728
|
|
|
728
729
|
ctx->status = EDHOC_SM_ABORTED;
|
|
729
730
|
ctx->error_code = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
731
|
+
ctx->message = EDHOC_MSG_4;
|
|
732
|
+
ctx->role = EDHOC_INITIATOR;
|
|
730
733
|
|
|
731
734
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
732
735
|
|
|
@@ -747,45 +750,44 @@ int edhoc_message_4_process(struct edhoc_context *ctx, const uint8_t *msg_4,
|
|
|
747
750
|
ctx->logger(ctx->user_ctx, "CIPHERTEXT_4", ctxt, ctxt_len);
|
|
748
751
|
|
|
749
752
|
/* 3. Compute K_4, IV_4 and AAD_4. */
|
|
750
|
-
|
|
751
|
-
memset(key, 0,
|
|
753
|
+
VLA_ALLOC(uint8_t, key, csuite.aead_key_length);
|
|
754
|
+
memset(key, 0, VLA_SIZEOF(key));
|
|
752
755
|
|
|
753
|
-
|
|
754
|
-
memset(iv, 0,
|
|
756
|
+
VLA_ALLOC(uint8_t, iv, csuite.aead_iv_length);
|
|
757
|
+
memset(iv, 0, VLA_SIZEOF(iv));
|
|
755
758
|
|
|
756
759
|
const size_t aad_len = compute_aad_4_len(ctx);
|
|
757
|
-
|
|
758
|
-
memset(aad, 0,
|
|
760
|
+
VLA_ALLOC(uint8_t, aad, aad_len);
|
|
761
|
+
memset(aad, 0, VLA_SIZEOF(aad));
|
|
759
762
|
|
|
760
|
-
ret = compute_key_iv_aad(ctx, key,
|
|
761
|
-
|
|
763
|
+
ret = compute_key_iv_aad(ctx, key, VLA_SIZE(key), iv, VLA_SIZE(iv), aad,
|
|
764
|
+
VLA_SIZE(aad));
|
|
762
765
|
|
|
763
766
|
if (EDHOC_SUCCESS != ret)
|
|
764
767
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
765
768
|
|
|
766
769
|
if (NULL != ctx->logger) {
|
|
767
|
-
ctx->logger(ctx->user_ctx, "K_4", key,
|
|
768
|
-
ctx->logger(ctx->user_ctx, "IV_4", iv,
|
|
769
|
-
ctx->logger(ctx->user_ctx, "AAD_4", aad,
|
|
770
|
+
ctx->logger(ctx->user_ctx, "K_4", key, VLA_SIZE(key));
|
|
771
|
+
ctx->logger(ctx->user_ctx, "IV_4", iv, VLA_SIZE(iv));
|
|
772
|
+
ctx->logger(ctx->user_ctx, "AAD_4", aad, VLA_SIZE(aad));
|
|
770
773
|
}
|
|
771
774
|
|
|
772
775
|
/* 4. Decrypt ciphertext. */
|
|
773
|
-
|
|
774
|
-
memset(ptxt, 0,
|
|
776
|
+
VLA_ALLOC(uint8_t, ptxt, ctxt_len - csuite.aead_tag_length);
|
|
777
|
+
memset(ptxt, 0, VLA_SIZEOF(ptxt));
|
|
775
778
|
|
|
776
|
-
ret = decrypt_ciphertext(ctx, key,
|
|
777
|
-
|
|
778
|
-
|
|
779
|
+
ret = decrypt_ciphertext(ctx, key, VLA_SIZE(key), iv, VLA_SIZE(iv), aad,
|
|
780
|
+
VLA_SIZE(aad), ctxt, ctxt_len, ptxt,
|
|
781
|
+
VLA_SIZE(ptxt));
|
|
779
782
|
|
|
780
783
|
if (EDHOC_SUCCESS != ret)
|
|
781
784
|
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
782
785
|
|
|
783
786
|
if (NULL != ctx->logger)
|
|
784
|
-
ctx->logger(ctx->user_ctx, "PLAINTEXT_4", ptxt,
|
|
785
|
-
ARRAY_SIZE_VLA(ptxt));
|
|
787
|
+
ctx->logger(ctx->user_ctx, "PLAINTEXT_4", ptxt, VLA_SIZE(ptxt));
|
|
786
788
|
|
|
787
789
|
/* 5. Parse CBOR plaintext (PLAINTEXT_4). */
|
|
788
|
-
ret = parse_plaintext(ctx, ptxt,
|
|
790
|
+
ret = parse_plaintext(ctx, ptxt, VLA_SIZE(ptxt));
|
|
789
791
|
|
|
790
792
|
if (EDHOC_SUCCESS != ret)
|
|
791
793
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
@@ -793,7 +795,7 @@ int edhoc_message_4_process(struct edhoc_context *ctx, const uint8_t *msg_4,
|
|
|
793
795
|
/* 6. Process EAD_4 if present. */
|
|
794
796
|
if (NULL != ctx->ead.process && 0 != ARRAY_SIZE(ctx->ead_token) - 1 &&
|
|
795
797
|
0 != ctx->nr_of_ead_tokens) {
|
|
796
|
-
ret = ctx->ead.process(ctx->user_ctx,
|
|
798
|
+
ret = ctx->ead.process(ctx->user_ctx, ctx->message,
|
|
797
799
|
ctx->ead_token, ctx->nr_of_ead_tokens);
|
|
798
800
|
|
|
799
801
|
if (EDHOC_SUCCESS != ret)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* \file edhoc_message_error.c
|
|
3
3
|
* \author Kamil Kielbasa
|
|
4
4
|
* \brief EDHOC message error.
|
|
5
|
-
* \version 0.
|
|
6
|
-
* \date 2024-
|
|
5
|
+
* \version 0.6
|
|
6
|
+
* \date 2024-08-05
|
|
7
7
|
*
|
|
8
8
|
* \copyright Copyright (c) 2024
|
|
9
9
|
*
|
|
@@ -57,12 +57,12 @@ int edhoc_message_error_compose(uint8_t *msg_err, size_t msg_err_size,
|
|
|
57
57
|
return EDHOC_ERROR_BAD_STATE;
|
|
58
58
|
|
|
59
59
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
60
|
-
struct message_error input = { .
|
|
60
|
+
struct message_error input = { .message_error_ERR_CODE =
|
|
61
61
|
(int32_t)code };
|
|
62
62
|
|
|
63
63
|
switch (code) {
|
|
64
64
|
case EDHOC_ERROR_CODE_SUCCESS: {
|
|
65
|
-
input.
|
|
65
|
+
input.message_error_ERR_INFO_present = false;
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -74,20 +74,20 @@ int edhoc_message_error_compose(uint8_t *msg_err, size_t msg_err_size,
|
|
|
74
74
|
if (info->written_entries > info->total_entries)
|
|
75
75
|
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
76
76
|
|
|
77
|
-
input.
|
|
78
|
-
input.
|
|
79
|
-
|
|
80
|
-
input.
|
|
81
|
-
|
|
82
|
-
input.
|
|
77
|
+
input.message_error_ERR_INFO_present = true;
|
|
78
|
+
input.message_error_ERR_INFO.message_error_ERR_INFO_choice =
|
|
79
|
+
message_error_ERR_INFO_tstr_c;
|
|
80
|
+
input.message_error_ERR_INFO.message_error_ERR_INFO_tstr.value =
|
|
81
|
+
(const uint8_t *)info->text_string;
|
|
82
|
+
input.message_error_ERR_INFO.message_error_ERR_INFO_tstr.len =
|
|
83
83
|
info->written_entries;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
case EDHOC_ERROR_CODE_WRONG_SELECTED_CIPHER_SUITE: {
|
|
88
|
-
input.
|
|
89
|
-
input.
|
|
90
|
-
|
|
88
|
+
input.message_error_ERR_INFO_present = true;
|
|
89
|
+
input.message_error_ERR_INFO.message_error_ERR_INFO_choice =
|
|
90
|
+
message_error_ERR_INFO_suites_m_c;
|
|
91
91
|
|
|
92
92
|
if (NULL == info || NULL == info->cipher_suites ||
|
|
93
93
|
0 == info->total_entries || 0 == info->written_entries)
|
|
@@ -96,21 +96,21 @@ int edhoc_message_error_compose(uint8_t *msg_err, size_t msg_err_size,
|
|
|
96
96
|
if (info->written_entries > info->total_entries)
|
|
97
97
|
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
98
98
|
|
|
99
|
-
struct
|
|
100
|
-
&input.
|
|
101
|
-
.
|
|
99
|
+
struct suites_r *suites =
|
|
100
|
+
&input.message_error_ERR_INFO
|
|
101
|
+
.message_error_ERR_INFO_suites_m;
|
|
102
102
|
|
|
103
103
|
if (1 == info->written_entries) {
|
|
104
|
-
suites->
|
|
105
|
-
suites->
|
|
104
|
+
suites->suites_choice = suites_int_c;
|
|
105
|
+
suites->suites_int = *info->cipher_suites;
|
|
106
106
|
} else {
|
|
107
|
-
if (ARRAY_SIZE(suites->
|
|
107
|
+
if (ARRAY_SIZE(suites->suites_int_l_int) <
|
|
108
108
|
info->written_entries)
|
|
109
109
|
return EDHOC_ERROR_BUFFER_TOO_SMALL;
|
|
110
110
|
|
|
111
|
-
suites->
|
|
112
|
-
suites->
|
|
113
|
-
memcpy(suites->
|
|
111
|
+
suites->suites_choice = suites_int_l_c;
|
|
112
|
+
suites->suites_int_l_int_count = info->written_entries;
|
|
113
|
+
memcpy(suites->suites_int_l_int, info->cipher_suites,
|
|
114
114
|
sizeof(*info->cipher_suites) *
|
|
115
115
|
info->written_entries);
|
|
116
116
|
}
|
|
@@ -119,9 +119,9 @@ int edhoc_message_error_compose(uint8_t *msg_err, size_t msg_err_size,
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
case EDHOC_ERROR_CODE_UNKNOWN_CREDENTIAL_REFERENCED: {
|
|
122
|
-
input.
|
|
123
|
-
input.
|
|
124
|
-
|
|
122
|
+
input.message_error_ERR_INFO_present = true;
|
|
123
|
+
input.message_error_ERR_INFO.message_error_ERR_INFO_choice =
|
|
124
|
+
message_error_ERR_INFO_bool_c;
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -154,7 +154,7 @@ int edhoc_message_error_process(const uint8_t *msg_err, size_t msg_err_len,
|
|
|
154
154
|
if (ZCBOR_SUCCESS != ret)
|
|
155
155
|
return EDHOC_ERROR_CBOR_FAILURE;
|
|
156
156
|
|
|
157
|
-
switch (result.
|
|
157
|
+
switch (result.message_error_ERR_CODE) {
|
|
158
158
|
case EDHOC_ERROR_CODE_SUCCESS: {
|
|
159
159
|
*code = EDHOC_ERROR_CODE_SUCCESS;
|
|
160
160
|
break;
|
|
@@ -167,10 +167,10 @@ int edhoc_message_error_process(const uint8_t *msg_err, size_t msg_err_len,
|
|
|
167
167
|
0 == info->total_entries)
|
|
168
168
|
break;
|
|
169
169
|
|
|
170
|
-
if (true == result.
|
|
170
|
+
if (true == result.message_error_ERR_INFO_present) {
|
|
171
171
|
const struct zcbor_string *tstr =
|
|
172
|
-
&result.
|
|
173
|
-
.
|
|
172
|
+
&result.message_error_ERR_INFO
|
|
173
|
+
.message_error_ERR_INFO_tstr;
|
|
174
174
|
|
|
175
175
|
if (tstr->len > info->total_entries)
|
|
176
176
|
return EDHOC_ERROR_BUFFER_TOO_SMALL;
|
|
@@ -190,29 +190,29 @@ int edhoc_message_error_process(const uint8_t *msg_err, size_t msg_err_len,
|
|
|
190
190
|
0 == info->total_entries)
|
|
191
191
|
break;
|
|
192
192
|
|
|
193
|
-
if (true == result.
|
|
194
|
-
const struct
|
|
195
|
-
&result.
|
|
196
|
-
.
|
|
193
|
+
if (true == result.message_error_ERR_INFO_present) {
|
|
194
|
+
const struct suites_r *suites =
|
|
195
|
+
&result.message_error_ERR_INFO
|
|
196
|
+
.message_error_ERR_INFO_suites_m;
|
|
197
197
|
|
|
198
|
-
switch (suites->
|
|
199
|
-
case
|
|
198
|
+
switch (suites->suites_choice) {
|
|
199
|
+
case suites_int_c: {
|
|
200
200
|
info->written_entries = 1;
|
|
201
|
-
*info->cipher_suites = suites->
|
|
201
|
+
*info->cipher_suites = suites->suites_int;
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
case
|
|
206
|
-
if (suites->
|
|
205
|
+
case suites_int_l_c: {
|
|
206
|
+
if (suites->suites_int_l_int_count >
|
|
207
207
|
info->total_entries)
|
|
208
208
|
return EDHOC_ERROR_BUFFER_TOO_SMALL;
|
|
209
209
|
|
|
210
210
|
info->written_entries =
|
|
211
|
-
suites->
|
|
211
|
+
suites->suites_int_l_int_count;
|
|
212
212
|
memcpy(info->cipher_suites,
|
|
213
|
-
suites->
|
|
213
|
+
suites->suites_int_l_int,
|
|
214
214
|
sizeof(*info->cipher_suites) *
|
|
215
|
-
suites->
|
|
215
|
+
suites->suites_int_l_int_count);
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
218
|
|