edhoc 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +10 -0
- package/dist/crypto.d.ts +29 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +205 -0
- package/dist/edhoc.d.ts +368 -0
- package/dist/edhoc.d.ts.map +1 -0
- package/dist/edhoc.js +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity.h"
|
|
9
|
+
#define TEST_INSTANCES
|
|
10
|
+
#include "self_assessment_utils.h"
|
|
11
|
+
|
|
12
|
+
static int SetToOneToFailInTearDown;
|
|
13
|
+
static int SetToOneMeanWeAlreadyCheckedThisGuy;
|
|
14
|
+
|
|
15
|
+
void setUp(void)
|
|
16
|
+
{
|
|
17
|
+
SetToOneToFailInTearDown = 0;
|
|
18
|
+
SetToOneMeanWeAlreadyCheckedThisGuy = 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void tearDown(void)
|
|
22
|
+
{
|
|
23
|
+
endPutcharSpy(); /* Stop suppressing test output */
|
|
24
|
+
if (SetToOneToFailInTearDown == 1)
|
|
25
|
+
{
|
|
26
|
+
/* These will be skipped internally if already failed/ignored */
|
|
27
|
+
TEST_FAIL_MESSAGE("<= Failed in tearDown");
|
|
28
|
+
TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
|
|
29
|
+
}
|
|
30
|
+
if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
|
|
31
|
+
{
|
|
32
|
+
UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
|
|
33
|
+
UNITY_OUTPUT_CHAR('\n');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void testEqualStrings(void)
|
|
38
|
+
{
|
|
39
|
+
const char *testString = "foo";
|
|
40
|
+
|
|
41
|
+
TEST_ASSERT_EQUAL_STRING(testString, testString);
|
|
42
|
+
TEST_ASSERT_EQUAL_STRING_MESSAGE("foo", "foo", "foo isn't foo");
|
|
43
|
+
TEST_ASSERT_EQUAL_STRING("foo", testString);
|
|
44
|
+
TEST_ASSERT_EQUAL_STRING(testString, "foo");
|
|
45
|
+
TEST_ASSERT_EQUAL_STRING("", "");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void testEqualStringsLen(void)
|
|
49
|
+
{
|
|
50
|
+
const char *testString = "foobar";
|
|
51
|
+
TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString));
|
|
52
|
+
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE("foobar", "foobaz", 5, "fooba isn't fooba");
|
|
53
|
+
TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3);
|
|
54
|
+
TEST_ASSERT_EQUAL_STRING_LEN(testString, "foo", 3);
|
|
55
|
+
TEST_ASSERT_EQUAL_STRING_LEN("", "", 3);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void testEqualStringsWithCarriageReturnsAndLineFeeds(void)
|
|
59
|
+
{
|
|
60
|
+
const char *testString = "foo\r\nbar";
|
|
61
|
+
|
|
62
|
+
TEST_ASSERT_EQUAL_STRING(testString, testString);
|
|
63
|
+
TEST_ASSERT_EQUAL_STRING("foo\r\nbar", "foo\r\nbar");
|
|
64
|
+
TEST_ASSERT_EQUAL_STRING("foo\r\nbar", testString);
|
|
65
|
+
TEST_ASSERT_EQUAL_STRING(testString, "foo\r\nbar");
|
|
66
|
+
TEST_ASSERT_EQUAL_STRING("", "");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void testNotEqualString1(void)
|
|
70
|
+
{
|
|
71
|
+
EXPECT_ABORT_BEGIN
|
|
72
|
+
TEST_ASSERT_EQUAL_STRING("foo", "bar");
|
|
73
|
+
VERIFY_FAILS_END
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void testNotEqualStringLen1(void)
|
|
77
|
+
{
|
|
78
|
+
EXPECT_ABORT_BEGIN
|
|
79
|
+
TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6);
|
|
80
|
+
VERIFY_FAILS_END
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void testNotEqualString2(void)
|
|
84
|
+
{
|
|
85
|
+
EXPECT_ABORT_BEGIN
|
|
86
|
+
TEST_ASSERT_EQUAL_STRING("foo", "");
|
|
87
|
+
VERIFY_FAILS_END
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void testNotEqualStringLen2(void)
|
|
91
|
+
{
|
|
92
|
+
EXPECT_ABORT_BEGIN
|
|
93
|
+
TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3);
|
|
94
|
+
VERIFY_FAILS_END
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void testNotEqualString3(void)
|
|
98
|
+
{
|
|
99
|
+
EXPECT_ABORT_BEGIN
|
|
100
|
+
TEST_ASSERT_EQUAL_STRING("", "bar");
|
|
101
|
+
VERIFY_FAILS_END
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void testNotEqualStringLen3(void)
|
|
105
|
+
{
|
|
106
|
+
EXPECT_ABORT_BEGIN
|
|
107
|
+
TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3);
|
|
108
|
+
VERIFY_FAILS_END
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void testNotEqualString4(void)
|
|
112
|
+
{
|
|
113
|
+
EXPECT_ABORT_BEGIN
|
|
114
|
+
TEST_ASSERT_EQUAL_STRING("bar\r", "bar\n");
|
|
115
|
+
VERIFY_FAILS_END
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void testNotEqualStringLen4(void)
|
|
119
|
+
{
|
|
120
|
+
EXPECT_ABORT_BEGIN
|
|
121
|
+
TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4);
|
|
122
|
+
VERIFY_FAILS_END
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void testNotEqualString5(void)
|
|
126
|
+
{
|
|
127
|
+
const char str1[] = { 0x41, 0x42, 0x03, 0x00 };
|
|
128
|
+
const char str2[] = { 0x41, 0x42, 0x04, 0x00 };
|
|
129
|
+
EXPECT_ABORT_BEGIN
|
|
130
|
+
TEST_ASSERT_EQUAL_STRING(str1, str2);
|
|
131
|
+
VERIFY_FAILS_END
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void testNotEqualString_ExpectedStringIsNull(void)
|
|
135
|
+
{
|
|
136
|
+
EXPECT_ABORT_BEGIN
|
|
137
|
+
TEST_ASSERT_EQUAL_STRING(NULL, "bar");
|
|
138
|
+
VERIFY_FAILS_END
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
void testNotEqualStringLen_ExpectedStringIsNull(void)
|
|
142
|
+
{
|
|
143
|
+
EXPECT_ABORT_BEGIN
|
|
144
|
+
TEST_ASSERT_EQUAL_STRING_LEN(NULL, "bar", 1);
|
|
145
|
+
VERIFY_FAILS_END
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void testNotEqualString_ActualStringIsNull(void)
|
|
149
|
+
{
|
|
150
|
+
EXPECT_ABORT_BEGIN
|
|
151
|
+
TEST_ASSERT_EQUAL_STRING("foo", NULL);
|
|
152
|
+
VERIFY_FAILS_END
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void testNotEqualStringLen_ActualStringIsNull(void)
|
|
156
|
+
{
|
|
157
|
+
EXPECT_ABORT_BEGIN
|
|
158
|
+
TEST_ASSERT_EQUAL_STRING_LEN("foo", NULL, 1);
|
|
159
|
+
VERIFY_FAILS_END
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void testNotEqualString_ExpectedStringIsLonger(void)
|
|
163
|
+
{
|
|
164
|
+
EXPECT_ABORT_BEGIN
|
|
165
|
+
TEST_ASSERT_EQUAL_STRING("foo2", "foo");
|
|
166
|
+
VERIFY_FAILS_END
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void testNotEqualString_ActualStringIsLonger(void)
|
|
170
|
+
{
|
|
171
|
+
EXPECT_ABORT_BEGIN
|
|
172
|
+
TEST_ASSERT_EQUAL_STRING("foo", "foo2");
|
|
173
|
+
VERIFY_FAILS_END
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void testEqualStringArrays(void)
|
|
177
|
+
{
|
|
178
|
+
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
|
|
179
|
+
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
|
|
180
|
+
|
|
181
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, expStrings, 3);
|
|
182
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 3);
|
|
183
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 2);
|
|
184
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 1);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
void testNotEqualStringArray1(void)
|
|
188
|
+
{
|
|
189
|
+
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
|
|
190
|
+
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
|
|
191
|
+
|
|
192
|
+
EXPECT_ABORT_BEGIN
|
|
193
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
194
|
+
VERIFY_FAILS_END
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
void testNotEqualStringArray2(void)
|
|
198
|
+
{
|
|
199
|
+
const char *testStrings[] = { "zoo", "boo", "woo", "moo" };
|
|
200
|
+
const char *expStrings[] = { "foo", "boo", "woo", "moo" };
|
|
201
|
+
|
|
202
|
+
EXPECT_ABORT_BEGIN
|
|
203
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
204
|
+
VERIFY_FAILS_END
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
void testNotEqualStringArray3(void)
|
|
208
|
+
{
|
|
209
|
+
const char *testStrings[] = { "foo", "boo", "woo", NULL };
|
|
210
|
+
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
|
|
211
|
+
|
|
212
|
+
EXPECT_ABORT_BEGIN
|
|
213
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
214
|
+
VERIFY_FAILS_END
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
void testNotEqualStringArray4(void)
|
|
218
|
+
{
|
|
219
|
+
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
|
|
220
|
+
const char *expStrings[] = { "foo", NULL, "woo", "moo" };
|
|
221
|
+
|
|
222
|
+
EXPECT_ABORT_BEGIN
|
|
223
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
224
|
+
VERIFY_FAILS_END
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void testNotEqualStringArray5(void)
|
|
228
|
+
{
|
|
229
|
+
const char **testStrings = NULL;
|
|
230
|
+
const char *expStrings[] = { "foo", "boo", "woo", "zoo" };
|
|
231
|
+
|
|
232
|
+
EXPECT_ABORT_BEGIN
|
|
233
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
234
|
+
VERIFY_FAILS_END
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
void testNotEqualStringArray6(void)
|
|
238
|
+
{
|
|
239
|
+
const char *testStrings[] = { "foo", "boo", "woo", "zoo" };
|
|
240
|
+
const char **expStrings = NULL;
|
|
241
|
+
|
|
242
|
+
EXPECT_ABORT_BEGIN
|
|
243
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
244
|
+
VERIFY_FAILS_END
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void testEqualStringArrayIfBothNulls(void)
|
|
248
|
+
{
|
|
249
|
+
const char **testStrings = NULL;
|
|
250
|
+
const char **expStrings = NULL;
|
|
251
|
+
|
|
252
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 4);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
void testNotEqualStringArrayLengthZero(void)
|
|
256
|
+
{
|
|
257
|
+
const char *testStrings[] = {NULL};
|
|
258
|
+
const char **expStrings = NULL;
|
|
259
|
+
|
|
260
|
+
EXPECT_ABORT_BEGIN
|
|
261
|
+
TEST_ASSERT_EQUAL_STRING_ARRAY(expStrings, testStrings, 0);
|
|
262
|
+
VERIFY_FAILS_END
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
void testEqualStringEachEqual(void)
|
|
266
|
+
{
|
|
267
|
+
const char *testStrings1[] = { "foo", "foo", "foo", "foo" };
|
|
268
|
+
const char *testStrings2[] = { "boo", "boo", "boo", "zoo" };
|
|
269
|
+
const char *testStrings3[] = { "", "", "", "" };
|
|
270
|
+
|
|
271
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 4);
|
|
272
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings1, 1);
|
|
273
|
+
TEST_ASSERT_EACH_EQUAL_STRING("boo", testStrings2, 3);
|
|
274
|
+
TEST_ASSERT_EACH_EQUAL_STRING("", testStrings3, 4);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void testNotEqualStringEachEqual1(void)
|
|
278
|
+
{
|
|
279
|
+
const char *testStrings[] = { "foo", "foo", "foo", "moo" };
|
|
280
|
+
|
|
281
|
+
EXPECT_ABORT_BEGIN
|
|
282
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
|
|
283
|
+
VERIFY_FAILS_END
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
void testNotEqualStringEachEqual2(void)
|
|
287
|
+
{
|
|
288
|
+
const char *testStrings[] = { "boo", "foo", "foo", "foo" };
|
|
289
|
+
|
|
290
|
+
EXPECT_ABORT_BEGIN
|
|
291
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
|
|
292
|
+
VERIFY_FAILS_END
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
void testNotEqualStringEachEqual3(void)
|
|
296
|
+
{
|
|
297
|
+
const char *testStrings[] = { "foo", "foo", "foo", NULL };
|
|
298
|
+
|
|
299
|
+
EXPECT_ABORT_BEGIN
|
|
300
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
|
|
301
|
+
VERIFY_FAILS_END
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void testNotEqualStringEachEqual4(void)
|
|
305
|
+
{
|
|
306
|
+
const char *testStrings[] = { "foo", "foo", "woo", "foo" };
|
|
307
|
+
|
|
308
|
+
EXPECT_ABORT_BEGIN
|
|
309
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", testStrings, 4);
|
|
310
|
+
VERIFY_FAILS_END
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
void testNotEqualStringEachEqual5(void)
|
|
314
|
+
{
|
|
315
|
+
EXPECT_ABORT_BEGIN
|
|
316
|
+
TEST_ASSERT_EACH_EQUAL_STRING("foo", NULL, 1);
|
|
317
|
+
VERIFY_FAILS_END
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
void testCstringsEscapeSequence(void)
|
|
321
|
+
{
|
|
322
|
+
#ifndef USING_OUTPUT_SPY
|
|
323
|
+
TEST_IGNORE();
|
|
324
|
+
#else
|
|
325
|
+
startPutcharSpy();
|
|
326
|
+
UnityPrint("\x16\x10");
|
|
327
|
+
endPutcharSpy();
|
|
328
|
+
TEST_ASSERT_EQUAL_STRING("\\x16\\x10", getBufferPutcharSpy());
|
|
329
|
+
#endif
|
|
330
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
typedef enum {
|
|
11
|
+
ENUM_A,
|
|
12
|
+
ENUM_2,
|
|
13
|
+
ENUM_C,
|
|
14
|
+
ENUM_4,
|
|
15
|
+
} test_enum_t;
|
|
16
|
+
|
|
17
|
+
static const float test_arr[] = {
|
|
18
|
+
1.2f,
|
|
19
|
+
2.3f,
|
|
20
|
+
3.4f,
|
|
21
|
+
};
|
|
@@ -17,6 +17,23 @@
|
|
|
17
17
|
extern "C" {
|
|
18
18
|
#endif
|
|
19
19
|
|
|
20
|
+
#define ZCBOR_STRINGIFY_PRE(x) #x
|
|
21
|
+
#define ZCBOR_STRINGIFY(s) ZCBOR_STRINGIFY_PRE(s)
|
|
22
|
+
|
|
23
|
+
#define ZCBOR_VERSION_MAJOR 0
|
|
24
|
+
#define ZCBOR_VERSION_MINOR 8
|
|
25
|
+
#define ZCBOR_VERSION_BUGFIX 1
|
|
26
|
+
|
|
27
|
+
/** The version string with dots and not prefix. */
|
|
28
|
+
#define ZCBOR_VERSION_STR ZCBOR_STRINGIFY(ZCBOR_VERSION_MAJOR) \
|
|
29
|
+
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_MINOR) \
|
|
30
|
+
"." ZCBOR_STRINGIFY(ZCBOR_VERSION_BUGFIX)
|
|
31
|
+
|
|
32
|
+
/** Monotonically increasing integer representing the version. */
|
|
33
|
+
#define ZCBOR_VERSION ((ZCBOR_VERSION_MAJOR << 24) \
|
|
34
|
+
+ (ZCBOR_VERSION_MINOR << 16) \
|
|
35
|
+
+ (ZCBOR_VERSION_BUGFIX << 8))
|
|
36
|
+
|
|
20
37
|
/** Convenience type that allows pointing to strings directly inside the payload
|
|
21
38
|
* without the need to copy out.
|
|
22
39
|
*/
|
|
@@ -40,54 +57,25 @@ struct zcbor_string_fragment {
|
|
|
40
57
|
/** Size to use in struct zcbor_string_fragment when the real size is unknown. */
|
|
41
58
|
#define ZCBOR_STRING_FRAGMENT_UNKNOWN_LENGTH SIZE_MAX
|
|
42
59
|
|
|
43
|
-
#ifdef ZCBOR_VERBOSE
|
|
44
|
-
#include <zephyr/sys/printk.h>
|
|
45
|
-
#define zcbor_trace() (printk("bytes left: %zu, byte: 0x%x, elem_count: 0x%" PRIxFAST32 ", err: %d, %s:%d\n",\
|
|
46
|
-
(size_t)state->payload_end - (size_t)state->payload, *state->payload, state->elem_count, \
|
|
47
|
-
state->constant_state ? state->constant_state->error : 0, __FILE__, __LINE__))
|
|
48
|
-
|
|
49
|
-
#define zcbor_print_assert(expr, ...) \
|
|
50
|
-
do { \
|
|
51
|
-
printk("ASSERTION \n \"" #expr \
|
|
52
|
-
"\"\nfailed at %s:%d with message:\n ", \
|
|
53
|
-
__FILE__, __LINE__); \
|
|
54
|
-
printk(__VA_ARGS__);\
|
|
55
|
-
} while(0)
|
|
56
|
-
#define zcbor_print(...) printk(__VA_ARGS__)
|
|
57
|
-
#else
|
|
58
|
-
#define zcbor_trace() ((void)state)
|
|
59
|
-
#define zcbor_print_assert(...)
|
|
60
|
-
#define zcbor_print(...)
|
|
61
|
-
#endif
|
|
62
|
-
|
|
63
|
-
#ifdef ZCBOR_ASSERTS
|
|
64
|
-
#define zcbor_assert(expr, ...) \
|
|
65
|
-
do { \
|
|
66
|
-
if (!(expr)) { \
|
|
67
|
-
zcbor_print_assert(expr, __VA_ARGS__); \
|
|
68
|
-
ZCBOR_FAIL(); \
|
|
69
|
-
} \
|
|
70
|
-
} while(0)
|
|
71
|
-
#define zcbor_assert_state(expr, ...) \
|
|
72
|
-
do { \
|
|
73
|
-
if (!(expr)) { \
|
|
74
|
-
zcbor_print_assert(expr, __VA_ARGS__); \
|
|
75
|
-
ZCBOR_ERR(ZCBOR_ERR_ASSERTION); \
|
|
76
|
-
} \
|
|
77
|
-
} while(0)
|
|
78
|
-
#else
|
|
79
|
-
#define zcbor_assert(expr, ...)
|
|
80
|
-
#define zcbor_assert_state(expr, ...)
|
|
81
|
-
#endif
|
|
82
|
-
|
|
83
60
|
#ifndef MIN
|
|
84
61
|
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
|
85
62
|
#endif
|
|
86
63
|
|
|
64
|
+
#ifndef MAX
|
|
65
|
+
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
|
|
66
|
+
#endif
|
|
67
|
+
|
|
87
68
|
#ifndef ZCBOR_ARRAY_SIZE
|
|
88
69
|
#define ZCBOR_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
|
89
70
|
#endif
|
|
90
71
|
|
|
72
|
+
/* Endian-dependent offset of smaller integer in a bigger one. */
|
|
73
|
+
#ifdef ZCBOR_BIG_ENDIAN
|
|
74
|
+
#define ZCBOR_ECPY_OFFS(dst_len, src_len) ((dst_len) - (src_len))
|
|
75
|
+
#else
|
|
76
|
+
#define ZCBOR_ECPY_OFFS(dst_len, src_len) (0)
|
|
77
|
+
#endif /* ZCBOR_BIG_ENDIAN */
|
|
78
|
+
|
|
91
79
|
#if SIZE_MAX <= UINT64_MAX
|
|
92
80
|
/** The ZCBOR_SUPPORTS_SIZE_T will be defined if processing of size_t type variables directly
|
|
93
81
|
* with zcbor_size_ functions is supported.
|
|
@@ -99,6 +87,7 @@ do { \
|
|
|
99
87
|
|
|
100
88
|
struct zcbor_state_constant;
|
|
101
89
|
|
|
90
|
+
/** The zcbor_state_t structure is used for both encoding and decoding. */
|
|
102
91
|
typedef struct {
|
|
103
92
|
union {
|
|
104
93
|
uint8_t *payload_mut;
|
|
@@ -115,12 +104,35 @@ union {
|
|
|
115
104
|
uint8_t const *payload_end; /**< The end of the payload. This will be
|
|
116
105
|
checked against payload before
|
|
117
106
|
processing each element. */
|
|
118
|
-
bool indefinite_length_array; /**< Is set to true if the decoder is currently
|
|
119
|
-
decoding the contents of an indefinite-
|
|
120
|
-
length array. */
|
|
121
107
|
bool payload_moved; /**< Is set to true while the state is stored as a backup
|
|
122
108
|
if @ref zcbor_update_state is called, since that function
|
|
123
109
|
updates the payload_end of all backed-up states. */
|
|
110
|
+
|
|
111
|
+
/* This is the "decode state", the part of zcbor_state_t that is only used by zcbor_decode.c. */
|
|
112
|
+
struct {
|
|
113
|
+
bool indefinite_length_array; /**< Is set to true if the decoder is currently
|
|
114
|
+
decoding the contents of an indefinite-
|
|
115
|
+
length array. */
|
|
116
|
+
bool counting_map_elems; /**< Is set to true while the number of elements of the
|
|
117
|
+
current map are being counted. */
|
|
118
|
+
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
119
|
+
uint8_t *map_search_elem_state; /**< Optional flags to use when searching unordered
|
|
120
|
+
maps. If this is not NULL and map_elem_count
|
|
121
|
+
is non-zero, this consists of one flag per element
|
|
122
|
+
in the current map. The n-th bit can be set to 0
|
|
123
|
+
to indicate that the n-th element in the
|
|
124
|
+
map should not be searched. These are manipulated
|
|
125
|
+
via zcbor_elem_processed() or
|
|
126
|
+
zcbor_unordered_map_search(), and should not be
|
|
127
|
+
manipulated directly. */
|
|
128
|
+
#else
|
|
129
|
+
size_t map_elems_processed; /**< The number of elements of an unordered map
|
|
130
|
+
that have been processed. */
|
|
131
|
+
#endif
|
|
132
|
+
size_t map_elem_count; /**< Number of elements in the current unordered map.
|
|
133
|
+
This also serves as the number of bits (not bytes)
|
|
134
|
+
in the map_search_elem_state array (when applicable). */
|
|
135
|
+
} decode_state;
|
|
124
136
|
struct zcbor_state_constant *constant_state; /**< The part of the state that is
|
|
125
137
|
not backed up and duplicated. */
|
|
126
138
|
} zcbor_state_t;
|
|
@@ -132,6 +144,11 @@ struct zcbor_state_constant {
|
|
|
132
144
|
int error;
|
|
133
145
|
#ifdef ZCBOR_STOP_ON_ERROR
|
|
134
146
|
bool stop_on_error;
|
|
147
|
+
#endif
|
|
148
|
+
bool manually_process_elem; /**< Whether an (unordered map) element should be automatically
|
|
149
|
+
marked as processed when found via @ref zcbor_search_map_key. */
|
|
150
|
+
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
151
|
+
uint8_t *map_search_elem_state_end; /**< The end of the @ref map_search_elem_state buffer. */
|
|
135
152
|
#endif
|
|
136
153
|
};
|
|
137
154
|
|
|
@@ -159,24 +176,32 @@ typedef enum
|
|
|
159
176
|
ZCBOR_MAJOR_TYPE_SIMPLE = 7, ///! Simple values and floats
|
|
160
177
|
} zcbor_major_type_t;
|
|
161
178
|
|
|
179
|
+
/** Extract the major type, i.e. the first 3 bits of the header byte. */
|
|
180
|
+
#define ZCBOR_MAJOR_TYPE(header_byte) ((zcbor_major_type_t)(((header_byte) >> 5) & 0x7))
|
|
181
|
+
|
|
182
|
+
/** Extract the additional info, i.e. the last 5 bits of the header byte. */
|
|
183
|
+
#define ZCBOR_ADDITIONAL(header_byte) ((header_byte) & 0x1F)
|
|
162
184
|
|
|
163
185
|
/** Convenience macro for failing out of a decoding/encoding function.
|
|
164
186
|
*/
|
|
165
187
|
#define ZCBOR_FAIL() \
|
|
166
188
|
do {\
|
|
167
|
-
|
|
189
|
+
zcbor_log("ZCBOR_FAIL "); \
|
|
190
|
+
zcbor_trace_file(state); \
|
|
168
191
|
return false; \
|
|
169
192
|
} while(0)
|
|
170
193
|
|
|
171
194
|
#define ZCBOR_FAIL_IF(expr) \
|
|
172
195
|
do {\
|
|
173
196
|
if (expr) { \
|
|
197
|
+
zcbor_log("ZCBOR_FAIL_IF(" #expr ") "); \
|
|
174
198
|
ZCBOR_FAIL(); \
|
|
175
199
|
} \
|
|
176
200
|
} while(0)
|
|
177
201
|
|
|
178
202
|
#define ZCBOR_ERR(err) \
|
|
179
203
|
do { \
|
|
204
|
+
zcbor_log("ZCBOR_ERR(%d) ", err); \
|
|
180
205
|
zcbor_error(state, err); \
|
|
181
206
|
ZCBOR_FAIL(); \
|
|
182
207
|
} while(0)
|
|
@@ -184,6 +209,7 @@ do { \
|
|
|
184
209
|
#define ZCBOR_ERR_IF(expr, err) \
|
|
185
210
|
do {\
|
|
186
211
|
if (expr) { \
|
|
212
|
+
zcbor_log("ZCBOR_ERR_IF(" #expr ", %d) ", err); \
|
|
187
213
|
ZCBOR_ERR(err); \
|
|
188
214
|
} \
|
|
189
215
|
} while(0)
|
|
@@ -213,7 +239,8 @@ do { \
|
|
|
213
239
|
|
|
214
240
|
#define ZCBOR_FLAG_RESTORE 1UL ///! Restore from the backup. Overwrite the current state with the state from the backup.
|
|
215
241
|
#define ZCBOR_FLAG_CONSUME 2UL ///! Consume the backup. Remove the backup from the stack of backups.
|
|
216
|
-
#define
|
|
242
|
+
#define ZCBOR_FLAG_KEEP_PAYLOAD 4UL ///! Keep the pre-restore payload after restoring.
|
|
243
|
+
#define ZCBOR_FLAG_KEEP_DECODE_STATE 8UL ///! Keep the pre-restore decode state (everything only used for decoding)
|
|
217
244
|
|
|
218
245
|
#define ZCBOR_SUCCESS 0
|
|
219
246
|
#define ZCBOR_ERR_NO_BACKUP_MEM 1
|
|
@@ -230,17 +257,20 @@ do { \
|
|
|
230
257
|
#define ZCBOR_ERR_WRONG_RANGE 12
|
|
231
258
|
#define ZCBOR_ERR_ITERATIONS 13
|
|
232
259
|
#define ZCBOR_ERR_ASSERTION 14
|
|
260
|
+
#define ZCBOR_ERR_PAYLOAD_OUTDATED 15 ///! Because of a call to @ref zcbor_update_state
|
|
261
|
+
#define ZCBOR_ERR_ELEM_NOT_FOUND 16
|
|
262
|
+
#define ZCBOR_ERR_MAP_MISALIGNED 17
|
|
263
|
+
#define ZCBOR_ERR_ELEMS_NOT_PROCESSED 18
|
|
264
|
+
#define ZCBOR_ERR_NOT_AT_END 19
|
|
265
|
+
#define ZCBOR_ERR_MAP_FLAGS_NOT_AVAILABLE 20
|
|
266
|
+
#define ZCBOR_ERR_INVALID_VALUE_ENCODING 21 ///! When ZCBOR_CANONICAL is defined, and the incoming data is not encoded with minimal length.
|
|
233
267
|
#define ZCBOR_ERR_UNKNOWN 31
|
|
234
268
|
|
|
235
269
|
/** The largest possible elem_count. */
|
|
236
|
-
#
|
|
237
|
-
#define ZCBOR_MAX_ELEM_COUNT UINT_FAST32_MAX
|
|
238
|
-
#else
|
|
239
|
-
#define ZCBOR_MAX_ELEM_COUNT ((size_t)(-1L))
|
|
240
|
-
#endif
|
|
270
|
+
#define ZCBOR_MAX_ELEM_COUNT SIZE_MAX
|
|
241
271
|
|
|
242
272
|
/** Initial value for elem_count for when it just needs to be large. */
|
|
243
|
-
#define ZCBOR_LARGE_ELEM_COUNT (ZCBOR_MAX_ELEM_COUNT -
|
|
273
|
+
#define ZCBOR_LARGE_ELEM_COUNT (ZCBOR_MAX_ELEM_COUNT - 15)
|
|
244
274
|
|
|
245
275
|
|
|
246
276
|
/** Take a backup of the current state. Overwrite the current elem_count. */
|
|
@@ -278,17 +308,30 @@ bool zcbor_union_end_code(zcbor_state_t *state);
|
|
|
278
308
|
* If there is no struct zcbor_state_constant (n_states == 1), error codes are
|
|
279
309
|
* not available.
|
|
280
310
|
* This means that you get a state with (n_states - 2) backups.
|
|
281
|
-
* payload, payload_len, and
|
|
282
|
-
*
|
|
311
|
+
* payload, payload_len, elem_count, and elem_state are used to initialize the first state.
|
|
312
|
+
* The elem_state is only needed for unordered maps, when ZCBOR_MAP_SMART_SEARCH is enabled.
|
|
313
|
+
* It is ignored otherwise.
|
|
283
314
|
*/
|
|
284
315
|
void zcbor_new_state(zcbor_state_t *state_array, size_t n_states,
|
|
285
|
-
const uint8_t *payload, size_t payload_len, size_t elem_count
|
|
316
|
+
const uint8_t *payload, size_t payload_len, size_t elem_count,
|
|
317
|
+
uint8_t *elem_state, size_t elem_state_bytes);
|
|
318
|
+
|
|
319
|
+
/** Do boilerplate entry function procedure.
|
|
320
|
+
* Initialize states, call function, and check the result.
|
|
321
|
+
*/
|
|
322
|
+
int zcbor_entry_function(const uint8_t *payload, size_t payload_len,
|
|
323
|
+
void *result, size_t *payload_len_out, zcbor_state_t *state, zcbor_decoder_t func,
|
|
324
|
+
size_t n_states, size_t elem_count);
|
|
286
325
|
|
|
287
326
|
#ifdef ZCBOR_STOP_ON_ERROR
|
|
288
|
-
/** Check stored error and fail if present, but only if stop_on_error is true.
|
|
327
|
+
/** Check stored error and fail if present, but only if stop_on_error is true.
|
|
328
|
+
*
|
|
329
|
+
* @retval true No error found
|
|
330
|
+
* @retval false An error was found
|
|
331
|
+
*/
|
|
289
332
|
static inline bool zcbor_check_error(const zcbor_state_t *state)
|
|
290
333
|
{
|
|
291
|
-
struct zcbor_state_constant
|
|
334
|
+
struct zcbor_state_constant *cs = state->constant_state;
|
|
292
335
|
return !(cs && cs->stop_on_error && cs->error);
|
|
293
336
|
}
|
|
294
337
|
#endif
|
|
@@ -341,7 +384,7 @@ static inline bool zcbor_payload_at_end(const zcbor_state_t *state)
|
|
|
341
384
|
* This function also updates all backups to the new payload_end.
|
|
342
385
|
* This sets a flag so that @ref zcbor_process_backup fails if a backup is
|
|
343
386
|
* processed with the flag @ref ZCBOR_FLAG_RESTORE, but without the flag
|
|
344
|
-
* @ref
|
|
387
|
+
* @ref ZCBOR_FLAG_KEEP_PAYLOAD since this would cause an invalid state.
|
|
345
388
|
*
|
|
346
389
|
* @param[inout] state The current state, will be updated with
|
|
347
390
|
* the new payload pointer.
|
|
@@ -408,12 +451,56 @@ bool zcbor_compare_strings(const struct zcbor_string *str1,
|
|
|
408
451
|
*
|
|
409
452
|
* @return The length of the header in bytes (1-9).
|
|
410
453
|
*/
|
|
411
|
-
size_t zcbor_header_len(
|
|
454
|
+
size_t zcbor_header_len(uint64_t value);
|
|
455
|
+
|
|
456
|
+
/** Like @ref zcbor_header_len but for integer of any size <= 8. */
|
|
457
|
+
size_t zcbor_header_len_ptr(const void *const value, size_t value_len);
|
|
458
|
+
|
|
459
|
+
/** Convert a float16 value to float32.
|
|
460
|
+
*
|
|
461
|
+
* @param[in] input The float16 value stored in a uint16_t.
|
|
462
|
+
*
|
|
463
|
+
* @return The resulting float32 value.
|
|
464
|
+
*/
|
|
465
|
+
float zcbor_float16_to_32(uint16_t input);
|
|
412
466
|
|
|
413
|
-
/**
|
|
467
|
+
/** Convert a float32 value to float16.
|
|
468
|
+
*
|
|
469
|
+
* @param[in] input The float32 value.
|
|
470
|
+
*
|
|
471
|
+
* @return The resulting float16 value as a uint16_t.
|
|
414
472
|
*/
|
|
415
|
-
|
|
473
|
+
uint16_t zcbor_float32_to_16(float input);
|
|
474
|
+
|
|
475
|
+
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
476
|
+
static inline size_t zcbor_round_up(size_t x, size_t align)
|
|
477
|
+
{
|
|
478
|
+
return (((x) + (align) - 1) / (align) * (align));
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
#define ZCBOR_BITS_PER_BYTE 8
|
|
482
|
+
/** Calculate the number of bytes needed to hold @p num_flags 1 bit flags
|
|
483
|
+
*/
|
|
484
|
+
static inline size_t zcbor_flags_to_bytes(size_t num_flags)
|
|
485
|
+
{
|
|
486
|
+
return zcbor_round_up(num_flags, ZCBOR_BITS_PER_BYTE) / ZCBOR_BITS_PER_BYTE;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Calculate the number of zcbor_state_t instances needed to hold @p num_flags 1 bit flags
|
|
490
|
+
*/
|
|
491
|
+
static inline size_t zcbor_flags_to_states(size_t num_flags)
|
|
492
|
+
{
|
|
493
|
+
return zcbor_round_up(num_flags, sizeof(zcbor_state_t) * ZCBOR_BITS_PER_BYTE)
|
|
494
|
+
/ (sizeof(zcbor_state_t) * ZCBOR_BITS_PER_BYTE);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
#define ZCBOR_FLAG_STATES(n_flags) zcbor_flags_to_states(n_flags)
|
|
498
|
+
|
|
499
|
+
#else
|
|
500
|
+
#define ZCBOR_FLAG_STATES(n_flags) 0
|
|
501
|
+
#endif
|
|
416
502
|
|
|
503
|
+
size_t strnlen(const char *, size_t);
|
|
417
504
|
|
|
418
505
|
#ifdef __cplusplus
|
|
419
506
|
}
|