edhoc 1.0.5 → 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/crypto.d.ts +9 -2
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +112 -84
- package/dist/edhoc.d.ts +31 -9
- package/dist/edhoc.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/dist/credentials.d.ts +0 -16
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js +0 -84
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* \file test_cipher_suite_2.c
|
|
3
|
-
* \author Kamil Kielbasa
|
|
4
|
-
* \brief Unit tests for cipher suite 2.
|
|
5
|
-
* \version 0.4
|
|
6
|
-
* \date 2024-01-01
|
|
7
|
-
*
|
|
8
|
-
* \copyright Copyright (c) 2024
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/* Include files ----------------------------------------------------------- */
|
|
13
|
-
|
|
14
|
-
/* Internal test header: */
|
|
15
|
-
#include "cipher_suites/cipher_suite_2.h"
|
|
16
|
-
#include "cipher_suites/test_cipher_suite_2.h"
|
|
17
|
-
|
|
18
|
-
/* Standard library headers: */
|
|
19
|
-
#include <stdio.h>
|
|
20
|
-
#include <stdint.h>
|
|
21
|
-
#include <stddef.h>
|
|
22
|
-
#include <string.h>
|
|
23
|
-
#include <assert.h>
|
|
24
|
-
|
|
25
|
-
/* EDHOC headers: */
|
|
26
|
-
#include "edhoc_crypto.h"
|
|
27
|
-
#include "edhoc_values.h"
|
|
28
|
-
#include "edhoc_macros.h"
|
|
29
|
-
|
|
30
|
-
/* PSA crypto header: */
|
|
31
|
-
#include <psa/crypto.h>
|
|
32
|
-
|
|
33
|
-
/* Module defines ---------------------------------------------------------- */
|
|
34
|
-
#define INPUT_TO_SIGN_LEN ((size_t)128)
|
|
35
|
-
|
|
36
|
-
/* Module types and type definitiones -------------------------------------- */
|
|
37
|
-
/* Module interface variables and constants -------------------------------- */
|
|
38
|
-
/* Static variables and constants ------------------------------------------ */
|
|
39
|
-
|
|
40
|
-
static const struct edhoc_keys keys = {
|
|
41
|
-
.generate_key = cipher_suite_2_key_generate,
|
|
42
|
-
.destroy_key = cipher_suite_2_key_destroy,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
static const struct edhoc_crypto crypto = {
|
|
46
|
-
.make_key_pair = cipher_suite_2_make_key_pair,
|
|
47
|
-
.key_agreement = cipher_suite_2_key_agreement,
|
|
48
|
-
.signature = cipher_suite_2_signature,
|
|
49
|
-
.verify = cipher_suite_2_verify,
|
|
50
|
-
.extract = cipher_suite_2_extract,
|
|
51
|
-
.expand = cipher_suite_2_expand,
|
|
52
|
-
.encrypt = cipher_suite_2_encrypt,
|
|
53
|
-
.decrypt = cipher_suite_2_decrypt,
|
|
54
|
-
.hash = cipher_suite_2_hash,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/* Static function declarations -------------------------------------------- */
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* \brief Helper function for printing arrays.
|
|
61
|
-
*/
|
|
62
|
-
static inline void print_array(const char *name, const uint8_t *buffer,
|
|
63
|
-
size_t buffer_length);
|
|
64
|
-
|
|
65
|
-
/* Static function definitions --------------------------------------------- */
|
|
66
|
-
|
|
67
|
-
static inline void print_array(const char *name, const uint8_t *buffer,
|
|
68
|
-
size_t buffer_length)
|
|
69
|
-
{
|
|
70
|
-
printf("%s:\tLEN( %zu )\n", name, buffer_length);
|
|
71
|
-
|
|
72
|
-
for (size_t i = 0; i < buffer_length; ++i) {
|
|
73
|
-
if (0 == i % 16 && i > 0) {
|
|
74
|
-
printf("\n");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
printf("%02x ", buffer[i]);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
printf("\n\n");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/* Module interface function definitions ----------------------------------- */
|
|
84
|
-
|
|
85
|
-
void test_cipher_suite_2_ecdsa(void)
|
|
86
|
-
{
|
|
87
|
-
int ret = PSA_ERROR_GENERIC_ERROR;
|
|
88
|
-
psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
|
|
89
|
-
|
|
90
|
-
const struct edhoc_keys *edhoc_keys = &keys;
|
|
91
|
-
const struct edhoc_crypto *edhoc_crypto = &crypto;
|
|
92
|
-
|
|
93
|
-
const uint8_t priv_key[ECC_COMP_KEY_LEN] = {
|
|
94
|
-
0xfb, 0x13, 0xad, 0xeb, 0x65, 0x18, 0xce, 0xe5,
|
|
95
|
-
0xf8, 0x84, 0x17, 0x66, 0x08, 0x41, 0x14, 0x2e,
|
|
96
|
-
0x83, 0x0a, 0x81, 0xfe, 0x33, 0x43, 0x80, 0xa9,
|
|
97
|
-
0x53, 0x40, 0x6a, 0x13, 0x05, 0xe8, 0x70, 0x6b,
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const uint8_t pub_key[ECC_UNCOMP_KEY_LEN] = {
|
|
101
|
-
0x04,
|
|
102
|
-
|
|
103
|
-
0xac, 0x75, 0xe9, 0xec, 0xe3, 0xe5, 0x0b, 0xfc,
|
|
104
|
-
0x8e, 0xd6, 0x03, 0x99, 0x88, 0x95, 0x22, 0x40,
|
|
105
|
-
0x5c, 0x47, 0xbf, 0x16, 0xdf, 0x96, 0x66, 0x0a,
|
|
106
|
-
0x41, 0x29, 0x8c, 0xb4, 0x30, 0x7f, 0x7e, 0xb6,
|
|
107
|
-
|
|
108
|
-
0x6e, 0x5d, 0xe6, 0x11, 0x38, 0x8a, 0x4b, 0x8a,
|
|
109
|
-
0x82, 0x11, 0x33, 0x4a, 0xc7, 0xd3, 0x7e, 0xcb,
|
|
110
|
-
0x52, 0xa3, 0x87, 0xd2, 0x57, 0xe6, 0xdb, 0x3c,
|
|
111
|
-
0x2a, 0x93, 0xdf, 0x21, 0xff, 0x3a, 0xff, 0xc8,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* \brief Random input for signature.
|
|
116
|
-
*/
|
|
117
|
-
uint8_t input[INPUT_TO_SIGN_LEN] = { 0 };
|
|
118
|
-
ret = psa_generate_random(input, ARRAY_SIZE(input));
|
|
119
|
-
assert(PSA_SUCCESS == ret);
|
|
120
|
-
|
|
121
|
-
print_array("Input for signature", input, ARRAY_SIZE(input));
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* \brief Generate signature.
|
|
125
|
-
*/
|
|
126
|
-
size_t sign_len = 0;
|
|
127
|
-
uint8_t sign[ECC_ECDSA_SIGN_LEN] = { 0 };
|
|
128
|
-
|
|
129
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_SIGNATURE, priv_key,
|
|
130
|
-
ARRAY_SIZE(priv_key), &key_id);
|
|
131
|
-
assert(EDHOC_SUCCESS == ret);
|
|
132
|
-
|
|
133
|
-
ret = edhoc_crypto->signature(NULL, &key_id, input, ARRAY_SIZE(input),
|
|
134
|
-
sign, ARRAY_SIZE(sign), &sign_len);
|
|
135
|
-
assert(EDHOC_SUCCESS == ret);
|
|
136
|
-
|
|
137
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
138
|
-
assert(EDHOC_SUCCESS == ret);
|
|
139
|
-
|
|
140
|
-
print_array("Signature", sign, sign_len);
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* \brief Verify signature.
|
|
144
|
-
*/
|
|
145
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_VERIFY, pub_key,
|
|
146
|
-
ARRAY_SIZE(pub_key), &key_id);
|
|
147
|
-
assert(EDHOC_SUCCESS == ret);
|
|
148
|
-
|
|
149
|
-
ret = edhoc_crypto->verify(NULL, &key_id, input, ARRAY_SIZE(input),
|
|
150
|
-
sign, sign_len);
|
|
151
|
-
assert(EDHOC_SUCCESS == ret);
|
|
152
|
-
|
|
153
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
154
|
-
assert(EDHOC_SUCCESS == ret);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
void test_cipher_suite_2_ecdh(void)
|
|
158
|
-
{
|
|
159
|
-
int ret = PSA_ERROR_GENERIC_ERROR;
|
|
160
|
-
psa_key_id_t key_id_a = PSA_KEY_HANDLE_INIT;
|
|
161
|
-
psa_key_id_t key_id_b = PSA_KEY_HANDLE_INIT;
|
|
162
|
-
|
|
163
|
-
const struct edhoc_keys *edhoc_keys = &keys;
|
|
164
|
-
const struct edhoc_crypto *edhoc_crypto = &crypto;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* \brief Alice ECDH public and private keys.
|
|
168
|
-
*/
|
|
169
|
-
size_t priv_key_len_a = 0;
|
|
170
|
-
uint8_t priv_key_a[ECC_COMP_KEY_LEN] = { 0 };
|
|
171
|
-
|
|
172
|
-
size_t pub_key_len_a = 0;
|
|
173
|
-
uint8_t pub_key_a[ECC_COMP_KEY_LEN] = { 0 };
|
|
174
|
-
|
|
175
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_MAKE_KEY_PAIR, NULL, 0,
|
|
176
|
-
&key_id_a);
|
|
177
|
-
assert(EDHOC_SUCCESS == ret);
|
|
178
|
-
|
|
179
|
-
ret = edhoc_crypto->make_key_pair(NULL, &key_id_a, priv_key_a,
|
|
180
|
-
ARRAY_SIZE(priv_key_a),
|
|
181
|
-
&priv_key_len_a, pub_key_a,
|
|
182
|
-
ARRAY_SIZE(pub_key_a),
|
|
183
|
-
&pub_key_len_a);
|
|
184
|
-
assert(EDHOC_SUCCESS == ret);
|
|
185
|
-
assert(ARRAY_SIZE(priv_key_a) == priv_key_len_a);
|
|
186
|
-
assert(ARRAY_SIZE(pub_key_a) == pub_key_len_a);
|
|
187
|
-
|
|
188
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id_a);
|
|
189
|
-
assert(EDHOC_SUCCESS == ret);
|
|
190
|
-
|
|
191
|
-
print_array("Alice private key", priv_key_a, ARRAY_SIZE(priv_key_a));
|
|
192
|
-
print_array("Alice public key", pub_key_a, ARRAY_SIZE(pub_key_a));
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* \brief Bob ECDH public and private keys.
|
|
196
|
-
*/
|
|
197
|
-
size_t priv_key_len_b = 0;
|
|
198
|
-
uint8_t priv_key_b[ECC_COMP_KEY_LEN] = { 0 };
|
|
199
|
-
|
|
200
|
-
size_t pub_key_len_b = 0;
|
|
201
|
-
uint8_t pub_key_b[ECC_COMP_KEY_LEN] = { 0 };
|
|
202
|
-
|
|
203
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_MAKE_KEY_PAIR, NULL, 0,
|
|
204
|
-
&key_id_b);
|
|
205
|
-
assert(EDHOC_SUCCESS == ret);
|
|
206
|
-
|
|
207
|
-
ret = edhoc_crypto->make_key_pair(NULL, &key_id_b, priv_key_b,
|
|
208
|
-
ARRAY_SIZE(priv_key_b),
|
|
209
|
-
&priv_key_len_b, pub_key_b,
|
|
210
|
-
ARRAY_SIZE(pub_key_b),
|
|
211
|
-
&pub_key_len_b);
|
|
212
|
-
assert(EDHOC_SUCCESS == ret);
|
|
213
|
-
assert(ARRAY_SIZE(priv_key_b) == priv_key_len_b);
|
|
214
|
-
assert(ARRAY_SIZE(pub_key_b) == pub_key_len_b);
|
|
215
|
-
|
|
216
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id_b);
|
|
217
|
-
assert(EDHOC_SUCCESS == ret);
|
|
218
|
-
|
|
219
|
-
print_array("Bob private key", priv_key_b, ARRAY_SIZE(priv_key_b));
|
|
220
|
-
print_array("Bob public key", pub_key_b, ARRAY_SIZE(pub_key_b));
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* \brief Shared secret for Alice:
|
|
224
|
-
* - Alice ECDH private key.
|
|
225
|
-
* - Bob ECDH public key.
|
|
226
|
-
*/
|
|
227
|
-
size_t shr_sec_len_a = 0;
|
|
228
|
-
uint8_t shr_sec_a[ECC_ECDH_KEY_AGREEMENT_LEN] = { 0 };
|
|
229
|
-
|
|
230
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_KEY_AGREEMENT, priv_key_a,
|
|
231
|
-
priv_key_len_a, &key_id_a);
|
|
232
|
-
assert(EDHOC_SUCCESS == ret);
|
|
233
|
-
|
|
234
|
-
ret = edhoc_crypto->key_agreement(NULL, &key_id_a, pub_key_b,
|
|
235
|
-
pub_key_len_b, shr_sec_a,
|
|
236
|
-
ARRAY_SIZE(shr_sec_a),
|
|
237
|
-
&shr_sec_len_a);
|
|
238
|
-
assert(EDHOC_SUCCESS == ret);
|
|
239
|
-
assert(ARRAY_SIZE(shr_sec_a) == shr_sec_len_a);
|
|
240
|
-
|
|
241
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id_a);
|
|
242
|
-
assert(EDHOC_SUCCESS == ret);
|
|
243
|
-
|
|
244
|
-
print_array("Alice shared secret", shr_sec_a, shr_sec_len_a);
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* \brief Shared secret for Bob:
|
|
248
|
-
* - Bob ECDH private key.
|
|
249
|
-
* - Alice ECDH public key.
|
|
250
|
-
*/
|
|
251
|
-
size_t shr_sec_len_b = 0;
|
|
252
|
-
uint8_t shr_sec_b[ECC_ECDH_KEY_AGREEMENT_LEN] = { 0 };
|
|
253
|
-
|
|
254
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_KEY_AGREEMENT, priv_key_b,
|
|
255
|
-
priv_key_len_b, &key_id_b);
|
|
256
|
-
assert(EDHOC_SUCCESS == ret);
|
|
257
|
-
|
|
258
|
-
ret = edhoc_crypto->key_agreement(NULL, &key_id_b, pub_key_a,
|
|
259
|
-
pub_key_len_a, shr_sec_b,
|
|
260
|
-
ARRAY_SIZE(shr_sec_b),
|
|
261
|
-
&shr_sec_len_b);
|
|
262
|
-
assert(EDHOC_SUCCESS == ret);
|
|
263
|
-
assert(ARRAY_SIZE(shr_sec_b) == shr_sec_len_b);
|
|
264
|
-
|
|
265
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id_b);
|
|
266
|
-
assert(PSA_SUCCESS == ret);
|
|
267
|
-
|
|
268
|
-
print_array("Bob shared secret", shr_sec_b, shr_sec_len_b);
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* \brief Compare if Alice and Bob has the same shared secrets.
|
|
272
|
-
*/
|
|
273
|
-
assert(shr_sec_len_a == shr_sec_len_b);
|
|
274
|
-
assert(0 == memcmp(shr_sec_a, shr_sec_b, shr_sec_len_a));
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* \brief Compare if Alice and Bob has not the same ECDH keys.
|
|
278
|
-
*/
|
|
279
|
-
assert(priv_key_len_a == priv_key_len_b);
|
|
280
|
-
assert(0 != memcmp(priv_key_a, priv_key_b, priv_key_len_a));
|
|
281
|
-
|
|
282
|
-
assert(pub_key_len_a == pub_key_len_b);
|
|
283
|
-
assert(0 != memcmp(pub_key_a, pub_key_b, pub_key_len_a));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
void test_cipher_suite_2_hkdf(void)
|
|
287
|
-
{
|
|
288
|
-
int ret = PSA_ERROR_GENERIC_ERROR;
|
|
289
|
-
psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
|
|
290
|
-
|
|
291
|
-
const struct edhoc_keys *edhoc_keys = &keys;
|
|
292
|
-
const struct edhoc_crypto *edhoc_crypto = &crypto;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* \brief Test vectors taken from RFC 5869: A.1. Test Case 1.
|
|
296
|
-
*/
|
|
297
|
-
const uint8_t ikm[] = {
|
|
298
|
-
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
|
|
299
|
-
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
|
|
300
|
-
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const uint8_t salt[] = {
|
|
304
|
-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
|
305
|
-
0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
const uint8_t info[] = {
|
|
309
|
-
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
const size_t L = 42;
|
|
313
|
-
|
|
314
|
-
const uint8_t prk[] = {
|
|
315
|
-
0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf,
|
|
316
|
-
0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
|
|
317
|
-
0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31,
|
|
318
|
-
0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5,
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const uint8_t okm[] = {
|
|
322
|
-
0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90,
|
|
323
|
-
0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d,
|
|
324
|
-
0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, 0x5d, 0xb0, 0x2d,
|
|
325
|
-
0x56, 0xec, 0xc4, 0xc5, 0xbf, 0x34, 0x00, 0x72, 0x08,
|
|
326
|
-
0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65,
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* \brief HDFK extract part.
|
|
331
|
-
*/
|
|
332
|
-
size_t comp_prk_len = 0;
|
|
333
|
-
uint8_t comp_prk[32] = { 0 };
|
|
334
|
-
|
|
335
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_EXTRACT, ikm,
|
|
336
|
-
ARRAY_SIZE(ikm), &key_id);
|
|
337
|
-
assert(EDHOC_SUCCESS == ret);
|
|
338
|
-
|
|
339
|
-
ret = edhoc_crypto->extract(NULL, &key_id, salt, ARRAY_SIZE(salt),
|
|
340
|
-
comp_prk, ARRAY_SIZE(comp_prk),
|
|
341
|
-
&comp_prk_len);
|
|
342
|
-
assert(EDHOC_SUCCESS == ret);
|
|
343
|
-
assert(ARRAY_SIZE(comp_prk) == comp_prk_len);
|
|
344
|
-
|
|
345
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
346
|
-
assert(EDHOC_SUCCESS == ret);
|
|
347
|
-
|
|
348
|
-
assert(comp_prk_len == ARRAY_SIZE(prk));
|
|
349
|
-
assert(0 == memcmp(comp_prk, prk, comp_prk_len));
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* \brief HDFK expand part.
|
|
353
|
-
*/
|
|
354
|
-
uint8_t comp_okm[L];
|
|
355
|
-
memset(comp_okm, 0, sizeof(comp_okm));
|
|
356
|
-
|
|
357
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_EXPAND, comp_prk,
|
|
358
|
-
ARRAY_SIZE(comp_prk), &key_id);
|
|
359
|
-
assert(EDHOC_SUCCESS == ret);
|
|
360
|
-
|
|
361
|
-
ret = edhoc_crypto->expand(NULL, &key_id, info, ARRAY_SIZE(info),
|
|
362
|
-
comp_okm, ARRAY_SIZE(comp_okm));
|
|
363
|
-
assert(EDHOC_SUCCESS == ret);
|
|
364
|
-
|
|
365
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
366
|
-
assert(EDHOC_SUCCESS == ret);
|
|
367
|
-
|
|
368
|
-
assert(0 == memcmp(comp_okm, okm, ARRAY_SIZE(okm)));
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
void test_cipher_suite_2_aead(void)
|
|
372
|
-
{
|
|
373
|
-
int ret = PSA_ERROR_GENERIC_ERROR;
|
|
374
|
-
psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
|
|
375
|
-
|
|
376
|
-
const struct edhoc_keys *edhoc_keys = &keys;
|
|
377
|
-
const struct edhoc_crypto *edhoc_crypto = &crypto;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* \brief AEAD key, iv and aad.
|
|
381
|
-
*/
|
|
382
|
-
const uint8_t key[16] = {
|
|
383
|
-
0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
|
|
384
|
-
};
|
|
385
|
-
const uint8_t iv[13] = {
|
|
386
|
-
0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2,
|
|
387
|
-
};
|
|
388
|
-
const uint8_t aad[4] = {
|
|
389
|
-
0,
|
|
390
|
-
1,
|
|
391
|
-
2,
|
|
392
|
-
3,
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* \brief AEAD encryption.
|
|
397
|
-
*/
|
|
398
|
-
const uint8_t ptxt[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
|
399
|
-
|
|
400
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_ENCRYPT, key,
|
|
401
|
-
ARRAY_SIZE(key), &key_id);
|
|
402
|
-
assert(EDHOC_SUCCESS == ret);
|
|
403
|
-
|
|
404
|
-
size_t ctxt_len = 0;
|
|
405
|
-
uint8_t ctxt[18] = { 0 };
|
|
406
|
-
ret = edhoc_crypto->encrypt(NULL, &key_id, iv, ARRAY_SIZE(iv), aad,
|
|
407
|
-
ARRAY_SIZE(aad), ptxt, ARRAY_SIZE(ptxt),
|
|
408
|
-
ctxt, ARRAY_SIZE(ctxt), &ctxt_len);
|
|
409
|
-
assert(EDHOC_SUCCESS == ret);
|
|
410
|
-
assert(ARRAY_SIZE(ctxt) == ctxt_len);
|
|
411
|
-
|
|
412
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
413
|
-
assert(EDHOC_SUCCESS == ret);
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* \brief AEAD decryption.
|
|
417
|
-
*/
|
|
418
|
-
size_t dec_ctxt_len = 0;
|
|
419
|
-
uint8_t dec_ctxt[ARRAY_SIZE(ptxt)] = { 0 };
|
|
420
|
-
|
|
421
|
-
ret = edhoc_keys->generate_key(NULL, EDHOC_KT_DECRYPT, key,
|
|
422
|
-
ARRAY_SIZE(key), &key_id);
|
|
423
|
-
assert(EDHOC_SUCCESS == ret);
|
|
424
|
-
|
|
425
|
-
ret = edhoc_crypto->decrypt(NULL, &key_id, iv, ARRAY_SIZE(iv), aad,
|
|
426
|
-
ARRAY_SIZE(aad), ctxt, ctxt_len, dec_ctxt,
|
|
427
|
-
ARRAY_SIZE(dec_ctxt), &dec_ctxt_len);
|
|
428
|
-
assert(EDHOC_SUCCESS == ret);
|
|
429
|
-
assert(ARRAY_SIZE(ptxt) == dec_ctxt_len);
|
|
430
|
-
|
|
431
|
-
ret = edhoc_keys->destroy_key(NULL, &key_id);
|
|
432
|
-
assert(EDHOC_SUCCESS == ret);
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* \brief Verify if plaintext is equal to decrypted ciphertext.
|
|
436
|
-
*/
|
|
437
|
-
assert(0 == memcmp(ptxt, dec_ctxt, ARRAY_SIZE(ptxt)));
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
void test_cipher_suite_2_hash(void)
|
|
441
|
-
{
|
|
442
|
-
int ret = PSA_ERROR_GENERIC_ERROR;
|
|
443
|
-
|
|
444
|
-
const struct edhoc_crypto *edhoc_crypto = &crypto;
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* \brief Input for hash function and expected hash.
|
|
448
|
-
*/
|
|
449
|
-
const uint8_t input[] = { 'A' };
|
|
450
|
-
|
|
451
|
-
const uint8_t exp_hash[32] = {
|
|
452
|
-
0x55, 0x9a, 0xea, 0xd0, 0x82, 0x64, 0xd5, 0x79,
|
|
453
|
-
0x5d, 0x39, 0x09, 0x71, 0x8c, 0xdd, 0x05, 0xab,
|
|
454
|
-
0xd4, 0x95, 0x72, 0xe8, 0x4f, 0xe5, 0x55, 0x90,
|
|
455
|
-
0xee, 0xf3, 0x1a, 0x88, 0xa0, 0x8f, 0xdf, 0xfd,
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* \brief Hash operation.
|
|
460
|
-
*/
|
|
461
|
-
size_t hash_len = 0;
|
|
462
|
-
uint8_t hash[32] = { 0 };
|
|
463
|
-
|
|
464
|
-
ret = edhoc_crypto->hash(NULL, input, ARRAY_SIZE(input), hash,
|
|
465
|
-
ARRAY_SIZE(hash), &hash_len);
|
|
466
|
-
assert(EDHOC_SUCCESS == ret);
|
|
467
|
-
assert(ARRAY_SIZE(hash) == hash_len);
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* \brief Verify if hashes are equals.
|
|
471
|
-
*/
|
|
472
|
-
assert(0 == memcmp(hash, exp_hash, ARRAY_SIZE(exp_hash)));
|
|
473
|
-
}
|