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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define EDHOC_COMPOSE_ASYNC_WORKER_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
7
8
|
extern "C" {
|
|
@@ -22,16 +23,11 @@ class EdhocComposeAsyncWorker : public Napi::AsyncWorker {
|
|
|
22
23
|
/**
|
|
23
24
|
* @brief Constructor for EdhocComposeAsyncWorker.
|
|
24
25
|
* @param env The Napi::Env object.
|
|
25
|
-
* @param deferred The deferred promise object.
|
|
26
26
|
* @param context The EDHOC context.
|
|
27
27
|
* @param messageNumber The message number.
|
|
28
28
|
* @param callback The callback function.
|
|
29
29
|
*/
|
|
30
|
-
EdhocComposeAsyncWorker(Napi::Env& env,
|
|
31
|
-
Napi::Promise::Deferred deferred,
|
|
32
|
-
struct edhoc_context& context,
|
|
33
|
-
int messageNumber,
|
|
34
|
-
CallbackType callback);
|
|
30
|
+
EdhocComposeAsyncWorker(Napi::Env& env, struct edhoc_context& context, int messageNumber, CallbackType callback);
|
|
35
31
|
|
|
36
32
|
/**
|
|
37
33
|
* @brief Executes the asynchronous worker task.
|
|
@@ -50,6 +46,12 @@ class EdhocComposeAsyncWorker : public Napi::AsyncWorker {
|
|
|
50
46
|
*/
|
|
51
47
|
void OnError(const Napi::Error& error) override;
|
|
52
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @brief Returns the promise object.
|
|
51
|
+
* @return The promise object.
|
|
52
|
+
*/
|
|
53
|
+
Napi::Promise GetPromise();
|
|
54
|
+
|
|
53
55
|
private:
|
|
54
56
|
Napi::Promise::Deferred deferred; ///< The deferred promise object.
|
|
55
57
|
struct edhoc_context& context; ///< The EDHOC context.
|
|
@@ -39,8 +39,7 @@ class EdhocCredentialManager {
|
|
|
39
39
|
* fetched credentials.
|
|
40
40
|
* @return EDHOC_SUCCESS if successful, otherwise an error code.
|
|
41
41
|
*/
|
|
42
|
-
static int FetchCredentials(void* user_context,
|
|
43
|
-
struct edhoc_auth_creds* credentials);
|
|
42
|
+
static int FetchCredentials(void* user_context, struct edhoc_auth_creds* credentials);
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* @brief Static function to verify the credentials.
|
|
@@ -63,8 +62,7 @@ class EdhocCredentialManager {
|
|
|
63
62
|
* fetched credentials.
|
|
64
63
|
* @return EDHOC_SUCCESS if successful, otherwise an error code.
|
|
65
64
|
*/
|
|
66
|
-
int callFetchCredentials(const void* user_context,
|
|
67
|
-
struct edhoc_auth_creds* credentials);
|
|
65
|
+
int callFetchCredentials(const void* user_context, struct edhoc_auth_creds* credentials);
|
|
68
66
|
|
|
69
67
|
/**
|
|
70
68
|
* @brief Calls the VerifyCredentials function.
|
|
@@ -80,14 +78,21 @@ class EdhocCredentialManager {
|
|
|
80
78
|
const uint8_t** public_key_reference,
|
|
81
79
|
size_t* public_key_length);
|
|
82
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @brief Sets up the async functions.
|
|
83
|
+
*/
|
|
84
|
+
void SetupAsyncFunctions();
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @brief Releases the async functions.
|
|
88
|
+
*/
|
|
89
|
+
void CleanupAsyncFunctions();
|
|
90
|
+
|
|
83
91
|
private:
|
|
84
|
-
std::vector<Napi::Reference<Napi::Object>>
|
|
85
|
-
|
|
86
|
-
Napi::
|
|
87
|
-
Napi::ThreadSafeFunction
|
|
88
|
-
fetchTsfn; ///< Thread-safe function for FetchCredentials
|
|
89
|
-
Napi::ThreadSafeFunction
|
|
90
|
-
verifyTsfn; ///< Thread-safe function for VerifyCredentials
|
|
92
|
+
std::vector<Napi::Reference<Napi::Object>> credentialReferences; ///< References to the JS objects
|
|
93
|
+
Napi::ObjectReference credentialManagerRef; ///< Reference to the JS object
|
|
94
|
+
Napi::ThreadSafeFunction fetchTsfn; ///< Thread-safe function for FetchCredentials
|
|
95
|
+
Napi::ThreadSafeFunction verifyTsfn; ///< Thread-safe function for VerifyCredentials
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* @brief Assosciates the thread-safe function with the JS object function.
|
|
@@ -43,20 +43,20 @@ class EdhocCryptoManager {
|
|
|
43
43
|
~EdhocCryptoManager();
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* @brief
|
|
46
|
+
* @brief Import a key.
|
|
47
47
|
*
|
|
48
48
|
* @param user_context The user context.
|
|
49
|
-
* @param key_type The type of the key to
|
|
49
|
+
* @param key_type The type of the key to import.
|
|
50
50
|
* @param raw_key The raw key data.
|
|
51
51
|
* @param raw_key_length The length of the raw key data.
|
|
52
|
-
* @param key_id The
|
|
52
|
+
* @param key_id The imported key ID.
|
|
53
53
|
* @return int The result code.
|
|
54
54
|
*/
|
|
55
|
-
static int
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
static int ImportKey(void* user_context,
|
|
56
|
+
enum edhoc_key_type key_type,
|
|
57
|
+
const uint8_t* raw_key,
|
|
58
|
+
size_t raw_key_length,
|
|
59
|
+
void* key_id);
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @brief Destroy a key.
|
|
@@ -263,20 +263,20 @@ class EdhocCryptoManager {
|
|
|
263
263
|
size_t* hash_length);
|
|
264
264
|
|
|
265
265
|
/**
|
|
266
|
-
* @brief Calls the
|
|
266
|
+
* @brief Calls the ImportKey function.
|
|
267
267
|
*
|
|
268
268
|
* @param user_context The user context.
|
|
269
|
-
* @param key_type The type of the key to
|
|
269
|
+
* @param key_type The type of the key to import.
|
|
270
270
|
* @param raw_key The raw key data.
|
|
271
271
|
* @param raw_key_length The length of the raw key data.
|
|
272
|
-
* @param key_id The
|
|
272
|
+
* @param key_id The imported key ID.
|
|
273
273
|
* @return int The result code.
|
|
274
274
|
*/
|
|
275
|
-
int
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
int callImportKey(const void* user_context,
|
|
276
|
+
enum edhoc_key_type key_type,
|
|
277
|
+
const uint8_t* raw_key,
|
|
278
|
+
size_t raw_key_length,
|
|
279
|
+
void* key_id);
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* @brief Calls the DestroyKey function.
|
|
@@ -481,17 +481,24 @@ class EdhocCryptoManager {
|
|
|
481
481
|
uint8_t* hash,
|
|
482
482
|
size_t hash_size,
|
|
483
483
|
size_t* hash_length);
|
|
484
|
+
/**
|
|
485
|
+
* @brief Sets up the async functions.
|
|
486
|
+
*/
|
|
487
|
+
void SetupAsyncFunctions();
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* @brief Releases the async functions.
|
|
491
|
+
*/
|
|
492
|
+
void CleanupAsyncFunctions();
|
|
484
493
|
|
|
485
494
|
private:
|
|
486
495
|
Napi::ObjectReference cryptoManagerRef; ///< Reference to the JS object
|
|
487
496
|
|
|
488
|
-
std::vector<Napi::Reference<Napi::Buffer<uint8_t>>>
|
|
489
|
-
bufferReferences; ///< References to the JS buffers
|
|
497
|
+
std::vector<Napi::Reference<Napi::Buffer<uint8_t>>> bufferReferences; ///< References to the JS buffers
|
|
490
498
|
|
|
491
499
|
/* Thread-safe functions */
|
|
492
|
-
Napi::ThreadSafeFunction
|
|
493
|
-
|
|
494
|
-
encryptTsfn, decryptTsfn, hashTsfn;
|
|
500
|
+
Napi::ThreadSafeFunction importTsfn, destroyTsfn, makeKeyPairTsfn, keyAgreementTsfn, signTsfn, verifyTsfn,
|
|
501
|
+
extractTsfn, expandTsfn, encryptTsfn, decryptTsfn, hashTsfn;
|
|
495
502
|
|
|
496
503
|
/**
|
|
497
504
|
* @brief Assosciates the thread-safe function with the JS object function.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define EDHOC_EAD_MANAGER_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <map>
|
|
6
7
|
#include <vector>
|
|
7
8
|
|
|
@@ -50,9 +51,7 @@ class EdhocEadManager {
|
|
|
50
51
|
* @param label The label associated with the EAD.
|
|
51
52
|
* @param ead The EAD data to be stored.
|
|
52
53
|
*/
|
|
53
|
-
void StoreEad(enum edhoc_message message,
|
|
54
|
-
int label,
|
|
55
|
-
const std::vector<uint8_t>& ead);
|
|
54
|
+
void StoreEad(enum edhoc_message message, int label, const std::vector<uint8_t>& ead);
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* @brief Stores the EAD for a specific EDHOC message using a Napi::Array.
|
|
@@ -143,9 +142,7 @@ class EdhocEadManager {
|
|
|
143
142
|
* @param ead_token_size The size of the EAD token structure.
|
|
144
143
|
* @return The status of the process operation.
|
|
145
144
|
*/
|
|
146
|
-
int callProcessEad(enum edhoc_message message,
|
|
147
|
-
const struct edhoc_ead_token* ead_token,
|
|
148
|
-
size_t ead_token_size);
|
|
145
|
+
int callProcessEad(enum edhoc_message message, const struct edhoc_ead_token* ead_token, size_t ead_token_size);
|
|
149
146
|
};
|
|
150
147
|
|
|
151
148
|
#endif // EDHOC_EAD_MANAGER_H
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
#ifndef
|
|
2
|
-
#define
|
|
1
|
+
#ifndef EDHOC_EXPORT_OSCORE_ASYNC_WORKER_H
|
|
2
|
+
#define EDHOC_EXPORT_OSCORE_ASYNC_WORKER_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <functional>
|
|
6
7
|
#include <vector>
|
|
7
8
|
|
|
@@ -10,36 +11,32 @@ extern "C" {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @class
|
|
14
|
+
* @class EdhocExportOscoreAsyncWorker
|
|
14
15
|
* @brief A class that represents an asynchronous worker for exporting Edhoc
|
|
15
16
|
* context.
|
|
16
17
|
*
|
|
17
18
|
* This class inherits from Napi::AsyncWorker and provides methods for executing
|
|
18
19
|
* the export operation asynchronously and handling the result or error.
|
|
19
20
|
*/
|
|
20
|
-
class
|
|
21
|
+
class EdhocExportOscoreAsyncWorker : public Napi::AsyncWorker {
|
|
21
22
|
public:
|
|
22
23
|
/**
|
|
23
24
|
* @brief The type definition for the callback function.
|
|
24
25
|
*/
|
|
25
|
-
using CallbackType = std::function<void(Napi::Env)>;
|
|
26
|
+
using CallbackType = std::function<void(Napi::Env&)>;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
|
-
* @brief Constructs a new
|
|
29
|
+
* @brief Constructs a new EdhocExportOscoreAsyncWorker object.
|
|
29
30
|
*
|
|
30
31
|
* @param env The Napi::Env object representing the current environment.
|
|
31
|
-
* @param deferred The Napi::Promise::Deferred object representing the
|
|
32
|
-
* deferred promise.
|
|
33
32
|
* @param context The reference to the edhoc_context structure.
|
|
34
33
|
*/
|
|
35
|
-
|
|
36
|
-
Napi::Promise::Deferred deferred,
|
|
37
|
-
struct edhoc_context& context);
|
|
34
|
+
EdhocExportOscoreAsyncWorker(Napi::Env& env, struct edhoc_context& context, CallbackType callback);
|
|
38
35
|
|
|
39
36
|
/**
|
|
40
|
-
* @brief Destroys the
|
|
37
|
+
* @brief Destroys the EdhocExportOscoreAsyncWorker object.
|
|
41
38
|
*/
|
|
42
|
-
~
|
|
39
|
+
~EdhocExportOscoreAsyncWorker() override;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* @brief Executes the asynchronous worker task.
|
|
@@ -58,14 +55,20 @@ class EdhocExportAsyncWorker : public Napi::AsyncWorker {
|
|
|
58
55
|
*/
|
|
59
56
|
void OnError(const Napi::Error& error) override;
|
|
60
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @brief Returns the promise object.
|
|
60
|
+
* @return The promise object.
|
|
61
|
+
*/
|
|
62
|
+
Napi::Promise GetPromise();
|
|
63
|
+
|
|
61
64
|
private:
|
|
62
|
-
Napi::Promise::Deferred deferred;
|
|
63
|
-
struct edhoc_context&
|
|
64
|
-
context; ///< The reference to the edhoc_context structure.
|
|
65
|
+
Napi::Promise::Deferred deferred; ///< The deferred promise object.
|
|
66
|
+
struct edhoc_context& context; ///< The reference to the edhoc_context structure.
|
|
65
67
|
std::vector<uint8_t> masterSecret; ///< The master secret.
|
|
66
68
|
std::vector<uint8_t> masterSalt; ///< The master salt.
|
|
67
69
|
std::vector<uint8_t> senderId; ///< The sender ID.
|
|
68
70
|
std::vector<uint8_t> recipientId; ///< The recipient ID.
|
|
71
|
+
CallbackType callback; ///< The callback function to be executed.
|
|
69
72
|
};
|
|
70
73
|
|
|
71
|
-
#endif //
|
|
74
|
+
#endif // EDHOC_EXPORT_OSCORE_ASYNC_WORKER_H
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#ifndef EDHOC_KEY_EXPORTER_ASYNC_WORKER_H
|
|
2
|
+
#define EDHOC_KEY_EXPORTER_ASYNC_WORKER_H
|
|
3
|
+
|
|
4
|
+
#include <napi.h>
|
|
5
|
+
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
extern "C" {
|
|
9
|
+
#include "edhoc.h"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @class EdhocKeyExporterAsyncWorker
|
|
14
|
+
* @brief A class that represents an asynchronous worker for exporting PRKs.
|
|
15
|
+
*
|
|
16
|
+
* This class inherits from the Napi::AsyncWorker class and is used to perform
|
|
17
|
+
* PRK export in a separate thread. It takes an Edhoc context, a label, a
|
|
18
|
+
* desired length, and a callback function as input parameters. The export is
|
|
19
|
+
* performed in the Execute() method, and the result is returned through the
|
|
20
|
+
* OnOK() method or an error is handled through the OnError() method.
|
|
21
|
+
*/
|
|
22
|
+
class EdhocKeyExporterAsyncWorker : public Napi::AsyncWorker {
|
|
23
|
+
public:
|
|
24
|
+
/**
|
|
25
|
+
* @brief The type definition for the callback function.
|
|
26
|
+
*/
|
|
27
|
+
using CallbackType = std::function<void(Napi::Env&)>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @brief Constructs a new EdhocKeyExporterAsyncWorker object.
|
|
31
|
+
*
|
|
32
|
+
* @param env The Napi::Env object representing the current environment.
|
|
33
|
+
* @param context The reference to the edhoc_context structure.
|
|
34
|
+
* @param label The label of the key to export.
|
|
35
|
+
* @param desiredLength The desired length of the key to export.
|
|
36
|
+
* @param callback The callback function to be called after the export.
|
|
37
|
+
*/
|
|
38
|
+
EdhocKeyExporterAsyncWorker(Napi::Env& env,
|
|
39
|
+
struct edhoc_context& context,
|
|
40
|
+
uint16_t label,
|
|
41
|
+
uint8_t desiredLength,
|
|
42
|
+
CallbackType callback);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @brief Executes the asynchronous worker task.
|
|
46
|
+
*/
|
|
47
|
+
void Execute() override;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @brief Executes when the asynchronous worker task is completed
|
|
51
|
+
* successfully.
|
|
52
|
+
*/
|
|
53
|
+
void OnOK() override;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @brief Executes when an error occurs during the asynchronous worker task.
|
|
57
|
+
* @param error The Napi::Error object.
|
|
58
|
+
*/
|
|
59
|
+
void OnError(const Napi::Error& error) override;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @brief Returns the promise object.
|
|
63
|
+
* @return The promise object.
|
|
64
|
+
*/
|
|
65
|
+
Napi::Promise GetPromise();
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
Napi::Promise::Deferred deferred;
|
|
69
|
+
struct edhoc_context& context;
|
|
70
|
+
uint16_t label;
|
|
71
|
+
uint8_t desiredLength;
|
|
72
|
+
std::vector<uint8_t> output;
|
|
73
|
+
CallbackType callback;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
#endif // EDHOC_KEY_EXPORTER_ASYNC_WORKER_H
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#ifndef EDHOC_KEY_UPDATE_ASYNC_WORKER_H
|
|
2
|
+
#define EDHOC_KEY_UPDATE_ASYNC_WORKER_H
|
|
3
|
+
|
|
4
|
+
#include <napi.h>
|
|
5
|
+
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
extern "C" {
|
|
9
|
+
#include "edhoc.h"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @class EdhocKeyUpdateAsyncWorker
|
|
14
|
+
* @brief A class that represents an asynchronous worker for key update.
|
|
15
|
+
*
|
|
16
|
+
* This class inherits from the Napi::AsyncWorker class and is used to perform
|
|
17
|
+
* key update in a separate thread. It takes an Edhoc context, a context buffer,
|
|
18
|
+
* and a callback function as input parameters. The key update is performed
|
|
19
|
+
* in the Execute() method, and the result is returned through the OnOK() method
|
|
20
|
+
* or an error is handled through the OnError() method.
|
|
21
|
+
*/
|
|
22
|
+
class EdhocKeyUpdateAsyncWorker : public Napi::AsyncWorker {
|
|
23
|
+
public:
|
|
24
|
+
/**
|
|
25
|
+
* @brief The type definition for the callback function.
|
|
26
|
+
*/
|
|
27
|
+
using CallbackType = std::function<void(Napi::Env&)>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @brief Constructs a new EdhocKeyUpdateAsyncWorker object.
|
|
31
|
+
*
|
|
32
|
+
* @param env The Napi::Env object representing the current environment.
|
|
33
|
+
* @param context The reference to the edhoc_context structure.
|
|
34
|
+
* @param contextBuffer The context buffer.
|
|
35
|
+
* @param callback The callback function to be called after the key update.
|
|
36
|
+
*/
|
|
37
|
+
EdhocKeyUpdateAsyncWorker(Napi::Env& env,
|
|
38
|
+
struct edhoc_context& context,
|
|
39
|
+
std::vector<uint8_t> contextBuffer,
|
|
40
|
+
CallbackType callback);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @brief Executes the asynchronous worker task.
|
|
44
|
+
*/
|
|
45
|
+
void Execute() override;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @brief Executes when the asynchronous worker task is completed
|
|
49
|
+
* successfully.
|
|
50
|
+
*/
|
|
51
|
+
void OnOK() override;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @brief Executes when an error occurs during the asynchronous worker task.
|
|
55
|
+
* @param error The Napi::Error object.
|
|
56
|
+
*/
|
|
57
|
+
void OnError(const Napi::Error& error) override;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @brief Returns the promise object.
|
|
61
|
+
* @return The promise object.
|
|
62
|
+
*/
|
|
63
|
+
Napi::Promise GetPromise();
|
|
64
|
+
|
|
65
|
+
private:
|
|
66
|
+
Napi::Promise::Deferred deferred;
|
|
67
|
+
struct edhoc_context& context;
|
|
68
|
+
std::vector<uint8_t> contextBuffer;
|
|
69
|
+
CallbackType callback;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
#endif // EDHOC_KEY_UPDATE_ASYNC_WORKER_H
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define EDHOC_PROCESS_ASYNC_WORKER_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <vector>
|
|
6
7
|
|
|
7
8
|
extern "C" {
|
|
@@ -31,7 +32,6 @@ class EdhocProcessAsyncWorker : public Napi::AsyncWorker {
|
|
|
31
32
|
* @brief Constructs a new instance of the EdhocProcessAsyncWorker class.
|
|
32
33
|
*
|
|
33
34
|
* @param env The Napi::Env object.
|
|
34
|
-
* @param deferred The Napi::Promise::Deferred object.
|
|
35
35
|
* @param context The reference to the edhoc_context structure.
|
|
36
36
|
* @param messageNumber The message number.
|
|
37
37
|
* @param buffer The Napi::Buffer<uint8_t> object containing the message
|
|
@@ -39,7 +39,6 @@ class EdhocProcessAsyncWorker : public Napi::AsyncWorker {
|
|
|
39
39
|
* @param callback The callback function to be called after processing.
|
|
40
40
|
*/
|
|
41
41
|
EdhocProcessAsyncWorker(Napi::Env& env,
|
|
42
|
-
Napi::Promise::Deferred deferred,
|
|
43
42
|
struct edhoc_context& context,
|
|
44
43
|
int messageNumber,
|
|
45
44
|
Napi::Buffer<uint8_t> buffer,
|
|
@@ -62,15 +61,20 @@ class EdhocProcessAsyncWorker : public Napi::AsyncWorker {
|
|
|
62
61
|
*/
|
|
63
62
|
void OnError(const Napi::Error& error) override;
|
|
64
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @brief Returns the promise object.
|
|
66
|
+
* @return The promise object.
|
|
67
|
+
*/
|
|
68
|
+
Napi::Promise GetPromise();
|
|
69
|
+
|
|
65
70
|
private:
|
|
66
|
-
Napi::Promise::Deferred deferred;
|
|
67
|
-
|
|
68
|
-
struct edhoc_context&
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
callback; ///< The callback function to be called after processing.
|
|
71
|
+
Napi::Promise::Deferred deferred; ///< The Napi::Promise::Deferred object for
|
|
72
|
+
///< resolving or rejecting the promise.
|
|
73
|
+
struct edhoc_context& context; ///< The reference to the edhoc_context structure.
|
|
74
|
+
int messageNumber; ///< The message number.
|
|
75
|
+
std::vector<uint8_t> messageBuffer; ///< The message buffer.
|
|
76
|
+
CallbackType callback; ///< The callback function to be called after processing.
|
|
77
|
+
std::vector<uint8_t> peerCipherSuites; ///< The peer cipher suites.
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
#endif // EDHOC_PROCESS_ASYNC_WORKER_H
|
package/include/LibEDHOC.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define LIB_EDHOC_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include "UserContext.h"
|
|
6
7
|
|
|
7
8
|
extern "C" {
|
|
@@ -88,20 +89,30 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
88
89
|
* associated with the LibEDHOC object.
|
|
89
90
|
*
|
|
90
91
|
* @param info The Napi::CallbackInfo representing the callback information.
|
|
91
|
-
* @return Napi::Value The
|
|
92
|
+
* @return Napi::Value The supported methods used in EDHOC.
|
|
92
93
|
*/
|
|
93
|
-
Napi::Value
|
|
94
|
+
Napi::Value GetMethods(const Napi::CallbackInfo& info);
|
|
94
95
|
|
|
95
96
|
/**
|
|
96
97
|
* @brief Sets the Method (RFC 9528: 3.2.) used in EDHOC.
|
|
97
98
|
*
|
|
98
|
-
* This method sets the
|
|
99
|
-
* object.
|
|
99
|
+
* This method sets the supported methods (RFC 9528: 3.2.) used in EDHOC for
|
|
100
|
+
* the LibEDHOC object.
|
|
100
101
|
*
|
|
101
102
|
* @param info The Napi::CallbackInfo representing the callback information.
|
|
102
|
-
* @param value The Napi::Value representing the
|
|
103
|
+
* @param value The Napi::Value representing the supported methods used in EDHOC.
|
|
103
104
|
*/
|
|
104
|
-
void
|
|
105
|
+
void SetMethods(const Napi::CallbackInfo& info, const Napi::Value& value);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @brief Gets the selected method.
|
|
109
|
+
*
|
|
110
|
+
* This method returns the selected method associated with the LibEDHOC object.
|
|
111
|
+
*
|
|
112
|
+
* @param info The Napi::CallbackInfo representing the callback information.
|
|
113
|
+
* @return Napi::Value The selected method.
|
|
114
|
+
*/
|
|
115
|
+
Napi::Value GetSelectedMethod(const Napi::CallbackInfo& info);
|
|
105
116
|
|
|
106
117
|
/**
|
|
107
118
|
* @brief Sets the cipher suites.
|
|
@@ -111,8 +122,7 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
111
122
|
* @param info The Napi::CallbackInfo representing the callback information.
|
|
112
123
|
* @param value The Napi::Value representing the cipher suites.
|
|
113
124
|
*/
|
|
114
|
-
void SetCipherSuites(const Napi::CallbackInfo& info,
|
|
115
|
-
const Napi::Value& value);
|
|
125
|
+
void SetCipherSuites(const Napi::CallbackInfo& info, const Napi::Value& value);
|
|
116
126
|
|
|
117
127
|
/**
|
|
118
128
|
* @brief Gets the cipher suites.
|
|
@@ -247,13 +257,32 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
247
257
|
*/
|
|
248
258
|
Napi::Value ExportOSCORE(const Napi::CallbackInfo& info);
|
|
249
259
|
|
|
260
|
+
/**
|
|
261
|
+
* @brief Exports keying material using the EDHOC_Exporter interface.
|
|
262
|
+
*
|
|
263
|
+
* This method derives keying material using the EDHOC_Exporter, which
|
|
264
|
+
* utilizes an `exporter_label`, `context`, and `length` to generate the
|
|
265
|
+
* key.
|
|
266
|
+
*
|
|
267
|
+
* @param info The Napi::CallbackInfo representing the callback information.
|
|
268
|
+
* @return Napi::Value The derived keying material.
|
|
269
|
+
*/
|
|
270
|
+
Napi::Value ExportKey(const Napi::CallbackInfo& info);
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @brief Performs a key update.
|
|
274
|
+
*
|
|
275
|
+
* This method performs a key update for the LibEDHOC object.
|
|
276
|
+
*
|
|
277
|
+
* @param info The Napi::CallbackInfo representing the callback information.
|
|
278
|
+
* @return Napi::Value void.
|
|
279
|
+
*/
|
|
280
|
+
Napi::Value KeyUpdate(const Napi::CallbackInfo& info);
|
|
281
|
+
|
|
250
282
|
private:
|
|
251
283
|
struct edhoc_context context; ///< The EDHOC context.
|
|
252
284
|
|
|
253
|
-
struct edhoc_connection_id
|
|
254
|
-
cid; ///< RFC 9528: 3.3.2. Representation of Byte String Identifiers.
|
|
255
|
-
|
|
256
|
-
enum edhoc_method method; ///< RFC 9528: 3.2. Method.
|
|
285
|
+
struct edhoc_connection_id cid; ///< RFC 9528: 3.3.2. Representation of Byte String Identifiers.
|
|
257
286
|
|
|
258
287
|
Napi::FunctionReference logger; ///< N-API reference to the logger function
|
|
259
288
|
|
|
@@ -271,10 +300,7 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
271
300
|
* @param buffer The buffer containing the log message.
|
|
272
301
|
* @param buffer_length The length of the log message buffer.
|
|
273
302
|
*/
|
|
274
|
-
static void Logger(void* user_context,
|
|
275
|
-
const char* name,
|
|
276
|
-
const uint8_t* buffer,
|
|
277
|
-
size_t buffer_length);
|
|
303
|
+
static void Logger(void* user_context, const char* name, const uint8_t* buffer, size_t buffer_length);
|
|
278
304
|
|
|
279
305
|
/**
|
|
280
306
|
* @brief Composes an EDHOC message.
|
|
@@ -285,8 +311,7 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
285
311
|
* @param message The EDHOC message to compose.
|
|
286
312
|
* @return Napi::Value The composed EDHOC message.
|
|
287
313
|
*/
|
|
288
|
-
Napi::Value ComposeMessage(const Napi::CallbackInfo& info,
|
|
289
|
-
enum edhoc_message message);
|
|
314
|
+
Napi::Value ComposeMessage(const Napi::CallbackInfo& info, enum edhoc_message message);
|
|
290
315
|
|
|
291
316
|
/**
|
|
292
317
|
* @brief Processes an EDHOC message.
|
|
@@ -297,8 +322,7 @@ class LibEDHOC : public Napi::ObjectWrap<LibEDHOC> {
|
|
|
297
322
|
* @param message The EDHOC message to process.
|
|
298
323
|
* @return Napi::Value The EAD data or Null for given EDHOC message.
|
|
299
324
|
*/
|
|
300
|
-
Napi::Value ProcessMessage(const Napi::CallbackInfo& info,
|
|
301
|
-
enum edhoc_message message);
|
|
325
|
+
Napi::Value ProcessMessage(const Napi::CallbackInfo& info, enum edhoc_message message);
|
|
302
326
|
};
|
|
303
327
|
|
|
304
328
|
#endif // LIB_EDHOC_H
|
package/include/UserContext.h
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
#define USER_CONTEXT_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <memory>
|
|
7
|
+
|
|
6
8
|
#include "EdhocCredentialManager.h"
|
|
7
9
|
#include "EdhocCryptoManager.h"
|
|
8
10
|
#include "EdhocEadManager.h"
|
|
@@ -61,19 +63,15 @@ class UserContext {
|
|
|
61
63
|
*
|
|
62
64
|
* @return A pointer to the EdhocCredentialManager.
|
|
63
65
|
*/
|
|
64
|
-
EdhocCredentialManager* GetCredentialManager() const {
|
|
65
|
-
return credentialManager.get();
|
|
66
|
-
}
|
|
66
|
+
EdhocCredentialManager* GetCredentialManager() const { return credentialManager.get(); }
|
|
67
67
|
|
|
68
68
|
Napi::ThreadSafeFunction logger; ///< The logger for the UserContext
|
|
69
|
-
Napi::ObjectReference
|
|
70
|
-
parent; ///< The parent object reference for the UserContext
|
|
69
|
+
Napi::ObjectReference parent; ///< The parent object reference for the UserContext
|
|
71
70
|
|
|
72
71
|
protected:
|
|
73
|
-
std::shared_ptr<EdhocCryptoManager> cryptoManager;
|
|
74
|
-
std::shared_ptr<EdhocEadManager> eadManager;
|
|
75
|
-
std::shared_ptr<EdhocCredentialManager>
|
|
76
|
-
credentialManager; ///< The credential manager
|
|
72
|
+
std::shared_ptr<EdhocCryptoManager> cryptoManager; ///< The crypto manager
|
|
73
|
+
std::shared_ptr<EdhocEadManager> eadManager; ///< The EAD manager
|
|
74
|
+
std::shared_ptr<EdhocCredentialManager> credentialManager; ///< The credential manager
|
|
77
75
|
};
|
|
78
76
|
|
|
79
77
|
#endif // USER_CONTEXT_H
|