edhoc 1.0.5 → 1.1.1
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,6 @@
|
|
|
7
7
|
#include <zephyr/ztest.h>
|
|
8
8
|
#include "pet_decode.h"
|
|
9
9
|
#include "serial/serial_recovery_decode.h"
|
|
10
|
-
#include "zcbor_debug.h" // Enables use of print functions when debugging tests.
|
|
11
10
|
|
|
12
11
|
uint8_t serial_rec_input1[] = {
|
|
13
12
|
/* "data" */
|
|
@@ -447,7 +446,7 @@ ZTEST(cbor_decode_test3, test_pet)
|
|
|
447
446
|
zassert_mem_equal("bar", pet.names[1].value, 3, "Expect first name 'bar'");
|
|
448
447
|
zassert_equal(8, pet.birthday.len, "Expect len 8 birthday");
|
|
449
448
|
zassert_mem_equal(exp_birthday, pet.birthday.value, 8, "Expect birthday");
|
|
450
|
-
zassert_equal(
|
|
449
|
+
zassert_equal(Pet_species_dog_c, pet.species_choice, "Expect dog");
|
|
451
450
|
}
|
|
452
451
|
|
|
453
452
|
|
|
@@ -483,23 +482,23 @@ ZTEST(cbor_decode_test3, test_serial1)
|
|
|
483
482
|
{
|
|
484
483
|
struct Upload upload;
|
|
485
484
|
size_t decode_len;
|
|
486
|
-
|
|
485
|
+
int ret = cbor_decode_Upload(serial_rec_input1,
|
|
487
486
|
sizeof(serial_rec_input1), &upload, &decode_len);
|
|
488
|
-
zassert_equal(ZCBOR_SUCCESS, ret, "decoding failed.");
|
|
487
|
+
zassert_equal(ZCBOR_SUCCESS, ret, "decoding failed: %d.", ret);
|
|
489
488
|
zassert_equal(sizeof(serial_rec_input1), decode_len, NULL);
|
|
490
489
|
|
|
491
490
|
zassert_equal(5, upload.members_count,
|
|
492
491
|
"expect 5 members");
|
|
493
|
-
zassert_equal(
|
|
492
|
+
zassert_equal(Member_data_c, upload.members[0].members
|
|
494
493
|
.Member_choice, "expect data 1st");
|
|
495
|
-
zassert_equal(
|
|
494
|
+
zassert_equal(Member_image_c, upload.members[1].members
|
|
496
495
|
.Member_choice, "expect image 2nd");
|
|
497
|
-
zassert_equal(
|
|
496
|
+
zassert_equal(Member_len_c, upload.members[2].members
|
|
498
497
|
.Member_choice, "was %d\r\n", upload.members[2].members
|
|
499
498
|
.Member_choice);
|
|
500
|
-
zassert_equal(
|
|
499
|
+
zassert_equal(Member_off_c, upload.members[3].members
|
|
501
500
|
.Member_choice, "expect off 4th");
|
|
502
|
-
zassert_equal(
|
|
501
|
+
zassert_equal(Member_sha_c, upload.members[4].members
|
|
503
502
|
.Member_choice, "expect sha 5th");
|
|
504
503
|
}
|
|
505
504
|
|
|
@@ -507,22 +506,22 @@ ZTEST(cbor_decode_test3, test_serial2)
|
|
|
507
506
|
{
|
|
508
507
|
struct Upload upload;
|
|
509
508
|
size_t decode_len;
|
|
510
|
-
|
|
509
|
+
int ret = cbor_decode_Upload(serial_rec_input2,
|
|
511
510
|
sizeof(serial_rec_input2), &upload, &decode_len);
|
|
512
|
-
zassert_equal(ZCBOR_SUCCESS, ret, "decoding failed.");
|
|
511
|
+
zassert_equal(ZCBOR_SUCCESS, ret, "decoding failed: %d.", ret);
|
|
513
512
|
zassert_equal(sizeof(serial_rec_input2), decode_len, NULL);
|
|
514
513
|
|
|
515
514
|
zassert_equal(5, upload.members_count,
|
|
516
515
|
"expect 5 members");
|
|
517
|
-
zassert_equal(
|
|
516
|
+
zassert_equal(Member_data_c, upload.members[0].members
|
|
518
517
|
.Member_choice, "expect data 1st");
|
|
519
|
-
zassert_equal(
|
|
518
|
+
zassert_equal(Member_image_c, upload.members[1].members
|
|
520
519
|
.Member_choice, "expect image 2nd");
|
|
521
|
-
zassert_equal(
|
|
520
|
+
zassert_equal(Member_len_c, upload.members[2].members
|
|
522
521
|
.Member_choice, "expect len 3rd");
|
|
523
|
-
zassert_equal(
|
|
522
|
+
zassert_equal(Member_off_c, upload.members[3].members
|
|
524
523
|
.Member_choice, "expect off 4th");
|
|
525
|
-
zassert_equal(
|
|
524
|
+
zassert_equal(Member_sha_c, upload.members[4].members
|
|
526
525
|
.Member_choice, "expect sha 5th");
|
|
527
526
|
}
|
|
528
527
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#include <math.h>
|
|
9
9
|
#include <corner_cases.h>
|
|
10
10
|
#include <zcbor_decode.h>
|
|
11
|
-
#include <
|
|
11
|
+
#include <zcbor_print.h>
|
|
12
12
|
|
|
13
13
|
#define CONCAT_BYTE(a,b) a ## b
|
|
14
14
|
|
|
@@ -78,8 +78,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
78
78
|
{
|
|
79
79
|
size_t decode_len = 0xFFFFFFFF;
|
|
80
80
|
const uint8_t payload_numbers2[] = {
|
|
81
|
-
LIST(
|
|
81
|
+
LIST(8),
|
|
82
82
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
83
|
+
0x3A, 0x7F, 0xFF, 0xFF, 0xFF, // -0x80000000
|
|
83
84
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
84
85
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
85
86
|
0x00, // 0
|
|
@@ -89,8 +90,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
89
90
|
END
|
|
90
91
|
};
|
|
91
92
|
const uint8_t payload_numbers2_1[] = {
|
|
92
|
-
LIST(
|
|
93
|
+
LIST(8),
|
|
93
94
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
95
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
94
96
|
0x3B, 0x01, 2, 3, 4, 5, 6, 7, 8, // -0x0102030405060709
|
|
95
97
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
96
98
|
0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 0xFFFFFFFFFFFFFFFF
|
|
@@ -100,8 +102,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
100
102
|
END
|
|
101
103
|
};
|
|
102
104
|
const uint8_t payload_numbers2_inv2[] = {
|
|
103
|
-
LIST(
|
|
105
|
+
LIST(8),
|
|
104
106
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
107
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
105
108
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
106
109
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
107
110
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
@@ -111,8 +114,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
111
114
|
END
|
|
112
115
|
};
|
|
113
116
|
const uint8_t payload_numbers2_inv3[] = {
|
|
114
|
-
LIST(
|
|
117
|
+
LIST(8),
|
|
115
118
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
119
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
116
120
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
117
121
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
118
122
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
@@ -122,8 +126,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
122
126
|
END
|
|
123
127
|
};
|
|
124
128
|
const uint8_t payload_numbers2_inv4[] = {
|
|
125
|
-
LIST(
|
|
129
|
+
LIST(8),
|
|
126
130
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
131
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
127
132
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
128
133
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456 INV
|
|
129
134
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
@@ -133,8 +138,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
133
138
|
END
|
|
134
139
|
};
|
|
135
140
|
const uint8_t payload_numbers2_inv5[] = {
|
|
136
|
-
LIST(
|
|
141
|
+
LIST(8),
|
|
137
142
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
143
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
138
144
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
139
145
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
140
146
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
@@ -144,8 +150,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
144
150
|
END
|
|
145
151
|
};
|
|
146
152
|
const uint8_t payload_numbers2_inv6[] = {
|
|
147
|
-
LIST(
|
|
153
|
+
LIST(8),
|
|
148
154
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
155
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
149
156
|
0x3B, 0x01, 2, 3, 4, 5, 6, 7, 8, // -0x0102030405060709
|
|
150
157
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
151
158
|
0x20, // -1 INV
|
|
@@ -155,8 +162,9 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
155
162
|
END
|
|
156
163
|
};
|
|
157
164
|
const uint8_t payload_numbers2_inv7[] = {
|
|
158
|
-
LIST(
|
|
165
|
+
LIST(8),
|
|
159
166
|
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
167
|
+
0x1A, 0x7F, 0xFF, 0xFF, 0xFF, // 0x7FFFFFFF
|
|
160
168
|
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
161
169
|
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
162
170
|
0x00, // 0
|
|
@@ -165,27 +173,55 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
165
173
|
0xD9, 0x04, 0xD3, 0x03, // #6.1235(3) INV
|
|
166
174
|
END
|
|
167
175
|
};
|
|
176
|
+
const uint8_t payload_numbers2_inv8[] = {
|
|
177
|
+
LIST(8),
|
|
178
|
+
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
179
|
+
0x3A, 0x80, 0x00, 0x00, 0x00, // -0x80000001 INV
|
|
180
|
+
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
181
|
+
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
182
|
+
0x00, // 0
|
|
183
|
+
0x3A, 0x80, 0x00, 0x00, 0x00, // -0x8000_0001
|
|
184
|
+
0x3A, 0x7F, 0xFF, 0xFF, 0xFF, // -0x8000_0000
|
|
185
|
+
0xD9, 0x04, 0xD2, 0x03, // #6.1234(3)
|
|
186
|
+
END
|
|
187
|
+
};
|
|
188
|
+
const uint8_t payload_numbers2_inv9[] = {
|
|
189
|
+
LIST(8),
|
|
190
|
+
0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
|
|
191
|
+
0x1A, 0x80, 0x00, 0x00, 0x00, // 0x80000000 INV
|
|
192
|
+
0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
|
|
193
|
+
0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
|
|
194
|
+
0x00, // 0
|
|
195
|
+
0x3A, 0x80, 0x00, 0x00, 0x00, // -0x8000_0001
|
|
196
|
+
0x3A, 0x7F, 0xFF, 0xFF, 0xFF, // -0x8000_0000
|
|
197
|
+
0xD9, 0x04, 0xD2, 0x03, // #6.1234(3)
|
|
198
|
+
END
|
|
199
|
+
};
|
|
168
200
|
struct Numbers2 numbers2;
|
|
201
|
+
int ret;
|
|
169
202
|
|
|
170
203
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Numbers2(payload_numbers2,
|
|
171
204
|
sizeof(payload_numbers2), &numbers2, &decode_len), NULL);
|
|
172
205
|
|
|
173
206
|
zassert_equal(0x123456, numbers2.threebytes, NULL);
|
|
207
|
+
zassert_equal(-0x80000000L, numbers2.int32, NULL);
|
|
174
208
|
zassert_equal(0x0102030405060708, numbers2.big_int, NULL);
|
|
175
209
|
zassert_equal(0x1102030405060709, numbers2.big_uint, NULL);
|
|
176
210
|
zassert_equal(0, numbers2.big_uint2, NULL);
|
|
177
211
|
zassert_equal(3, numbers2.tagged_int, NULL);
|
|
178
212
|
|
|
179
|
-
|
|
180
|
-
sizeof(payload_numbers2_1), &numbers2, &decode_len)
|
|
213
|
+
ret = cbor_decode_Numbers2(payload_numbers2_1,
|
|
214
|
+
sizeof(payload_numbers2_1), &numbers2, &decode_len);
|
|
215
|
+
zassert_equal(ZCBOR_SUCCESS, ret, "%d\r\n", ret);
|
|
181
216
|
|
|
182
217
|
zassert_equal(0x123456, numbers2.threebytes, NULL);
|
|
218
|
+
zassert_equal(0x7FFFFFFFL, numbers2.int32, NULL);
|
|
183
219
|
zassert_equal(-0x0102030405060709, numbers2.big_int, NULL);
|
|
184
220
|
zassert_equal(0x1102030405060709, numbers2.big_uint, NULL);
|
|
185
221
|
zassert_equal(0xFFFFFFFFFFFFFFFF, numbers2.big_uint2, NULL);
|
|
186
222
|
zassert_equal(3, numbers2.tagged_int, NULL);
|
|
187
223
|
|
|
188
|
-
|
|
224
|
+
ret = cbor_decode_Numbers2(payload_numbers2_inv2,
|
|
189
225
|
sizeof(payload_numbers2_inv2), &numbers2, &decode_len);
|
|
190
226
|
zassert_equal(ZCBOR_ERR_WRONG_VALUE, ret, "%d\r\n", ret);
|
|
191
227
|
|
|
@@ -204,6 +240,15 @@ ZTEST(cbor_decode_test5, test_numbers2)
|
|
|
204
240
|
|
|
205
241
|
zassert_equal(ZCBOR_ERR_WRONG_VALUE, cbor_decode_Numbers2(payload_numbers2_inv7,
|
|
206
242
|
sizeof(payload_numbers2_inv7), &numbers2, &decode_len), NULL);
|
|
243
|
+
|
|
244
|
+
ret = cbor_decode_Numbers2(payload_numbers2_inv8,
|
|
245
|
+
sizeof(payload_numbers2_inv8), &numbers2, &decode_len);
|
|
246
|
+
zassert_equal(sizeof(numbers2.int32) == 4 ? ZCBOR_ERR_INT_SIZE : ZCBOR_ERR_WRONG_RANGE,
|
|
247
|
+
ret, "%d\r\n", ret);
|
|
248
|
+
|
|
249
|
+
zassert_equal(sizeof(numbers2.int32) == 4 ? ZCBOR_ERR_INT_SIZE : ZCBOR_ERR_WRONG_RANGE,
|
|
250
|
+
cbor_decode_Numbers2(payload_numbers2_inv9,
|
|
251
|
+
sizeof(payload_numbers2_inv9), &numbers2, &decode_len), NULL);
|
|
207
252
|
}
|
|
208
253
|
|
|
209
254
|
|
|
@@ -217,19 +262,19 @@ ZTEST(cbor_decode_test5, test_tagged_union)
|
|
|
217
262
|
const uint8_t payload_tagged_union2[] = {0xD9, 0x09, 0x29, 0x10};
|
|
218
263
|
const uint8_t payload_tagged_union3_inv[] = {0xD9, 0x10, 0xE1, 0x10};
|
|
219
264
|
|
|
220
|
-
struct
|
|
265
|
+
struct TaggedUnion_r result;
|
|
221
266
|
|
|
222
267
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_TaggedUnion(payload_tagged_union1,
|
|
223
268
|
sizeof(payload_tagged_union1), &result, &decode_len), "%d\r\n");
|
|
224
269
|
|
|
225
270
|
zassert_equal(sizeof(payload_tagged_union1), decode_len, NULL);
|
|
226
|
-
zassert_equal(
|
|
227
|
-
zassert_true(result.
|
|
271
|
+
zassert_equal(TaggedUnion_bool_c, result.TaggedUnion_choice, NULL);
|
|
272
|
+
zassert_true(result.Bool, NULL);
|
|
228
273
|
|
|
229
274
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_TaggedUnion(payload_tagged_union2,
|
|
230
275
|
sizeof(payload_tagged_union2), &result, &decode_len), NULL);
|
|
231
276
|
|
|
232
|
-
zassert_equal(
|
|
277
|
+
zassert_equal(TaggedUnion_uint_c, result.TaggedUnion_choice, NULL);
|
|
233
278
|
zassert_equal(0x10, result.uint, NULL);
|
|
234
279
|
|
|
235
280
|
zassert_equal(ZCBOR_ERR_WRONG_TYPE, cbor_decode_TaggedUnion(payload_tagged_union3_inv,
|
|
@@ -658,43 +703,43 @@ ZTEST(cbor_decode_test5, test_union)
|
|
|
658
703
|
0x03, 0x23, 0x03, 0x23, 0x03, 0x23}; /* Too many */
|
|
659
704
|
size_t decode_len;
|
|
660
705
|
|
|
661
|
-
struct
|
|
706
|
+
struct Union_r union_r;
|
|
662
707
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union1, sizeof(payload_union1),
|
|
663
|
-
&
|
|
664
|
-
zassert_equal(
|
|
708
|
+
&union_r, NULL), NULL);
|
|
709
|
+
zassert_equal(Union_Group_m_c, union_r.Union_choice, NULL);
|
|
665
710
|
|
|
666
711
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union2, sizeof(payload_union2),
|
|
667
|
-
&
|
|
668
|
-
zassert_equal(
|
|
669
|
-
zassert_equal(1,
|
|
712
|
+
&union_r, NULL), NULL);
|
|
713
|
+
zassert_equal(Union_MultiGroup_m_c, union_r.Union_choice, NULL);
|
|
714
|
+
zassert_equal(1, union_r.MultiGroup_m.MultiGroup_count, "was %d\r\n", union_r.MultiGroup_m.MultiGroup_count);
|
|
670
715
|
|
|
671
716
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union3, sizeof(payload_union3),
|
|
672
|
-
&
|
|
673
|
-
zassert_equal(
|
|
717
|
+
&union_r, NULL), NULL);
|
|
718
|
+
zassert_equal(Union_uint3_l_c, union_r.Union_choice, NULL);
|
|
674
719
|
|
|
675
720
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union4, sizeof(payload_union4),
|
|
676
|
-
&
|
|
677
|
-
zassert_equal(
|
|
721
|
+
&union_r, NULL), NULL);
|
|
722
|
+
zassert_equal(Union_hello_tstr_c, union_r.Union_choice, NULL);
|
|
678
723
|
|
|
679
724
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union6, sizeof(payload_union6),
|
|
680
|
-
&
|
|
681
|
-
zassert_equal(
|
|
682
|
-
zassert_equal(6,
|
|
725
|
+
&union_r, &decode_len), NULL);
|
|
726
|
+
zassert_equal(Union_MultiGroup_m_c, union_r.Union_choice, NULL);
|
|
727
|
+
zassert_equal(6, union_r.MultiGroup_m.MultiGroup_count, NULL);
|
|
683
728
|
zassert_equal(12, decode_len, NULL);
|
|
684
729
|
|
|
685
730
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union7_long, sizeof(payload_union7_long),
|
|
686
|
-
&
|
|
731
|
+
&union_r, &decode_len), NULL);
|
|
687
732
|
zassert_equal(2, decode_len, NULL);
|
|
688
733
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union8_long, sizeof(payload_union8_long),
|
|
689
|
-
&
|
|
734
|
+
&union_r, &decode_len), NULL);
|
|
690
735
|
zassert_equal(2, decode_len, NULL);
|
|
691
736
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union9_long, sizeof(payload_union9_long),
|
|
692
|
-
&
|
|
737
|
+
&union_r, &decode_len), NULL);
|
|
693
738
|
zassert_equal(2, decode_len, NULL);
|
|
694
739
|
|
|
695
740
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Union(payload_union10_inv, sizeof(payload_union10_inv),
|
|
696
|
-
&
|
|
697
|
-
zassert_equal(6,
|
|
741
|
+
&union_r, &decode_len), NULL);
|
|
742
|
+
zassert_equal(6, union_r.MultiGroup_m.MultiGroup_count, NULL);
|
|
698
743
|
zassert_equal(12, decode_len, NULL);
|
|
699
744
|
}
|
|
700
745
|
|
|
@@ -721,9 +766,9 @@ ZTEST(cbor_decode_test5, test_levels)
|
|
|
721
766
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Level1(payload_levels1,
|
|
722
767
|
sizeof(payload_levels1), &level1, NULL), NULL);
|
|
723
768
|
|
|
724
|
-
zassert_equal(2, level1.
|
|
725
|
-
zassert_equal(4, level1.
|
|
726
|
-
zassert_equal(4, level1.
|
|
769
|
+
zassert_equal(2, level1.Level3_m_count, NULL);
|
|
770
|
+
zassert_equal(4, level1.Level3_m[0].Level4_m_count, NULL);
|
|
771
|
+
zassert_equal(4, level1.Level3_m[1].Level4_m_count, NULL);
|
|
727
772
|
}
|
|
728
773
|
|
|
729
774
|
|
|
@@ -770,13 +815,13 @@ ZTEST(cbor_decode_test5, test_map)
|
|
|
770
815
|
|
|
771
816
|
struct Map map;
|
|
772
817
|
|
|
773
|
-
zassert_equal(
|
|
818
|
+
zassert_equal(union_nintuint_c, -8,
|
|
774
819
|
"The union_int optimization seems to not be working.\r\n");
|
|
775
820
|
|
|
776
821
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Map(payload_map1, sizeof(payload_map1),
|
|
777
822
|
&map, NULL), NULL);
|
|
778
823
|
zassert_false(map.listkey, NULL);
|
|
779
|
-
zassert_equal(
|
|
824
|
+
zassert_equal(union_uint7uint_c, map.union_choice, NULL);
|
|
780
825
|
zassert_equal(1, map.uint7uint, NULL);
|
|
781
826
|
zassert_equal(2, map.twotothree_count, NULL);
|
|
782
827
|
zassert_equal(5, map.twotothree[0].twotothree.len, NULL);
|
|
@@ -790,7 +835,7 @@ ZTEST(cbor_decode_test5, test_map)
|
|
|
790
835
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Map(payload_map3, sizeof(payload_map3),
|
|
791
836
|
&map, NULL), NULL);
|
|
792
837
|
zassert_true(map.listkey, NULL);
|
|
793
|
-
zassert_equal(
|
|
838
|
+
zassert_equal(union_uint7uint_c, map.union_choice, NULL);
|
|
794
839
|
zassert_equal(1, map.uint7uint, NULL);
|
|
795
840
|
zassert_equal(3, map.twotothree_count, NULL);
|
|
796
841
|
zassert_equal(5, map.twotothree[0].twotothree.len, NULL);
|
|
@@ -810,7 +855,7 @@ ZTEST(cbor_decode_test5, test_map)
|
|
|
810
855
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Map(payload_map5, sizeof(payload_map5),
|
|
811
856
|
&map, NULL), NULL);
|
|
812
857
|
zassert_false(map.listkey, NULL);
|
|
813
|
-
zassert_equal(
|
|
858
|
+
zassert_equal(union_nintuint_c, map.union_choice, NULL);
|
|
814
859
|
zassert_equal(1, map.nintuint, NULL);
|
|
815
860
|
zassert_equal(2, map.twotothree_count, NULL);
|
|
816
861
|
}
|
|
@@ -837,7 +882,7 @@ ZTEST(cbor_decode_test5, test_empty_map)
|
|
|
837
882
|
const uint8_t payload4[] = {MAP(0), END MAP(0), END MAP(0), END};
|
|
838
883
|
size_t num_decode;
|
|
839
884
|
|
|
840
|
-
ZCBOR_STATE_D(state, 0, payload4, sizeof(payload4), 3);
|
|
885
|
+
ZCBOR_STATE_D(state, 0, payload4, sizeof(payload4), 3, 0);
|
|
841
886
|
|
|
842
887
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_EmptyMap(payload1, sizeof(payload1), NULL, NULL), NULL);
|
|
843
888
|
#ifdef TEST_INDEFINITE_LENGTH_ARRAYS
|
|
@@ -904,30 +949,30 @@ ZTEST(cbor_decode_test5, test_nested_map_list_map)
|
|
|
904
949
|
int ret = cbor_decode_NestedMapListMap(payload_nested_mlm1,
|
|
905
950
|
sizeof(payload_nested_mlm1), &maplistmap, NULL);
|
|
906
951
|
zassert_equal(ZCBOR_SUCCESS, ret, "%d\r\n", ret);
|
|
907
|
-
zassert_equal(1, maplistmap.
|
|
908
|
-
zassert_equal(0, maplistmap.
|
|
952
|
+
zassert_equal(1, maplistmap.map_l_count, NULL);
|
|
953
|
+
zassert_equal(0, maplistmap.map_l[0].map_count, NULL);
|
|
909
954
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_NestedMapListMap(payload_nested_mlm2,
|
|
910
955
|
sizeof(payload_nested_mlm2), &maplistmap, NULL), NULL);
|
|
911
|
-
zassert_equal(1, maplistmap.
|
|
912
|
-
zassert_equal(1, maplistmap.
|
|
956
|
+
zassert_equal(1, maplistmap.map_l_count, NULL);
|
|
957
|
+
zassert_equal(1, maplistmap.map_l[0].map_count, NULL);
|
|
913
958
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_NestedMapListMap(payload_nested_mlm3,
|
|
914
959
|
sizeof(payload_nested_mlm3), &maplistmap, NULL), NULL);
|
|
915
|
-
zassert_equal(1, maplistmap.
|
|
916
|
-
zassert_equal(2, maplistmap.
|
|
960
|
+
zassert_equal(1, maplistmap.map_l_count, NULL);
|
|
961
|
+
zassert_equal(2, maplistmap.map_l[0].map_count, NULL);
|
|
917
962
|
ret = cbor_decode_NestedMapListMap(payload_nested_mlm4_inv,
|
|
918
963
|
sizeof(payload_nested_mlm4_inv), &maplistmap, NULL);
|
|
919
964
|
zassert_equal(ZCBOR_ERR_ITERATIONS, ret, "%d\r\n", ret);
|
|
920
965
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_NestedMapListMap(payload_nested_mlm5,
|
|
921
966
|
sizeof(payload_nested_mlm5), &maplistmap, NULL), NULL);
|
|
922
|
-
zassert_equal(2, maplistmap.
|
|
923
|
-
zassert_equal(0, maplistmap.
|
|
924
|
-
zassert_equal(0, maplistmap.
|
|
967
|
+
zassert_equal(2, maplistmap.map_l_count, NULL);
|
|
968
|
+
zassert_equal(0, maplistmap.map_l[0].map_count, NULL);
|
|
969
|
+
zassert_equal(0, maplistmap.map_l[1].map_count, NULL);
|
|
925
970
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_NestedMapListMap(payload_nested_mlm6,
|
|
926
971
|
sizeof(payload_nested_mlm6), &maplistmap, NULL), NULL);
|
|
927
|
-
zassert_equal(3, maplistmap.
|
|
928
|
-
zassert_equal(0, maplistmap.
|
|
929
|
-
zassert_equal(0, maplistmap.
|
|
930
|
-
zassert_equal(2, maplistmap.
|
|
972
|
+
zassert_equal(3, maplistmap.map_l_count, NULL);
|
|
973
|
+
zassert_equal(0, maplistmap.map_l[0].map_count, NULL);
|
|
974
|
+
zassert_equal(0, maplistmap.map_l[1].map_count, NULL);
|
|
975
|
+
zassert_equal(2, maplistmap.map_l[2].map_count, NULL);
|
|
931
976
|
}
|
|
932
977
|
|
|
933
978
|
|
|
@@ -1293,18 +1338,18 @@ ZTEST(cbor_decode_test5, test_unabstracted)
|
|
|
1293
1338
|
sizeof(payload_unabstracted0),
|
|
1294
1339
|
&result_unabstracted, &out_len), NULL);
|
|
1295
1340
|
zassert_equal(result_unabstracted.unabstractedunion1_choice,
|
|
1296
|
-
|
|
1341
|
+
Unabstracted_unabstractedunion1_choice1_c, NULL);
|
|
1297
1342
|
zassert_equal(result_unabstracted.unabstractedunion2_choice,
|
|
1298
|
-
|
|
1343
|
+
Unabstracted_unabstractedunion2_uint3_c, NULL);
|
|
1299
1344
|
zassert_equal(sizeof(payload_unabstracted0), out_len, NULL);
|
|
1300
1345
|
|
|
1301
1346
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Unabstracted(payload_unabstracted1,
|
|
1302
1347
|
sizeof(payload_unabstracted1),
|
|
1303
1348
|
&result_unabstracted, &out_len), NULL);
|
|
1304
1349
|
zassert_equal(result_unabstracted.unabstractedunion1_choice,
|
|
1305
|
-
|
|
1350
|
+
Unabstracted_unabstractedunion1_choice2_c, NULL);
|
|
1306
1351
|
zassert_equal(result_unabstracted.unabstractedunion2_choice,
|
|
1307
|
-
|
|
1352
|
+
Unabstracted_unabstractedunion2_choice4_c, NULL);
|
|
1308
1353
|
zassert_equal(sizeof(payload_unabstracted1), out_len, NULL);
|
|
1309
1354
|
|
|
1310
1355
|
int ret = cbor_decode_Unabstracted(payload_unabstracted2_inv,
|
|
@@ -1360,13 +1405,13 @@ ZTEST(cbor_decode_test5, test_doublemap)
|
|
|
1360
1405
|
&result_doublemap, &out_len), NULL);
|
|
1361
1406
|
zassert_equal(result_doublemap.uintmap_count, 2, NULL);
|
|
1362
1407
|
zassert_equal(result_doublemap.uintmap[0].uintmap_key, 1, NULL);
|
|
1363
|
-
zassert_true(result_doublemap.uintmap[0].
|
|
1364
|
-
zassert_equal(result_doublemap.uintmap[0].
|
|
1365
|
-
zassert_false(result_doublemap.uintmap[0].
|
|
1408
|
+
zassert_true(result_doublemap.uintmap[0].MyKeys_m.uint1int_present, NULL);
|
|
1409
|
+
zassert_equal(result_doublemap.uintmap[0].MyKeys_m.uint1int.uint1int, 1, NULL);
|
|
1410
|
+
zassert_false(result_doublemap.uintmap[0].MyKeys_m.uint2int_present, NULL);
|
|
1366
1411
|
zassert_equal(result_doublemap.uintmap[1].uintmap_key, 2, NULL);
|
|
1367
|
-
zassert_false(result_doublemap.uintmap[1].
|
|
1368
|
-
zassert_true(result_doublemap.uintmap[1].
|
|
1369
|
-
zassert_equal(result_doublemap.uintmap[1].
|
|
1412
|
+
zassert_false(result_doublemap.uintmap[1].MyKeys_m.uint1int_present, NULL);
|
|
1413
|
+
zassert_true(result_doublemap.uintmap[1].MyKeys_m.uint2int_present, NULL);
|
|
1414
|
+
zassert_equal(result_doublemap.uintmap[1].MyKeys_m.uint2int.uint2int, 2, NULL);
|
|
1370
1415
|
|
|
1371
1416
|
int ret = cbor_decode_DoubleMap(payload_doublemap1_inv,
|
|
1372
1417
|
sizeof(payload_doublemap1_inv),
|
|
@@ -1814,22 +1859,22 @@ ZTEST(cbor_decode_test5, test_map_length)
|
|
|
1814
1859
|
sizeof(map_length_payload2), &result, &num_decode), NULL);
|
|
1815
1860
|
zassert_equal(sizeof(map_length_payload2), num_decode, NULL);
|
|
1816
1861
|
zassert_true(result.end_device_array_present, NULL);
|
|
1817
|
-
zassert_equal(0, result.end_device_array.
|
|
1862
|
+
zassert_equal(0, result.end_device_array.uuid_m_count, NULL);
|
|
1818
1863
|
|
|
1819
1864
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_MapLength(map_length_payload3,
|
|
1820
1865
|
sizeof(map_length_payload3), &result, &num_decode), NULL);
|
|
1821
1866
|
zassert_equal(sizeof(map_length_payload3), num_decode, NULL);
|
|
1822
1867
|
zassert_true(result.end_device_array_present, NULL);
|
|
1823
|
-
zassert_equal(1, result.end_device_array.
|
|
1868
|
+
zassert_equal(1, result.end_device_array.uuid_m_count, NULL);
|
|
1824
1869
|
|
|
1825
1870
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_MapLength(map_length_payload4,
|
|
1826
1871
|
sizeof(map_length_payload4), &result, &num_decode), NULL);
|
|
1827
1872
|
zassert_equal(sizeof(map_length_payload4), num_decode, NULL);
|
|
1828
1873
|
zassert_true(result.end_device_array_present, NULL);
|
|
1829
|
-
zassert_equal(2, result.end_device_array.
|
|
1830
|
-
zassert_equal(16, result.end_device_array.
|
|
1831
|
-
zassert_equal(16, result.end_device_array.
|
|
1832
|
-
zassert_equal(8, result.end_device_array.
|
|
1874
|
+
zassert_equal(2, result.end_device_array.uuid_m_count, NULL);
|
|
1875
|
+
zassert_equal(16, result.end_device_array.uuid_m[0].len, NULL);
|
|
1876
|
+
zassert_equal(16, result.end_device_array.uuid_m[1].len, NULL);
|
|
1877
|
+
zassert_equal(8, result.end_device_array.uuid_m[1].value[8], NULL);
|
|
1833
1878
|
|
|
1834
1879
|
zassert_equal(ZCBOR_ERR_WRONG_RANGE, cbor_decode_MapLength(map_length_payload5_inv,
|
|
1835
1880
|
sizeof(map_length_payload5_inv), &result, &num_decode), NULL);
|
|
@@ -1879,48 +1924,48 @@ ZTEST(cbor_decode_test5, test_union_int)
|
|
|
1879
1924
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt1(union_int_payload1,
|
|
1880
1925
|
sizeof(union_int_payload1), &result1, &num_decode), NULL);
|
|
1881
1926
|
zassert_equal(sizeof(union_int_payload1), num_decode, NULL);
|
|
1882
|
-
zassert_equal(result1.union_choice,
|
|
1927
|
+
zassert_equal(result1.union_choice, UnionInt1_union_uint1_l_c, NULL);
|
|
1883
1928
|
|
|
1884
1929
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt2(union_int_payload1,
|
|
1885
1930
|
sizeof(union_int_payload1), &result2, &num_decode), NULL);
|
|
1886
1931
|
zassert_equal(sizeof(union_int_payload1), num_decode, NULL);
|
|
1887
|
-
zassert_equal(result2.union_choice,
|
|
1932
|
+
zassert_equal(result2.union_choice, union_uint5_l_c, NULL);
|
|
1888
1933
|
|
|
1889
1934
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt1(union_int_payload2,
|
|
1890
1935
|
sizeof(union_int_payload2), &result1, &num_decode), NULL);
|
|
1891
1936
|
zassert_equal(sizeof(union_int_payload2), num_decode, NULL);
|
|
1892
|
-
zassert_equal(result1.union_choice,
|
|
1937
|
+
zassert_equal(result1.union_choice, UnionInt1_union_uint2_l_c, NULL);
|
|
1893
1938
|
zassert_equal(result1.bstr.len, 16, NULL);
|
|
1894
1939
|
zassert_mem_equal(result1.bstr.value, "This is thousand", 16, NULL);
|
|
1895
1940
|
|
|
1896
1941
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt2(union_int_payload2,
|
|
1897
1942
|
sizeof(union_int_payload2), &result2, &num_decode), NULL);
|
|
1898
1943
|
zassert_equal(sizeof(union_int_payload2), num_decode, NULL);
|
|
1899
|
-
zassert_equal(result2.union_choice,
|
|
1944
|
+
zassert_equal(result2.union_choice, union_uint1000_l_c, NULL);
|
|
1900
1945
|
zassert_equal(result2.bstr.len, 16, NULL);
|
|
1901
1946
|
zassert_mem_equal(result2.bstr.value, "This is thousand", 16, NULL);
|
|
1902
1947
|
|
|
1903
1948
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt1(union_int_payload3,
|
|
1904
1949
|
sizeof(union_int_payload3), &result1, &num_decode), NULL);
|
|
1905
1950
|
zassert_equal(sizeof(union_int_payload3), num_decode, NULL);
|
|
1906
|
-
zassert_equal(result1.union_choice,
|
|
1907
|
-
zassert_equal(result1.
|
|
1908
|
-
zassert_equal(result1.
|
|
1951
|
+
zassert_equal(result1.union_choice, UnionInt1_union_uint3_l_c, NULL);
|
|
1952
|
+
zassert_equal(result1.number_m.number_choice, number_int_c, NULL);
|
|
1953
|
+
zassert_equal(result1.number_m.Int, 1, NULL);
|
|
1909
1954
|
|
|
1910
1955
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_UnionInt2(union_int_payload3,
|
|
1911
1956
|
sizeof(union_int_payload3), &result2, &num_decode), NULL);
|
|
1912
1957
|
zassert_equal(sizeof(union_int_payload3), num_decode, NULL);
|
|
1913
|
-
zassert_equal(result2.union_choice,
|
|
1914
|
-
zassert_equal(result2.
|
|
1915
|
-
zassert_equal(result2.
|
|
1958
|
+
zassert_equal(result2.union_choice, union_nint_l_c, NULL);
|
|
1959
|
+
zassert_equal(result2.number_m.number_choice, number_int_c, NULL);
|
|
1960
|
+
zassert_equal(result2.number_m.Int, 1, NULL);
|
|
1916
1961
|
|
|
1917
1962
|
int err = cbor_decode_UnionInt2(union_int_payload6,
|
|
1918
1963
|
sizeof(union_int_payload6), &result2, &num_decode);
|
|
1919
1964
|
zassert_equal(ZCBOR_SUCCESS, err, "%d\r\n", err);
|
|
1920
1965
|
zassert_equal(sizeof(union_int_payload6), num_decode, NULL);
|
|
1921
|
-
zassert_equal(result2.union_choice,
|
|
1922
|
-
zassert_equal(result2.
|
|
1923
|
-
zassert_mem_equal(result2.
|
|
1966
|
+
zassert_equal(result2.union_choice, UnionInt2_union_Structure_One_m_c, NULL);
|
|
1967
|
+
zassert_equal(result2.Structure_One_m.some_array.len, 2, NULL);
|
|
1968
|
+
zassert_mem_equal(result2.Structure_One_m.some_array.value, "hi", 2, NULL);
|
|
1924
1969
|
|
|
1925
1970
|
err = cbor_decode_UnionInt1(union_int_payload4_inv,
|
|
1926
1971
|
sizeof(union_int_payload4_inv), &result1, &num_decode);
|
|
@@ -1975,7 +2020,27 @@ ZTEST(cbor_decode_test5, test_intmax)
|
|
|
1975
2020
|
0x1B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
1976
2021
|
END
|
|
1977
2022
|
};
|
|
2023
|
+
uint8_t intmax3_payload1[] = {LIST(3),
|
|
2024
|
+
0x18, 254,
|
|
2025
|
+
0x19, 0xFF, 0xFE,
|
|
2026
|
+
MAP(1),
|
|
2027
|
+
0x38, 127,
|
|
2028
|
+
0x58, 127,
|
|
2029
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2030
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2031
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2032
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2033
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2034
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2035
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2036
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
2037
|
+
END
|
|
2038
|
+
END
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
|
|
1978
2042
|
struct Intmax2 result2;
|
|
2043
|
+
struct Intmax3 result3;
|
|
1979
2044
|
size_t num_decode;
|
|
1980
2045
|
|
|
1981
2046
|
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Intmax1(intmax1_payload1,
|
|
@@ -2005,6 +2070,85 @@ ZTEST(cbor_decode_test5, test_intmax)
|
|
|
2005
2070
|
zassert_equal(result2.UINT_32, UINT32_MAX, NULL);
|
|
2006
2071
|
zassert_equal(result2.INT_64, INT64_MAX, NULL);
|
|
2007
2072
|
zassert_equal(result2.UINT_64, UINT64_MAX, NULL);
|
|
2073
|
+
|
|
2074
|
+
int res = cbor_decode_Intmax3(intmax3_payload1,
|
|
2075
|
+
sizeof(intmax3_payload1), &result3, &num_decode);
|
|
2076
|
+
zassert_equal(ZCBOR_SUCCESS, res, "%s\n", zcbor_error_str(res));
|
|
2077
|
+
zassert_equal(sizeof(intmax3_payload1), num_decode, NULL);
|
|
2078
|
+
zassert_equal(result3.union_choice, Intmax3_union_uint254_c, NULL);
|
|
2079
|
+
zassert_equal(result3.Int, 65534, NULL);
|
|
2080
|
+
zassert_equal(result3.nintbstr.len, 127, NULL);
|
|
2008
2081
|
}
|
|
2009
2082
|
|
|
2083
|
+
|
|
2084
|
+
/* Test that zcbor generates variable names that don't contain unsupported characters. */
|
|
2085
|
+
ZTEST(cbor_decode_test5, test_invalid_identifiers)
|
|
2086
|
+
{
|
|
2087
|
+
struct InvalidIdentifiers result;
|
|
2088
|
+
uint8_t invalid_identifiers_payload1[] = {
|
|
2089
|
+
LIST(3),
|
|
2090
|
+
0x64, '1', 'o', 'n', 'e',
|
|
2091
|
+
0x02, /* Ø */
|
|
2092
|
+
0x67, '{', '[', 'a', '-', 'z', ']', '}',
|
|
2093
|
+
END
|
|
2094
|
+
};
|
|
2095
|
+
|
|
2096
|
+
zassert_equal(ZCBOR_SUCCESS, cbor_decode_InvalidIdentifiers(invalid_identifiers_payload1,
|
|
2097
|
+
sizeof(invalid_identifiers_payload1), &result, NULL), NULL);
|
|
2098
|
+
zassert_true(result._1one_tstr_present, NULL);
|
|
2099
|
+
zassert_true(result.__present, NULL);
|
|
2100
|
+
zassert_true(result.a_z_tstr_present, NULL);
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
|
|
2104
|
+
ZTEST(cbor_decode_test5, test_uint64_list)
|
|
2105
|
+
{
|
|
2106
|
+
uint8_t uint64_list_payload1[] = {LIST(8),
|
|
2107
|
+
0x10,
|
|
2108
|
+
0x18, 0x20,
|
|
2109
|
+
0x19, 0x12, 0x34,
|
|
2110
|
+
0x1a, 0x12, 0x34, 0x56, 0x78,
|
|
2111
|
+
0x1b, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
|
2112
|
+
0x3b, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,
|
|
2113
|
+
0x1b, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
|
2114
|
+
0x3b, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xee,
|
|
2115
|
+
END
|
|
2116
|
+
};
|
|
2117
|
+
|
|
2118
|
+
struct Uint64List result;
|
|
2119
|
+
size_t num_decode;
|
|
2120
|
+
|
|
2121
|
+
zassert_equal(ZCBOR_SUCCESS, cbor_decode_Uint64List(uint64_list_payload1,
|
|
2122
|
+
sizeof(uint64_list_payload1), &result, &num_decode), NULL);
|
|
2123
|
+
zassert_equal(sizeof(uint64_list_payload1), num_decode, NULL);
|
|
2124
|
+
|
|
2125
|
+
zassert_equal(5, result.uint64_count, NULL);
|
|
2126
|
+
zassert_equal(0x10, result.uint64[0], NULL);
|
|
2127
|
+
zassert_equal(0x20, result.uint64[1], NULL);
|
|
2128
|
+
zassert_equal(0x1234, result.uint64[2], NULL);
|
|
2129
|
+
zassert_equal(0x12345678, result.uint64[3], NULL);
|
|
2130
|
+
zassert_equal(0x123456789abcdef0, result.uint64[4], NULL);
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
ZTEST(cbor_decode_test5, test_bstr_size)
|
|
2135
|
+
{
|
|
2136
|
+
uint8_t bstr_size_payload1[] = {MAP(1),
|
|
2137
|
+
0x61, 's',
|
|
2138
|
+
0x4c, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
|
|
2139
|
+
0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb,
|
|
2140
|
+
END
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
struct BstrSize result;
|
|
2144
|
+
size_t num_decode;
|
|
2145
|
+
|
|
2146
|
+
zassert_equal(ZCBOR_SUCCESS, cbor_decode_BstrSize(bstr_size_payload1,
|
|
2147
|
+
sizeof(bstr_size_payload1), &result, &num_decode), NULL);
|
|
2148
|
+
zassert_equal(sizeof(bstr_size_payload1), num_decode, NULL);
|
|
2149
|
+
|
|
2150
|
+
zassert_equal(12, result.bstr12_m.s.len, NULL);
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
|
|
2010
2154
|
ZTEST_SUITE(cbor_decode_test5, NULL, NULL, NULL, NULL, NULL);
|