edhoc 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +10 -0
- package/dist/crypto.d.ts +29 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +205 -0
- package/dist/edhoc.d.ts +368 -0
- package/dist/edhoc.d.ts.map +1 -0
- package/dist/edhoc.js +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -1,447 +1,445 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* \file cipher_suite_0.c
|
|
3
|
-
* \author Kamil Kielbasa
|
|
4
|
-
* \brief Example implementation of cipher suite 0.
|
|
5
|
-
* \version 0.
|
|
6
|
-
* \date 2024-
|
|
7
|
-
*
|
|
8
|
-
* \copyright Copyright (c) 2024
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/* Include files ----------------------------------------------------------- */
|
|
13
|
-
|
|
14
|
-
/* Internal test header: */
|
|
15
|
-
#include "
|
|
16
|
-
|
|
17
|
-
/* Standard library header: */
|
|
18
|
-
#include <stdint.h>
|
|
19
|
-
#include <stddef.h>
|
|
20
|
-
#include <string.h>
|
|
21
|
-
|
|
22
|
-
/* EDHOC headers: */
|
|
23
|
-
#include "edhoc_crypto.h"
|
|
24
|
-
#include "edhoc_values.h"
|
|
25
|
-
#include "edhoc_macros.h"
|
|
26
|
-
|
|
27
|
-
/* PSA crypto header: */
|
|
28
|
-
#include <psa/crypto.h>
|
|
29
|
-
|
|
30
|
-
/* Compact25519 crypto headers: */
|
|
31
|
-
#include <c25519/c25519.h>
|
|
32
|
-
#include <compact_x25519.h>
|
|
33
|
-
#include <compact_ed25519.h>
|
|
34
|
-
|
|
35
|
-
/* Module defines ---------------------------------------------------------- */
|
|
36
|
-
#define AEAD_TAG_LEN (8)
|
|
37
|
-
#define AEAD_KEY_LEN (16)
|
|
38
|
-
|
|
39
|
-
/* Module types and type definitiones -------------------------------------- */
|
|
40
|
-
/* Module interface variables and constants -------------------------------- */
|
|
41
|
-
/* Static variables and constants ------------------------------------------ */
|
|
42
|
-
/* Static function declarations -------------------------------------------- */
|
|
43
|
-
/* Static function definitions --------------------------------------------- */
|
|
44
|
-
|
|
45
|
-
/* Module interface function definitions ----------------------------------- */
|
|
46
|
-
|
|
47
|
-
int
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
(void)user_ctx;
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
* 1. Generate key attr
|
|
55
|
-
*/
|
|
56
|
-
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
57
|
-
psa_set_key_lifetime(&attr, PSA_KEY_LIFETIME_VOLATILE);
|
|
58
|
-
|
|
59
|
-
switch (key_type) {
|
|
60
|
-
case EDHOC_KT_MAKE_KEY_PAIR:
|
|
61
|
-
return EDHOC_SUCCESS;
|
|
62
|
-
|
|
63
|
-
case EDHOC_KT_KEY_AGREEMENT:
|
|
64
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
65
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
66
|
-
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(X25519_SHARED_SIZE));
|
|
67
|
-
break;
|
|
68
|
-
|
|
69
|
-
case EDHOC_KT_SIGNATURE:
|
|
70
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
71
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
72
|
-
psa_set_key_bits(&attr,
|
|
73
|
-
PSA_BYTES_TO_BITS(ED25519_PRIVATE_KEY_SIZE));
|
|
74
|
-
break;
|
|
75
|
-
|
|
76
|
-
case EDHOC_KT_VERIFY:
|
|
77
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
78
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
79
|
-
psa_set_key_bits(&attr,
|
|
80
|
-
PSA_BYTES_TO_BITS(ED25519_PUBLIC_KEY_SIZE));
|
|
81
|
-
break;
|
|
82
|
-
|
|
83
|
-
case EDHOC_KT_EXTRACT:
|
|
84
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DERIVE);
|
|
85
|
-
psa_set_key_algorithm(&attr,
|
|
86
|
-
PSA_ALG_HKDF_EXTRACT(PSA_ALG_SHA_256));
|
|
87
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_DERIVE);
|
|
88
|
-
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(raw_key_len));
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
case EDHOC_KT_EXPAND:
|
|
92
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DERIVE);
|
|
93
|
-
psa_set_key_algorithm(&attr,
|
|
94
|
-
PSA_ALG_HKDF_EXPAND(PSA_ALG_SHA_256));
|
|
95
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_DERIVE);
|
|
96
|
-
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(raw_key_len));
|
|
97
|
-
break;
|
|
98
|
-
|
|
99
|
-
case EDHOC_KT_ENCRYPT:
|
|
100
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_ENCRYPT);
|
|
101
|
-
psa_set_key_algorithm(
|
|
102
|
-
&attr, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM,
|
|
103
|
-
AEAD_TAG_LEN));
|
|
104
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_AES);
|
|
105
|
-
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(AEAD_KEY_LEN));
|
|
106
|
-
break;
|
|
107
|
-
|
|
108
|
-
case EDHOC_KT_DECRYPT:
|
|
109
|
-
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DECRYPT);
|
|
110
|
-
psa_set_key_algorithm(
|
|
111
|
-
&attr, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM,
|
|
112
|
-
AEAD_TAG_LEN));
|
|
113
|
-
psa_set_key_type(&attr, PSA_KEY_TYPE_AES);
|
|
114
|
-
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(AEAD_KEY_LEN));
|
|
115
|
-
break;
|
|
116
|
-
|
|
117
|
-
default:
|
|
118
|
-
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/*
|
|
122
|
-
* 2. Import key identifier
|
|
123
|
-
*/
|
|
124
|
-
psa_key_id_t *psa_kid = kid;
|
|
125
|
-
*psa_kid = PSA_KEY_HANDLE_INIT;
|
|
126
|
-
|
|
127
|
-
const psa_status_t ret =
|
|
128
|
-
psa_import_key(&attr, raw_key, raw_key_len, psa_kid);
|
|
129
|
-
|
|
130
|
-
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
131
|
-
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
int cipher_suite_0_key_destroy(void *user_ctx, void *kid)
|
|
135
|
-
{
|
|
136
|
-
(void)user_ctx;
|
|
137
|
-
|
|
138
|
-
if (NULL == kid)
|
|
139
|
-
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
140
|
-
|
|
141
|
-
psa_key_id_t *psa_kid = kid;
|
|
142
|
-
const psa_status_t ret = psa_destroy_key(*psa_kid);
|
|
143
|
-
*psa_kid = PSA_KEY_HANDLE_INIT;
|
|
144
|
-
|
|
145
|
-
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
146
|
-
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
int cipher_suite_0_make_key_pair(void *user_ctx, const void *kid,
|
|
150
|
-
uint8_t *
|
|
151
|
-
size_t
|
|
152
|
-
size_t *
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const uint8_t *
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
const uint8_t *
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
447
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* \file cipher_suite_0.c
|
|
3
|
+
* \author Kamil Kielbasa
|
|
4
|
+
* \brief Example implementation of cipher suite 0.
|
|
5
|
+
* \version 0.6
|
|
6
|
+
* \date 2024-08-05
|
|
7
|
+
*
|
|
8
|
+
* \copyright Copyright (c) 2024
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* Include files ----------------------------------------------------------- */
|
|
13
|
+
|
|
14
|
+
/* Internal test header: */
|
|
15
|
+
#include "cipher_suite_0.h"
|
|
16
|
+
|
|
17
|
+
/* Standard library header: */
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
#include <stddef.h>
|
|
20
|
+
#include <string.h>
|
|
21
|
+
|
|
22
|
+
/* EDHOC headers: */
|
|
23
|
+
#include "edhoc_crypto.h"
|
|
24
|
+
#include "edhoc_values.h"
|
|
25
|
+
#include "edhoc_macros.h"
|
|
26
|
+
|
|
27
|
+
/* PSA crypto header: */
|
|
28
|
+
#include <psa/crypto.h>
|
|
29
|
+
|
|
30
|
+
/* Compact25519 crypto headers: */
|
|
31
|
+
#include <c25519/c25519.h>
|
|
32
|
+
#include <compact_x25519.h>
|
|
33
|
+
#include <compact_ed25519.h>
|
|
34
|
+
|
|
35
|
+
/* Module defines ---------------------------------------------------------- */
|
|
36
|
+
#define AEAD_TAG_LEN (8)
|
|
37
|
+
#define AEAD_KEY_LEN (16)
|
|
38
|
+
|
|
39
|
+
/* Module types and type definitiones -------------------------------------- */
|
|
40
|
+
/* Module interface variables and constants -------------------------------- */
|
|
41
|
+
/* Static variables and constants ------------------------------------------ */
|
|
42
|
+
/* Static function declarations -------------------------------------------- */
|
|
43
|
+
/* Static function definitions --------------------------------------------- */
|
|
44
|
+
|
|
45
|
+
/* Module interface function definitions ----------------------------------- */
|
|
46
|
+
|
|
47
|
+
int cipher_suite_0_key_import(void *user_ctx, enum edhoc_key_type key_type,
|
|
48
|
+
const uint8_t *raw_key, size_t raw_key_len,
|
|
49
|
+
void *kid)
|
|
50
|
+
{
|
|
51
|
+
(void)user_ctx;
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* 1. Generate key attr
|
|
55
|
+
*/
|
|
56
|
+
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
57
|
+
psa_set_key_lifetime(&attr, PSA_KEY_LIFETIME_VOLATILE);
|
|
58
|
+
|
|
59
|
+
switch (key_type) {
|
|
60
|
+
case EDHOC_KT_MAKE_KEY_PAIR:
|
|
61
|
+
return EDHOC_SUCCESS;
|
|
62
|
+
|
|
63
|
+
case EDHOC_KT_KEY_AGREEMENT:
|
|
64
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
65
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
66
|
+
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(X25519_SHARED_SIZE));
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
case EDHOC_KT_SIGNATURE:
|
|
70
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
71
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
72
|
+
psa_set_key_bits(&attr,
|
|
73
|
+
PSA_BYTES_TO_BITS(ED25519_PRIVATE_KEY_SIZE));
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case EDHOC_KT_VERIFY:
|
|
77
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_EXPORT);
|
|
78
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_RAW_DATA);
|
|
79
|
+
psa_set_key_bits(&attr,
|
|
80
|
+
PSA_BYTES_TO_BITS(ED25519_PUBLIC_KEY_SIZE));
|
|
81
|
+
break;
|
|
82
|
+
|
|
83
|
+
case EDHOC_KT_EXTRACT:
|
|
84
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DERIVE);
|
|
85
|
+
psa_set_key_algorithm(&attr,
|
|
86
|
+
PSA_ALG_HKDF_EXTRACT(PSA_ALG_SHA_256));
|
|
87
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_DERIVE);
|
|
88
|
+
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(raw_key_len));
|
|
89
|
+
break;
|
|
90
|
+
|
|
91
|
+
case EDHOC_KT_EXPAND:
|
|
92
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DERIVE);
|
|
93
|
+
psa_set_key_algorithm(&attr,
|
|
94
|
+
PSA_ALG_HKDF_EXPAND(PSA_ALG_SHA_256));
|
|
95
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_DERIVE);
|
|
96
|
+
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(raw_key_len));
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case EDHOC_KT_ENCRYPT:
|
|
100
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_ENCRYPT);
|
|
101
|
+
psa_set_key_algorithm(
|
|
102
|
+
&attr, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM,
|
|
103
|
+
AEAD_TAG_LEN));
|
|
104
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_AES);
|
|
105
|
+
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(AEAD_KEY_LEN));
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case EDHOC_KT_DECRYPT:
|
|
109
|
+
psa_set_key_usage_flags(&attr, PSA_KEY_USAGE_DECRYPT);
|
|
110
|
+
psa_set_key_algorithm(
|
|
111
|
+
&attr, PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM,
|
|
112
|
+
AEAD_TAG_LEN));
|
|
113
|
+
psa_set_key_type(&attr, PSA_KEY_TYPE_AES);
|
|
114
|
+
psa_set_key_bits(&attr, PSA_BYTES_TO_BITS(AEAD_KEY_LEN));
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
default:
|
|
118
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* 2. Import key identifier
|
|
123
|
+
*/
|
|
124
|
+
psa_key_id_t *psa_kid = kid;
|
|
125
|
+
*psa_kid = PSA_KEY_HANDLE_INIT;
|
|
126
|
+
|
|
127
|
+
const psa_status_t ret =
|
|
128
|
+
psa_import_key(&attr, raw_key, raw_key_len, psa_kid);
|
|
129
|
+
|
|
130
|
+
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
131
|
+
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
int cipher_suite_0_key_destroy(void *user_ctx, void *kid)
|
|
135
|
+
{
|
|
136
|
+
(void)user_ctx;
|
|
137
|
+
|
|
138
|
+
if (NULL == kid)
|
|
139
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
140
|
+
|
|
141
|
+
psa_key_id_t *psa_kid = kid;
|
|
142
|
+
const psa_status_t ret = psa_destroy_key(*psa_kid);
|
|
143
|
+
*psa_kid = PSA_KEY_HANDLE_INIT;
|
|
144
|
+
|
|
145
|
+
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
146
|
+
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
int cipher_suite_0_make_key_pair(void *user_ctx, const void *kid,
|
|
150
|
+
uint8_t *priv_key, size_t priv_key_size,
|
|
151
|
+
size_t *priv_key_len, uint8_t *pub_key,
|
|
152
|
+
size_t pub_key_size, size_t *pub_key_len)
|
|
153
|
+
{
|
|
154
|
+
(void)user_ctx;
|
|
155
|
+
|
|
156
|
+
if (NULL == kid || NULL == priv_key || 0 == priv_key_size ||
|
|
157
|
+
NULL == priv_key_len || NULL == pub_key || 0 == pub_key_size ||
|
|
158
|
+
NULL == pub_key_len)
|
|
159
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
160
|
+
|
|
161
|
+
if (X25519_KEY_SIZE != priv_key_size || X25519_KEY_SIZE != pub_key_size)
|
|
162
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
163
|
+
|
|
164
|
+
uint8_t seed[X25519_KEY_SIZE] = { 0 };
|
|
165
|
+
const psa_status_t ret = psa_generate_random(seed, sizeof(seed));
|
|
166
|
+
|
|
167
|
+
if (PSA_SUCCESS != ret)
|
|
168
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
169
|
+
|
|
170
|
+
compact_x25519_keygen(priv_key, pub_key, seed);
|
|
171
|
+
*priv_key_len = X25519_KEY_SIZE;
|
|
172
|
+
*pub_key_len = X25519_KEY_SIZE;
|
|
173
|
+
|
|
174
|
+
return EDHOC_SUCCESS;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
int cipher_suite_0_key_agreement(void *user_ctx, const void *kid,
|
|
178
|
+
const uint8_t *peer_pub_key,
|
|
179
|
+
size_t peer_pub_key_len, uint8_t *shr_sec,
|
|
180
|
+
size_t shr_sec_size, size_t *shr_sec_len)
|
|
181
|
+
{
|
|
182
|
+
(void)user_ctx;
|
|
183
|
+
|
|
184
|
+
if (NULL == kid || NULL == peer_pub_key || 0 == peer_pub_key_len ||
|
|
185
|
+
NULL == shr_sec || 0 == shr_sec_size || NULL == shr_sec_len)
|
|
186
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
187
|
+
|
|
188
|
+
if (X25519_KEY_SIZE != peer_pub_key_len ||
|
|
189
|
+
X25519_SHARED_SIZE != shr_sec_size)
|
|
190
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
191
|
+
|
|
192
|
+
size_t priv_key_len = 0;
|
|
193
|
+
uint8_t priv_key[X25519_KEY_SIZE] = { 0 };
|
|
194
|
+
|
|
195
|
+
const psa_key_id_t *psa_kid = kid;
|
|
196
|
+
const psa_status_t ret = psa_export_key(
|
|
197
|
+
*psa_kid, priv_key, ARRAY_SIZE(priv_key), &priv_key_len);
|
|
198
|
+
|
|
199
|
+
if (PSA_SUCCESS != ret || ARRAY_SIZE(priv_key) != priv_key_len)
|
|
200
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
201
|
+
|
|
202
|
+
uint8_t e[F25519_SIZE] = { 0 };
|
|
203
|
+
f25519_copy(e, priv_key);
|
|
204
|
+
c25519_prepare(e);
|
|
205
|
+
c25519_smult(shr_sec, peer_pub_key, e);
|
|
206
|
+
|
|
207
|
+
*shr_sec_len = X25519_SHARED_SIZE;
|
|
208
|
+
|
|
209
|
+
return EDHOC_SUCCESS;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
int cipher_suite_0_signature(void *user_ctx, const void *kid,
|
|
213
|
+
const uint8_t *input, size_t input_len,
|
|
214
|
+
uint8_t *sign, size_t sign_size, size_t *sign_len)
|
|
215
|
+
{
|
|
216
|
+
(void)user_ctx;
|
|
217
|
+
|
|
218
|
+
if (NULL == kid || NULL == input || 0 == input_len || NULL == sign ||
|
|
219
|
+
0 == sign_size || NULL == sign_len)
|
|
220
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
221
|
+
|
|
222
|
+
if (ED25519_SIGNATURE_SIZE != sign_size)
|
|
223
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
224
|
+
|
|
225
|
+
size_t priv_key_len = 0;
|
|
226
|
+
uint8_t priv_key[ED25519_PRIVATE_KEY_SIZE] = { 0 };
|
|
227
|
+
|
|
228
|
+
const psa_key_id_t *psa_kid = kid;
|
|
229
|
+
const psa_status_t ret = psa_export_key(
|
|
230
|
+
*psa_kid, priv_key, ARRAY_SIZE(priv_key), &priv_key_len);
|
|
231
|
+
|
|
232
|
+
if (PSA_SUCCESS != ret || ARRAY_SIZE(priv_key) != priv_key_len)
|
|
233
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
234
|
+
|
|
235
|
+
compact_ed25519_sign(sign, priv_key, input, input_len);
|
|
236
|
+
*sign_len = ED25519_SIGNATURE_SIZE;
|
|
237
|
+
|
|
238
|
+
return EDHOC_SUCCESS;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
int cipher_suite_0_verify(void *user_ctx, const void *kid, const uint8_t *input,
|
|
242
|
+
size_t input_len, const uint8_t *sign,
|
|
243
|
+
size_t sign_len)
|
|
244
|
+
{
|
|
245
|
+
(void)user_ctx;
|
|
246
|
+
|
|
247
|
+
if (NULL == kid || NULL == input || 0 == input_len || NULL == sign ||
|
|
248
|
+
0 == sign_len)
|
|
249
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
250
|
+
|
|
251
|
+
if (ED25519_SIGNATURE_SIZE != sign_len)
|
|
252
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
253
|
+
|
|
254
|
+
size_t pub_key_len = 0;
|
|
255
|
+
uint8_t pub_key[ED25519_PUBLIC_KEY_SIZE] = { 0 };
|
|
256
|
+
|
|
257
|
+
const psa_key_id_t *psa_kid = kid;
|
|
258
|
+
const psa_status_t ret = psa_export_key(
|
|
259
|
+
*psa_kid, pub_key, ARRAY_SIZE(pub_key), &pub_key_len);
|
|
260
|
+
|
|
261
|
+
if (PSA_SUCCESS != ret || ARRAY_SIZE(pub_key) != pub_key_len)
|
|
262
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
263
|
+
|
|
264
|
+
const bool verified =
|
|
265
|
+
compact_ed25519_verify(sign, pub_key, input, input_len);
|
|
266
|
+
|
|
267
|
+
return (true == verified) ? EDHOC_SUCCESS : EDHOC_ERROR_CRYPTO_FAILURE;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
int cipher_suite_0_extract(void *user_ctx, const void *kid, const uint8_t *salt,
|
|
271
|
+
size_t salt_len, uint8_t *prk, size_t prk_size,
|
|
272
|
+
size_t *prk_len)
|
|
273
|
+
{
|
|
274
|
+
(void)user_ctx;
|
|
275
|
+
|
|
276
|
+
if (NULL == kid || NULL == salt || 0 == salt_len || NULL == prk ||
|
|
277
|
+
0 == prk_size || NULL == prk_len)
|
|
278
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
279
|
+
|
|
280
|
+
psa_status_t ret = PSA_ERROR_GENERIC_ERROR;
|
|
281
|
+
|
|
282
|
+
const psa_key_id_t *psa_kid = kid;
|
|
283
|
+
psa_key_derivation_operation_t ctx = PSA_KEY_DERIVATION_OPERATION_INIT;
|
|
284
|
+
|
|
285
|
+
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
286
|
+
ret = psa_get_key_attributes(*psa_kid, &attr);
|
|
287
|
+
if (PSA_SUCCESS != ret)
|
|
288
|
+
goto psa_error;
|
|
289
|
+
|
|
290
|
+
ret = psa_key_derivation_setup(&ctx, psa_get_key_algorithm(&attr));
|
|
291
|
+
if (PSA_SUCCESS != ret)
|
|
292
|
+
goto psa_error;
|
|
293
|
+
|
|
294
|
+
ret = psa_key_derivation_input_bytes(
|
|
295
|
+
&ctx, PSA_KEY_DERIVATION_INPUT_SALT, salt, salt_len);
|
|
296
|
+
if (PSA_SUCCESS != ret)
|
|
297
|
+
goto psa_error;
|
|
298
|
+
|
|
299
|
+
ret = psa_key_derivation_input_key(
|
|
300
|
+
&ctx, PSA_KEY_DERIVATION_INPUT_SECRET, *psa_kid);
|
|
301
|
+
if (PSA_SUCCESS != ret)
|
|
302
|
+
goto psa_error;
|
|
303
|
+
|
|
304
|
+
ret = psa_key_derivation_set_capacity(&ctx, prk_size);
|
|
305
|
+
if (PSA_SUCCESS != ret)
|
|
306
|
+
goto psa_error;
|
|
307
|
+
|
|
308
|
+
ret = psa_key_derivation_output_bytes(&ctx, prk, prk_size);
|
|
309
|
+
if (PSA_SUCCESS != ret)
|
|
310
|
+
goto psa_error;
|
|
311
|
+
|
|
312
|
+
*prk_len = prk_size;
|
|
313
|
+
psa_key_derivation_abort(&ctx);
|
|
314
|
+
|
|
315
|
+
return EDHOC_SUCCESS;
|
|
316
|
+
|
|
317
|
+
psa_error:
|
|
318
|
+
psa_key_derivation_abort(&ctx);
|
|
319
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
int cipher_suite_0_expand(void *user_ctx, const void *kid, const uint8_t *info,
|
|
323
|
+
size_t info_len, uint8_t *okm, size_t okm_len)
|
|
324
|
+
{
|
|
325
|
+
(void)user_ctx;
|
|
326
|
+
|
|
327
|
+
if (NULL == kid || NULL == info || 0 == info_len || NULL == okm ||
|
|
328
|
+
0 == okm_len)
|
|
329
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
330
|
+
|
|
331
|
+
psa_status_t ret = PSA_ERROR_GENERIC_ERROR;
|
|
332
|
+
|
|
333
|
+
const psa_key_id_t *psa_kid = kid;
|
|
334
|
+
psa_key_derivation_operation_t ctx = PSA_KEY_DERIVATION_OPERATION_INIT;
|
|
335
|
+
|
|
336
|
+
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
337
|
+
ret = psa_get_key_attributes(*psa_kid, &attr);
|
|
338
|
+
if (PSA_SUCCESS != ret)
|
|
339
|
+
goto psa_error;
|
|
340
|
+
|
|
341
|
+
ret = psa_key_derivation_setup(&ctx, psa_get_key_algorithm(&attr));
|
|
342
|
+
if (PSA_SUCCESS != ret)
|
|
343
|
+
goto psa_error;
|
|
344
|
+
|
|
345
|
+
ret = psa_key_derivation_input_key(
|
|
346
|
+
&ctx, PSA_KEY_DERIVATION_INPUT_SECRET, *psa_kid);
|
|
347
|
+
if (PSA_SUCCESS != ret)
|
|
348
|
+
goto psa_error;
|
|
349
|
+
|
|
350
|
+
ret = psa_key_derivation_input_bytes(
|
|
351
|
+
&ctx, PSA_KEY_DERIVATION_INPUT_INFO, info, info_len);
|
|
352
|
+
if (PSA_SUCCESS != ret)
|
|
353
|
+
goto psa_error;
|
|
354
|
+
|
|
355
|
+
ret = psa_key_derivation_set_capacity(&ctx, okm_len);
|
|
356
|
+
if (PSA_SUCCESS != ret)
|
|
357
|
+
goto psa_error;
|
|
358
|
+
|
|
359
|
+
ret = psa_key_derivation_output_bytes(&ctx, okm, okm_len);
|
|
360
|
+
if (PSA_SUCCESS != ret)
|
|
361
|
+
goto psa_error;
|
|
362
|
+
|
|
363
|
+
psa_key_derivation_abort(&ctx);
|
|
364
|
+
return EDHOC_SUCCESS;
|
|
365
|
+
|
|
366
|
+
psa_error:
|
|
367
|
+
psa_key_derivation_abort(&ctx);
|
|
368
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
int cipher_suite_0_encrypt(void *user_ctx, const void *kid,
|
|
372
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
373
|
+
const uint8_t *ad, size_t ad_len,
|
|
374
|
+
const uint8_t *ptxt, size_t ptxt_len, uint8_t *ctxt,
|
|
375
|
+
size_t ctxt_size, size_t *ctxt_len)
|
|
376
|
+
{
|
|
377
|
+
(void)user_ctx;
|
|
378
|
+
|
|
379
|
+
/* Plaintext might be zero length buffer. */
|
|
380
|
+
if (NULL == kid || NULL == nonce || 0 == nonce_len || NULL == ad ||
|
|
381
|
+
0 == ad_len || NULL == ctxt || 0 == ctxt_size || NULL == ctxt_len)
|
|
382
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
383
|
+
|
|
384
|
+
psa_status_t ret = PSA_ERROR_GENERIC_ERROR;
|
|
385
|
+
const psa_key_id_t *psa_kid = kid;
|
|
386
|
+
|
|
387
|
+
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
388
|
+
ret = psa_get_key_attributes(*psa_kid, &attr);
|
|
389
|
+
|
|
390
|
+
if (PSA_SUCCESS != ret)
|
|
391
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
392
|
+
|
|
393
|
+
ret = psa_aead_encrypt(*psa_kid, psa_get_key_algorithm(&attr), nonce,
|
|
394
|
+
nonce_len, ad, ad_len, ptxt, ptxt_len, ctxt,
|
|
395
|
+
ctxt_size, ctxt_len);
|
|
396
|
+
|
|
397
|
+
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
398
|
+
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
int cipher_suite_0_decrypt(void *user_ctx, const void *kid,
|
|
402
|
+
const uint8_t *nonce, size_t nonce_len,
|
|
403
|
+
const uint8_t *ad, size_t ad_len,
|
|
404
|
+
const uint8_t *ctxt, size_t ctxt_len, uint8_t *ptxt,
|
|
405
|
+
size_t ptxt_size, size_t *ptxt_len)
|
|
406
|
+
{
|
|
407
|
+
(void)user_ctx;
|
|
408
|
+
|
|
409
|
+
/* Plaintext might be zero length buffer. */
|
|
410
|
+
if (NULL == kid || NULL == nonce || 0 == nonce_len || NULL == ad ||
|
|
411
|
+
0 == ad_len || NULL == ctxt || 0 == ctxt_len || NULL == ptxt_len)
|
|
412
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
413
|
+
|
|
414
|
+
psa_status_t ret = PSA_ERROR_GENERIC_ERROR;
|
|
415
|
+
const psa_key_id_t *psa_kid = kid;
|
|
416
|
+
|
|
417
|
+
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
418
|
+
ret = psa_get_key_attributes(*psa_kid, &attr);
|
|
419
|
+
|
|
420
|
+
if (PSA_SUCCESS != ret)
|
|
421
|
+
return EDHOC_ERROR_CRYPTO_FAILURE;
|
|
422
|
+
|
|
423
|
+
ret = psa_aead_decrypt(*psa_kid, psa_get_key_algorithm(&attr), nonce,
|
|
424
|
+
nonce_len, ad, ad_len, ctxt, ctxt_len, ptxt,
|
|
425
|
+
ptxt_size, ptxt_len);
|
|
426
|
+
|
|
427
|
+
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
428
|
+
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
int cipher_suite_0_hash(void *user_ctx, const uint8_t *input, size_t input_len,
|
|
432
|
+
uint8_t *hash, size_t hash_size, size_t *hash_len)
|
|
433
|
+
{
|
|
434
|
+
(void)user_ctx;
|
|
435
|
+
|
|
436
|
+
if (NULL == input || 0 == input_len || NULL == hash || 0 == hash_size ||
|
|
437
|
+
NULL == hash_len)
|
|
438
|
+
return EDHOC_ERROR_INVALID_ARGUMENT;
|
|
439
|
+
|
|
440
|
+
const psa_status_t ret = psa_hash_compute(
|
|
441
|
+
PSA_ALG_SHA_256, input, input_len, hash, hash_size, hash_len);
|
|
442
|
+
|
|
443
|
+
return (PSA_SUCCESS == ret) ? EDHOC_SUCCESS :
|
|
444
|
+
EDHOC_ERROR_CRYPTO_FAILURE;
|
|
445
|
+
}
|