edhoc 1.0.4 → 1.1.0
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/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +10 -0
- package/dist/crypto.d.ts +29 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +205 -0
- package/dist/edhoc.d.ts +368 -0
- package/dist/edhoc.d.ts.map +1 -0
- package/dist/edhoc.js +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- 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/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
|
@@ -1,936 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* \file test_edhoc_handshake_x5chain_cs_0.c
|
|
3
|
-
* \author Kamil Kielbasa
|
|
4
|
-
* \brief EDHOC handshake unit test for X.509 chain authentication method
|
|
5
|
-
* with real crypto usage.
|
|
6
|
-
* \version 0.4
|
|
7
|
-
* \date 2024-01-01
|
|
8
|
-
*
|
|
9
|
-
* \copyright Copyright (c) 2024
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/* Include files ----------------------------------------------------------- */
|
|
14
|
-
|
|
15
|
-
/* Internal test headers: */
|
|
16
|
-
#include "x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h"
|
|
17
|
-
#include "x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h"
|
|
18
|
-
#include "x509_chain_cs_0/test_vector_x5chain_cs_0.h"
|
|
19
|
-
#include "cipher_suites/cipher_suite_0.h"
|
|
20
|
-
|
|
21
|
-
/* Standard library headers: */
|
|
22
|
-
#include <stdio.h>
|
|
23
|
-
#include <string.h>
|
|
24
|
-
#include <stdint.h>
|
|
25
|
-
#include <stddef.h>
|
|
26
|
-
#include <assert.h>
|
|
27
|
-
#include <stdbool.h>
|
|
28
|
-
|
|
29
|
-
/* EDHOC header: */
|
|
30
|
-
#define EDHOC_ALLOW_PRIVATE_ACCESS
|
|
31
|
-
#include "edhoc.h"
|
|
32
|
-
|
|
33
|
-
/* PSA crypto header: */
|
|
34
|
-
#include <psa/crypto.h>
|
|
35
|
-
|
|
36
|
-
/* Module defines ---------------------------------------------------------- */
|
|
37
|
-
#define OSCORE_MASTER_SECRET_LENGTH (16)
|
|
38
|
-
#define OSCORE_MASTER_SALT_LENGTH (8)
|
|
39
|
-
#define DH_KEY_AGREEMENT_LENGTH (32)
|
|
40
|
-
#define ENTROPY_LENGTH (16)
|
|
41
|
-
|
|
42
|
-
/* Module types and type definitiones -------------------------------------- */
|
|
43
|
-
/* Module interface variables and constants -------------------------------- */
|
|
44
|
-
/* Static function declarations -------------------------------------------- */
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* \brief Helper function for printing arrays.
|
|
48
|
-
*/
|
|
49
|
-
static inline void print_array(void *user_context, const char *name,
|
|
50
|
-
const uint8_t *buffer, size_t buffer_length);
|
|
51
|
-
|
|
52
|
-
/* Static variables and constants ------------------------------------------ */
|
|
53
|
-
|
|
54
|
-
static const struct edhoc_cipher_suite edhoc_cipher_suite_0 = {
|
|
55
|
-
.value = 0,
|
|
56
|
-
.aead_key_length = 16,
|
|
57
|
-
.aead_tag_length = 8,
|
|
58
|
-
.aead_iv_length = 13,
|
|
59
|
-
.hash_length = 32,
|
|
60
|
-
.mac_length = 32,
|
|
61
|
-
.ecc_key_length = 32,
|
|
62
|
-
.ecc_sign_length = 64,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
static const struct edhoc_keys edhoc_keys = {
|
|
66
|
-
.generate_key = cipher_suite_0_key_generate,
|
|
67
|
-
.destroy_key = cipher_suite_0_key_destroy,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
static const struct edhoc_crypto edhoc_crypto = {
|
|
71
|
-
.make_key_pair = cipher_suite_0_make_key_pair,
|
|
72
|
-
.key_agreement = cipher_suite_0_key_agreement,
|
|
73
|
-
.signature = cipher_suite_0_signature,
|
|
74
|
-
.verify = cipher_suite_0_verify,
|
|
75
|
-
.extract = cipher_suite_0_extract,
|
|
76
|
-
.expand = cipher_suite_0_expand,
|
|
77
|
-
.encrypt = cipher_suite_0_encrypt,
|
|
78
|
-
.decrypt = cipher_suite_0_decrypt,
|
|
79
|
-
.hash = cipher_suite_0_hash,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
static const struct edhoc_credentials edhoc_auth_cred_single_cert_mocked_init = {
|
|
83
|
-
.fetch = auth_cred_fetch_init_x5chain_cs_0_single_cert,
|
|
84
|
-
.verify = auth_cred_verify_init_x5chain_cs_0_single_cert,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
static const struct edhoc_credentials edhoc_auth_cred_single_cert_mocked_resp = {
|
|
88
|
-
.fetch = auth_cred_fetch_resp_x5chain_cs_0_single_cert,
|
|
89
|
-
.verify = auth_cred_verify_resp_x5chain_cs_0_single_cert,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
static const struct edhoc_credentials edhoc_auth_cred_many_certs_mocked_init = {
|
|
93
|
-
.fetch = auth_cred_fetch_init_x5chain_cs_0_many_certs,
|
|
94
|
-
.verify = auth_cred_verify_init_x5chain_cs_0_many_certs,
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
static const struct edhoc_credentials edhoc_auth_cred_many_certs_mocked_resp = {
|
|
98
|
-
.fetch = auth_cred_fetch_resp_x5chain_cs_0_many_certs,
|
|
99
|
-
.verify = auth_cred_verify_resp_x5chain_cs_0_many_certs,
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/* Static function definitions --------------------------------------------- */
|
|
103
|
-
|
|
104
|
-
static inline void print_array(void *user_context, const char *name,
|
|
105
|
-
const uint8_t *buffer, size_t buffer_length)
|
|
106
|
-
{
|
|
107
|
-
(void)user_context;
|
|
108
|
-
|
|
109
|
-
printf("%s:\tLEN( %zu )\n", name, buffer_length);
|
|
110
|
-
|
|
111
|
-
for (size_t i = 0; i < buffer_length; ++i) {
|
|
112
|
-
if (0 == i % 16 && i > 0) {
|
|
113
|
-
printf("\n");
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
printf("%02x ", buffer[i]);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
printf("\n\n");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/* Module interface function definitions ----------------------------------- */
|
|
123
|
-
|
|
124
|
-
void test_edhoc_handshake_x5chain_cs_0_single_cert_e2e_real_crypto(void)
|
|
125
|
-
{
|
|
126
|
-
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
127
|
-
enum edhoc_error_code error_code_recv =
|
|
128
|
-
EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* \brief Setup initiator context.
|
|
132
|
-
*/
|
|
133
|
-
struct edhoc_context init_ctx = { 0 };
|
|
134
|
-
struct edhoc_connection_id init_cid = {
|
|
135
|
-
.encode_type = EDHOC_CID_TYPE_ONE_BYTE_INTEGER,
|
|
136
|
-
.int_value = (int8_t)C_I[0],
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
ret = edhoc_context_init(&init_ctx);
|
|
140
|
-
assert(EDHOC_SUCCESS == ret);
|
|
141
|
-
init_ctx.logger = print_array;
|
|
142
|
-
|
|
143
|
-
ret = edhoc_set_method(&init_ctx, METHOD);
|
|
144
|
-
assert(EDHOC_SUCCESS == ret);
|
|
145
|
-
|
|
146
|
-
ret = edhoc_set_cipher_suites(&init_ctx, &edhoc_cipher_suite_0, 1);
|
|
147
|
-
assert(EDHOC_SUCCESS == ret);
|
|
148
|
-
|
|
149
|
-
ret = edhoc_set_connection_id(&init_ctx, init_cid);
|
|
150
|
-
assert(EDHOC_SUCCESS == ret);
|
|
151
|
-
|
|
152
|
-
ret = edhoc_bind_keys(&init_ctx, edhoc_keys);
|
|
153
|
-
assert(EDHOC_SUCCESS == ret);
|
|
154
|
-
|
|
155
|
-
ret = edhoc_bind_crypto(&init_ctx, edhoc_crypto);
|
|
156
|
-
assert(EDHOC_SUCCESS == ret);
|
|
157
|
-
|
|
158
|
-
ret = edhoc_bind_credentials(&init_ctx,
|
|
159
|
-
edhoc_auth_cred_single_cert_mocked_init);
|
|
160
|
-
assert(EDHOC_SUCCESS == ret);
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* \brief Setup responder context.
|
|
164
|
-
*/
|
|
165
|
-
struct edhoc_context resp_ctx = { 0 };
|
|
166
|
-
struct edhoc_connection_id resp_cid = {
|
|
167
|
-
.encode_type = EDHOC_CID_TYPE_BYTE_STRING,
|
|
168
|
-
.bstr_length = ARRAY_SIZE(C_R),
|
|
169
|
-
};
|
|
170
|
-
memcpy(resp_cid.bstr_value, C_R, ARRAY_SIZE(C_R));
|
|
171
|
-
|
|
172
|
-
ret = edhoc_context_init(&resp_ctx);
|
|
173
|
-
assert(EDHOC_SUCCESS == ret);
|
|
174
|
-
resp_ctx.logger = print_array;
|
|
175
|
-
|
|
176
|
-
ret = edhoc_set_method(&resp_ctx, METHOD);
|
|
177
|
-
assert(EDHOC_SUCCESS == ret);
|
|
178
|
-
|
|
179
|
-
ret = edhoc_set_cipher_suites(&resp_ctx, &edhoc_cipher_suite_0, 1);
|
|
180
|
-
assert(EDHOC_SUCCESS == ret);
|
|
181
|
-
|
|
182
|
-
ret = edhoc_set_connection_id(&resp_ctx, resp_cid);
|
|
183
|
-
assert(EDHOC_SUCCESS == ret);
|
|
184
|
-
|
|
185
|
-
ret = edhoc_bind_keys(&resp_ctx, edhoc_keys);
|
|
186
|
-
assert(EDHOC_SUCCESS == ret);
|
|
187
|
-
|
|
188
|
-
ret = edhoc_bind_crypto(&resp_ctx, edhoc_crypto);
|
|
189
|
-
assert(EDHOC_SUCCESS == ret);
|
|
190
|
-
|
|
191
|
-
ret = edhoc_bind_credentials(&resp_ctx,
|
|
192
|
-
edhoc_auth_cred_single_cert_mocked_resp);
|
|
193
|
-
assert(EDHOC_SUCCESS == ret);
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* \brief One buffer for whole EDHOC handshake.
|
|
197
|
-
*/
|
|
198
|
-
uint8_t buffer[1000] = { 0 };
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* \brief EDHOC message 1 compose.
|
|
202
|
-
*/
|
|
203
|
-
memset(buffer, 0, sizeof(buffer));
|
|
204
|
-
size_t msg_1_len = 0;
|
|
205
|
-
uint8_t *msg_1 = buffer;
|
|
206
|
-
|
|
207
|
-
ret = edhoc_message_1_compose(&init_ctx, msg_1, ARRAY_SIZE(buffer),
|
|
208
|
-
&msg_1_len);
|
|
209
|
-
assert(EDHOC_SUCCESS == ret);
|
|
210
|
-
assert(EDHOC_SM_WAIT_M2 == init_ctx.status);
|
|
211
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
212
|
-
assert(EDHOC_PRK_STATE_INVALID == init_ctx.prk_state);
|
|
213
|
-
assert(EDHOC_TH_STATE_1 == init_ctx.th_state);
|
|
214
|
-
|
|
215
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
216
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
217
|
-
assert(EDHOC_SUCCESS == ret);
|
|
218
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* \brief EDHOC message 1 process.
|
|
222
|
-
*/
|
|
223
|
-
ret = edhoc_message_1_process(&resp_ctx, msg_1, msg_1_len);
|
|
224
|
-
assert(EDHOC_SUCCESS == ret);
|
|
225
|
-
assert(EDHOC_SM_RECEIVED_M1 == resp_ctx.status);
|
|
226
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
227
|
-
assert(EDHOC_TH_STATE_1 == resp_ctx.th_state);
|
|
228
|
-
assert(EDHOC_PRK_STATE_INVALID == resp_ctx.prk_state);
|
|
229
|
-
|
|
230
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
231
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
232
|
-
assert(EDHOC_SUCCESS == ret);
|
|
233
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
234
|
-
|
|
235
|
-
assert(EDHOC_CID_TYPE_ONE_BYTE_INTEGER ==
|
|
236
|
-
resp_ctx.peer_cid.encode_type);
|
|
237
|
-
assert((int8_t)C_I[0] == resp_ctx.peer_cid.int_value);
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* \brief EDHOC message 2 compose.
|
|
241
|
-
*/
|
|
242
|
-
memset(buffer, 0, sizeof(buffer));
|
|
243
|
-
size_t msg_2_len = 0;
|
|
244
|
-
uint8_t *msg_2 = buffer;
|
|
245
|
-
|
|
246
|
-
ret = edhoc_message_2_compose(&resp_ctx, msg_2, ARRAY_SIZE(buffer),
|
|
247
|
-
&msg_2_len);
|
|
248
|
-
assert(EDHOC_SUCCESS == ret);
|
|
249
|
-
assert(EDHOC_SM_WAIT_M3 == resp_ctx.status);
|
|
250
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
251
|
-
assert(EDHOC_TH_STATE_3 == resp_ctx.th_state);
|
|
252
|
-
assert(EDHOC_PRK_STATE_3E2M == resp_ctx.prk_state);
|
|
253
|
-
|
|
254
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
255
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
256
|
-
assert(EDHOC_SUCCESS == ret);
|
|
257
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* \brief EDHOC message 2 process.
|
|
261
|
-
*/
|
|
262
|
-
ret = edhoc_message_2_process(&init_ctx, msg_2, msg_2_len);
|
|
263
|
-
|
|
264
|
-
assert(EDHOC_SUCCESS == ret);
|
|
265
|
-
assert(EDHOC_SM_VERIFIED_M2 == init_ctx.status);
|
|
266
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
267
|
-
assert(EDHOC_TH_STATE_3 == init_ctx.th_state);
|
|
268
|
-
assert(EDHOC_PRK_STATE_3E2M == init_ctx.prk_state);
|
|
269
|
-
|
|
270
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
271
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
272
|
-
assert(EDHOC_SUCCESS == ret);
|
|
273
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
274
|
-
|
|
275
|
-
assert(EDHOC_CID_TYPE_BYTE_STRING == init_ctx.peer_cid.encode_type);
|
|
276
|
-
assert(ARRAY_SIZE(C_R) == init_ctx.peer_cid.bstr_length);
|
|
277
|
-
assert(0 == memcmp(C_R, init_ctx.peer_cid.bstr_value,
|
|
278
|
-
init_ctx.peer_cid.bstr_length));
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* \brief Verify ephemeral DH key agreement.
|
|
282
|
-
*/
|
|
283
|
-
assert(DH_KEY_AGREEMENT_LENGTH == init_ctx.dh_secret_len);
|
|
284
|
-
assert(DH_KEY_AGREEMENT_LENGTH == resp_ctx.dh_secret_len);
|
|
285
|
-
assert(init_ctx.dh_secret_len == resp_ctx.dh_secret_len);
|
|
286
|
-
assert(0 == memcmp(init_ctx.dh_secret, resp_ctx.dh_secret,
|
|
287
|
-
DH_KEY_AGREEMENT_LENGTH));
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* \brief EDHOC message 3 compose.
|
|
291
|
-
*/
|
|
292
|
-
memset(buffer, 0, sizeof(buffer));
|
|
293
|
-
size_t msg_3_len = 0;
|
|
294
|
-
uint8_t *msg_3 = buffer;
|
|
295
|
-
|
|
296
|
-
ret = edhoc_message_3_compose(&init_ctx, msg_3, ARRAY_SIZE(buffer),
|
|
297
|
-
&msg_3_len);
|
|
298
|
-
|
|
299
|
-
assert(EDHOC_SUCCESS == ret);
|
|
300
|
-
assert(EDHOC_SM_COMPLETED == init_ctx.status);
|
|
301
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
302
|
-
assert(EDHOC_TH_STATE_4 == init_ctx.th_state);
|
|
303
|
-
assert(EDHOC_PRK_STATE_4E3M == init_ctx.prk_state);
|
|
304
|
-
|
|
305
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
306
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
307
|
-
assert(EDHOC_SUCCESS == ret);
|
|
308
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* \brief EDHOC message 3 process.
|
|
312
|
-
*/
|
|
313
|
-
ret = edhoc_message_3_process(&resp_ctx, msg_3, msg_3_len);
|
|
314
|
-
|
|
315
|
-
assert(EDHOC_SUCCESS == ret);
|
|
316
|
-
assert(EDHOC_SM_COMPLETED == resp_ctx.status);
|
|
317
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
318
|
-
assert(EDHOC_TH_STATE_4 == resp_ctx.th_state);
|
|
319
|
-
assert(EDHOC_PRK_STATE_4E3M == resp_ctx.prk_state);
|
|
320
|
-
|
|
321
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
322
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
323
|
-
assert(EDHOC_SUCCESS == ret);
|
|
324
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* \brief EDHOC message 4 compose.
|
|
328
|
-
*/
|
|
329
|
-
memset(buffer, 0, sizeof(buffer));
|
|
330
|
-
size_t msg_4_len = 0;
|
|
331
|
-
uint8_t *msg_4 = buffer;
|
|
332
|
-
|
|
333
|
-
ret = edhoc_message_4_compose(&resp_ctx, msg_4, ARRAY_SIZE(buffer),
|
|
334
|
-
&msg_4_len);
|
|
335
|
-
|
|
336
|
-
assert(EDHOC_SUCCESS == ret);
|
|
337
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
338
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
339
|
-
assert(EDHOC_TH_STATE_4 == resp_ctx.th_state);
|
|
340
|
-
assert(EDHOC_PRK_STATE_4E3M == resp_ctx.prk_state);
|
|
341
|
-
|
|
342
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
343
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
344
|
-
assert(EDHOC_SUCCESS == ret);
|
|
345
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* \brief EDHOC message 3 process.
|
|
349
|
-
*/
|
|
350
|
-
ret = edhoc_message_4_process(&init_ctx, msg_4, msg_4_len);
|
|
351
|
-
|
|
352
|
-
assert(EDHOC_SUCCESS == ret);
|
|
353
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
354
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
355
|
-
assert(EDHOC_TH_STATE_4 == init_ctx.th_state);
|
|
356
|
-
assert(EDHOC_PRK_STATE_4E3M == init_ctx.prk_state);
|
|
357
|
-
|
|
358
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
359
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
360
|
-
assert(EDHOC_SUCCESS == ret);
|
|
361
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* \brief Initiator - derive OSCORE secret & salt.
|
|
365
|
-
*/
|
|
366
|
-
uint8_t init_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
367
|
-
uint8_t init_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
368
|
-
size_t init_sender_id_len = 0;
|
|
369
|
-
uint8_t init_sender_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
370
|
-
size_t init_recipient_id_len = 0;
|
|
371
|
-
uint8_t init_recipient_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
372
|
-
|
|
373
|
-
ret = edhoc_export_oscore_session(
|
|
374
|
-
&init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
375
|
-
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
376
|
-
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
377
|
-
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
378
|
-
&init_recipient_id_len);
|
|
379
|
-
assert(EDHOC_SUCCESS == ret);
|
|
380
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
381
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
382
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* \brief Responder - derive OSCORE secret & salt.
|
|
386
|
-
*/
|
|
387
|
-
uint8_t resp_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
388
|
-
uint8_t resp_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
389
|
-
size_t resp_sender_id_len = 0;
|
|
390
|
-
uint8_t resp_sender_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
391
|
-
size_t resp_recipient_id_len = 0;
|
|
392
|
-
uint8_t resp_recipient_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
393
|
-
|
|
394
|
-
ret = edhoc_export_oscore_session(
|
|
395
|
-
&resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
396
|
-
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
397
|
-
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
398
|
-
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
399
|
-
&resp_recipient_id_len);
|
|
400
|
-
assert(EDHOC_SUCCESS == ret);
|
|
401
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
402
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
403
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* \brief Verify OSCORE master secret:
|
|
407
|
-
*/
|
|
408
|
-
assert(0 == memcmp(init_master_secret, resp_master_secret,
|
|
409
|
-
sizeof(resp_master_secret)));
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* \brief Verify OSCORE master salt:
|
|
413
|
-
*/
|
|
414
|
-
assert(0 == memcmp(init_master_salt, resp_master_salt,
|
|
415
|
-
sizeof(resp_master_salt)));
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* \brief Verify OSCORE sender and recipient identifiers (cross check).
|
|
419
|
-
*/
|
|
420
|
-
assert(init_sender_id_len == resp_recipient_id_len);
|
|
421
|
-
assert(0 ==
|
|
422
|
-
memcmp(init_sender_id, resp_recipient_id, init_sender_id_len));
|
|
423
|
-
assert(init_recipient_id_len == resp_sender_id_len);
|
|
424
|
-
assert(0 ==
|
|
425
|
-
memcmp(init_recipient_id, resp_sender_id, resp_sender_id_len));
|
|
426
|
-
|
|
427
|
-
uint8_t entropy[ENTROPY_LENGTH] = { 0 };
|
|
428
|
-
ret = psa_generate_random(entropy, sizeof(entropy));
|
|
429
|
-
assert(PSA_SUCCESS == ret);
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* \brief Initiator - perform EDHOC key update.
|
|
433
|
-
*/
|
|
434
|
-
ret = edhoc_export_key_update(&init_ctx, entropy, ARRAY_SIZE(entropy));
|
|
435
|
-
assert(EDHOC_SUCCESS == ret);
|
|
436
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
437
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* \brief Responder - perform EDHOC key update.
|
|
441
|
-
*/
|
|
442
|
-
ret = edhoc_export_key_update(&resp_ctx, entropy, ARRAY_SIZE(entropy));
|
|
443
|
-
assert(EDHOC_SUCCESS == ret);
|
|
444
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
445
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* \brief Verify new PRK_out.
|
|
449
|
-
*/
|
|
450
|
-
assert(init_ctx.prk_state == resp_ctx.prk_state);
|
|
451
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
452
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
453
|
-
|
|
454
|
-
assert(init_ctx.prk_len == resp_ctx.prk_len);
|
|
455
|
-
assert(0 == memcmp(init_ctx.prk, resp_ctx.prk, resp_ctx.prk_len));
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* \brief Initiator - derive OSCORE secret & salt.
|
|
459
|
-
*/
|
|
460
|
-
memset(init_master_secret, 0, sizeof(init_master_secret));
|
|
461
|
-
memset(init_master_salt, 0, sizeof(init_master_salt));
|
|
462
|
-
init_sender_id_len = 0;
|
|
463
|
-
memset(init_sender_id, 0, sizeof(init_sender_id));
|
|
464
|
-
init_recipient_id_len = 0;
|
|
465
|
-
memset(init_recipient_id, 0, sizeof(init_recipient_id));
|
|
466
|
-
|
|
467
|
-
ret = edhoc_export_oscore_session(
|
|
468
|
-
&init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
469
|
-
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
470
|
-
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
471
|
-
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
472
|
-
&init_recipient_id_len);
|
|
473
|
-
assert(EDHOC_SUCCESS == ret);
|
|
474
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
475
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
476
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* \brief Responder - derive OSCORE secret & salt.
|
|
480
|
-
*/
|
|
481
|
-
memset(resp_master_secret, 0, sizeof(resp_master_secret));
|
|
482
|
-
memset(resp_master_salt, 0, sizeof(resp_master_salt));
|
|
483
|
-
resp_sender_id_len = 0;
|
|
484
|
-
memset(resp_sender_id, 0, sizeof(resp_sender_id));
|
|
485
|
-
resp_recipient_id_len = 0;
|
|
486
|
-
memset(resp_recipient_id, 0, sizeof(resp_recipient_id));
|
|
487
|
-
|
|
488
|
-
ret = edhoc_export_oscore_session(
|
|
489
|
-
&resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
490
|
-
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
491
|
-
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
492
|
-
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
493
|
-
&resp_recipient_id_len);
|
|
494
|
-
assert(EDHOC_SUCCESS == ret);
|
|
495
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
496
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
497
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* \brief Verify OSCORE master secret:
|
|
501
|
-
*/
|
|
502
|
-
assert(0 == memcmp(init_master_secret, resp_master_secret,
|
|
503
|
-
sizeof(resp_master_secret)));
|
|
504
|
-
|
|
505
|
-
/**
|
|
506
|
-
* \brief Verify OSCORE master salt:
|
|
507
|
-
*/
|
|
508
|
-
assert(0 == memcmp(init_master_salt, resp_master_salt,
|
|
509
|
-
sizeof(resp_master_salt)));
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* \brief Verify OSCORE sender and recipient identifiers (cross check).
|
|
513
|
-
*/
|
|
514
|
-
assert(init_sender_id_len == resp_recipient_id_len);
|
|
515
|
-
assert(0 ==
|
|
516
|
-
memcmp(init_sender_id, resp_recipient_id, init_sender_id_len));
|
|
517
|
-
assert(init_recipient_id_len == resp_sender_id_len);
|
|
518
|
-
assert(0 ==
|
|
519
|
-
memcmp(init_recipient_id, resp_sender_id, resp_sender_id_len));
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* \brief Clean up of EDHOC context's.
|
|
523
|
-
*/
|
|
524
|
-
ret = edhoc_context_deinit(&init_ctx);
|
|
525
|
-
assert(EDHOC_SUCCESS == ret);
|
|
526
|
-
|
|
527
|
-
ret = edhoc_context_deinit(&resp_ctx);
|
|
528
|
-
assert(EDHOC_SUCCESS == ret);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
void test_edhoc_handshake_x5chain_cs_0_many_certs_e2e_real_crypto(void)
|
|
532
|
-
{
|
|
533
|
-
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
534
|
-
enum edhoc_error_code error_code_recv =
|
|
535
|
-
EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* \brief Setup initiator context.
|
|
539
|
-
*/
|
|
540
|
-
struct edhoc_context init_ctx = { 0 };
|
|
541
|
-
struct edhoc_connection_id init_cid = {
|
|
542
|
-
.encode_type = EDHOC_CID_TYPE_ONE_BYTE_INTEGER,
|
|
543
|
-
.int_value = (int8_t)C_I[0],
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
ret = edhoc_context_init(&init_ctx);
|
|
547
|
-
assert(EDHOC_SUCCESS == ret);
|
|
548
|
-
init_ctx.logger = print_array;
|
|
549
|
-
|
|
550
|
-
ret = edhoc_set_method(&init_ctx, METHOD);
|
|
551
|
-
assert(EDHOC_SUCCESS == ret);
|
|
552
|
-
|
|
553
|
-
ret = edhoc_set_cipher_suites(&init_ctx, &edhoc_cipher_suite_0, 1);
|
|
554
|
-
assert(EDHOC_SUCCESS == ret);
|
|
555
|
-
|
|
556
|
-
ret = edhoc_set_connection_id(&init_ctx, init_cid);
|
|
557
|
-
assert(EDHOC_SUCCESS == ret);
|
|
558
|
-
|
|
559
|
-
ret = edhoc_bind_keys(&init_ctx, edhoc_keys);
|
|
560
|
-
assert(EDHOC_SUCCESS == ret);
|
|
561
|
-
|
|
562
|
-
ret = edhoc_bind_crypto(&init_ctx, edhoc_crypto);
|
|
563
|
-
assert(EDHOC_SUCCESS == ret);
|
|
564
|
-
|
|
565
|
-
ret = edhoc_bind_credentials(&init_ctx,
|
|
566
|
-
edhoc_auth_cred_many_certs_mocked_init);
|
|
567
|
-
assert(EDHOC_SUCCESS == ret);
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* \brief Setup responder context.
|
|
571
|
-
*/
|
|
572
|
-
struct edhoc_context resp_ctx = { 0 };
|
|
573
|
-
struct edhoc_connection_id resp_cid = {
|
|
574
|
-
.encode_type = EDHOC_CID_TYPE_BYTE_STRING,
|
|
575
|
-
.bstr_length = ARRAY_SIZE(C_R),
|
|
576
|
-
};
|
|
577
|
-
memcpy(resp_cid.bstr_value, C_R, ARRAY_SIZE(C_R));
|
|
578
|
-
|
|
579
|
-
ret = edhoc_context_init(&resp_ctx);
|
|
580
|
-
assert(EDHOC_SUCCESS == ret);
|
|
581
|
-
resp_ctx.logger = print_array;
|
|
582
|
-
|
|
583
|
-
ret = edhoc_set_method(&resp_ctx, METHOD);
|
|
584
|
-
assert(EDHOC_SUCCESS == ret);
|
|
585
|
-
|
|
586
|
-
ret = edhoc_set_cipher_suites(&resp_ctx, &edhoc_cipher_suite_0, 1);
|
|
587
|
-
assert(EDHOC_SUCCESS == ret);
|
|
588
|
-
|
|
589
|
-
ret = edhoc_set_connection_id(&resp_ctx, resp_cid);
|
|
590
|
-
assert(EDHOC_SUCCESS == ret);
|
|
591
|
-
|
|
592
|
-
ret = edhoc_bind_keys(&resp_ctx, edhoc_keys);
|
|
593
|
-
assert(EDHOC_SUCCESS == ret);
|
|
594
|
-
|
|
595
|
-
ret = edhoc_bind_crypto(&resp_ctx, edhoc_crypto);
|
|
596
|
-
assert(EDHOC_SUCCESS == ret);
|
|
597
|
-
|
|
598
|
-
ret = edhoc_bind_credentials(&resp_ctx,
|
|
599
|
-
edhoc_auth_cred_many_certs_mocked_resp);
|
|
600
|
-
assert(EDHOC_SUCCESS == ret);
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* \brief One buffer for whole EDHOC handshake.
|
|
604
|
-
*/
|
|
605
|
-
uint8_t buffer[2000] = { 0 };
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* \brief EDHOC message 1 compose.
|
|
609
|
-
*/
|
|
610
|
-
memset(buffer, 0, sizeof(buffer));
|
|
611
|
-
size_t msg_1_len = 0;
|
|
612
|
-
uint8_t *msg_1 = buffer;
|
|
613
|
-
|
|
614
|
-
ret = edhoc_message_1_compose(&init_ctx, msg_1, ARRAY_SIZE(buffer),
|
|
615
|
-
&msg_1_len);
|
|
616
|
-
assert(EDHOC_SUCCESS == ret);
|
|
617
|
-
assert(EDHOC_SM_WAIT_M2 == init_ctx.status);
|
|
618
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
619
|
-
assert(EDHOC_PRK_STATE_INVALID == init_ctx.prk_state);
|
|
620
|
-
assert(EDHOC_TH_STATE_1 == init_ctx.th_state);
|
|
621
|
-
|
|
622
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
623
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
624
|
-
assert(EDHOC_SUCCESS == ret);
|
|
625
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* \brief EDHOC message 1 process.
|
|
629
|
-
*/
|
|
630
|
-
ret = edhoc_message_1_process(&resp_ctx, msg_1, msg_1_len);
|
|
631
|
-
assert(EDHOC_SUCCESS == ret);
|
|
632
|
-
assert(EDHOC_SM_RECEIVED_M1 == resp_ctx.status);
|
|
633
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
634
|
-
assert(EDHOC_TH_STATE_1 == resp_ctx.th_state);
|
|
635
|
-
assert(EDHOC_PRK_STATE_INVALID == resp_ctx.prk_state);
|
|
636
|
-
|
|
637
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
638
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
639
|
-
assert(EDHOC_SUCCESS == ret);
|
|
640
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
641
|
-
|
|
642
|
-
assert(EDHOC_CID_TYPE_ONE_BYTE_INTEGER ==
|
|
643
|
-
resp_ctx.peer_cid.encode_type);
|
|
644
|
-
assert((int8_t)C_I[0] == resp_ctx.peer_cid.int_value);
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* \brief EDHOC message 2 compose.
|
|
648
|
-
*/
|
|
649
|
-
memset(buffer, 0, sizeof(buffer));
|
|
650
|
-
size_t msg_2_len = 0;
|
|
651
|
-
uint8_t *msg_2 = buffer;
|
|
652
|
-
|
|
653
|
-
ret = edhoc_message_2_compose(&resp_ctx, msg_2, ARRAY_SIZE(buffer),
|
|
654
|
-
&msg_2_len);
|
|
655
|
-
assert(EDHOC_SUCCESS == ret);
|
|
656
|
-
assert(EDHOC_SM_WAIT_M3 == resp_ctx.status);
|
|
657
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
658
|
-
assert(EDHOC_TH_STATE_3 == resp_ctx.th_state);
|
|
659
|
-
assert(EDHOC_PRK_STATE_3E2M == resp_ctx.prk_state);
|
|
660
|
-
|
|
661
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
662
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
663
|
-
assert(EDHOC_SUCCESS == ret);
|
|
664
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* \brief EDHOC message 2 process.
|
|
668
|
-
*/
|
|
669
|
-
ret = edhoc_message_2_process(&init_ctx, msg_2, msg_2_len);
|
|
670
|
-
|
|
671
|
-
assert(EDHOC_SUCCESS == ret);
|
|
672
|
-
assert(EDHOC_SM_VERIFIED_M2 == init_ctx.status);
|
|
673
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
674
|
-
assert(EDHOC_TH_STATE_3 == init_ctx.th_state);
|
|
675
|
-
assert(EDHOC_PRK_STATE_3E2M == init_ctx.prk_state);
|
|
676
|
-
|
|
677
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
678
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
679
|
-
assert(EDHOC_SUCCESS == ret);
|
|
680
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
681
|
-
|
|
682
|
-
assert(EDHOC_CID_TYPE_BYTE_STRING == init_ctx.peer_cid.encode_type);
|
|
683
|
-
assert(ARRAY_SIZE(C_R) == init_ctx.peer_cid.bstr_length);
|
|
684
|
-
assert(0 == memcmp(C_R, init_ctx.peer_cid.bstr_value,
|
|
685
|
-
init_ctx.peer_cid.bstr_length));
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* \brief Verify ephemeral DH key agreement.
|
|
689
|
-
*/
|
|
690
|
-
assert(DH_KEY_AGREEMENT_LENGTH == init_ctx.dh_secret_len);
|
|
691
|
-
assert(DH_KEY_AGREEMENT_LENGTH == resp_ctx.dh_secret_len);
|
|
692
|
-
assert(init_ctx.dh_secret_len == resp_ctx.dh_secret_len);
|
|
693
|
-
assert(0 == memcmp(init_ctx.dh_secret, resp_ctx.dh_secret,
|
|
694
|
-
DH_KEY_AGREEMENT_LENGTH));
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* \brief EDHOC message 3 compose.
|
|
698
|
-
*/
|
|
699
|
-
memset(buffer, 0, sizeof(buffer));
|
|
700
|
-
size_t msg_3_len = 0;
|
|
701
|
-
uint8_t *msg_3 = buffer;
|
|
702
|
-
|
|
703
|
-
ret = edhoc_message_3_compose(&init_ctx, msg_3, ARRAY_SIZE(buffer),
|
|
704
|
-
&msg_3_len);
|
|
705
|
-
|
|
706
|
-
assert(EDHOC_SUCCESS == ret);
|
|
707
|
-
assert(EDHOC_SM_COMPLETED == init_ctx.status);
|
|
708
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
709
|
-
assert(EDHOC_TH_STATE_4 == init_ctx.th_state);
|
|
710
|
-
assert(EDHOC_PRK_STATE_4E3M == init_ctx.prk_state);
|
|
711
|
-
|
|
712
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
713
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
714
|
-
assert(EDHOC_SUCCESS == ret);
|
|
715
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
* \brief EDHOC message 3 process.
|
|
719
|
-
*/
|
|
720
|
-
ret = edhoc_message_3_process(&resp_ctx, msg_3, msg_3_len);
|
|
721
|
-
|
|
722
|
-
assert(EDHOC_SUCCESS == ret);
|
|
723
|
-
assert(EDHOC_SM_COMPLETED == resp_ctx.status);
|
|
724
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
725
|
-
assert(EDHOC_TH_STATE_4 == resp_ctx.th_state);
|
|
726
|
-
assert(EDHOC_PRK_STATE_4E3M == resp_ctx.prk_state);
|
|
727
|
-
|
|
728
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
729
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
730
|
-
assert(EDHOC_SUCCESS == ret);
|
|
731
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* \brief EDHOC message 4 compose.
|
|
735
|
-
*/
|
|
736
|
-
memset(buffer, 0, sizeof(buffer));
|
|
737
|
-
size_t msg_4_len = 0;
|
|
738
|
-
uint8_t *msg_4 = buffer;
|
|
739
|
-
|
|
740
|
-
ret = edhoc_message_4_compose(&resp_ctx, msg_4, ARRAY_SIZE(buffer),
|
|
741
|
-
&msg_4_len);
|
|
742
|
-
|
|
743
|
-
assert(EDHOC_SUCCESS == ret);
|
|
744
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
745
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
746
|
-
assert(EDHOC_TH_STATE_4 == resp_ctx.th_state);
|
|
747
|
-
assert(EDHOC_PRK_STATE_4E3M == resp_ctx.prk_state);
|
|
748
|
-
|
|
749
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
750
|
-
ret = edhoc_error_get_code(&resp_ctx, &error_code_recv);
|
|
751
|
-
assert(EDHOC_SUCCESS == ret);
|
|
752
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* \brief EDHOC message 3 process.
|
|
756
|
-
*/
|
|
757
|
-
ret = edhoc_message_4_process(&init_ctx, msg_4, msg_4_len);
|
|
758
|
-
|
|
759
|
-
assert(EDHOC_SUCCESS == ret);
|
|
760
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
761
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
762
|
-
assert(EDHOC_TH_STATE_4 == init_ctx.th_state);
|
|
763
|
-
assert(EDHOC_PRK_STATE_4E3M == init_ctx.prk_state);
|
|
764
|
-
|
|
765
|
-
error_code_recv = EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
766
|
-
ret = edhoc_error_get_code(&init_ctx, &error_code_recv);
|
|
767
|
-
assert(EDHOC_SUCCESS == ret);
|
|
768
|
-
assert(EDHOC_ERROR_CODE_SUCCESS == error_code_recv);
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* \brief Initiator - derive OSCORE secret & salt.
|
|
772
|
-
*/
|
|
773
|
-
uint8_t init_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
774
|
-
uint8_t init_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
775
|
-
size_t init_sender_id_len = 0;
|
|
776
|
-
uint8_t init_sender_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
777
|
-
size_t init_recipient_id_len = 0;
|
|
778
|
-
uint8_t init_recipient_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
779
|
-
|
|
780
|
-
ret = edhoc_export_oscore_session(
|
|
781
|
-
&init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
782
|
-
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
783
|
-
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
784
|
-
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
785
|
-
&init_recipient_id_len);
|
|
786
|
-
assert(EDHOC_SUCCESS == ret);
|
|
787
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
788
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
789
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
790
|
-
|
|
791
|
-
/**
|
|
792
|
-
* \brief Responder - derive OSCORE secret & salt.
|
|
793
|
-
*/
|
|
794
|
-
uint8_t resp_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
795
|
-
uint8_t resp_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
796
|
-
size_t resp_sender_id_len = 0;
|
|
797
|
-
uint8_t resp_sender_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
798
|
-
size_t resp_recipient_id_len = 0;
|
|
799
|
-
uint8_t resp_recipient_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
800
|
-
|
|
801
|
-
ret = edhoc_export_oscore_session(
|
|
802
|
-
&resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
803
|
-
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
804
|
-
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
805
|
-
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
806
|
-
&resp_recipient_id_len);
|
|
807
|
-
assert(EDHOC_SUCCESS == ret);
|
|
808
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
809
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
810
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* \brief Verify OSCORE master secret:
|
|
814
|
-
*/
|
|
815
|
-
assert(0 == memcmp(init_master_secret, resp_master_secret,
|
|
816
|
-
sizeof(resp_master_secret)));
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* \brief Verify OSCORE master salt:
|
|
820
|
-
*/
|
|
821
|
-
assert(0 == memcmp(init_master_salt, resp_master_salt,
|
|
822
|
-
sizeof(resp_master_salt)));
|
|
823
|
-
|
|
824
|
-
/**
|
|
825
|
-
* \brief Verify OSCORE sender and recipient identifiers (cross check).
|
|
826
|
-
*/
|
|
827
|
-
assert(init_sender_id_len == resp_recipient_id_len);
|
|
828
|
-
assert(0 ==
|
|
829
|
-
memcmp(init_sender_id, resp_recipient_id, init_sender_id_len));
|
|
830
|
-
assert(init_recipient_id_len == resp_sender_id_len);
|
|
831
|
-
assert(0 ==
|
|
832
|
-
memcmp(init_recipient_id, resp_sender_id, resp_sender_id_len));
|
|
833
|
-
|
|
834
|
-
uint8_t entropy[ENTROPY_LENGTH] = { 0 };
|
|
835
|
-
ret = psa_generate_random(entropy, sizeof(entropy));
|
|
836
|
-
assert(PSA_SUCCESS == ret);
|
|
837
|
-
|
|
838
|
-
/**
|
|
839
|
-
* \brief Initiator - perform EDHOC key update.
|
|
840
|
-
*/
|
|
841
|
-
ret = edhoc_export_key_update(&init_ctx, entropy, ARRAY_SIZE(entropy));
|
|
842
|
-
assert(EDHOC_SUCCESS == ret);
|
|
843
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
844
|
-
assert(true == init_ctx.is_oscore_export_allowed);
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* \brief Responder - perform EDHOC key update.
|
|
848
|
-
*/
|
|
849
|
-
ret = edhoc_export_key_update(&resp_ctx, entropy, ARRAY_SIZE(entropy));
|
|
850
|
-
assert(EDHOC_SUCCESS == ret);
|
|
851
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
852
|
-
assert(true == resp_ctx.is_oscore_export_allowed);
|
|
853
|
-
|
|
854
|
-
/**
|
|
855
|
-
* \brief Verify new PRK_out.
|
|
856
|
-
*/
|
|
857
|
-
assert(init_ctx.prk_state == resp_ctx.prk_state);
|
|
858
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
859
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
860
|
-
|
|
861
|
-
assert(init_ctx.prk_len == resp_ctx.prk_len);
|
|
862
|
-
assert(0 == memcmp(init_ctx.prk, resp_ctx.prk, resp_ctx.prk_len));
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
* \brief Initiator - derive OSCORE secret & salt.
|
|
866
|
-
*/
|
|
867
|
-
memset(init_master_secret, 0, sizeof(init_master_secret));
|
|
868
|
-
memset(init_master_salt, 0, sizeof(init_master_salt));
|
|
869
|
-
init_sender_id_len = 0;
|
|
870
|
-
memset(init_sender_id, 0, sizeof(init_sender_id));
|
|
871
|
-
init_recipient_id_len = 0;
|
|
872
|
-
memset(init_recipient_id, 0, sizeof(init_recipient_id));
|
|
873
|
-
|
|
874
|
-
ret = edhoc_export_oscore_session(
|
|
875
|
-
&init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
876
|
-
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
877
|
-
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
878
|
-
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
879
|
-
&init_recipient_id_len);
|
|
880
|
-
assert(EDHOC_SUCCESS == ret);
|
|
881
|
-
assert(EDHOC_SM_PERSISTED == init_ctx.status);
|
|
882
|
-
assert(false == init_ctx.is_oscore_export_allowed);
|
|
883
|
-
assert(EDHOC_PRK_STATE_OUT == init_ctx.prk_state);
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* \brief Responder - derive OSCORE secret & salt.
|
|
887
|
-
*/
|
|
888
|
-
memset(resp_master_secret, 0, sizeof(resp_master_secret));
|
|
889
|
-
memset(resp_master_salt, 0, sizeof(resp_master_salt));
|
|
890
|
-
resp_sender_id_len = 0;
|
|
891
|
-
memset(resp_sender_id, 0, sizeof(resp_sender_id));
|
|
892
|
-
resp_recipient_id_len = 0;
|
|
893
|
-
memset(resp_recipient_id, 0, sizeof(resp_recipient_id));
|
|
894
|
-
|
|
895
|
-
ret = edhoc_export_oscore_session(
|
|
896
|
-
&resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
897
|
-
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
898
|
-
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
899
|
-
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
900
|
-
&resp_recipient_id_len);
|
|
901
|
-
assert(EDHOC_SUCCESS == ret);
|
|
902
|
-
assert(EDHOC_SM_PERSISTED == resp_ctx.status);
|
|
903
|
-
assert(false == resp_ctx.is_oscore_export_allowed);
|
|
904
|
-
assert(EDHOC_PRK_STATE_OUT == resp_ctx.prk_state);
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* \brief Verify OSCORE master secret:
|
|
908
|
-
*/
|
|
909
|
-
assert(0 == memcmp(init_master_secret, resp_master_secret,
|
|
910
|
-
sizeof(resp_master_secret)));
|
|
911
|
-
|
|
912
|
-
/**
|
|
913
|
-
* \brief Verify OSCORE master salt:
|
|
914
|
-
*/
|
|
915
|
-
assert(0 == memcmp(init_master_salt, resp_master_salt,
|
|
916
|
-
sizeof(resp_master_salt)));
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* \brief Verify OSCORE sender and recipient identifiers (cross check).
|
|
920
|
-
*/
|
|
921
|
-
assert(init_sender_id_len == resp_recipient_id_len);
|
|
922
|
-
assert(0 ==
|
|
923
|
-
memcmp(init_sender_id, resp_recipient_id, init_sender_id_len));
|
|
924
|
-
assert(init_recipient_id_len == resp_sender_id_len);
|
|
925
|
-
assert(0 ==
|
|
926
|
-
memcmp(init_recipient_id, resp_sender_id, resp_sender_id_len));
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* \brief Clean up of EDHOC context's.
|
|
930
|
-
*/
|
|
931
|
-
ret = edhoc_context_deinit(&init_ctx);
|
|
932
|
-
assert(EDHOC_SUCCESS == ret);
|
|
933
|
-
|
|
934
|
-
ret = edhoc_context_deinit(&resp_ctx);
|
|
935
|
-
assert(EDHOC_SUCCESS == ret);
|
|
936
|
-
}
|