edhoc 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/crypto.d.ts +9 -2
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +112 -84
- package/dist/edhoc.d.ts +31 -9
- package/dist/edhoc.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/dist/credentials.d.ts +0 -16
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js +0 -84
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
#include <zephyr/ztest.h>
|
|
8
8
|
#include "manifest3_decode.h"
|
|
9
9
|
#include "manifest3_encode.h"
|
|
10
|
-
#include "
|
|
10
|
+
#include "zcbor_print.h"
|
|
11
11
|
|
|
12
12
|
/* draft-ietf-suit-manifest-02 Example 0 */
|
|
13
13
|
uint8_t test_vector0_02[] = {
|
|
@@ -244,7 +244,7 @@ void test_command_sequence(struct zcbor_string *sequence_str,
|
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
zcbor_log("\r\ntest %s\r\n", name);
|
|
248
248
|
|
|
249
249
|
memset(&sequence1, 0, sizeof(sequence1));
|
|
250
250
|
int res = cbor_decode_SUIT_Command_Sequence(sequence_str->value,
|
|
@@ -263,48 +263,48 @@ void test_command_sequence(struct zcbor_string *sequence_str,
|
|
|
263
263
|
sequence_str->len,
|
|
264
264
|
NULL);
|
|
265
265
|
|
|
266
|
-
for (uint32_t i = 0; i < sequence1.
|
|
267
|
-
struct
|
|
266
|
+
for (uint32_t i = 0; i < sequence1.SUIT_Command_Sequence_union_count; i++) {
|
|
267
|
+
struct SUIT_Directive_r *directive;
|
|
268
268
|
bool directive_present;
|
|
269
269
|
directive = &sequence1
|
|
270
|
-
.
|
|
271
|
-
.
|
|
270
|
+
.SUIT_Command_Sequence_union[i]
|
|
271
|
+
.SUIT_Command_Sequence_union_SUIT_Directive_m;
|
|
272
272
|
directive_present = sequence1
|
|
273
|
-
.
|
|
274
|
-
.
|
|
275
|
-
==
|
|
273
|
+
.SUIT_Command_Sequence_union[i]
|
|
274
|
+
.SUIT_Command_Sequence_union_choice
|
|
275
|
+
== SUIT_Command_Sequence_union_SUIT_Directive_m_c;
|
|
276
276
|
|
|
277
277
|
run_seq = &directive
|
|
278
|
-
->
|
|
278
|
+
->SUIT_Directive_suit_directive_run_sequence_m_l_SUIT_Command_Sequence_bstr;
|
|
279
279
|
run_seq_present = directive_present
|
|
280
280
|
&& directive
|
|
281
|
-
->
|
|
282
|
-
==
|
|
281
|
+
->SUIT_Directive_choice
|
|
282
|
+
== SUIT_Directive_suit_directive_run_sequence_m_l_c;
|
|
283
283
|
test_command_sequence(run_seq, run_seq_present, "run_seq");
|
|
284
284
|
|
|
285
285
|
for (uint32_t j = 0; j < directive
|
|
286
|
-
->
|
|
287
|
-
.
|
|
286
|
+
->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
|
|
287
|
+
.SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr_count; j++) {
|
|
288
288
|
|
|
289
289
|
try_each1 = &directive
|
|
290
|
-
->
|
|
291
|
-
.
|
|
290
|
+
->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
|
|
291
|
+
.SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr[j];
|
|
292
292
|
try_each1_present = directive_present
|
|
293
|
-
&& directive->
|
|
294
|
-
==
|
|
293
|
+
&& directive->SUIT_Directive_choice
|
|
294
|
+
== SUIT_Directive_suit_directive_try_each_m_l_c;
|
|
295
295
|
test_command_sequence(try_each1, try_each1_present, "try_each1");
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
try_each2 = &directive
|
|
299
|
-
->
|
|
300
|
-
.
|
|
299
|
+
->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
|
|
300
|
+
.SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr;
|
|
301
301
|
try_each2_present = directive_present
|
|
302
|
-
&& directive->
|
|
303
|
-
==
|
|
302
|
+
&& directive->SUIT_Directive_choice
|
|
303
|
+
== SUIT_Directive_suit_directive_try_each_m_l_c
|
|
304
304
|
&& directive
|
|
305
|
-
->
|
|
306
|
-
.
|
|
307
|
-
==
|
|
305
|
+
->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
|
|
306
|
+
.SUIT_Directive_Try_Each_Argument_union_choice
|
|
307
|
+
== SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr_c;
|
|
308
308
|
test_command_sequence(try_each2, try_each2_present, "try_each2");
|
|
309
309
|
|
|
310
310
|
}
|
|
@@ -338,102 +338,102 @@ void test_manifest(const uint8_t *input, uint32_t len)
|
|
|
338
338
|
int res;
|
|
339
339
|
size_t out_len;
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
zcbor_log("test_vector at: 0x%zx\r\n", (size_t)input);
|
|
342
|
+
zcbor_log("test_vector end at: 0x%zx\r\n",
|
|
343
343
|
((size_t)input) + len);
|
|
344
344
|
res = cbor_decode_SUIT_Outer_Wrapper(input, len, &outerwrapper1, NULL);
|
|
345
345
|
zassert_equal(ZCBOR_SUCCESS, res, "top-level decoding failed.");
|
|
346
346
|
|
|
347
347
|
dependency1 = &outerwrapper1
|
|
348
|
-
.
|
|
349
|
-
.
|
|
348
|
+
.SUIT_Outer_Wrapper_suit_dependency_resolution
|
|
349
|
+
.SUIT_Outer_Wrapper_suit_dependency_resolution;
|
|
350
350
|
dependency1_present = outerwrapper1
|
|
351
|
-
.
|
|
351
|
+
.SUIT_Outer_Wrapper_suit_dependency_resolution_present;
|
|
352
352
|
test_command_sequence(dependency1, dependency1_present, "dependency1");
|
|
353
353
|
|
|
354
354
|
fetch1 = &outerwrapper1
|
|
355
|
-
.
|
|
356
|
-
.
|
|
355
|
+
.SUIT_Outer_Wrapper_suit_payload_fetch
|
|
356
|
+
.SUIT_Outer_Wrapper_suit_payload_fetch;
|
|
357
357
|
fetch1_present = outerwrapper1
|
|
358
|
-
.
|
|
358
|
+
.SUIT_Outer_Wrapper_suit_payload_fetch_present;
|
|
359
359
|
test_command_sequence(fetch1, fetch1_present, "fetch1");
|
|
360
360
|
|
|
361
361
|
install1 = &outerwrapper1
|
|
362
|
-
.
|
|
363
|
-
.
|
|
362
|
+
.SUIT_Outer_Wrapper_suit_install
|
|
363
|
+
.SUIT_Outer_Wrapper_suit_install;
|
|
364
364
|
install1_present = outerwrapper1
|
|
365
|
-
.
|
|
365
|
+
.SUIT_Outer_Wrapper_suit_install_present;
|
|
366
366
|
test_command_sequence(install1, install1_present, "install1");
|
|
367
367
|
|
|
368
368
|
manifest = &outerwrapper1
|
|
369
|
-
.
|
|
370
|
-
.
|
|
369
|
+
.SUIT_Outer_Wrapper_SUIT_Manifest_Wrapped_m
|
|
370
|
+
.SUIT_Manifest_Wrapped_suit_manifest_cbor;
|
|
371
371
|
|
|
372
372
|
common_seq = &manifest
|
|
373
|
-
->
|
|
374
|
-
.
|
|
375
|
-
.
|
|
376
|
-
.
|
|
373
|
+
->SUIT_Manifest_suit_common
|
|
374
|
+
.SUIT_Manifest_suit_common_cbor
|
|
375
|
+
.SUIT_Common_suit_common_sequence
|
|
376
|
+
.SUIT_Common_suit_common_sequence;
|
|
377
377
|
common_seq_present = manifest
|
|
378
|
-
->
|
|
378
|
+
->SUIT_Manifest_suit_common_present
|
|
379
379
|
&& manifest
|
|
380
|
-
->
|
|
381
|
-
.
|
|
382
|
-
.
|
|
380
|
+
->SUIT_Manifest_suit_common
|
|
381
|
+
.SUIT_Manifest_suit_common_cbor
|
|
382
|
+
.SUIT_Common_suit_common_sequence_present;
|
|
383
383
|
test_command_sequence(common_seq, common_seq_present, "common_seq");
|
|
384
384
|
|
|
385
385
|
dependency2 = &manifest
|
|
386
|
-
->
|
|
387
|
-
.
|
|
386
|
+
->SUIT_Manifest_suit_dependency_resolution
|
|
387
|
+
.SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr;
|
|
388
388
|
dependency2_present = manifest
|
|
389
|
-
->
|
|
389
|
+
->SUIT_Manifest_suit_dependency_resolution_present
|
|
390
390
|
&& manifest
|
|
391
|
-
->
|
|
392
|
-
.
|
|
393
|
-
|
|
391
|
+
->SUIT_Manifest_suit_dependency_resolution
|
|
392
|
+
.SUIT_Manifest_suit_dependency_resolution_choice ==
|
|
393
|
+
SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr_c;
|
|
394
394
|
test_command_sequence(dependency2, dependency2_present, "dependency2");
|
|
395
395
|
|
|
396
396
|
fetch2 = &manifest
|
|
397
|
-
->
|
|
398
|
-
.
|
|
397
|
+
->SUIT_Manifest_suit_payload_fetch
|
|
398
|
+
.SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr;
|
|
399
399
|
fetch2_present = manifest
|
|
400
|
-
->
|
|
400
|
+
->SUIT_Manifest_suit_payload_fetch_present
|
|
401
401
|
&& manifest
|
|
402
|
-
->
|
|
403
|
-
.
|
|
404
|
-
|
|
402
|
+
->SUIT_Manifest_suit_payload_fetch
|
|
403
|
+
.SUIT_Manifest_suit_payload_fetch_choice ==
|
|
404
|
+
SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr_c;
|
|
405
405
|
test_command_sequence(fetch2, fetch2_present, "fetch2");
|
|
406
406
|
|
|
407
407
|
install2 = &manifest
|
|
408
|
-
->
|
|
409
|
-
.
|
|
408
|
+
->SUIT_Manifest_suit_install
|
|
409
|
+
.SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr;
|
|
410
410
|
install2_present = manifest
|
|
411
|
-
->
|
|
411
|
+
->SUIT_Manifest_suit_install_present
|
|
412
412
|
&& manifest
|
|
413
|
-
->
|
|
414
|
-
.
|
|
415
|
-
|
|
413
|
+
->SUIT_Manifest_suit_install
|
|
414
|
+
.SUIT_Manifest_suit_install_choice ==
|
|
415
|
+
SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr_c;
|
|
416
416
|
test_command_sequence(install2, install2_present, "install2");
|
|
417
417
|
|
|
418
418
|
validate = &manifest
|
|
419
|
-
->
|
|
420
|
-
.
|
|
419
|
+
->SUIT_Manifest_suit_validate
|
|
420
|
+
.SUIT_Manifest_suit_validate;
|
|
421
421
|
validate_present = manifest
|
|
422
|
-
->
|
|
422
|
+
->SUIT_Manifest_suit_validate_present;
|
|
423
423
|
test_command_sequence(validate, validate_present, "validate");
|
|
424
424
|
|
|
425
425
|
load = &manifest
|
|
426
|
-
->
|
|
427
|
-
.
|
|
426
|
+
->SUIT_Manifest_suit_load
|
|
427
|
+
.SUIT_Manifest_suit_load;
|
|
428
428
|
load_present = manifest
|
|
429
|
-
->
|
|
429
|
+
->SUIT_Manifest_suit_load_present;
|
|
430
430
|
test_command_sequence(load, load_present, "load");
|
|
431
431
|
|
|
432
432
|
run = &manifest
|
|
433
|
-
->
|
|
434
|
-
.
|
|
433
|
+
->SUIT_Manifest_suit_run
|
|
434
|
+
.SUIT_Manifest_suit_run;
|
|
435
435
|
run_present = manifest
|
|
436
|
-
->
|
|
436
|
+
->SUIT_Manifest_suit_run_present;
|
|
437
437
|
test_command_sequence(run, run_present, "run");
|
|
438
438
|
|
|
439
439
|
res = cbor_encode_SUIT_Outer_Wrapper(output,
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
#include <zephyr/ztest.h>
|
|
8
8
|
#include <pet_encode.h>
|
|
9
9
|
#include <zcbor_encode.h>
|
|
10
|
-
#include <zcbor_debug.h> // Enables use of print functions when debugging tests.
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
#define CONCAT_BYTE(a,b) a ## b
|
|
@@ -41,7 +40,7 @@ ZTEST(cbor_encode_test2, test_pet)
|
|
|
41
40
|
.names = {{.value = "foo", .len = 3}, {.value = "bar", .len = 3}},
|
|
42
41
|
.names_count = 2,
|
|
43
42
|
.birthday = {.value = (uint8_t[]){1,2,3,4,5,6,7,8}, .len = 8},
|
|
44
|
-
.species_choice =
|
|
43
|
+
.species_choice = Pet_species_dog_c
|
|
45
44
|
};
|
|
46
45
|
uint8_t exp_output[] = {
|
|
47
46
|
LIST(3),
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
#include <zephyr/ztest.h>
|
|
8
8
|
#include "corner_cases_encode.h"
|
|
9
|
-
#include "zcbor_debug.h" // Enables use of print functions when debugging tests.
|
|
10
9
|
|
|
11
10
|
#define CONCAT_BYTE(a,b) a ## b
|
|
12
11
|
|
|
@@ -87,8 +86,9 @@ ZTEST(cbor_encode_test3, test_numbers)
|
|
|
87
86
|
ZTEST(cbor_encode_test3, test_numbers2)
|
|
88
87
|
{
|
|
89
88
|
const uint8_t exp_payload_numbers2[] = {
|
|
90
|
-
LIST(
|
|
89
|
+
LIST(8),
|
|
91
90
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
91
|
+
0x3A, 0x7F, 0xFF, 0xFF, 0xFF, // -0x8000_0000
|
|
92
92
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
93
93
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
94
94
|
0x00, // 0
|
|
@@ -99,6 +99,7 @@ ZTEST(cbor_encode_test3, test_numbers2)
|
|
|
99
99
|
};
|
|
100
100
|
struct Numbers2 numbers2 = {
|
|
101
101
|
.threebytes = 0x123456,
|
|
102
|
+
.int32 = -0x80000000L,
|
|
102
103
|
.big_int = 0x0102030405060708,
|
|
103
104
|
.big_uint = 0x1102030405060709,
|
|
104
105
|
.big_uint2 = 0,
|
|
@@ -122,9 +123,9 @@ ZTEST(cbor_encode_test3, test_tagged_union)
|
|
|
122
123
|
|
|
123
124
|
uint8_t output[5];
|
|
124
125
|
|
|
125
|
-
struct
|
|
126
|
-
input.TaggedUnion_choice =
|
|
127
|
-
input.
|
|
126
|
+
struct TaggedUnion_r input;
|
|
127
|
+
input.TaggedUnion_choice = TaggedUnion_bool_c;
|
|
128
|
+
input.Bool = true;
|
|
128
129
|
|
|
129
130
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_TaggedUnion(output,
|
|
130
131
|
sizeof(output), &input, &encode_len), "%d\r\n");
|
|
@@ -132,7 +133,7 @@ ZTEST(cbor_encode_test3, test_tagged_union)
|
|
|
132
133
|
zassert_equal(sizeof(exp_payload_tagged_union1), encode_len, NULL);
|
|
133
134
|
zassert_mem_equal(exp_payload_tagged_union1, output, sizeof(exp_payload_tagged_union1), NULL);
|
|
134
135
|
|
|
135
|
-
input.TaggedUnion_choice =
|
|
136
|
+
input.TaggedUnion_choice = TaggedUnion_uint_c;
|
|
136
137
|
input.uint = 0x10;
|
|
137
138
|
|
|
138
139
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_TaggedUnion(output,
|
|
@@ -512,43 +513,43 @@ ZTEST(cbor_encode_test3, test_union)
|
|
|
512
513
|
0x03, 0x23, 0x03, 0x23, 0x03, 0x23
|
|
513
514
|
};
|
|
514
515
|
|
|
515
|
-
struct
|
|
516
|
-
struct
|
|
517
|
-
struct
|
|
518
|
-
struct
|
|
519
|
-
struct
|
|
520
|
-
struct
|
|
516
|
+
struct Union_r union1 = {.Union_choice = Union_Group_m_c};
|
|
517
|
+
struct Union_r union2 = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 1};
|
|
518
|
+
struct Union_r union3 = {.Union_choice = Union_uint3_l_c};
|
|
519
|
+
struct Union_r union4 = {.Union_choice = Union_hello_tstr_c};
|
|
520
|
+
struct Union_r union5 = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 6};
|
|
521
|
+
struct Union_r union6_inv = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 7};
|
|
521
522
|
|
|
522
523
|
uint8_t output[15];
|
|
523
524
|
size_t out_len;
|
|
524
525
|
|
|
525
526
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
|
|
526
|
-
&
|
|
527
|
+
&union1, &out_len), NULL);
|
|
527
528
|
zassert_equal(sizeof(exp_payload_union1), out_len, NULL);
|
|
528
529
|
zassert_mem_equal(exp_payload_union1, output, sizeof(exp_payload_union1), NULL);
|
|
529
530
|
|
|
530
531
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
|
|
531
|
-
&
|
|
532
|
+
&union2, &out_len), NULL);
|
|
532
533
|
zassert_equal(sizeof(exp_payload_union2), out_len, NULL);
|
|
533
534
|
zassert_mem_equal(exp_payload_union2, output, sizeof(exp_payload_union2), NULL);
|
|
534
535
|
|
|
535
536
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
|
|
536
|
-
&
|
|
537
|
+
&union3, &out_len), NULL);
|
|
537
538
|
zassert_equal(sizeof(exp_payload_union3), out_len, NULL);
|
|
538
539
|
zassert_mem_equal(exp_payload_union3, output, sizeof(exp_payload_union3), NULL);
|
|
539
540
|
|
|
540
541
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
|
|
541
|
-
&
|
|
542
|
+
&union4, &out_len), NULL);
|
|
542
543
|
zassert_equal(sizeof(exp_payload_union4), out_len, NULL);
|
|
543
544
|
zassert_mem_equal(exp_payload_union4, output, sizeof(exp_payload_union4), NULL);
|
|
544
545
|
|
|
545
546
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
|
|
546
|
-
&
|
|
547
|
+
&union5, &out_len), NULL);
|
|
547
548
|
zassert_equal(sizeof(exp_payload_union5), out_len, NULL);
|
|
548
549
|
zassert_mem_equal(exp_payload_union5, output, sizeof(exp_payload_union5), NULL);
|
|
549
550
|
|
|
550
551
|
zassert_equal(ZCBOR_ERR_ITERATIONS, cbor_encode_Union(output, sizeof(output),
|
|
551
|
-
&
|
|
552
|
+
&union6_inv, &out_len), NULL);
|
|
552
553
|
}
|
|
553
554
|
|
|
554
555
|
ZTEST(cbor_encode_test3, test_levels)
|
|
@@ -572,8 +573,8 @@ ZTEST(cbor_encode_test3, test_levels)
|
|
|
572
573
|
uint8_t output[32];
|
|
573
574
|
size_t out_len;
|
|
574
575
|
|
|
575
|
-
struct Level2 level1 = {.
|
|
576
|
-
{.
|
|
576
|
+
struct Level2 level1 = {.Level3_m_count = 2, .Level3_m = {
|
|
577
|
+
{.Level4_m_count = 4}, {.Level4_m_count = 4}
|
|
577
578
|
}};
|
|
578
579
|
_Static_assert(sizeof(exp_payload_levels1) <= sizeof(output),
|
|
579
580
|
"Payload is larger than output");
|
|
@@ -613,7 +614,7 @@ ZTEST(cbor_encode_test3, test_map)
|
|
|
613
614
|
};
|
|
614
615
|
|
|
615
616
|
struct Map map1 = {
|
|
616
|
-
.union_choice =
|
|
617
|
+
.union_choice = union_uint7uint_c,
|
|
617
618
|
.uint7uint = 1,
|
|
618
619
|
.twotothree_count = 2,
|
|
619
620
|
.twotothree = {
|
|
@@ -623,7 +624,7 @@ ZTEST(cbor_encode_test3, test_map)
|
|
|
623
624
|
};
|
|
624
625
|
struct Map map2 = {
|
|
625
626
|
.listkey = true,
|
|
626
|
-
.union_choice =
|
|
627
|
+
.union_choice = union_uint7uint_c,
|
|
627
628
|
.uint7uint = 1,
|
|
628
629
|
.twotothree_count = 3,
|
|
629
630
|
.twotothree = {
|
|
@@ -633,7 +634,7 @@ ZTEST(cbor_encode_test3, test_map)
|
|
|
633
634
|
}
|
|
634
635
|
};
|
|
635
636
|
struct Map map3 = {
|
|
636
|
-
.union_choice =
|
|
637
|
+
.union_choice = union_nintuint_c,
|
|
637
638
|
.nintuint = 1,
|
|
638
639
|
.twotothree_count = 2,
|
|
639
640
|
.twotothree = {
|
|
@@ -740,31 +741,31 @@ ZTEST(cbor_encode_test3, test_nested_map_list_map)
|
|
|
740
741
|
const uint8_t exp_payload_nested_mlm4[] = {MAP(2), LIST(0), END LIST(0), END LIST(0), END LIST(0), END END};
|
|
741
742
|
const uint8_t exp_payload_nested_mlm5[] = {MAP(3), LIST(0), END LIST(0), END LIST(0), END LIST(0), END LIST(0), END LIST(2), MAP(0), END MAP(0), END END END};
|
|
742
743
|
struct NestedMapListMap maplistmap1 = {
|
|
743
|
-
.
|
|
744
|
-
.
|
|
744
|
+
.map_l_count = 1,
|
|
745
|
+
.map_l = {{0}}
|
|
745
746
|
};
|
|
746
747
|
struct NestedMapListMap maplistmap2 = {
|
|
747
|
-
.
|
|
748
|
-
.
|
|
748
|
+
.map_l_count = 1,
|
|
749
|
+
.map_l = {
|
|
749
750
|
{.map_count = 1}
|
|
750
751
|
}
|
|
751
752
|
};
|
|
752
753
|
struct NestedMapListMap maplistmap3 = {
|
|
753
|
-
.
|
|
754
|
-
.
|
|
754
|
+
.map_l_count = 1,
|
|
755
|
+
.map_l = {
|
|
755
756
|
{.map_count = 2}
|
|
756
757
|
}
|
|
757
758
|
};
|
|
758
759
|
struct NestedMapListMap maplistmap4 = {
|
|
759
|
-
.
|
|
760
|
-
.
|
|
760
|
+
.map_l_count = 2,
|
|
761
|
+
.map_l = {
|
|
761
762
|
{.map_count = 0},
|
|
762
763
|
{.map_count = 0},
|
|
763
764
|
}
|
|
764
765
|
};
|
|
765
766
|
struct NestedMapListMap maplistmap5 = {
|
|
766
|
-
.
|
|
767
|
-
.
|
|
767
|
+
.map_l_count = 3,
|
|
768
|
+
.map_l = {
|
|
768
769
|
{.map_count = 0},
|
|
769
770
|
{.map_count = 0},
|
|
770
771
|
{.map_count = 2},
|
|
@@ -1072,12 +1073,12 @@ ZTEST(cbor_encode_test3, test_unabstracted)
|
|
|
1072
1073
|
uint8_t exp_payload_unabstracted0[] = {LIST(2), 0x01, 0x03, END};
|
|
1073
1074
|
uint8_t exp_payload_unabstracted1[] = {LIST(2), 0x02, 0x04, END};
|
|
1074
1075
|
struct Unabstracted result_unabstracted0 = {
|
|
1075
|
-
.unabstractedunion1_choice =
|
|
1076
|
-
.unabstractedunion2_choice =
|
|
1076
|
+
.unabstractedunion1_choice = Unabstracted_unabstractedunion1_choice1_c,
|
|
1077
|
+
.unabstractedunion2_choice = Unabstracted_unabstractedunion2_uint3_c,
|
|
1077
1078
|
};
|
|
1078
1079
|
struct Unabstracted result_unabstracted1 = {
|
|
1079
|
-
.unabstractedunion1_choice =
|
|
1080
|
-
.unabstractedunion2_choice =
|
|
1080
|
+
.unabstractedunion1_choice = Unabstracted_unabstractedunion1_choice2_c,
|
|
1081
|
+
.unabstractedunion2_choice = Unabstracted_unabstractedunion2_choice4_c,
|
|
1081
1082
|
};
|
|
1082
1083
|
uint8_t output[4];
|
|
1083
1084
|
size_t out_len;
|
|
@@ -1153,14 +1154,14 @@ ZTEST(cbor_encode_test3, test_doublemap)
|
|
|
1153
1154
|
.uintmap = {
|
|
1154
1155
|
{
|
|
1155
1156
|
.uintmap_key = 1,
|
|
1156
|
-
.
|
|
1157
|
+
.MyKeys_m = {
|
|
1157
1158
|
.uint1int_present = true,
|
|
1158
1159
|
.uint1int = {.uint1int = 1},
|
|
1159
1160
|
}
|
|
1160
1161
|
},
|
|
1161
1162
|
{
|
|
1162
1163
|
.uintmap_key = 2,
|
|
1163
|
-
.
|
|
1164
|
+
.MyKeys_m = {
|
|
1164
1165
|
.uint2int_present = true,
|
|
1165
1166
|
.uint2int = {.uint2int = 2},
|
|
1166
1167
|
}
|
|
@@ -1351,7 +1352,7 @@ ZTEST(cbor_encode_test3, test_map_length)
|
|
|
1351
1352
|
uint8_t output[60];
|
|
1352
1353
|
|
|
1353
1354
|
uint8_t mac[] = {1, 2, 3, 4, 5, 6};
|
|
1354
|
-
uint8_t
|
|
1355
|
+
uint8_t uuid_m[] = {8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 0};
|
|
1355
1356
|
|
|
1356
1357
|
input.result = 1;
|
|
1357
1358
|
input.mac_addr.len = 6;
|
|
@@ -1364,23 +1365,23 @@ ZTEST(cbor_encode_test3, test_map_length)
|
|
|
1364
1365
|
zassert_mem_equal(exp_map_length_payload1, output, num_encode, NULL);
|
|
1365
1366
|
|
|
1366
1367
|
input.end_device_array_present = true;
|
|
1367
|
-
input.end_device_array.
|
|
1368
|
+
input.end_device_array.uuid_m_count = 0;
|
|
1368
1369
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_MapLength(output,
|
|
1369
1370
|
sizeof(output), &input, &num_encode), NULL);
|
|
1370
1371
|
zassert_equal(sizeof(exp_map_length_payload2), num_encode, "%d != %d\r\n", sizeof(exp_map_length_payload2), num_encode);
|
|
1371
1372
|
zassert_mem_equal(exp_map_length_payload2, output, num_encode, NULL);
|
|
1372
1373
|
|
|
1373
|
-
input.end_device_array.
|
|
1374
|
-
input.end_device_array.
|
|
1375
|
-
input.end_device_array.
|
|
1374
|
+
input.end_device_array.uuid_m_count = 1;
|
|
1375
|
+
input.end_device_array.uuid_m[0].len = 16;
|
|
1376
|
+
input.end_device_array.uuid_m[0].value = uuid_m;
|
|
1376
1377
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_MapLength(output,
|
|
1377
1378
|
sizeof(output), &input, &num_encode), NULL);
|
|
1378
1379
|
zassert_equal(sizeof(exp_map_length_payload3), num_encode, "%d != %d\r\n", sizeof(exp_map_length_payload3), num_encode);
|
|
1379
1380
|
zassert_mem_equal(exp_map_length_payload3, output, num_encode, NULL);
|
|
1380
1381
|
|
|
1381
|
-
input.end_device_array.
|
|
1382
|
-
input.end_device_array.
|
|
1383
|
-
input.end_device_array.
|
|
1382
|
+
input.end_device_array.uuid_m_count = 2;
|
|
1383
|
+
input.end_device_array.uuid_m[1].len = 16;
|
|
1384
|
+
input.end_device_array.uuid_m[1].value = uuid_m;
|
|
1384
1385
|
int err = cbor_encode_MapLength(output,
|
|
1385
1386
|
sizeof(output), &input, &num_encode);
|
|
1386
1387
|
zassert_equal(ZCBOR_SUCCESS, err, "%d\r\b", err);
|
|
@@ -1392,7 +1393,7 @@ ZTEST(cbor_encode_test3, test_map_length)
|
|
|
1392
1393
|
sizeof(output), &input, &num_encode), NULL);
|
|
1393
1394
|
|
|
1394
1395
|
input.mac_addr.len++;
|
|
1395
|
-
input.end_device_array.
|
|
1396
|
+
input.end_device_array.uuid_m[1].len++;
|
|
1396
1397
|
err = cbor_encode_MapLength(output,
|
|
1397
1398
|
sizeof(output), &input, &num_encode);
|
|
1398
1399
|
zassert_equal(ZCBOR_ERR_WRONG_RANGE, err, "%d\r\b", err);
|
|
@@ -1421,13 +1422,13 @@ ZTEST(cbor_encode_test3, test_union_int)
|
|
|
1421
1422
|
size_t num_encode;
|
|
1422
1423
|
uint8_t output[60];
|
|
1423
1424
|
|
|
1424
|
-
input.union_choice =
|
|
1425
|
+
input.union_choice = union_uint5_l_c;
|
|
1425
1426
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
|
|
1426
1427
|
&input, &num_encode), NULL);
|
|
1427
1428
|
zassert_equal(sizeof(exp_union_int_payload1), num_encode, NULL);
|
|
1428
1429
|
zassert_mem_equal(exp_union_int_payload1, output, num_encode, NULL);
|
|
1429
1430
|
|
|
1430
|
-
input.union_choice =
|
|
1431
|
+
input.union_choice = union_uint1000_l_c;
|
|
1431
1432
|
input.bstr.len = 16;
|
|
1432
1433
|
input.bstr.value = (uint8_t *)&"This is thousand";
|
|
1433
1434
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
|
|
@@ -1435,17 +1436,17 @@ ZTEST(cbor_encode_test3, test_union_int)
|
|
|
1435
1436
|
zassert_equal(sizeof(exp_union_int_payload2), num_encode, NULL);
|
|
1436
1437
|
zassert_mem_equal(exp_union_int_payload2, output, num_encode, NULL);
|
|
1437
1438
|
|
|
1438
|
-
input.union_choice =
|
|
1439
|
-
input.
|
|
1440
|
-
input.
|
|
1439
|
+
input.union_choice = union_nint_l_c;
|
|
1440
|
+
input.number_m.number_choice = number_int_c;
|
|
1441
|
+
input.number_m.Int = 1;
|
|
1441
1442
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
|
|
1442
1443
|
&input, &num_encode), NULL);
|
|
1443
1444
|
zassert_equal(sizeof(exp_union_int_payload3), num_encode, NULL);
|
|
1444
1445
|
zassert_mem_equal(exp_union_int_payload3, output, num_encode, NULL);
|
|
1445
1446
|
|
|
1446
|
-
input.union_choice =
|
|
1447
|
-
input.
|
|
1448
|
-
input.
|
|
1447
|
+
input.union_choice = UnionInt2_union_Structure_One_m_c;
|
|
1448
|
+
input.Structure_One_m.some_array.value = (uint8_t *)&"hi";
|
|
1449
|
+
input.Structure_One_m.some_array.len = 2;
|
|
1449
1450
|
zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
|
|
1450
1451
|
&input, &num_encode), NULL);
|
|
1451
1452
|
zassert_equal(sizeof(exp_union_int_payload4), num_encode, NULL);
|
|
@@ -1524,4 +1525,30 @@ ZTEST(cbor_encode_test3, test_intmax)
|
|
|
1524
1525
|
zassert_mem_equal(exp_intmax2_payload2, output, num_encode, NULL);
|
|
1525
1526
|
}
|
|
1526
1527
|
|
|
1528
|
+
|
|
1529
|
+
/* Test that zcbor generates variable names that don't contain unsupported characters. */
|
|
1530
|
+
ZTEST(cbor_encode_test3, test_invalid_identifiers)
|
|
1531
|
+
{
|
|
1532
|
+
uint8_t exp_invalid_identifiers_payload1[] = {
|
|
1533
|
+
LIST(3),
|
|
1534
|
+
0x64, '1', 'o', 'n', 'e',
|
|
1535
|
+
0x02, /* Ø */
|
|
1536
|
+
0x67, '{', '[', 'a', '-', 'z', ']', '}',
|
|
1537
|
+
END
|
|
1538
|
+
};
|
|
1539
|
+
struct InvalidIdentifiers input;
|
|
1540
|
+
size_t num_encode;
|
|
1541
|
+
uint8_t output[100];
|
|
1542
|
+
|
|
1543
|
+
input._1one_tstr_present = true;
|
|
1544
|
+
input.__present = true;
|
|
1545
|
+
input.a_z_tstr_present = true;
|
|
1546
|
+
|
|
1547
|
+
zassert_equal(ZCBOR_SUCCESS, cbor_encode_InvalidIdentifiers(output,
|
|
1548
|
+
sizeof(output), &input, &num_encode), NULL);
|
|
1549
|
+
zassert_equal(sizeof(exp_invalid_identifiers_payload1), num_encode, NULL);
|
|
1550
|
+
zassert_mem_equal(exp_invalid_identifiers_payload1, output, num_encode, NULL);
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
|
|
1527
1554
|
ZTEST_SUITE(cbor_encode_test3, NULL, NULL, NULL, NULL, NULL);
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
#include <zephyr/ztest.h>
|
|
8
8
|
#include "senml_encode.h"
|
|
9
|
-
#include "zcbor_debug.h" // Enables use of print functions when debugging tests.
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
@@ -33,23 +32,23 @@
|
|
|
33
32
|
ZTEST(cbor_encode_test4, test_senml)
|
|
34
33
|
{
|
|
35
34
|
struct lwm2m_senml input = {
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
.
|
|
47
|
-
.
|
|
35
|
+
.lwm2m_senml_record_m[0] = {
|
|
36
|
+
.record_bn = {.record_bn = {.value = "Foo", .len = 3}},
|
|
37
|
+
.record_bn_present = 1,
|
|
38
|
+
.record_bt = {.record_bt = 42},
|
|
39
|
+
.record_bt_present = 1,
|
|
40
|
+
.record_n = {.record_n = {.value = "Bar", .len = 3}},
|
|
41
|
+
.record_n_present = 1,
|
|
42
|
+
.record_t = {.record_t = 7},
|
|
43
|
+
.record_t_present = 1,
|
|
44
|
+
.record_union = {
|
|
45
|
+
.union_vb = true,
|
|
46
|
+
.record_union_choice = union_vb_c,
|
|
48
47
|
},
|
|
49
|
-
.
|
|
50
|
-
.
|
|
48
|
+
.record_union_present = 1,
|
|
49
|
+
.record_key_value_pair_m_count = 0,
|
|
51
50
|
},
|
|
52
|
-
.
|
|
51
|
+
.lwm2m_senml_record_m_count = 1,
|
|
53
52
|
};
|
|
54
53
|
uint8_t payload[100];
|
|
55
54
|
size_t encode_len;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#include "everything_decode.h"
|
|
2
|
+
#include "main_entry.h"
|
|
3
|
+
|
|
4
|
+
bool fuzz_one_input(const uint8_t *data, size_t size)
|
|
5
|
+
{
|
|
6
|
+
size_t payload_len_out = 0;
|
|
7
|
+
struct EverythingUnion_r result;
|
|
8
|
+
bool ret = cbor_decode_EverythingUnion(data, size,
|
|
9
|
+
&result,
|
|
10
|
+
&payload_len_out);
|
|
11
|
+
return ret;
|
|
12
|
+
}
|