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
package/include/Utils.h
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
#define UTILS_H
|
|
3
3
|
|
|
4
4
|
#include <napi.h>
|
|
5
|
+
|
|
5
6
|
#include <cstdint>
|
|
7
|
+
#include <future>
|
|
6
8
|
#include <string>
|
|
7
9
|
#include <vector>
|
|
8
10
|
|
|
@@ -20,22 +22,8 @@ extern "C" {
|
|
|
20
22
|
*/
|
|
21
23
|
class Utils {
|
|
22
24
|
public:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* This helper function is designed to encapsulate the cleanup logic for N-API
|
|
26
|
-
* resources, ensuring that function references are reset and thread-safe
|
|
27
|
-
* functions are released properly. This prevents memory leaks and ensures
|
|
28
|
-
* that asynchronous operations using thread-safe functions do not attempt to
|
|
29
|
-
* call into JavaScript after the native resources have been disposed of.
|
|
30
|
-
*
|
|
31
|
-
* @param funcRef A reference to a N-API function that may be called from
|
|
32
|
-
* native code. This function reference will be reset if it is not empty.
|
|
33
|
-
* @param tsfn A N-API thread-safe function that facilitates calling
|
|
34
|
-
* JavaScript functions asynchronously from native threads. This thread-safe
|
|
35
|
-
* function will be released and set to nullptr.
|
|
36
|
-
*/
|
|
37
|
-
static void ResetAndRelease(Napi::FunctionReference& funcRef,
|
|
38
|
-
Napi::ThreadSafeFunction& tsfn);
|
|
25
|
+
using SuccessHandler = std::function<void(Napi::Env, Napi::Value)>;
|
|
26
|
+
using ErrorHandler = std::function<void(Napi::Env, Napi::Error)>;
|
|
39
27
|
|
|
40
28
|
/**
|
|
41
29
|
* Invokes a JavaScript function with promise handling.
|
|
@@ -50,12 +38,31 @@ class Utils {
|
|
|
50
38
|
* @param callbackLambda A lambda function to handle the result of the
|
|
51
39
|
* function call.
|
|
52
40
|
*/
|
|
53
|
-
static void InvokeJSFunctionWithPromiseHandling(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
static void InvokeJSFunctionWithPromiseHandling(Napi::Env env,
|
|
42
|
+
Napi::Object jsObject,
|
|
43
|
+
Napi::Function jsCallback,
|
|
44
|
+
const std::vector<napi_value>& args,
|
|
45
|
+
SuccessHandler successLambda,
|
|
46
|
+
ErrorHandler errorLambda);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates a promise error handler for a given promise.
|
|
50
|
+
*
|
|
51
|
+
* @tparam T The type of the promise.
|
|
52
|
+
* @param promise The promise to handle errors for.
|
|
53
|
+
* @return A lambda function that sets the exception on the promise.
|
|
54
|
+
*/
|
|
55
|
+
template <typename T>
|
|
56
|
+
static ErrorHandler CreatePromiseErrorHandler(std::promise<T>& promise, T defaultValue) {
|
|
57
|
+
return [&promise, defaultValue](Napi::Env env, Napi::Error error) {
|
|
58
|
+
auto exception = std::current_exception();
|
|
59
|
+
if (exception) {
|
|
60
|
+
promise.set_exception(exception);
|
|
61
|
+
} else {
|
|
62
|
+
promise.set_value(defaultValue);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
59
66
|
|
|
60
67
|
/**
|
|
61
68
|
* Converts a JavaScript value to an EDHOC connection ID structure.
|
|
@@ -75,8 +82,7 @@ class Utils {
|
|
|
75
82
|
* @param value The EDHOC connection ID structure.
|
|
76
83
|
* @return A N-API value representing the connection ID.
|
|
77
84
|
*/
|
|
78
|
-
static Napi::Value CreateJsValueFromEdhocCid(
|
|
79
|
-
Napi::Env env, struct edhoc_connection_id value);
|
|
85
|
+
static Napi::Value CreateJsValueFromEdhocCid(Napi::Env env, struct edhoc_connection_id value);
|
|
80
86
|
|
|
81
87
|
/**
|
|
82
88
|
* Converts a JavaScript number to a strongly typed enum.
|
|
@@ -102,9 +108,7 @@ class Utils {
|
|
|
102
108
|
* @param length Pointer to a size_t variable where the length of the encoded
|
|
103
109
|
* data will be stored.
|
|
104
110
|
*/
|
|
105
|
-
static void EncodeInt64ToBuffer(int64_t value,
|
|
106
|
-
uint8_t* buffer,
|
|
107
|
-
size_t* length);
|
|
111
|
+
static void EncodeInt64ToBuffer(int64_t value, uint8_t* buffer, size_t* length);
|
|
108
112
|
};
|
|
109
113
|
|
|
110
114
|
#endif // UTILS_H
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edhoc",
|
|
3
3
|
"description": "A Node.js implementation of EDHOC (Ephemeral Diffie-Hellman Over COSE) protocol for lightweight authenticated key exchange in IoT and other constrained environments.",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"debug": "npx node-gyp build --debug",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"semantic-release": "semantic-release",
|
|
14
14
|
"pretest": "npm run rebuild",
|
|
15
15
|
"rebuild": "node-gyp rebuild",
|
|
16
|
-
"test": "
|
|
16
|
+
"test": "jest"
|
|
17
17
|
},
|
|
18
18
|
"private": false,
|
|
19
19
|
"gypfile": true,
|
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
"@noble/curves": "^1.4.0",
|
|
23
23
|
"bindings": "^1.5.0",
|
|
24
24
|
"cbor": "^9.0.2",
|
|
25
|
+
"chalk": "^5.3.0",
|
|
25
26
|
"coap": "^1.3.0",
|
|
27
|
+
"colors": "^1.4.0",
|
|
26
28
|
"node-addon-api": "^8.0.0",
|
|
27
29
|
"node-gyp-build": "^4.8.1",
|
|
28
|
-
"patch-package": "^8.0.0"
|
|
30
|
+
"patch-package": "^8.0.0",
|
|
31
|
+
"wtfnode": "^0.9.3"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
34
|
"@commitlint/cli": "^19.3.0",
|
|
@@ -37,13 +40,21 @@
|
|
|
37
40
|
"@semantic-release/github": "^10.1.1",
|
|
38
41
|
"@types/elliptic": "^6.4.18",
|
|
39
42
|
"@types/eslint__js": "^8.42.3",
|
|
43
|
+
"@types/jest": "^29.5.14",
|
|
44
|
+
"@types/node": "^22.13.4",
|
|
40
45
|
"eslint": "^8.57.0",
|
|
46
|
+
"jest": "^29.7.0",
|
|
41
47
|
"mocha": "^10.7.0",
|
|
42
48
|
"nyc": "^17.0.0",
|
|
43
49
|
"prebuildify": "^6.0.1",
|
|
44
50
|
"prebuildify-cross": "^5.1.0",
|
|
45
51
|
"semantic-release": "^24.0.0",
|
|
52
|
+
"ts-jest": "^29.2.5",
|
|
46
53
|
"typescript": "^5.5.4",
|
|
47
54
|
"typescript-eslint": "^7.17.0"
|
|
55
|
+
},
|
|
56
|
+
"jest": {
|
|
57
|
+
"preset": "ts-jest",
|
|
58
|
+
"testEnvironment": "node"
|
|
48
59
|
}
|
|
49
60
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
#include "EdhocComposeAsyncWorker.h"
|
|
2
2
|
|
|
3
3
|
static const size_t kInitialBufferSize = 1024 * 10;
|
|
4
|
-
static constexpr const char* kErrorInvalidMessageNumber =
|
|
5
|
-
|
|
6
|
-
static constexpr const char* kErrorMessageFormat =
|
|
7
|
-
"Failed to compose EDHOC message %d. Error code: %d";
|
|
4
|
+
static constexpr const char* kErrorInvalidMessageNumber = "Invalid message number";
|
|
5
|
+
static constexpr const char* kErrorMessageFormat = "Failed to compose EDHOC message %d. Error code: %d";
|
|
8
6
|
static constexpr size_t kErrorBufferSize = 100;
|
|
9
7
|
|
|
10
|
-
EdhocComposeAsyncWorker::EdhocComposeAsyncWorker(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
int messageNumber,
|
|
15
|
-
CallbackType callback)
|
|
8
|
+
EdhocComposeAsyncWorker::EdhocComposeAsyncWorker(Napi::Env& env,
|
|
9
|
+
struct edhoc_context& context,
|
|
10
|
+
int messageNumber,
|
|
11
|
+
CallbackType callback)
|
|
16
12
|
: Napi::AsyncWorker(env),
|
|
17
|
-
deferred(
|
|
13
|
+
deferred(Napi::Promise::Deferred::New(env)),
|
|
18
14
|
context(context),
|
|
19
15
|
messageNumber(messageNumber),
|
|
20
16
|
callback(std::move(callback)) {}
|
|
@@ -27,28 +23,16 @@ void EdhocComposeAsyncWorker::Execute() {
|
|
|
27
23
|
int ret = EDHOC_ERROR_GENERIC_ERROR;
|
|
28
24
|
switch (messageNumber) {
|
|
29
25
|
case EDHOC_MSG_1:
|
|
30
|
-
ret = edhoc_message_1_compose(&context,
|
|
31
|
-
composedMessage.data(),
|
|
32
|
-
composedMessage.size(),
|
|
33
|
-
&composedMessageLength);
|
|
26
|
+
ret = edhoc_message_1_compose(&context, composedMessage.data(), composedMessage.size(), &composedMessageLength);
|
|
34
27
|
break;
|
|
35
28
|
case EDHOC_MSG_2:
|
|
36
|
-
ret = edhoc_message_2_compose(&context,
|
|
37
|
-
composedMessage.data(),
|
|
38
|
-
composedMessage.size(),
|
|
39
|
-
&composedMessageLength);
|
|
29
|
+
ret = edhoc_message_2_compose(&context, composedMessage.data(), composedMessage.size(), &composedMessageLength);
|
|
40
30
|
break;
|
|
41
31
|
case EDHOC_MSG_3:
|
|
42
|
-
ret = edhoc_message_3_compose(&context,
|
|
43
|
-
composedMessage.data(),
|
|
44
|
-
composedMessage.size(),
|
|
45
|
-
&composedMessageLength);
|
|
32
|
+
ret = edhoc_message_3_compose(&context, composedMessage.data(), composedMessage.size(), &composedMessageLength);
|
|
46
33
|
break;
|
|
47
34
|
case EDHOC_MSG_4:
|
|
48
|
-
ret = edhoc_message_4_compose(&context,
|
|
49
|
-
composedMessage.data(),
|
|
50
|
-
composedMessage.size(),
|
|
51
|
-
&composedMessageLength);
|
|
35
|
+
ret = edhoc_message_4_compose(&context, composedMessage.data(), composedMessage.size(), &composedMessageLength);
|
|
52
36
|
break;
|
|
53
37
|
default:
|
|
54
38
|
SetError(kErrorInvalidMessageNumber);
|
|
@@ -59,11 +43,7 @@ void EdhocComposeAsyncWorker::Execute() {
|
|
|
59
43
|
|
|
60
44
|
if (ret != EDHOC_SUCCESS) {
|
|
61
45
|
char errorMessage[kErrorBufferSize];
|
|
62
|
-
std::snprintf(errorMessage,
|
|
63
|
-
kErrorBufferSize,
|
|
64
|
-
kErrorMessageFormat,
|
|
65
|
-
messageNumber + 1,
|
|
66
|
-
ret);
|
|
46
|
+
std::snprintf(errorMessage, kErrorBufferSize, kErrorMessageFormat, messageNumber + 1, ret);
|
|
67
47
|
SetError(errorMessage);
|
|
68
48
|
}
|
|
69
49
|
|
|
@@ -75,14 +55,17 @@ void EdhocComposeAsyncWorker::Execute() {
|
|
|
75
55
|
void EdhocComposeAsyncWorker::OnOK() {
|
|
76
56
|
Napi::Env env = Env();
|
|
77
57
|
Napi::HandleScope scope(env);
|
|
78
|
-
deferred.Resolve(Napi::Buffer<uint8_t>::Copy(
|
|
79
|
-
env, composedMessage.data(), composedMessage.size()));
|
|
58
|
+
deferred.Resolve(Napi::Buffer<uint8_t>::Copy(env, composedMessage.data(), composedMessage.size()));
|
|
80
59
|
callback(env);
|
|
81
60
|
}
|
|
82
61
|
|
|
83
62
|
void EdhocComposeAsyncWorker::OnError(const Napi::Error& error) {
|
|
84
63
|
Napi::Env env = Env();
|
|
85
64
|
Napi::HandleScope scope(env);
|
|
86
|
-
deferred.Reject(
|
|
65
|
+
deferred.Reject(error.Value());
|
|
87
66
|
callback(env);
|
|
88
67
|
}
|
|
68
|
+
|
|
69
|
+
Napi::Promise EdhocComposeAsyncWorker::GetPromise() {
|
|
70
|
+
return deferred.Promise();
|
|
71
|
+
}
|