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
|
@@ -0,0 +1,1135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \file module_test_x5chain_sign_keys_suite_0.c
|
|
3
|
+
* \author Kamil Kielbasa
|
|
4
|
+
* \brief Module tests for EDHOC handshake with:
|
|
5
|
+
* - X.509 chain.
|
|
6
|
+
* - signature keys.
|
|
7
|
+
* - cipher suite 0.
|
|
8
|
+
* \version 0.6
|
|
9
|
+
* \date 2024-08-05
|
|
10
|
+
*
|
|
11
|
+
* \copyright Copyright (c) 2024
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/* Include files ----------------------------------------------------------- */
|
|
16
|
+
|
|
17
|
+
/* Test vector header: */
|
|
18
|
+
#include "test_vector_x5chain_sign_keys_suite_0.h"
|
|
19
|
+
|
|
20
|
+
/* Cipher suite 0 header: */
|
|
21
|
+
#include "cipher_suite_0.h"
|
|
22
|
+
|
|
23
|
+
/* Standard library headers: */
|
|
24
|
+
#include <stdio.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
#include <stdint.h>
|
|
27
|
+
#include <stddef.h>
|
|
28
|
+
#include <stdbool.h>
|
|
29
|
+
|
|
30
|
+
/* EDHOC header: */
|
|
31
|
+
#define EDHOC_ALLOW_PRIVATE_ACCESS
|
|
32
|
+
#include <edhoc.h>
|
|
33
|
+
|
|
34
|
+
/* PSA crypto header: */
|
|
35
|
+
#include <psa/crypto.h>
|
|
36
|
+
|
|
37
|
+
/* Unity headers: */
|
|
38
|
+
#include <unity.h>
|
|
39
|
+
#include <unity_fixture.h>
|
|
40
|
+
|
|
41
|
+
/* Module defines ---------------------------------------------------------- */
|
|
42
|
+
|
|
43
|
+
#define OSCORE_MASTER_SECRET_LENGTH (16)
|
|
44
|
+
#define OSCORE_MASTER_SALT_LENGTH (8)
|
|
45
|
+
#define DH_KEY_AGREEMENT_LENGTH (32)
|
|
46
|
+
#define ENTROPY_LENGTH (16)
|
|
47
|
+
|
|
48
|
+
/* Module types and type definitiones -------------------------------------- */
|
|
49
|
+
/* Module interface variables and constants -------------------------------- */
|
|
50
|
+
/* Static function declarations -------------------------------------------- */
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* \brief Authentication credentials fetch callback for initiator
|
|
54
|
+
* for single certificate.
|
|
55
|
+
*/
|
|
56
|
+
static int auth_cred_fetch_init_single_cert(void *user_ctx,
|
|
57
|
+
struct edhoc_auth_creds *auth_cred);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* \brief Authentication credentials fetch callback for responder
|
|
61
|
+
* for single certificate.
|
|
62
|
+
*/
|
|
63
|
+
static int auth_cred_fetch_resp_single_cert(void *user_ctx,
|
|
64
|
+
struct edhoc_auth_creds *auth_cred);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* \brief Authentication credentials verify callback for initiator
|
|
68
|
+
* for single certificate.
|
|
69
|
+
*/
|
|
70
|
+
static int auth_cred_verify_init_single_cert(void *user_ctx,
|
|
71
|
+
struct edhoc_auth_creds *auth_cred,
|
|
72
|
+
const uint8_t **pub_key,
|
|
73
|
+
size_t *pub_key_len);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* \brief Authentication credentials verify callback for responder
|
|
77
|
+
* for single certificate.
|
|
78
|
+
*/
|
|
79
|
+
static int auth_cred_verify_resp_single_cert(void *user_ctx,
|
|
80
|
+
struct edhoc_auth_creds *auth_cred,
|
|
81
|
+
const uint8_t **pub_key,
|
|
82
|
+
size_t *pub_key_len);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* \brief Authentication credentials fetch callback for initiator
|
|
86
|
+
* for many certificates.
|
|
87
|
+
*/
|
|
88
|
+
static int auth_cred_fetch_init_many_certs(void *user_ctx,
|
|
89
|
+
struct edhoc_auth_creds *auth_cred);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* \brief Authentication credentials fetch callback for responder
|
|
93
|
+
* for many certificates.
|
|
94
|
+
*/
|
|
95
|
+
static int auth_cred_fetch_resp_many_certs(void *user_ctx,
|
|
96
|
+
struct edhoc_auth_creds *auth_cred);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* \brief Authentication credentials verify callback for initiator
|
|
100
|
+
* for single certificate.
|
|
101
|
+
*/
|
|
102
|
+
static int auth_cred_verify_init_many_certs(void *user_ctx,
|
|
103
|
+
struct edhoc_auth_creds *auth_cred,
|
|
104
|
+
const uint8_t **pub_key,
|
|
105
|
+
size_t *pub_key_len);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* \brief Authentication credentials verify callback for responder
|
|
109
|
+
* for single certificate.
|
|
110
|
+
*/
|
|
111
|
+
static int auth_cred_verify_resp_many_certs(void *user_ctx,
|
|
112
|
+
struct edhoc_auth_creds *auth_cred,
|
|
113
|
+
const uint8_t **pub_key,
|
|
114
|
+
size_t *pub_key_len);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* \brief Helper function for printing arrays.
|
|
118
|
+
*/
|
|
119
|
+
static inline void print_array(void *user_context, const char *name,
|
|
120
|
+
const uint8_t *buffer, size_t buffer_length);
|
|
121
|
+
|
|
122
|
+
/* Static variables and constants ------------------------------------------ */
|
|
123
|
+
|
|
124
|
+
static int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
125
|
+
static enum edhoc_error_code error_code_recv =
|
|
126
|
+
EDHOC_ERROR_CODE_UNSPECIFIED_ERROR;
|
|
127
|
+
|
|
128
|
+
static struct edhoc_context edhoc_initiator_context = { 0 };
|
|
129
|
+
static struct edhoc_context *init_ctx = &edhoc_initiator_context;
|
|
130
|
+
|
|
131
|
+
static struct edhoc_context edhoc_responder_context = { 0 };
|
|
132
|
+
static struct edhoc_context *resp_ctx = &edhoc_responder_context;
|
|
133
|
+
|
|
134
|
+
static const struct edhoc_cipher_suite edhoc_cipher_suite_0 = {
|
|
135
|
+
.value = 0,
|
|
136
|
+
.aead_key_length = 16,
|
|
137
|
+
.aead_tag_length = 8,
|
|
138
|
+
.aead_iv_length = 13,
|
|
139
|
+
.hash_length = 32,
|
|
140
|
+
.mac_length = 32,
|
|
141
|
+
.ecc_key_length = 32,
|
|
142
|
+
.ecc_sign_length = 64,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
static const struct edhoc_keys edhoc_keys = {
|
|
146
|
+
.import_key = cipher_suite_0_key_import,
|
|
147
|
+
.destroy_key = cipher_suite_0_key_destroy,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
static const struct edhoc_crypto edhoc_crypto = {
|
|
151
|
+
.make_key_pair = cipher_suite_0_make_key_pair,
|
|
152
|
+
.key_agreement = cipher_suite_0_key_agreement,
|
|
153
|
+
.signature = cipher_suite_0_signature,
|
|
154
|
+
.verify = cipher_suite_0_verify,
|
|
155
|
+
.extract = cipher_suite_0_extract,
|
|
156
|
+
.expand = cipher_suite_0_expand,
|
|
157
|
+
.encrypt = cipher_suite_0_encrypt,
|
|
158
|
+
.decrypt = cipher_suite_0_decrypt,
|
|
159
|
+
.hash = cipher_suite_0_hash,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
static const struct edhoc_credentials edhoc_auth_cred_single_cert_mocked_init = {
|
|
163
|
+
.fetch = auth_cred_fetch_init_single_cert,
|
|
164
|
+
.verify = auth_cred_verify_init_single_cert,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
static const struct edhoc_credentials edhoc_auth_cred_single_cert_mocked_resp = {
|
|
168
|
+
.fetch = auth_cred_fetch_resp_single_cert,
|
|
169
|
+
.verify = auth_cred_verify_resp_single_cert,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
static const struct edhoc_credentials edhoc_auth_cred_many_certs_mocked_init = {
|
|
173
|
+
.fetch = auth_cred_fetch_init_many_certs,
|
|
174
|
+
.verify = auth_cred_verify_init_many_certs,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
static const struct edhoc_credentials edhoc_auth_cred_many_certs_mocked_resp = {
|
|
178
|
+
.fetch = auth_cred_fetch_resp_many_certs,
|
|
179
|
+
.verify = auth_cred_verify_resp_many_certs,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/* Static function definitions --------------------------------------------- */
|
|
183
|
+
|
|
184
|
+
static int auth_cred_fetch_init_single_cert(void *user_ctx,
|
|
185
|
+
struct edhoc_auth_creds *auth_cred)
|
|
186
|
+
{
|
|
187
|
+
(void)user_ctx;
|
|
188
|
+
|
|
189
|
+
if (NULL == auth_cred)
|
|
190
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
191
|
+
|
|
192
|
+
auth_cred->label = EDHOC_COSE_HEADER_X509_CHAIN;
|
|
193
|
+
auth_cred->x509_chain.nr_of_certs = 1;
|
|
194
|
+
auth_cred->x509_chain.cert[0] = CRED_I;
|
|
195
|
+
auth_cred->x509_chain.cert_len[0] = ARRAY_SIZE(CRED_I);
|
|
196
|
+
|
|
197
|
+
const int ret = cipher_suite_0_key_import(NULL, EDHOC_KT_SIGNATURE,
|
|
198
|
+
SK_I, ARRAY_SIZE(SK_I),
|
|
199
|
+
auth_cred->priv_key_id);
|
|
200
|
+
|
|
201
|
+
if (EDHOC_SUCCESS != ret)
|
|
202
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
203
|
+
|
|
204
|
+
return EDHOC_SUCCESS;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static int auth_cred_fetch_resp_single_cert(void *user_ctx,
|
|
208
|
+
struct edhoc_auth_creds *auth_cred)
|
|
209
|
+
{
|
|
210
|
+
(void)user_ctx;
|
|
211
|
+
|
|
212
|
+
if (NULL == auth_cred)
|
|
213
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
214
|
+
|
|
215
|
+
auth_cred->label = EDHOC_COSE_HEADER_X509_CHAIN;
|
|
216
|
+
auth_cred->x509_chain.nr_of_certs = 1;
|
|
217
|
+
auth_cred->x509_chain.cert[0] = CRED_R;
|
|
218
|
+
auth_cred->x509_chain.cert_len[0] = ARRAY_SIZE(CRED_R);
|
|
219
|
+
|
|
220
|
+
const int ret = cipher_suite_0_key_import(NULL, EDHOC_KT_SIGNATURE,
|
|
221
|
+
SK_R, ARRAY_SIZE(SK_R),
|
|
222
|
+
auth_cred->priv_key_id);
|
|
223
|
+
|
|
224
|
+
if (EDHOC_SUCCESS != ret)
|
|
225
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
226
|
+
|
|
227
|
+
return EDHOC_SUCCESS;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static int auth_cred_verify_init_single_cert(void *user_ctx,
|
|
231
|
+
struct edhoc_auth_creds *auth_cred,
|
|
232
|
+
const uint8_t **pub_key,
|
|
233
|
+
size_t *pub_key_len)
|
|
234
|
+
{
|
|
235
|
+
(void)user_ctx;
|
|
236
|
+
|
|
237
|
+
if (NULL == auth_cred || NULL == pub_key || NULL == pub_key_len)
|
|
238
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* \brief Verify COSE header label value.
|
|
242
|
+
*/
|
|
243
|
+
if (EDHOC_COSE_HEADER_X509_CHAIN != auth_cred->label)
|
|
244
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* \brief Verify received number of certificates.
|
|
248
|
+
*/
|
|
249
|
+
if (1 != auth_cred->x509_chain.nr_of_certs)
|
|
250
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* \brief Verify received peer certificate length.
|
|
254
|
+
*/
|
|
255
|
+
if (auth_cred->x509_chain.cert_len[0] != ARRAY_SIZE(CRED_R))
|
|
256
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* \brief Verify received peer certificate.
|
|
260
|
+
*/
|
|
261
|
+
if (0 != memcmp(CRED_R, auth_cred->x509_chain.cert[0],
|
|
262
|
+
auth_cred->x509_chain.cert_len[0]))
|
|
263
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* \brief If successful then assign public key.
|
|
267
|
+
*/
|
|
268
|
+
*pub_key = PK_R;
|
|
269
|
+
*pub_key_len = ARRAY_SIZE(PK_R);
|
|
270
|
+
|
|
271
|
+
return EDHOC_SUCCESS;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
static int auth_cred_verify_resp_single_cert(void *user_ctx,
|
|
275
|
+
struct edhoc_auth_creds *auth_cred,
|
|
276
|
+
const uint8_t **pub_key,
|
|
277
|
+
size_t *pub_key_len)
|
|
278
|
+
{
|
|
279
|
+
(void)user_ctx;
|
|
280
|
+
|
|
281
|
+
if (NULL == auth_cred || NULL == pub_key || NULL == pub_key_len)
|
|
282
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* \brief Verify COSE header label value.
|
|
286
|
+
*/
|
|
287
|
+
if (EDHOC_COSE_HEADER_X509_CHAIN != auth_cred->label)
|
|
288
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* \brief Verify received number of certificates.
|
|
292
|
+
*/
|
|
293
|
+
if (1 != auth_cred->x509_chain.nr_of_certs)
|
|
294
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* \brief Verify received peer certificate length.
|
|
298
|
+
*/
|
|
299
|
+
if (auth_cred->x509_chain.cert_len[0] != ARRAY_SIZE(CRED_I))
|
|
300
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* \brief Verify received peer certificate.
|
|
304
|
+
*/
|
|
305
|
+
if (0 != memcmp(CRED_I, auth_cred->x509_chain.cert[0],
|
|
306
|
+
auth_cred->x509_chain.cert_len[0]))
|
|
307
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* \brief If successful then assign public key.
|
|
311
|
+
*/
|
|
312
|
+
*pub_key = PK_I;
|
|
313
|
+
*pub_key_len = ARRAY_SIZE(PK_I);
|
|
314
|
+
|
|
315
|
+
return EDHOC_SUCCESS;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
static int auth_cred_fetch_init_many_certs(void *user_ctx,
|
|
319
|
+
struct edhoc_auth_creds *auth_cred)
|
|
320
|
+
{
|
|
321
|
+
(void)user_ctx;
|
|
322
|
+
|
|
323
|
+
if (NULL == auth_cred)
|
|
324
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
325
|
+
|
|
326
|
+
auth_cred->label = EDHOC_COSE_HEADER_X509_CHAIN;
|
|
327
|
+
auth_cred->x509_chain.nr_of_certs = 2;
|
|
328
|
+
|
|
329
|
+
auth_cred->x509_chain.cert[0] = CRED_I;
|
|
330
|
+
auth_cred->x509_chain.cert_len[0] = ARRAY_SIZE(CRED_I);
|
|
331
|
+
|
|
332
|
+
auth_cred->x509_chain.cert[1] = CRED_R;
|
|
333
|
+
auth_cred->x509_chain.cert_len[1] = ARRAY_SIZE(CRED_R);
|
|
334
|
+
|
|
335
|
+
const int ret = cipher_suite_0_key_import(NULL, EDHOC_KT_SIGNATURE,
|
|
336
|
+
SK_I, ARRAY_SIZE(SK_I),
|
|
337
|
+
auth_cred->priv_key_id);
|
|
338
|
+
|
|
339
|
+
if (EDHOC_SUCCESS != ret)
|
|
340
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
341
|
+
|
|
342
|
+
return EDHOC_SUCCESS;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
static int auth_cred_fetch_resp_many_certs(void *user_ctx,
|
|
346
|
+
struct edhoc_auth_creds *auth_cred)
|
|
347
|
+
{
|
|
348
|
+
(void)user_ctx;
|
|
349
|
+
|
|
350
|
+
if (NULL == auth_cred)
|
|
351
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
352
|
+
|
|
353
|
+
auth_cred->label = EDHOC_COSE_HEADER_X509_CHAIN;
|
|
354
|
+
auth_cred->x509_chain.nr_of_certs = 2;
|
|
355
|
+
|
|
356
|
+
auth_cred->x509_chain.cert[0] = CRED_R;
|
|
357
|
+
auth_cred->x509_chain.cert_len[0] = ARRAY_SIZE(CRED_R);
|
|
358
|
+
|
|
359
|
+
auth_cred->x509_chain.cert[1] = CRED_I;
|
|
360
|
+
auth_cred->x509_chain.cert_len[1] = ARRAY_SIZE(CRED_I);
|
|
361
|
+
|
|
362
|
+
const int ret = cipher_suite_0_key_import(NULL, EDHOC_KT_SIGNATURE,
|
|
363
|
+
SK_R, ARRAY_SIZE(SK_R),
|
|
364
|
+
auth_cred->priv_key_id);
|
|
365
|
+
|
|
366
|
+
if (EDHOC_SUCCESS != ret)
|
|
367
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
368
|
+
|
|
369
|
+
return EDHOC_SUCCESS;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
static int auth_cred_verify_init_many_certs(void *user_ctx,
|
|
373
|
+
struct edhoc_auth_creds *auth_cred,
|
|
374
|
+
const uint8_t **pub_key,
|
|
375
|
+
size_t *pub_key_len)
|
|
376
|
+
{
|
|
377
|
+
(void)user_ctx;
|
|
378
|
+
|
|
379
|
+
if (NULL == auth_cred || NULL == pub_key || NULL == pub_key_len)
|
|
380
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* \brief Verify COSE header label value.
|
|
384
|
+
*/
|
|
385
|
+
if (EDHOC_COSE_HEADER_X509_CHAIN != auth_cred->label)
|
|
386
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* \brief Verify received number of certificates.
|
|
390
|
+
*/
|
|
391
|
+
if (2 != auth_cred->x509_chain.nr_of_certs)
|
|
392
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* \brief Verify received peer certificate length.
|
|
396
|
+
*/
|
|
397
|
+
if (auth_cred->x509_chain.cert_len[0] != ARRAY_SIZE(CRED_R))
|
|
398
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* \brief Verify received peer certificate.
|
|
402
|
+
*/
|
|
403
|
+
if (0 != memcmp(CRED_R, auth_cred->x509_chain.cert[0],
|
|
404
|
+
auth_cred->x509_chain.cert_len[0]))
|
|
405
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* \brief Verify received peer certificate length.
|
|
409
|
+
*/
|
|
410
|
+
if (auth_cred->x509_chain.cert_len[1] != ARRAY_SIZE(CRED_I))
|
|
411
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* \brief Verify received peer certificate.
|
|
415
|
+
*/
|
|
416
|
+
if (0 != memcmp(CRED_I, auth_cred->x509_chain.cert[1],
|
|
417
|
+
auth_cred->x509_chain.cert_len[1]))
|
|
418
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* \brief If successful then assign public key.
|
|
422
|
+
*/
|
|
423
|
+
*pub_key = PK_R;
|
|
424
|
+
*pub_key_len = ARRAY_SIZE(PK_R);
|
|
425
|
+
|
|
426
|
+
return EDHOC_SUCCESS;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
static int auth_cred_verify_resp_many_certs(void *user_ctx,
|
|
430
|
+
struct edhoc_auth_creds *auth_cred,
|
|
431
|
+
const uint8_t **pub_key,
|
|
432
|
+
size_t *pub_key_len)
|
|
433
|
+
{
|
|
434
|
+
(void)user_ctx;
|
|
435
|
+
|
|
436
|
+
if (NULL == auth_cred || NULL == pub_key || NULL == pub_key_len)
|
|
437
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* \brief Verify COSE header label value.
|
|
441
|
+
*/
|
|
442
|
+
if (EDHOC_COSE_HEADER_X509_CHAIN != auth_cred->label)
|
|
443
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* \brief Verify received number of certificates.
|
|
447
|
+
*/
|
|
448
|
+
if (2 != auth_cred->x509_chain.nr_of_certs)
|
|
449
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* \brief Verify received peer certificate length.
|
|
453
|
+
*/
|
|
454
|
+
if (auth_cred->x509_chain.cert_len[0] != ARRAY_SIZE(CRED_I))
|
|
455
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* \brief Verify received peer certificate.
|
|
459
|
+
*/
|
|
460
|
+
if (0 != memcmp(CRED_I, auth_cred->x509_chain.cert[0],
|
|
461
|
+
auth_cred->x509_chain.cert_len[0]))
|
|
462
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* \brief Verify received peer certificate length.
|
|
466
|
+
*/
|
|
467
|
+
if (auth_cred->x509_chain.cert_len[1] != ARRAY_SIZE(CRED_R))
|
|
468
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* \brief Verify received peer certificate.
|
|
472
|
+
*/
|
|
473
|
+
if (0 != memcmp(CRED_R, auth_cred->x509_chain.cert[1],
|
|
474
|
+
auth_cred->x509_chain.cert_len[1]))
|
|
475
|
+
return EDHOC_ERROR_CREDENTIALS_FAILURE;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* \brief If successful then assign public key.
|
|
479
|
+
*/
|
|
480
|
+
*pub_key = PK_I;
|
|
481
|
+
*pub_key_len = ARRAY_SIZE(PK_I);
|
|
482
|
+
|
|
483
|
+
return EDHOC_SUCCESS;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
static inline void print_array(void *user_context, const char *name,
|
|
487
|
+
const uint8_t *buffer, size_t buffer_length)
|
|
488
|
+
{
|
|
489
|
+
(void)user_context;
|
|
490
|
+
|
|
491
|
+
printf("%s:\tLEN( %zu )\n", name, buffer_length);
|
|
492
|
+
|
|
493
|
+
for (size_t i = 0; i < buffer_length; ++i) {
|
|
494
|
+
if (0 == i % 16 && i > 0) {
|
|
495
|
+
printf("\n");
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
printf("%02x ", buffer[i]);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
printf("\n\n");
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/* Module interface function definitions ----------------------------------- */
|
|
505
|
+
|
|
506
|
+
TEST_GROUP(x5chain_sign_keys_suite_0);
|
|
507
|
+
|
|
508
|
+
TEST_SETUP(x5chain_sign_keys_suite_0)
|
|
509
|
+
{
|
|
510
|
+
ret = psa_crypto_init();
|
|
511
|
+
TEST_ASSERT_EQUAL(PSA_SUCCESS, ret);
|
|
512
|
+
|
|
513
|
+
const enum edhoc_method methods[] = { METHOD };
|
|
514
|
+
const struct edhoc_cipher_suite cipher_suites[] = {
|
|
515
|
+
edhoc_cipher_suite_0,
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const struct edhoc_connection_id init_cid = {
|
|
519
|
+
.encode_type = EDHOC_CID_TYPE_ONE_BYTE_INTEGER,
|
|
520
|
+
.int_value = (int8_t)C_I[0],
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
struct edhoc_connection_id resp_cid = {
|
|
524
|
+
.encode_type = EDHOC_CID_TYPE_BYTE_STRING,
|
|
525
|
+
.bstr_length = ARRAY_SIZE(C_R),
|
|
526
|
+
};
|
|
527
|
+
memcpy(&resp_cid.bstr_value, C_R, ARRAY_SIZE(C_R));
|
|
528
|
+
|
|
529
|
+
ret = edhoc_context_init(init_ctx);
|
|
530
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
531
|
+
|
|
532
|
+
ret = edhoc_set_methods(init_ctx, methods, ARRAY_SIZE(methods));
|
|
533
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
534
|
+
|
|
535
|
+
ret = edhoc_set_cipher_suites(init_ctx, cipher_suites,
|
|
536
|
+
ARRAY_SIZE(cipher_suites));
|
|
537
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
538
|
+
|
|
539
|
+
ret = edhoc_set_connection_id(init_ctx, &init_cid);
|
|
540
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
541
|
+
|
|
542
|
+
ret = edhoc_bind_keys(init_ctx, &edhoc_keys);
|
|
543
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
544
|
+
|
|
545
|
+
ret = edhoc_bind_crypto(init_ctx, &edhoc_crypto);
|
|
546
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
547
|
+
|
|
548
|
+
ret = edhoc_context_init(resp_ctx);
|
|
549
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
550
|
+
|
|
551
|
+
ret = edhoc_set_methods(resp_ctx, methods, ARRAY_SIZE(methods));
|
|
552
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
553
|
+
|
|
554
|
+
ret = edhoc_set_cipher_suites(resp_ctx, cipher_suites,
|
|
555
|
+
ARRAY_SIZE(cipher_suites));
|
|
556
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
557
|
+
|
|
558
|
+
ret = edhoc_set_connection_id(resp_ctx, &resp_cid);
|
|
559
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
560
|
+
|
|
561
|
+
ret = edhoc_bind_keys(resp_ctx, &edhoc_keys);
|
|
562
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
563
|
+
|
|
564
|
+
ret = edhoc_bind_crypto(resp_ctx, &edhoc_crypto);
|
|
565
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
566
|
+
|
|
567
|
+
#if defined(TEST_TRACES)
|
|
568
|
+
init_ctx->logger = print_array;
|
|
569
|
+
resp_ctx->logger = print_array;
|
|
570
|
+
#endif
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
TEST_TEAR_DOWN(x5chain_sign_keys_suite_0)
|
|
574
|
+
{
|
|
575
|
+
mbedtls_psa_crypto_free();
|
|
576
|
+
|
|
577
|
+
ret = edhoc_context_deinit(init_ctx);
|
|
578
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
579
|
+
|
|
580
|
+
ret = edhoc_context_deinit(resp_ctx);
|
|
581
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
TEST(x5chain_sign_keys_suite_0, one_cert_in_chain)
|
|
585
|
+
{
|
|
586
|
+
uint8_t buffer[1000] = { 0 };
|
|
587
|
+
|
|
588
|
+
/* Required missing setup. */
|
|
589
|
+
ret = edhoc_bind_credentials(init_ctx,
|
|
590
|
+
&edhoc_auth_cred_single_cert_mocked_init);
|
|
591
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
592
|
+
|
|
593
|
+
ret = edhoc_bind_credentials(resp_ctx,
|
|
594
|
+
&edhoc_auth_cred_single_cert_mocked_resp);
|
|
595
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
596
|
+
|
|
597
|
+
memset(buffer, 0, sizeof(buffer));
|
|
598
|
+
size_t msg_1_len = 0;
|
|
599
|
+
uint8_t *msg_1 = buffer;
|
|
600
|
+
|
|
601
|
+
/* EDHOC message 1 compose. */
|
|
602
|
+
ret = edhoc_message_1_compose(init_ctx, msg_1, ARRAY_SIZE(buffer),
|
|
603
|
+
&msg_1_len);
|
|
604
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
605
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_WAIT_M2, init_ctx->status);
|
|
606
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
607
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_INVALID, init_ctx->prk_state);
|
|
608
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_1, init_ctx->th_state);
|
|
609
|
+
|
|
610
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
611
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
612
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
613
|
+
|
|
614
|
+
/* EDHOC message 1 process. */
|
|
615
|
+
ret = edhoc_message_1_process(resp_ctx, msg_1, msg_1_len);
|
|
616
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
617
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_RECEIVED_M1, resp_ctx->status);
|
|
618
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
619
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_1, resp_ctx->th_state);
|
|
620
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_INVALID, resp_ctx->prk_state);
|
|
621
|
+
|
|
622
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
623
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
624
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
625
|
+
|
|
626
|
+
TEST_ASSERT_EQUAL(EDHOC_CID_TYPE_ONE_BYTE_INTEGER,
|
|
627
|
+
resp_ctx->peer_cid.encode_type);
|
|
628
|
+
TEST_ASSERT_EQUAL((int8_t)C_I[0], resp_ctx->peer_cid.int_value);
|
|
629
|
+
|
|
630
|
+
memset(buffer, 0, sizeof(buffer));
|
|
631
|
+
size_t msg_2_len = 0;
|
|
632
|
+
uint8_t *msg_2 = buffer;
|
|
633
|
+
|
|
634
|
+
/* EDHOC message 2 compose. */
|
|
635
|
+
ret = edhoc_message_2_compose(resp_ctx, msg_2, ARRAY_SIZE(buffer),
|
|
636
|
+
&msg_2_len);
|
|
637
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
638
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_WAIT_M3, resp_ctx->status);
|
|
639
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
640
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_3, resp_ctx->th_state);
|
|
641
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_3E2M, resp_ctx->prk_state);
|
|
642
|
+
|
|
643
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
644
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
645
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
646
|
+
|
|
647
|
+
/* EDHOC message 2 process. */
|
|
648
|
+
ret = edhoc_message_2_process(init_ctx, msg_2, msg_2_len);
|
|
649
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
650
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_VERIFIED_M2, init_ctx->status);
|
|
651
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
652
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_3, init_ctx->th_state);
|
|
653
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_3E2M, init_ctx->prk_state);
|
|
654
|
+
|
|
655
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
656
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
657
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
658
|
+
|
|
659
|
+
TEST_ASSERT_EQUAL(EDHOC_CID_TYPE_BYTE_STRING,
|
|
660
|
+
init_ctx->peer_cid.encode_type);
|
|
661
|
+
TEST_ASSERT_EQUAL(ARRAY_SIZE(C_R), init_ctx->peer_cid.bstr_length);
|
|
662
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(C_R, init_ctx->peer_cid.bstr_value,
|
|
663
|
+
init_ctx->peer_cid.bstr_length);
|
|
664
|
+
|
|
665
|
+
TEST_ASSERT_EQUAL(DH_KEY_AGREEMENT_LENGTH, init_ctx->dh_secret_len);
|
|
666
|
+
TEST_ASSERT_EQUAL(DH_KEY_AGREEMENT_LENGTH, resp_ctx->dh_secret_len);
|
|
667
|
+
TEST_ASSERT_EQUAL(init_ctx->dh_secret_len, resp_ctx->dh_secret_len);
|
|
668
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_ctx->dh_secret, resp_ctx->dh_secret,
|
|
669
|
+
DH_KEY_AGREEMENT_LENGTH);
|
|
670
|
+
|
|
671
|
+
memset(buffer, 0, sizeof(buffer));
|
|
672
|
+
size_t msg_3_len = 0;
|
|
673
|
+
uint8_t *msg_3 = buffer;
|
|
674
|
+
|
|
675
|
+
/* EDHOC message 3 compose. */
|
|
676
|
+
ret = edhoc_message_3_compose(init_ctx, msg_3, ARRAY_SIZE(buffer),
|
|
677
|
+
&msg_3_len);
|
|
678
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
679
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_COMPLETED, init_ctx->status);
|
|
680
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
681
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, init_ctx->th_state);
|
|
682
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, init_ctx->prk_state);
|
|
683
|
+
|
|
684
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
685
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
686
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
687
|
+
|
|
688
|
+
/* EDHOC message 3 process. */
|
|
689
|
+
ret = edhoc_message_3_process(resp_ctx, msg_3, msg_3_len);
|
|
690
|
+
|
|
691
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
692
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_COMPLETED, resp_ctx->status);
|
|
693
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
694
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, resp_ctx->th_state);
|
|
695
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, resp_ctx->prk_state);
|
|
696
|
+
|
|
697
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
698
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
699
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
700
|
+
|
|
701
|
+
memset(buffer, 0, sizeof(buffer));
|
|
702
|
+
size_t msg_4_len = 0;
|
|
703
|
+
uint8_t *msg_4 = buffer;
|
|
704
|
+
|
|
705
|
+
/* EDHOC message 4 compose. */
|
|
706
|
+
ret = edhoc_message_4_compose(resp_ctx, msg_4, ARRAY_SIZE(buffer),
|
|
707
|
+
&msg_4_len);
|
|
708
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
709
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
710
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
711
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, resp_ctx->th_state);
|
|
712
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, resp_ctx->prk_state);
|
|
713
|
+
|
|
714
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
715
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
716
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
717
|
+
|
|
718
|
+
/* EDHOC message 4 process. */
|
|
719
|
+
ret = edhoc_message_4_process(init_ctx, msg_4, msg_4_len);
|
|
720
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
721
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
722
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
723
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, init_ctx->th_state);
|
|
724
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, init_ctx->prk_state);
|
|
725
|
+
|
|
726
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
727
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
728
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
729
|
+
|
|
730
|
+
/* Derive OSCORE master secret and master salt. */
|
|
731
|
+
uint8_t init_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
732
|
+
uint8_t init_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
733
|
+
size_t init_sender_id_len = 0;
|
|
734
|
+
uint8_t init_sender_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
735
|
+
size_t init_recipient_id_len = 0;
|
|
736
|
+
uint8_t init_recipient_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
737
|
+
|
|
738
|
+
ret = edhoc_export_oscore_session(
|
|
739
|
+
init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
740
|
+
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
741
|
+
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
742
|
+
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
743
|
+
&init_recipient_id_len);
|
|
744
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
745
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
746
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
747
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
748
|
+
|
|
749
|
+
/* Derive OSCORE master secret and master salt. */
|
|
750
|
+
uint8_t resp_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
751
|
+
uint8_t resp_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
752
|
+
size_t resp_sender_id_len = 0;
|
|
753
|
+
uint8_t resp_sender_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
754
|
+
size_t resp_recipient_id_len = 0;
|
|
755
|
+
uint8_t resp_recipient_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
756
|
+
|
|
757
|
+
ret = edhoc_export_oscore_session(
|
|
758
|
+
resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
759
|
+
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
760
|
+
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
761
|
+
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
762
|
+
&resp_recipient_id_len);
|
|
763
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
764
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
765
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
766
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
767
|
+
|
|
768
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_secret, resp_master_secret,
|
|
769
|
+
ARRAY_SIZE(resp_master_secret));
|
|
770
|
+
|
|
771
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_salt, resp_master_salt,
|
|
772
|
+
ARRAY_SIZE(resp_master_salt));
|
|
773
|
+
|
|
774
|
+
TEST_ASSERT_EQUAL(init_sender_id_len, resp_recipient_id_len);
|
|
775
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_sender_id, resp_recipient_id,
|
|
776
|
+
init_sender_id_len);
|
|
777
|
+
TEST_ASSERT_EQUAL(init_recipient_id_len, resp_sender_id_len);
|
|
778
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_recipient_id, resp_sender_id,
|
|
779
|
+
resp_sender_id_len);
|
|
780
|
+
|
|
781
|
+
uint8_t entropy[ENTROPY_LENGTH] = { 0 };
|
|
782
|
+
ret = psa_generate_random(entropy, sizeof(entropy));
|
|
783
|
+
TEST_ASSERT_EQUAL(PSA_SUCCESS, ret);
|
|
784
|
+
|
|
785
|
+
/* EDHOC key update method. */
|
|
786
|
+
ret = edhoc_export_key_update(init_ctx, entropy, ARRAY_SIZE(entropy));
|
|
787
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
788
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
789
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
790
|
+
|
|
791
|
+
/* EDHOC key update method. */
|
|
792
|
+
ret = edhoc_export_key_update(resp_ctx, entropy, ARRAY_SIZE(entropy));
|
|
793
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
794
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
795
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
796
|
+
|
|
797
|
+
TEST_ASSERT_EQUAL(init_ctx->prk_state, resp_ctx->prk_state);
|
|
798
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
799
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
800
|
+
|
|
801
|
+
TEST_ASSERT_EQUAL(init_ctx->prk_len, resp_ctx->prk_len);
|
|
802
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_ctx->prk, resp_ctx->prk,
|
|
803
|
+
resp_ctx->prk_len);
|
|
804
|
+
|
|
805
|
+
/* Derive OSCORE master secret and master salt. */
|
|
806
|
+
memset(init_master_secret, 0, sizeof(init_master_secret));
|
|
807
|
+
memset(init_master_salt, 0, sizeof(init_master_salt));
|
|
808
|
+
init_sender_id_len = 0;
|
|
809
|
+
memset(init_sender_id, 0, sizeof(init_sender_id));
|
|
810
|
+
init_recipient_id_len = 0;
|
|
811
|
+
memset(init_recipient_id, 0, sizeof(init_recipient_id));
|
|
812
|
+
|
|
813
|
+
ret = edhoc_export_oscore_session(
|
|
814
|
+
init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
815
|
+
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
816
|
+
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
817
|
+
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
818
|
+
&init_recipient_id_len);
|
|
819
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
820
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
821
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
822
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
823
|
+
|
|
824
|
+
/* Derive OSCORE master secret and master salt. */
|
|
825
|
+
memset(resp_master_secret, 0, sizeof(resp_master_secret));
|
|
826
|
+
memset(resp_master_salt, 0, sizeof(resp_master_salt));
|
|
827
|
+
resp_sender_id_len = 0;
|
|
828
|
+
memset(resp_sender_id, 0, sizeof(resp_sender_id));
|
|
829
|
+
resp_recipient_id_len = 0;
|
|
830
|
+
memset(resp_recipient_id, 0, sizeof(resp_recipient_id));
|
|
831
|
+
|
|
832
|
+
ret = edhoc_export_oscore_session(
|
|
833
|
+
resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
834
|
+
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
835
|
+
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
836
|
+
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
837
|
+
&resp_recipient_id_len);
|
|
838
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
839
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
840
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
841
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
842
|
+
|
|
843
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_secret, resp_master_secret,
|
|
844
|
+
ARRAY_SIZE(resp_master_secret));
|
|
845
|
+
|
|
846
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_salt, resp_master_salt,
|
|
847
|
+
ARRAY_SIZE(resp_master_salt));
|
|
848
|
+
|
|
849
|
+
TEST_ASSERT_EQUAL(init_sender_id_len, resp_recipient_id_len);
|
|
850
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_sender_id, resp_recipient_id,
|
|
851
|
+
init_sender_id_len);
|
|
852
|
+
TEST_ASSERT_EQUAL(init_recipient_id_len, resp_sender_id_len);
|
|
853
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_recipient_id, resp_sender_id,
|
|
854
|
+
resp_sender_id_len);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
TEST(x5chain_sign_keys_suite_0, two_certs_in_chain)
|
|
858
|
+
{
|
|
859
|
+
uint8_t buffer[2000] = { 0 };
|
|
860
|
+
|
|
861
|
+
/* Required missing setup. */
|
|
862
|
+
ret = edhoc_bind_credentials(init_ctx,
|
|
863
|
+
&edhoc_auth_cred_many_certs_mocked_init);
|
|
864
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
865
|
+
|
|
866
|
+
ret = edhoc_bind_credentials(resp_ctx,
|
|
867
|
+
&edhoc_auth_cred_many_certs_mocked_resp);
|
|
868
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
869
|
+
|
|
870
|
+
memset(buffer, 0, sizeof(buffer));
|
|
871
|
+
size_t msg_1_len = 0;
|
|
872
|
+
uint8_t *msg_1 = buffer;
|
|
873
|
+
|
|
874
|
+
/* EDHOC message 1 compose. */
|
|
875
|
+
ret = edhoc_message_1_compose(init_ctx, msg_1, ARRAY_SIZE(buffer),
|
|
876
|
+
&msg_1_len);
|
|
877
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
878
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_WAIT_M2, init_ctx->status);
|
|
879
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
880
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_INVALID, init_ctx->prk_state);
|
|
881
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_1, init_ctx->th_state);
|
|
882
|
+
|
|
883
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
884
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
885
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* \brief EDHOC message 1 process.
|
|
889
|
+
*/
|
|
890
|
+
ret = edhoc_message_1_process(resp_ctx, msg_1, msg_1_len);
|
|
891
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
892
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_RECEIVED_M1, resp_ctx->status);
|
|
893
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
894
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_1, resp_ctx->th_state);
|
|
895
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_INVALID, resp_ctx->prk_state);
|
|
896
|
+
|
|
897
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
898
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
899
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
900
|
+
|
|
901
|
+
TEST_ASSERT_EQUAL(EDHOC_CID_TYPE_ONE_BYTE_INTEGER,
|
|
902
|
+
resp_ctx->peer_cid.encode_type);
|
|
903
|
+
TEST_ASSERT_EQUAL((int8_t)C_I[0], resp_ctx->peer_cid.int_value);
|
|
904
|
+
|
|
905
|
+
memset(buffer, 0, sizeof(buffer));
|
|
906
|
+
size_t msg_2_len = 0;
|
|
907
|
+
uint8_t *msg_2 = buffer;
|
|
908
|
+
|
|
909
|
+
/* EDHOC message 2 compose. */
|
|
910
|
+
ret = edhoc_message_2_compose(resp_ctx, msg_2, ARRAY_SIZE(buffer),
|
|
911
|
+
&msg_2_len);
|
|
912
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
913
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_WAIT_M3, resp_ctx->status);
|
|
914
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
915
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_3, resp_ctx->th_state);
|
|
916
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_3E2M, resp_ctx->prk_state);
|
|
917
|
+
|
|
918
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
919
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
920
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
921
|
+
|
|
922
|
+
/* EDHOC message 2 process. */
|
|
923
|
+
ret = edhoc_message_2_process(init_ctx, msg_2, msg_2_len);
|
|
924
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
925
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_VERIFIED_M2, init_ctx->status);
|
|
926
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
927
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_3, init_ctx->th_state);
|
|
928
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_3E2M, init_ctx->prk_state);
|
|
929
|
+
|
|
930
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
931
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
932
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
933
|
+
|
|
934
|
+
TEST_ASSERT_EQUAL(EDHOC_CID_TYPE_BYTE_STRING,
|
|
935
|
+
init_ctx->peer_cid.encode_type);
|
|
936
|
+
TEST_ASSERT_EQUAL(ARRAY_SIZE(C_R), init_ctx->peer_cid.bstr_length);
|
|
937
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(C_R, init_ctx->peer_cid.bstr_value,
|
|
938
|
+
init_ctx->peer_cid.bstr_length);
|
|
939
|
+
|
|
940
|
+
TEST_ASSERT_EQUAL(DH_KEY_AGREEMENT_LENGTH, init_ctx->dh_secret_len);
|
|
941
|
+
TEST_ASSERT_EQUAL(DH_KEY_AGREEMENT_LENGTH, resp_ctx->dh_secret_len);
|
|
942
|
+
TEST_ASSERT_EQUAL(init_ctx->dh_secret_len, resp_ctx->dh_secret_len);
|
|
943
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_ctx->dh_secret, resp_ctx->dh_secret,
|
|
944
|
+
DH_KEY_AGREEMENT_LENGTH);
|
|
945
|
+
|
|
946
|
+
memset(buffer, 0, sizeof(buffer));
|
|
947
|
+
size_t msg_3_len = 0;
|
|
948
|
+
uint8_t *msg_3 = buffer;
|
|
949
|
+
|
|
950
|
+
/* EDHOC message 3 compose. */
|
|
951
|
+
ret = edhoc_message_3_compose(init_ctx, msg_3, ARRAY_SIZE(buffer),
|
|
952
|
+
&msg_3_len);
|
|
953
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
954
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_COMPLETED, init_ctx->status);
|
|
955
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
956
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, init_ctx->th_state);
|
|
957
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, init_ctx->prk_state);
|
|
958
|
+
|
|
959
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
960
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
961
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
962
|
+
|
|
963
|
+
/* EDHOC message 3 process. */
|
|
964
|
+
ret = edhoc_message_3_process(resp_ctx, msg_3, msg_3_len);
|
|
965
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
966
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_COMPLETED, resp_ctx->status);
|
|
967
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
968
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, resp_ctx->th_state);
|
|
969
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, resp_ctx->prk_state);
|
|
970
|
+
|
|
971
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
972
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
973
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
974
|
+
|
|
975
|
+
memset(buffer, 0, sizeof(buffer));
|
|
976
|
+
size_t msg_4_len = 0;
|
|
977
|
+
uint8_t *msg_4 = buffer;
|
|
978
|
+
|
|
979
|
+
/* EDHOC message 4 compose. */
|
|
980
|
+
ret = edhoc_message_4_compose(resp_ctx, msg_4, ARRAY_SIZE(buffer),
|
|
981
|
+
&msg_4_len);
|
|
982
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
983
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
984
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
985
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, resp_ctx->th_state);
|
|
986
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, resp_ctx->prk_state);
|
|
987
|
+
|
|
988
|
+
ret = edhoc_error_get_code(resp_ctx, &error_code_recv);
|
|
989
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
990
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
991
|
+
|
|
992
|
+
/* EDHOC message 4 process. */
|
|
993
|
+
ret = edhoc_message_4_process(init_ctx, msg_4, msg_4_len);
|
|
994
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
995
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
996
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
997
|
+
TEST_ASSERT_EQUAL(EDHOC_TH_STATE_4, init_ctx->th_state);
|
|
998
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_4E3M, init_ctx->prk_state);
|
|
999
|
+
|
|
1000
|
+
ret = edhoc_error_get_code(init_ctx, &error_code_recv);
|
|
1001
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1002
|
+
TEST_ASSERT_EQUAL(EDHOC_ERROR_CODE_SUCCESS, error_code_recv);
|
|
1003
|
+
|
|
1004
|
+
/* Derive OSCORE master secret and master salt. */
|
|
1005
|
+
uint8_t init_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
1006
|
+
uint8_t init_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
1007
|
+
size_t init_sender_id_len = 0;
|
|
1008
|
+
uint8_t init_sender_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
1009
|
+
size_t init_recipient_id_len = 0;
|
|
1010
|
+
uint8_t init_recipient_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
1011
|
+
|
|
1012
|
+
ret = edhoc_export_oscore_session(
|
|
1013
|
+
init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
1014
|
+
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
1015
|
+
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
1016
|
+
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
1017
|
+
&init_recipient_id_len);
|
|
1018
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1019
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
1020
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
1021
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
1022
|
+
|
|
1023
|
+
/* Derive OSCORE master secret and master salt. */
|
|
1024
|
+
uint8_t resp_master_secret[OSCORE_MASTER_SECRET_LENGTH] = { 0 };
|
|
1025
|
+
uint8_t resp_master_salt[OSCORE_MASTER_SALT_LENGTH] = { 0 };
|
|
1026
|
+
size_t resp_sender_id_len = 0;
|
|
1027
|
+
uint8_t resp_sender_id[ARRAY_SIZE(C_I)] = { 0 };
|
|
1028
|
+
size_t resp_recipient_id_len = 0;
|
|
1029
|
+
uint8_t resp_recipient_id[ARRAY_SIZE(C_R)] = { 0 };
|
|
1030
|
+
|
|
1031
|
+
ret = edhoc_export_oscore_session(
|
|
1032
|
+
resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
1033
|
+
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
1034
|
+
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
1035
|
+
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
1036
|
+
&resp_recipient_id_len);
|
|
1037
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1038
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
1039
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
1040
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
1041
|
+
|
|
1042
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_secret, resp_master_secret,
|
|
1043
|
+
ARRAY_SIZE(resp_master_secret));
|
|
1044
|
+
|
|
1045
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_salt, resp_master_salt,
|
|
1046
|
+
ARRAY_SIZE(resp_master_salt));
|
|
1047
|
+
|
|
1048
|
+
TEST_ASSERT_EQUAL(init_sender_id_len, resp_recipient_id_len);
|
|
1049
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_sender_id, resp_recipient_id,
|
|
1050
|
+
init_sender_id_len);
|
|
1051
|
+
TEST_ASSERT_EQUAL(init_recipient_id_len, resp_sender_id_len);
|
|
1052
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_recipient_id, resp_sender_id,
|
|
1053
|
+
resp_sender_id_len);
|
|
1054
|
+
|
|
1055
|
+
uint8_t entropy[ENTROPY_LENGTH] = { 0 };
|
|
1056
|
+
ret = psa_generate_random(entropy, sizeof(entropy));
|
|
1057
|
+
TEST_ASSERT_EQUAL(PSA_SUCCESS, ret);
|
|
1058
|
+
|
|
1059
|
+
/* EDHOC key update method. */
|
|
1060
|
+
ret = edhoc_export_key_update(init_ctx, entropy, ARRAY_SIZE(entropy));
|
|
1061
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1062
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
1063
|
+
TEST_ASSERT_EQUAL(true, init_ctx->is_oscore_export_allowed);
|
|
1064
|
+
|
|
1065
|
+
/* EDHOC key update method. */
|
|
1066
|
+
ret = edhoc_export_key_update(resp_ctx, entropy, ARRAY_SIZE(entropy));
|
|
1067
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1068
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
1069
|
+
TEST_ASSERT_EQUAL(true, resp_ctx->is_oscore_export_allowed);
|
|
1070
|
+
|
|
1071
|
+
TEST_ASSERT_EQUAL(init_ctx->prk_state, resp_ctx->prk_state);
|
|
1072
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
1073
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
1074
|
+
|
|
1075
|
+
TEST_ASSERT_EQUAL(init_ctx->prk_len, resp_ctx->prk_len);
|
|
1076
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_ctx->prk, resp_ctx->prk,
|
|
1077
|
+
resp_ctx->prk_len);
|
|
1078
|
+
|
|
1079
|
+
/* Derive OSCORE master secret and master salt. */
|
|
1080
|
+
memset(init_master_secret, 0, sizeof(init_master_secret));
|
|
1081
|
+
memset(init_master_salt, 0, sizeof(init_master_salt));
|
|
1082
|
+
init_sender_id_len = 0;
|
|
1083
|
+
memset(init_sender_id, 0, sizeof(init_sender_id));
|
|
1084
|
+
init_recipient_id_len = 0;
|
|
1085
|
+
memset(init_recipient_id, 0, sizeof(init_recipient_id));
|
|
1086
|
+
|
|
1087
|
+
ret = edhoc_export_oscore_session(
|
|
1088
|
+
init_ctx, init_master_secret, ARRAY_SIZE(init_master_secret),
|
|
1089
|
+
init_master_salt, ARRAY_SIZE(init_master_salt), init_sender_id,
|
|
1090
|
+
ARRAY_SIZE(init_sender_id), &init_sender_id_len,
|
|
1091
|
+
init_recipient_id, ARRAY_SIZE(init_recipient_id),
|
|
1092
|
+
&init_recipient_id_len);
|
|
1093
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1094
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, init_ctx->status);
|
|
1095
|
+
TEST_ASSERT_EQUAL(false, init_ctx->is_oscore_export_allowed);
|
|
1096
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, init_ctx->prk_state);
|
|
1097
|
+
|
|
1098
|
+
/* Derive OSCORE master secret and master salt. */
|
|
1099
|
+
memset(resp_master_secret, 0, sizeof(resp_master_secret));
|
|
1100
|
+
memset(resp_master_salt, 0, sizeof(resp_master_salt));
|
|
1101
|
+
resp_sender_id_len = 0;
|
|
1102
|
+
memset(resp_sender_id, 0, sizeof(resp_sender_id));
|
|
1103
|
+
resp_recipient_id_len = 0;
|
|
1104
|
+
memset(resp_recipient_id, 0, sizeof(resp_recipient_id));
|
|
1105
|
+
|
|
1106
|
+
ret = edhoc_export_oscore_session(
|
|
1107
|
+
resp_ctx, resp_master_secret, ARRAY_SIZE(resp_master_secret),
|
|
1108
|
+
resp_master_salt, ARRAY_SIZE(resp_master_salt), resp_sender_id,
|
|
1109
|
+
ARRAY_SIZE(resp_sender_id), &resp_sender_id_len,
|
|
1110
|
+
resp_recipient_id, ARRAY_SIZE(resp_recipient_id),
|
|
1111
|
+
&resp_recipient_id_len);
|
|
1112
|
+
TEST_ASSERT_EQUAL(EDHOC_SUCCESS, ret);
|
|
1113
|
+
TEST_ASSERT_EQUAL(EDHOC_SM_PERSISTED, resp_ctx->status);
|
|
1114
|
+
TEST_ASSERT_EQUAL(false, resp_ctx->is_oscore_export_allowed);
|
|
1115
|
+
TEST_ASSERT_EQUAL(EDHOC_PRK_STATE_OUT, resp_ctx->prk_state);
|
|
1116
|
+
|
|
1117
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_secret, resp_master_secret,
|
|
1118
|
+
ARRAY_SIZE(resp_master_secret));
|
|
1119
|
+
|
|
1120
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_master_salt, resp_master_salt,
|
|
1121
|
+
ARRAY_SIZE(resp_master_salt));
|
|
1122
|
+
|
|
1123
|
+
TEST_ASSERT_EQUAL(init_sender_id_len, resp_recipient_id_len);
|
|
1124
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_sender_id, resp_recipient_id,
|
|
1125
|
+
init_sender_id_len);
|
|
1126
|
+
TEST_ASSERT_EQUAL(init_recipient_id_len, resp_sender_id_len);
|
|
1127
|
+
TEST_ASSERT_EQUAL_UINT8_ARRAY(init_recipient_id, resp_sender_id,
|
|
1128
|
+
resp_sender_id_len);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
TEST_GROUP_RUNNER(x5chain_sign_keys_suite_0)
|
|
1132
|
+
{
|
|
1133
|
+
RUN_TEST_CASE(x5chain_sign_keys_suite_0, one_cert_in_chain);
|
|
1134
|
+
RUN_TEST_CASE(x5chain_sign_keys_suite_0, two_certs_in_chain);
|
|
1135
|
+
}
|