edhoc 1.4.0 → 2.0.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/.clang-format +79 -0
- package/README.md +6 -5
- package/dist/cbor-utils.d.ts +30 -0
- package/dist/cbor-utils.d.ts.map +1 -0
- package/dist/cbor-utils.js +179 -0
- package/dist/cipher-suites.d.ts +13 -0
- package/dist/cipher-suites.d.ts.map +1 -0
- package/dist/cipher-suites.js +22 -0
- package/dist/edhoc.d.ts +84 -283
- package/dist/edhoc.d.ts.map +1 -1
- package/dist/edhoc.js +562 -34
- package/package.json +5 -19
- package/.gitmodules +0 -3
- package/binding.gyp +0 -66
- package/dist/bindings.d.ts +0 -5
- package/dist/bindings.d.ts.map +0 -1
- package/dist/bindings.js +0 -10
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +0 -34
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +0 -102
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +0 -37
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +0 -34
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +0 -35
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +0 -38
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +0 -180
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +0 -69
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +0 -69
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +0 -53
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +0 -53
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +0 -152
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +0 -152
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +0 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +0 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +0 -115
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +0 -115
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +0 -50
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +0 -92
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +0 -92
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +0 -216
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +0 -217
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +0 -212
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +0 -212
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +0 -87
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +0 -87
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +0 -54
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +0 -54
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +0 -31
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +0 -10
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +0 -18
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +0 -9
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +0 -69
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +0 -38
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +0 -53
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +0 -57
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +0 -31
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +0 -10
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +0 -18
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +0 -9
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +0 -71
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +0 -40
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +0 -16
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +0 -18
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +0 -19
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +0 -17
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +0 -19
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +0 -31
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +0 -10
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +0 -18
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +0 -9
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +0 -69
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +0 -38
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +0 -31
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +0 -10
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +0 -18
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +0 -9
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +0 -70
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +0 -42
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +0 -53
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +0 -57
- package/external/libedhoc/externals/Unity/examples/unity_config.h +0 -251
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +0 -44
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +0 -129
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +0 -310
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +0 -95
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +0 -51
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +0 -20
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +0 -40
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +0 -246
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +0 -33
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +0 -203
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +0 -61
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +0 -326
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +0 -50
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +0 -57
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +0 -17
- package/external/libedhoc/externals/Unity/src/unity.c +0 -2501
- package/external/libedhoc/externals/Unity/src/unity.h +0 -698
- package/external/libedhoc/externals/Unity/src/unity_internals.h +0 -1183
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +0 -61
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +0 -57
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +0 -55
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +0 -15
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +0 -80
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +0 -76
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +0 -75
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +0 -13
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +0 -89
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +0 -89
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +0 -77
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +0 -89
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +0 -89
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +0 -90
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +0 -67
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +0 -70
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +0 -58
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +0 -67
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +0 -70
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +0 -71
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +0 -18
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +0 -16
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +0 -21
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +0 -20
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +0 -204
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +0 -73
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +0 -200
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +0 -151
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +0 -2941
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +0 -375
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +0 -1285
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +0 -1395
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +0 -2863
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +0 -783
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +0 -82
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +0 -309
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +0 -28
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +0 -330
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +0 -21
- package/external/libedhoc/externals/compact25519/src/c25519/c25519.c +0 -126
- package/external/libedhoc/externals/compact25519/src/c25519/c25519.h +0 -49
- package/external/libedhoc/externals/compact25519/src/c25519/ed25519.c +0 -323
- package/external/libedhoc/externals/compact25519/src/c25519/ed25519.h +0 -84
- package/external/libedhoc/externals/compact25519/src/c25519/edsign.c +0 -171
- package/external/libedhoc/externals/compact25519/src/c25519/edsign.h +0 -53
- package/external/libedhoc/externals/compact25519/src/c25519/f25519.c +0 -330
- package/external/libedhoc/externals/compact25519/src/c25519/f25519.h +0 -98
- package/external/libedhoc/externals/compact25519/src/c25519/fprime.c +0 -226
- package/external/libedhoc/externals/compact25519/src/c25519/fprime.h +0 -81
- package/external/libedhoc/externals/compact25519/src/c25519/sha512.c +0 -230
- package/external/libedhoc/externals/compact25519/src/c25519/sha512.h +0 -54
- package/external/libedhoc/externals/compact25519/src/compact_ed25519.c +0 -46
- package/external/libedhoc/externals/compact25519/src/compact_ed25519.h +0 -110
- package/external/libedhoc/externals/compact25519/src/compact_wipe.c +0 -12
- package/external/libedhoc/externals/compact25519/src/compact_wipe.h +0 -14
- package/external/libedhoc/externals/compact25519/src/compact_x25519.c +0 -68
- package/external/libedhoc/externals/compact25519/src/compact_x25519.h +0 -101
- package/external/libedhoc/externals/compact25519/test/pcg_random.h +0 -25
- package/external/libedhoc/externals/compact25519/test/run-all.c +0 -178
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/Hacl_Curve25519.h +0 -21
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/everest.h +0 -234
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt128.h +0 -124
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h +0 -280
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlib.h +0 -29
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/c_endianness.h +0 -204
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/builtin.h +0 -16
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/callconv.h +0 -46
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/compat.h +0 -34
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/debug.h +0 -57
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/target.h +0 -102
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/types.h +0 -61
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/kremlin/internal/wasmsupport.h +0 -5
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/vs2013/Hacl_Curve25519.h +0 -21
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/vs2013/inttypes.h +0 -36
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/vs2013/stdbool.h +0 -31
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/include/everest/x25519.h +0 -190
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/Hacl_Curve25519.c +0 -760
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/Hacl_Curve25519_joined.c +0 -50
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/everest.c +0 -102
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt128_extracted.c +0 -413
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c +0 -100
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/legacy/Hacl_Curve25519.c +0 -805
- package/external/libedhoc/externals/mbedtls/3rdparty/everest/library/x25519.c +0 -186
- package/external/libedhoc/externals/mbedtls/3rdparty/p256-m/p256-m/p256-m.c +0 -1514
- package/external/libedhoc/externals/mbedtls/3rdparty/p256-m/p256-m/p256-m.h +0 -135
- package/external/libedhoc/externals/mbedtls/3rdparty/p256-m/p256-m_driver_entrypoints.c +0 -312
- package/external/libedhoc/externals/mbedtls/3rdparty/p256-m/p256-m_driver_entrypoints.h +0 -219
- package/external/libedhoc/externals/mbedtls/configs/config-ccm-psk-dtls1_2.h +0 -92
- package/external/libedhoc/externals/mbedtls/configs/config-ccm-psk-tls1_2.h +0 -83
- package/external/libedhoc/externals/mbedtls/configs/config-no-entropy.h +0 -73
- package/external/libedhoc/externals/mbedtls/configs/config-suite-b.h +0 -106
- package/external/libedhoc/externals/mbedtls/configs/config-symmetric-only.h +0 -77
- package/external/libedhoc/externals/mbedtls/configs/config-thread.h +0 -76
- package/external/libedhoc/externals/mbedtls/configs/crypto-config-ccm-aes-sha256.h +0 -25
- package/external/libedhoc/externals/mbedtls/configs/crypto_config_profile_medium.h +0 -136
- package/external/libedhoc/externals/mbedtls/configs/tfm_mbedcrypto_config_profile_medium.h +0 -609
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_encdec.h +0 -54
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_hashing.h +0 -30
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_mainpage.h +0 -19
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_rng.h +0 -27
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_ssltls.h +0 -37
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_tcpip.h +0 -32
- package/external/libedhoc/externals/mbedtls/doxygen/input/doc_x509.h +0 -31
- package/external/libedhoc/externals/mbedtls/include/mbedtls/aes.h +0 -627
- package/external/libedhoc/externals/mbedtls/include/mbedtls/aria.h +0 -341
- package/external/libedhoc/externals/mbedtls/include/mbedtls/asn1.h +0 -641
- package/external/libedhoc/externals/mbedtls/include/mbedtls/asn1write.h +0 -389
- package/external/libedhoc/externals/mbedtls/include/mbedtls/base64.h +0 -82
- package/external/libedhoc/externals/mbedtls/include/mbedtls/bignum.h +0 -1084
- package/external/libedhoc/externals/mbedtls/include/mbedtls/build_info.h +0 -146
- package/external/libedhoc/externals/mbedtls/include/mbedtls/camellia.h +0 -303
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ccm.h +0 -518
- package/external/libedhoc/externals/mbedtls/include/mbedtls/chacha20.h +0 -202
- package/external/libedhoc/externals/mbedtls/include/mbedtls/chachapoly.h +0 -342
- package/external/libedhoc/externals/mbedtls/include/mbedtls/check_config.h +0 -1206
- package/external/libedhoc/externals/mbedtls/include/mbedtls/cipher.h +0 -1183
- package/external/libedhoc/externals/mbedtls/include/mbedtls/cmac.h +0 -246
- package/external/libedhoc/externals/mbedtls/include/mbedtls/compat-2.x.h +0 -46
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +0 -183
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +0 -877
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +0 -334
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +0 -142
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_ssl.h +0 -76
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_adjust_x509.h +0 -25
- package/external/libedhoc/externals/mbedtls/include/mbedtls/config_psa.h +0 -55
- package/external/libedhoc/externals/mbedtls/include/mbedtls/constant_time.h +0 -36
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ctr_drbg.h +0 -564
- package/external/libedhoc/externals/mbedtls/include/mbedtls/debug.h +0 -308
- package/external/libedhoc/externals/mbedtls/include/mbedtls/des.h +0 -385
- package/external/libedhoc/externals/mbedtls/include/mbedtls/dhm.h +0 -972
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ecdh.h +0 -441
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ecdsa.h +0 -671
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ecjpake.h +0 -298
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ecp.h +0 -1362
- package/external/libedhoc/externals/mbedtls/include/mbedtls/entropy.h +0 -273
- package/external/libedhoc/externals/mbedtls/include/mbedtls/error.h +0 -201
- package/external/libedhoc/externals/mbedtls/include/mbedtls/gcm.h +0 -370
- package/external/libedhoc/externals/mbedtls/include/mbedtls/hkdf.h +0 -124
- package/external/libedhoc/externals/mbedtls/include/mbedtls/hmac_drbg.h +0 -434
- package/external/libedhoc/externals/mbedtls/include/mbedtls/lms.h +0 -440
- package/external/libedhoc/externals/mbedtls/include/mbedtls/mbedtls_config.h +0 -4116
- package/external/libedhoc/externals/mbedtls/include/mbedtls/md.h +0 -640
- package/external/libedhoc/externals/mbedtls/include/mbedtls/md5.h +0 -190
- package/external/libedhoc/externals/mbedtls/include/mbedtls/memory_buffer_alloc.h +0 -142
- package/external/libedhoc/externals/mbedtls/include/mbedtls/net_sockets.h +0 -299
- package/external/libedhoc/externals/mbedtls/include/mbedtls/nist_kw.h +0 -166
- package/external/libedhoc/externals/mbedtls/include/mbedtls/oid.h +0 -722
- package/external/libedhoc/externals/mbedtls/include/mbedtls/pem.h +0 -160
- package/external/libedhoc/externals/mbedtls/include/mbedtls/pk.h +0 -1091
- package/external/libedhoc/externals/mbedtls/include/mbedtls/pkcs12.h +0 -186
- package/external/libedhoc/externals/mbedtls/include/mbedtls/pkcs5.h +0 -197
- package/external/libedhoc/externals/mbedtls/include/mbedtls/pkcs7.h +0 -241
- package/external/libedhoc/externals/mbedtls/include/mbedtls/platform.h +0 -485
- package/external/libedhoc/externals/mbedtls/include/mbedtls/platform_time.h +0 -79
- package/external/libedhoc/externals/mbedtls/include/mbedtls/platform_util.h +0 -201
- package/external/libedhoc/externals/mbedtls/include/mbedtls/poly1305.h +0 -168
- package/external/libedhoc/externals/mbedtls/include/mbedtls/private_access.h +0 -20
- package/external/libedhoc/externals/mbedtls/include/mbedtls/psa_util.h +0 -104
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ripemd160.h +0 -136
- package/external/libedhoc/externals/mbedtls/include/mbedtls/rsa.h +0 -1143
- package/external/libedhoc/externals/mbedtls/include/mbedtls/sha1.h +0 -219
- package/external/libedhoc/externals/mbedtls/include/mbedtls/sha256.h +0 -198
- package/external/libedhoc/externals/mbedtls/include/mbedtls/sha3.h +0 -172
- package/external/libedhoc/externals/mbedtls/include/mbedtls/sha512.h +0 -208
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ssl.h +0 -5369
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ssl_cache.h +0 -187
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ssl_ciphersuites.h +0 -616
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ssl_cookie.h +0 -106
- package/external/libedhoc/externals/mbedtls/include/mbedtls/ssl_ticket.h +0 -181
- package/external/libedhoc/externals/mbedtls/include/mbedtls/threading.h +0 -105
- package/external/libedhoc/externals/mbedtls/include/mbedtls/timing.h +0 -94
- package/external/libedhoc/externals/mbedtls/include/mbedtls/version.h +0 -78
- package/external/libedhoc/externals/mbedtls/include/mbedtls/x509.h +0 -550
- package/external/libedhoc/externals/mbedtls/include/mbedtls/x509_crl.h +0 -184
- package/external/libedhoc/externals/mbedtls/include/mbedtls/x509_crt.h +0 -1196
- package/external/libedhoc/externals/mbedtls/include/mbedtls/x509_csr.h +0 -319
- package/external/libedhoc/externals/mbedtls/include/psa/build_info.h +0 -20
- package/external/libedhoc/externals/mbedtls/include/psa/crypto.h +0 -4685
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_adjust_auto_enabled.h +0 -21
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +0 -91
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_adjust_config_synonyms.h +0 -45
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_builtin_composites.h +0 -210
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_builtin_key_derivation.h +0 -118
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_builtin_primitives.h +0 -114
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_compat.h +0 -153
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_config.h +0 -153
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_driver_common.h +0 -44
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_driver_contexts_composites.h +0 -151
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +0 -52
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_driver_contexts_primitives.h +0 -105
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_extra.h +0 -2064
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_legacy.h +0 -88
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_platform.h +0 -92
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_se_driver.h +0 -1383
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_sizes.h +0 -1282
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_struct.h +0 -460
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_types.h +0 -453
- package/external/libedhoc/externals/mbedtls/include/psa/crypto_values.h +0 -2756
- package/external/libedhoc/externals/mbedtls/library/aes.c +0 -2315
- package/external/libedhoc/externals/mbedtls/library/aesce.c +0 -503
- package/external/libedhoc/externals/mbedtls/library/aesce.h +0 -121
- package/external/libedhoc/externals/mbedtls/library/aesni.c +0 -802
- package/external/libedhoc/externals/mbedtls/library/aesni.h +0 -158
- package/external/libedhoc/externals/mbedtls/library/alignment.h +0 -509
- package/external/libedhoc/externals/mbedtls/library/aria.c +0 -991
- package/external/libedhoc/externals/mbedtls/library/asn1parse.c +0 -467
- package/external/libedhoc/externals/mbedtls/library/asn1write.c +0 -436
- package/external/libedhoc/externals/mbedtls/library/base64.c +0 -299
- package/external/libedhoc/externals/mbedtls/library/base64_internal.h +0 -45
- package/external/libedhoc/externals/mbedtls/library/bignum.c +0 -2806
- package/external/libedhoc/externals/mbedtls/library/bignum_core.c +0 -894
- package/external/libedhoc/externals/mbedtls/library/bignum_core.h +0 -763
- package/external/libedhoc/externals/mbedtls/library/bignum_mod.c +0 -394
- package/external/libedhoc/externals/mbedtls/library/bignum_mod.h +0 -452
- package/external/libedhoc/externals/mbedtls/library/bignum_mod_raw.c +0 -276
- package/external/libedhoc/externals/mbedtls/library/bignum_mod_raw.h +0 -416
- package/external/libedhoc/externals/mbedtls/library/bignum_mod_raw_invasive.h +0 -34
- package/external/libedhoc/externals/mbedtls/library/bn_mul.h +0 -1094
- package/external/libedhoc/externals/mbedtls/library/camellia.c +0 -1044
- package/external/libedhoc/externals/mbedtls/library/ccm.c +0 -712
- package/external/libedhoc/externals/mbedtls/library/chacha20.c +0 -497
- package/external/libedhoc/externals/mbedtls/library/chachapoly.c +0 -478
- package/external/libedhoc/externals/mbedtls/library/check_crypto_config.h +0 -141
- package/external/libedhoc/externals/mbedtls/library/cipher.c +0 -1664
- package/external/libedhoc/externals/mbedtls/library/cipher_wrap.c +0 -2422
- package/external/libedhoc/externals/mbedtls/library/cipher_wrap.h +0 -132
- package/external/libedhoc/externals/mbedtls/library/cmac.c +0 -1067
- package/external/libedhoc/externals/mbedtls/library/common.h +0 -325
- package/external/libedhoc/externals/mbedtls/library/constant_time.c +0 -261
- package/external/libedhoc/externals/mbedtls/library/constant_time_impl.h +0 -554
- package/external/libedhoc/externals/mbedtls/library/constant_time_internal.h +0 -579
- package/external/libedhoc/externals/mbedtls/library/ctr_drbg.c +0 -881
- package/external/libedhoc/externals/mbedtls/library/debug.c +0 -465
- package/external/libedhoc/externals/mbedtls/library/des.c +0 -1042
- package/external/libedhoc/externals/mbedtls/library/dhm.c +0 -712
- package/external/libedhoc/externals/mbedtls/library/ecdh.c +0 -685
- package/external/libedhoc/externals/mbedtls/library/ecdsa.c +0 -867
- package/external/libedhoc/externals/mbedtls/library/ecjpake.c +0 -1216
- package/external/libedhoc/externals/mbedtls/library/ecp.c +0 -3631
- package/external/libedhoc/externals/mbedtls/library/ecp_curves.c +0 -5467
- package/external/libedhoc/externals/mbedtls/library/ecp_curves_new.c +0 -6043
- package/external/libedhoc/externals/mbedtls/library/ecp_internal_alt.h +0 -287
- package/external/libedhoc/externals/mbedtls/library/ecp_invasive.h +0 -325
- package/external/libedhoc/externals/mbedtls/library/entropy.c +0 -676
- package/external/libedhoc/externals/mbedtls/library/entropy_poll.c +0 -229
- package/external/libedhoc/externals/mbedtls/library/entropy_poll.h +0 -64
- package/external/libedhoc/externals/mbedtls/library/error.c +0 -878
- package/external/libedhoc/externals/mbedtls/library/gcm.c +0 -1168
- package/external/libedhoc/externals/mbedtls/library/hkdf.c +0 -161
- package/external/libedhoc/externals/mbedtls/library/hmac_drbg.c +0 -633
- package/external/libedhoc/externals/mbedtls/library/lmots.c +0 -821
- package/external/libedhoc/externals/mbedtls/library/lmots.h +0 -311
- package/external/libedhoc/externals/mbedtls/library/lms.c +0 -779
- package/external/libedhoc/externals/mbedtls/library/md.c +0 -1108
- package/external/libedhoc/externals/mbedtls/library/md5.c +0 -426
- package/external/libedhoc/externals/mbedtls/library/md_psa.h +0 -63
- package/external/libedhoc/externals/mbedtls/library/md_wrap.h +0 -46
- package/external/libedhoc/externals/mbedtls/library/memory_buffer_alloc.c +0 -745
- package/external/libedhoc/externals/mbedtls/library/mps_common.h +0 -181
- package/external/libedhoc/externals/mbedtls/library/mps_error.h +0 -89
- package/external/libedhoc/externals/mbedtls/library/mps_reader.c +0 -538
- package/external/libedhoc/externals/mbedtls/library/mps_reader.h +0 -366
- package/external/libedhoc/externals/mbedtls/library/mps_trace.c +0 -112
- package/external/libedhoc/externals/mbedtls/library/mps_trace.h +0 -154
- package/external/libedhoc/externals/mbedtls/library/net_sockets.c +0 -696
- package/external/libedhoc/externals/mbedtls/library/nist_kw.c +0 -725
- package/external/libedhoc/externals/mbedtls/library/oid.c +0 -1154
- package/external/libedhoc/externals/mbedtls/library/padlock.c +0 -155
- package/external/libedhoc/externals/mbedtls/library/padlock.h +0 -111
- package/external/libedhoc/externals/mbedtls/library/pem.c +0 -520
- package/external/libedhoc/externals/mbedtls/library/pk.c +0 -970
- package/external/libedhoc/externals/mbedtls/library/pk_internal.h +0 -118
- package/external/libedhoc/externals/mbedtls/library/pk_wrap.c +0 -1834
- package/external/libedhoc/externals/mbedtls/library/pk_wrap.h +0 -156
- package/external/libedhoc/externals/mbedtls/library/pkcs12.c +0 -447
- package/external/libedhoc/externals/mbedtls/library/pkcs5.c +0 -496
- package/external/libedhoc/externals/mbedtls/library/pkcs7.c +0 -773
- package/external/libedhoc/externals/mbedtls/library/pkparse.c +0 -1845
- package/external/libedhoc/externals/mbedtls/library/pkwrite.c +0 -836
- package/external/libedhoc/externals/mbedtls/library/pkwrite.h +0 -112
- package/external/libedhoc/externals/mbedtls/library/platform.c +0 -402
- package/external/libedhoc/externals/mbedtls/library/platform_util.c +0 -285
- package/external/libedhoc/externals/mbedtls/library/poly1305.c +0 -492
- package/external/libedhoc/externals/mbedtls/library/psa_crypto.c +0 -8432
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_aead.c +0 -653
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_aead.h +0 -499
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_cipher.c +0 -590
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_cipher.h +0 -293
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_client.c +0 -67
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_core.h +0 -838
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_core_common.h +0 -52
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_driver_wrappers.h +0 -2871
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +0 -256
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +0 -31
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_ecp.c +0 -561
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_ecp.h +0 -267
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_ffdh.c +0 -295
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_ffdh.h +0 -132
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_hash.c +0 -470
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_hash.h +0 -211
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_invasive.h +0 -70
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_its.h +0 -131
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_mac.c +0 -496
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_mac.h +0 -264
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_pake.c +0 -571
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_pake.h +0 -159
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_random_impl.h +0 -192
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_rsa.c +0 -727
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_rsa.h +0 -317
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_se.c +0 -373
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_se.h +0 -185
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_slot_management.c +0 -559
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_slot_management.h +0 -213
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_storage.c +0 -481
- package/external/libedhoc/externals/mbedtls/library/psa_crypto_storage.h +0 -384
- package/external/libedhoc/externals/mbedtls/library/psa_its_file.c +0 -259
- package/external/libedhoc/externals/mbedtls/library/psa_util.c +0 -160
- package/external/libedhoc/externals/mbedtls/library/psa_util_internal.h +0 -96
- package/external/libedhoc/externals/mbedtls/library/ripemd160.c +0 -490
- package/external/libedhoc/externals/mbedtls/library/rsa.c +0 -2640
- package/external/libedhoc/externals/mbedtls/library/rsa_alt_helpers.c +0 -447
- package/external/libedhoc/externals/mbedtls/library/rsa_alt_helpers.h +0 -208
- package/external/libedhoc/externals/mbedtls/library/sha1.c +0 -480
- package/external/libedhoc/externals/mbedtls/library/sha256.c +0 -946
- package/external/libedhoc/externals/mbedtls/library/sha3.c +0 -626
- package/external/libedhoc/externals/mbedtls/library/sha512.c +0 -1111
- package/external/libedhoc/externals/mbedtls/library/ssl_cache.c +0 -410
- package/external/libedhoc/externals/mbedtls/library/ssl_ciphersuites.c +0 -2050
- package/external/libedhoc/externals/mbedtls/library/ssl_client.c +0 -1017
- package/external/libedhoc/externals/mbedtls/library/ssl_client.h +0 -22
- package/external/libedhoc/externals/mbedtls/library/ssl_cookie.c +0 -380
- package/external/libedhoc/externals/mbedtls/library/ssl_debug_helpers.h +0 -78
- package/external/libedhoc/externals/mbedtls/library/ssl_debug_helpers_generated.c +0 -234
- package/external/libedhoc/externals/mbedtls/library/ssl_misc.h +0 -2847
- package/external/libedhoc/externals/mbedtls/library/ssl_msg.c +0 -6155
- package/external/libedhoc/externals/mbedtls/library/ssl_ticket.c +0 -540
- package/external/libedhoc/externals/mbedtls/library/ssl_tls.c +0 -9577
- package/external/libedhoc/externals/mbedtls/library/ssl_tls12_client.c +0 -3607
- package/external/libedhoc/externals/mbedtls/library/ssl_tls12_server.c +0 -4403
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_client.c +0 -3046
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_generic.c +0 -1740
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_invasive.h +0 -23
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_keys.c +0 -1897
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_keys.h +0 -651
- package/external/libedhoc/externals/mbedtls/library/ssl_tls13_server.c +0 -3146
- package/external/libedhoc/externals/mbedtls/library/threading.c +0 -181
- package/external/libedhoc/externals/mbedtls/library/timing.c +0 -154
- package/external/libedhoc/externals/mbedtls/library/version.c +0 -32
- package/external/libedhoc/externals/mbedtls/library/version_features.c +0 -826
- package/external/libedhoc/externals/mbedtls/library/x509.c +0 -1776
- package/external/libedhoc/externals/mbedtls/library/x509_create.c +0 -557
- package/external/libedhoc/externals/mbedtls/library/x509_crl.c +0 -712
- package/external/libedhoc/externals/mbedtls/library/x509_crt.c +0 -3292
- package/external/libedhoc/externals/mbedtls/library/x509_csr.c +0 -574
- package/external/libedhoc/externals/mbedtls/library/x509write.c +0 -174
- package/external/libedhoc/externals/mbedtls/library/x509write_crt.c +0 -681
- package/external/libedhoc/externals/mbedtls/library/x509write_csr.c +0 -331
- package/external/libedhoc/externals/mbedtls/programs/aes/crypt_and_hash.c +0 -573
- package/external/libedhoc/externals/mbedtls/programs/cipher/cipher_aead_demo.c +0 -259
- package/external/libedhoc/externals/mbedtls/programs/fuzz/common.c +0 -105
- package/external/libedhoc/externals/mbedtls/programs/fuzz/common.h +0 -25
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_client.c +0 -195
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_dtlsclient.c +0 -138
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_dtlsserver.c +0 -183
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_pkcs7.c +0 -20
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_privkey.c +0 -106
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_pubkey.c +0 -86
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_server.c +0 -218
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_x509crl.c +0 -41
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_x509crt.c +0 -41
- package/external/libedhoc/externals/mbedtls/programs/fuzz/fuzz_x509csr.c +0 -41
- package/external/libedhoc/externals/mbedtls/programs/fuzz/onefile.c +0 -69
- package/external/libedhoc/externals/mbedtls/programs/hash/generic_sum.c +0 -209
- package/external/libedhoc/externals/mbedtls/programs/hash/hello.c +0 -45
- package/external/libedhoc/externals/mbedtls/programs/hash/md_hmac_demo.c +0 -136
- package/external/libedhoc/externals/mbedtls/programs/pkey/dh_client.c +0 -274
- package/external/libedhoc/externals/mbedtls/programs/pkey/dh_genprime.c +0 -161
- package/external/libedhoc/externals/mbedtls/programs/pkey/dh_server.c +0 -296
- package/external/libedhoc/externals/mbedtls/programs/pkey/ecdh_curve25519.c +0 -189
- package/external/libedhoc/externals/mbedtls/programs/pkey/ecdsa.c +0 -217
- package/external/libedhoc/externals/mbedtls/programs/pkey/gen_key.c +0 -419
- package/external/libedhoc/externals/mbedtls/programs/pkey/key_app.c +0 -316
- package/external/libedhoc/externals/mbedtls/programs/pkey/key_app_writer.c +0 -435
- package/external/libedhoc/externals/mbedtls/programs/pkey/mpi_demo.c +0 -84
- package/external/libedhoc/externals/mbedtls/programs/pkey/pk_decrypt.c +0 -153
- package/external/libedhoc/externals/mbedtls/programs/pkey/pk_encrypt.c +0 -154
- package/external/libedhoc/externals/mbedtls/programs/pkey/pk_sign.c +0 -155
- package/external/libedhoc/externals/mbedtls/programs/pkey/pk_verify.c +0 -128
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_decrypt.c +0 -172
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_encrypt.c +0 -149
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_genkey.c +0 -141
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_sign.c +0 -155
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_sign_pss.c +0 -161
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_verify.c +0 -131
- package/external/libedhoc/externals/mbedtls/programs/pkey/rsa_verify_pss.c +0 -136
- package/external/libedhoc/externals/mbedtls/programs/psa/aead_demo.c +0 -281
- package/external/libedhoc/externals/mbedtls/programs/psa/crypto_examples.c +0 -321
- package/external/libedhoc/externals/mbedtls/programs/psa/hmac_demo.c +0 -159
- package/external/libedhoc/externals/mbedtls/programs/psa/key_ladder_demo.c +0 -691
- package/external/libedhoc/externals/mbedtls/programs/psa/psa_constant_names.c +0 -310
- package/external/libedhoc/externals/mbedtls/programs/psa/psa_constant_names_generated.c +0 -474
- package/external/libedhoc/externals/mbedtls/programs/random/gen_entropy.c +0 -75
- package/external/libedhoc/externals/mbedtls/programs/random/gen_random_ctr_drbg.c +0 -107
- package/external/libedhoc/externals/mbedtls/programs/ssl/dtls_client.c +0 -342
- package/external/libedhoc/externals/mbedtls/programs/ssl/dtls_server.c +0 -408
- package/external/libedhoc/externals/mbedtls/programs/ssl/mini_client.c +0 -274
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_client1.c +0 -288
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_client2.c +0 -3118
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_context_info.c +0 -1009
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_fork_server.c +0 -381
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_mail_client.c +0 -804
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_pthread_server.c +0 -489
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_server.c +0 -362
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_server2.c +0 -4268
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_test_common_source.c +0 -375
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_test_lib.c +0 -601
- package/external/libedhoc/externals/mbedtls/programs/ssl/ssl_test_lib.h +0 -306
- package/external/libedhoc/externals/mbedtls/programs/test/benchmark.c +0 -1284
- package/external/libedhoc/externals/mbedtls/programs/test/cmake_package/cmake_package.c +0 -27
- package/external/libedhoc/externals/mbedtls/programs/test/cmake_package_install/cmake_package_install.c +0 -28
- package/external/libedhoc/externals/mbedtls/programs/test/cmake_subproject/cmake_subproject.c +0 -28
- package/external/libedhoc/externals/mbedtls/programs/test/dlopen.c +0 -92
- package/external/libedhoc/externals/mbedtls/programs/test/query_compile_time_config.c +0 -66
- package/external/libedhoc/externals/mbedtls/programs/test/query_config.c +0 -5137
- package/external/libedhoc/externals/mbedtls/programs/test/query_config.h +0 -34
- package/external/libedhoc/externals/mbedtls/programs/test/query_included_headers.c +0 -29
- package/external/libedhoc/externals/mbedtls/programs/test/selftest.c +0 -583
- package/external/libedhoc/externals/mbedtls/programs/test/udp_proxy.c +0 -967
- package/external/libedhoc/externals/mbedtls/programs/test/zeroize.c +0 -72
- package/external/libedhoc/externals/mbedtls/programs/util/pem2der.c +0 -265
- package/external/libedhoc/externals/mbedtls/programs/util/strerror.c +0 -61
- package/external/libedhoc/externals/mbedtls/programs/wince_main.c +0 -31
- package/external/libedhoc/externals/mbedtls/programs/x509/cert_app.c +0 -456
- package/external/libedhoc/externals/mbedtls/programs/x509/cert_req.c +0 -509
- package/external/libedhoc/externals/mbedtls/programs/x509/cert_write.c +0 -1012
- package/external/libedhoc/externals/mbedtls/programs/x509/crl_app.c +0 -132
- package/external/libedhoc/externals/mbedtls/programs/x509/load_roots.c +0 -165
- package/external/libedhoc/externals/mbedtls/programs/x509/req_app.c +0 -132
- package/external/libedhoc/externals/mbedtls/tests/configs/tls13-only.h +0 -31
- package/external/libedhoc/externals/mbedtls/tests/configs/user-config-for-test.h +0 -89
- package/external/libedhoc/externals/mbedtls/tests/configs/user-config-malloc-0-null.h +0 -22
- package/external/libedhoc/externals/mbedtls/tests/configs/user-config-zeroize-memset.h +0 -17
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/aes_alt.h +0 -23
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/aria_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/camellia_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/ccm_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/chacha20_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/chachapoly_alt.h +0 -18
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/cmac_alt.h +0 -15
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/des_alt.h +0 -22
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/dhm_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/ecjpake_alt.h +0 -15
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/ecp_alt.h +0 -22
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/gcm_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/md5_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/nist_kw_alt.h +0 -15
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/platform_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/poly1305_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/ripemd160_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/rsa_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/sha1_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/sha256_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/sha512_alt.h +0 -16
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/threading_alt.h +0 -14
- package/external/libedhoc/externals/mbedtls/tests/include/alt-dummy/timing_alt.h +0 -19
- package/external/libedhoc/externals/mbedtls/tests/include/alt-extra/psa/crypto.h +0 -7
- package/external/libedhoc/externals/mbedtls/tests/include/baremetal-override/time.h +0 -6
- package/external/libedhoc/externals/mbedtls/tests/include/spe/crypto_spe.h +0 -131
- package/external/libedhoc/externals/mbedtls/tests/include/test/arguments.h +0 -26
- package/external/libedhoc/externals/mbedtls/tests/include/test/asn1_helpers.h +0 -38
- package/external/libedhoc/externals/mbedtls/tests/include/test/bignum_helpers.h +0 -106
- package/external/libedhoc/externals/mbedtls/tests/include/test/certs.h +0 -234
- package/external/libedhoc/externals/mbedtls/tests/include/test/constant_flow.h +0 -71
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/aead.h +0 -121
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/asymmetric_encryption.h +0 -67
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/cipher.h +0 -130
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/config_test_driver.h +0 -44
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/crypto_config_test_driver_extension.h +0 -430
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/hash.h +0 -64
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/key_agreement.h +0 -62
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/key_management.h +0 -123
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/mac.h +0 -125
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/pake.h +0 -75
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/signature.h +0 -112
- package/external/libedhoc/externals/mbedtls/tests/include/test/drivers/test_driver.h +0 -32
- package/external/libedhoc/externals/mbedtls/tests/include/test/fake_external_rng_for_test.h +0 -40
- package/external/libedhoc/externals/mbedtls/tests/include/test/helpers.h +0 -268
- package/external/libedhoc/externals/mbedtls/tests/include/test/macros.h +0 -250
- package/external/libedhoc/externals/mbedtls/tests/include/test/psa_crypto_helpers.h +0 -398
- package/external/libedhoc/externals/mbedtls/tests/include/test/psa_exercise_key.h +0 -223
- package/external/libedhoc/externals/mbedtls/tests/include/test/psa_helpers.h +0 -24
- package/external/libedhoc/externals/mbedtls/tests/include/test/random.h +0 -91
- package/external/libedhoc/externals/mbedtls/tests/include/test/ssl_helpers.h +0 -628
- package/external/libedhoc/externals/mbedtls/tests/src/asn1_helpers.c +0 -62
- package/external/libedhoc/externals/mbedtls/tests/src/bignum_helpers.c +0 -145
- package/external/libedhoc/externals/mbedtls/tests/src/certs.c +0 -480
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/hash.c +0 -199
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/platform_builtin_keys.c +0 -78
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_aead.c +0 -462
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_asymmetric_encryption.c +0 -151
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_cipher.c +0 -424
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_key_agreement.c +0 -147
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_key_management.c +0 -783
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_mac.c +0 -422
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_pake.c +0 -202
- package/external/libedhoc/externals/mbedtls/tests/src/drivers/test_driver_signature.c +0 -405
- package/external/libedhoc/externals/mbedtls/tests/src/fake_external_rng_for_test.c +0 -45
- package/external/libedhoc/externals/mbedtls/tests/src/helpers.c +0 -353
- package/external/libedhoc/externals/mbedtls/tests/src/psa_crypto_helpers.c +0 -196
- package/external/libedhoc/externals/mbedtls/tests/src/psa_exercise_key.c +0 -989
- package/external/libedhoc/externals/mbedtls/tests/src/random.c +0 -136
- package/external/libedhoc/externals/mbedtls/tests/src/test_certs.h +0 -1226
- package/external/libedhoc/externals/mbedtls/tests/src/test_helpers/ssl_helpers.c +0 -2292
- package/external/libedhoc/externals/mbedtls/tests/src/threading_helpers.c +0 -210
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +0 -509
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +0 -447
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +0 -240
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +0 -165
- package/external/libedhoc/externals/zcbor/include/zcbor_tags.h +0 -94
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +0 -41
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +0 -39
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +0 -39
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +0 -47
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +0 -128
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +0 -60
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +0 -61
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +0 -430
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +0 -1567
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +0 -609
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +0 -367
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +0 -189
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +0 -528
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +0 -2154
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +0 -134
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -862
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +0 -363
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +0 -453
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +0 -122
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +0 -1554
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +0 -65
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +0 -12
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +0 -136
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_pet.c +0 -12
- package/external/libedhoc/externals/zcbor/tests/fuzz/main_entry.c +0 -60
- package/external/libedhoc/externals/zcbor/tests/fuzz/main_entry.h +0 -5
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +0 -1437
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +0 -203
- package/external/libedhoc/include/edhoc.h +0 -687
- package/external/libedhoc/include/edhoc_common.h +0 -289
- package/external/libedhoc/include/edhoc_context.h +0 -343
- package/external/libedhoc/include/edhoc_credentials.h +0 -265
- package/external/libedhoc/include/edhoc_crypto.h +0 -331
- package/external/libedhoc/include/edhoc_ead.h +0 -102
- package/external/libedhoc/include/edhoc_macros.h +0 -60
- package/external/libedhoc/include/edhoc_values.h +0 -181
- package/external/libedhoc/library/edhoc.c +0 -253
- package/external/libedhoc/library/edhoc_common.c +0 -1314
- package/external/libedhoc/library/edhoc_exporter.c +0 -542
- package/external/libedhoc/library/edhoc_message_1.c +0 -474
- package/external/libedhoc/library/edhoc_message_2.c +0 -1697
- package/external/libedhoc/library/edhoc_message_3.c +0 -1467
- package/external/libedhoc/library/edhoc_message_4.c +0 -828
- package/external/libedhoc/library/edhoc_message_error.c +0 -238
- package/external/libedhoc/tests/include/cipher_suite_0.h +0 -131
- package/external/libedhoc/tests/include/cipher_suite_2.h +0 -139
- package/external/libedhoc/tests/include/test_vector_rfc9529_chapter_2.h +0 -786
- package/external/libedhoc/tests/include/test_vector_rfc9529_chapter_3.h +0 -529
- package/external/libedhoc/tests/include/test_vector_x5chain_sign_keys_suite_0.h +0 -137
- package/external/libedhoc/tests/include/test_vector_x5chain_sign_keys_suite_2.h +0 -168
- package/external/libedhoc/tests/include/test_vector_x5chain_static_dh_keys_suite_2.h +0 -162
- package/external/libedhoc/tests/include/test_vector_x5t_sign_keys_suite_2.h +0 -180
- package/external/libedhoc/tests/src/cipher_suite_0.c +0 -445
- package/external/libedhoc/tests/src/cipher_suite_2.c +0 -600
- package/external/libedhoc/tests/src/module_test_api.c +0 -430
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +0 -395
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +0 -392
- package/external/libedhoc/tests/src/module_test_error_message.c +0 -251
- package/external/libedhoc/tests/src/module_test_main.c +0 -49
- package/external/libedhoc/tests/src/module_test_rfc9528_suites_negotiation.c +0 -541
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +0 -2681
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +0 -1635
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +0 -1135
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +0 -1249
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +0 -798
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +0 -956
- package/include/Binding.h +0 -359
- package/include/EdhocComposeAsyncWorker.h +0 -49
- package/include/EdhocCredentialManager.h +0 -106
- package/include/EdhocCryptoManager.h +0 -495
- package/include/EdhocEadManager.h +0 -147
- package/include/EdhocExportOscoreAsyncWorker.h +0 -57
- package/include/EdhocKeyExporterAsyncWorker.h +0 -56
- package/include/EdhocKeyUpdateAsyncWorker.h +0 -55
- package/include/EdhocProcessAsyncWorker.h +0 -55
- package/include/RunningContext.h +0 -102
- package/include/Suites.h +0 -27
- package/include/Utils.h +0 -71
- package/patches/prebuildify-cross+5.1.0.dev.patch +0 -26
- package/patches/prebuildify-cross+5.1.1.dev.patch +0 -26
- 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/Binding.cpp +0 -446
- package/src/EdhocComposeAsyncWorker.cpp +0 -60
- package/src/EdhocCredentialManager.cpp +0 -425
- package/src/EdhocCryptoManager.cpp +0 -593
- package/src/EdhocEadManager.cpp +0 -148
- package/src/EdhocExportOscoreAsyncWorker.cpp +0 -67
- package/src/EdhocKeyExporterAsyncWorker.cpp +0 -39
- package/src/EdhocKeyUpdateAsyncWorker.cpp +0 -31
- package/src/EdhocProcessAsyncWorker.cpp +0 -120
- package/src/RunningContext.cpp +0 -95
- package/src/Suites.cpp +0 -120
- package/src/Utils.cpp +0 -54
- package/test/basic.test.ts +0 -127
- package/test/vectors.test.ts +0 -111
|
@@ -1,1567 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
#include <stdint.h>
|
|
8
|
-
#include <stdbool.h>
|
|
9
|
-
#include <stddef.h>
|
|
10
|
-
#include <string.h>
|
|
11
|
-
#include <inttypes.h>
|
|
12
|
-
#include "zcbor_decode.h"
|
|
13
|
-
#include "zcbor_common.h"
|
|
14
|
-
#include "zcbor_print.h"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Return value length from additional value.
|
|
18
|
-
*/
|
|
19
|
-
static size_t additional_len(uint8_t additional)
|
|
20
|
-
{
|
|
21
|
-
if (additional <= ZCBOR_VALUE_IN_HEADER) {
|
|
22
|
-
return 0;
|
|
23
|
-
} else if (ZCBOR_VALUE_IS_1_BYTE <= additional && additional <= ZCBOR_VALUE_IS_8_BYTES) {
|
|
24
|
-
/* 24 => 1
|
|
25
|
-
* 25 => 2
|
|
26
|
-
* 26 => 4
|
|
27
|
-
* 27 => 8
|
|
28
|
-
*/
|
|
29
|
-
return 1U << (additional - ZCBOR_VALUE_IS_1_BYTE);
|
|
30
|
-
}
|
|
31
|
-
return 0xF;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
static bool initial_checks(zcbor_state_t *state)
|
|
36
|
-
{
|
|
37
|
-
ZCBOR_CHECK_ERROR();
|
|
38
|
-
ZCBOR_CHECK_PAYLOAD();
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
static bool type_check(zcbor_state_t *state, zcbor_major_type_t exp_major_type)
|
|
44
|
-
{
|
|
45
|
-
if (!initial_checks(state)) {
|
|
46
|
-
ZCBOR_FAIL();
|
|
47
|
-
}
|
|
48
|
-
zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(*state->payload);
|
|
49
|
-
|
|
50
|
-
if (major_type != exp_major_type) {
|
|
51
|
-
ZCBOR_ERR(ZCBOR_ERR_WRONG_TYPE);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#define INITIAL_CHECKS() \
|
|
58
|
-
do {\
|
|
59
|
-
if (!initial_checks(state)) { \
|
|
60
|
-
ZCBOR_FAIL(); \
|
|
61
|
-
} \
|
|
62
|
-
} while(0)
|
|
63
|
-
|
|
64
|
-
#define INITIAL_CHECKS_WITH_TYPE(exp_major_type) \
|
|
65
|
-
do {\
|
|
66
|
-
if (!type_check(state, exp_major_type)) { \
|
|
67
|
-
ZCBOR_FAIL(); \
|
|
68
|
-
} \
|
|
69
|
-
} while(0)
|
|
70
|
-
|
|
71
|
-
static void err_restore(zcbor_state_t *state, int err)
|
|
72
|
-
{
|
|
73
|
-
state->payload = state->payload_bak;
|
|
74
|
-
state->elem_count++;
|
|
75
|
-
zcbor_error(state, err);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#define ERR_RESTORE(err) \
|
|
79
|
-
do { \
|
|
80
|
-
err_restore(state, err); \
|
|
81
|
-
ZCBOR_FAIL(); \
|
|
82
|
-
} while(0)
|
|
83
|
-
|
|
84
|
-
#define FAIL_RESTORE() \
|
|
85
|
-
do { \
|
|
86
|
-
state->payload = state->payload_bak; \
|
|
87
|
-
state->elem_count++; \
|
|
88
|
-
ZCBOR_FAIL(); \
|
|
89
|
-
} while(0)
|
|
90
|
-
|
|
91
|
-
#define PRINT_FUNC() zcbor_log("%s ", __func__);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
static void endian_copy(uint8_t *dst, const uint8_t *src, size_t src_len)
|
|
95
|
-
{
|
|
96
|
-
#ifdef ZCBOR_BIG_ENDIAN
|
|
97
|
-
memcpy(dst, src, src_len);
|
|
98
|
-
#else
|
|
99
|
-
for (size_t i = 0; i < src_len; i++) {
|
|
100
|
-
dst[i] = src[src_len - 1 - i];
|
|
101
|
-
}
|
|
102
|
-
#endif /* ZCBOR_BIG_ENDIAN */
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/** Get a single value.
|
|
107
|
-
*
|
|
108
|
-
* @details @p ppayload must point to the header byte. This function will
|
|
109
|
-
* retrieve the value (either from within the additional info, or from
|
|
110
|
-
* the subsequent bytes) and return it in the result. The result can
|
|
111
|
-
* have arbitrary length.
|
|
112
|
-
*
|
|
113
|
-
* The function will also validate
|
|
114
|
-
* - Min/max constraints on the value.
|
|
115
|
-
* - That @p payload doesn't overrun past @p payload_end.
|
|
116
|
-
* - That @p elem_count has not been exhausted.
|
|
117
|
-
*
|
|
118
|
-
* @p ppayload and @p elem_count are updated if the function
|
|
119
|
-
* succeeds. If not, they are left unchanged.
|
|
120
|
-
*
|
|
121
|
-
* CBOR values are always big-endian, so this function converts from
|
|
122
|
-
* big to little-endian if necessary (@ref ZCBOR_BIG_ENDIAN).
|
|
123
|
-
*/
|
|
124
|
-
static bool value_extract(zcbor_state_t *state,
|
|
125
|
-
void *const result, size_t result_len)
|
|
126
|
-
{
|
|
127
|
-
zcbor_trace(state, "value_extract");
|
|
128
|
-
zcbor_assert_state(result_len != 0, "0-length result not supported.\r\n");
|
|
129
|
-
zcbor_assert_state(result_len <= 8, "result sizes above 8 bytes not supported.\r\n");
|
|
130
|
-
zcbor_assert_state(result != NULL, "result cannot be NULL.\r\n");
|
|
131
|
-
|
|
132
|
-
INITIAL_CHECKS();
|
|
133
|
-
ZCBOR_ERR_IF((state->elem_count == 0), ZCBOR_ERR_LOW_ELEM_COUNT);
|
|
134
|
-
|
|
135
|
-
uint8_t additional = ZCBOR_ADDITIONAL(*state->payload);
|
|
136
|
-
size_t len = additional_len(additional);
|
|
137
|
-
uint8_t *result_offs = (uint8_t *)result + ZCBOR_ECPY_OFFS(result_len, MAX(1, len));
|
|
138
|
-
|
|
139
|
-
ZCBOR_ERR_IF(additional > ZCBOR_VALUE_IS_8_BYTES, ZCBOR_ERR_ADDITIONAL_INVAL);
|
|
140
|
-
ZCBOR_ERR_IF(len > result_len, ZCBOR_ERR_INT_SIZE);
|
|
141
|
-
ZCBOR_ERR_IF((state->payload + len + 1) > state->payload_end,
|
|
142
|
-
ZCBOR_ERR_NO_PAYLOAD);
|
|
143
|
-
|
|
144
|
-
memset(result, 0, result_len);
|
|
145
|
-
|
|
146
|
-
if (len == 0) {
|
|
147
|
-
*result_offs = additional;
|
|
148
|
-
} else {
|
|
149
|
-
endian_copy(result_offs, state->payload + 1, len);
|
|
150
|
-
|
|
151
|
-
#ifdef ZCBOR_CANONICAL
|
|
152
|
-
ZCBOR_ERR_IF((zcbor_header_len_ptr(result, result_len) != (len + 1)),
|
|
153
|
-
ZCBOR_ERR_INVALID_VALUE_ENCODING);
|
|
154
|
-
#endif
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
state->payload_bak = state->payload;
|
|
158
|
-
(state->payload) += len + 1;
|
|
159
|
-
(state->elem_count)--;
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
bool zcbor_int_decode(zcbor_state_t *state, void *result, size_t result_size)
|
|
165
|
-
{
|
|
166
|
-
PRINT_FUNC();
|
|
167
|
-
INITIAL_CHECKS();
|
|
168
|
-
zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(*state->payload);
|
|
169
|
-
uint8_t *result_uint8 = (uint8_t *)result;
|
|
170
|
-
int8_t *result_int8 = (int8_t *)result;
|
|
171
|
-
|
|
172
|
-
if (major_type != ZCBOR_MAJOR_TYPE_PINT
|
|
173
|
-
&& major_type != ZCBOR_MAJOR_TYPE_NINT) {
|
|
174
|
-
/* Value to be read doesn't have the right type. */
|
|
175
|
-
ZCBOR_ERR(ZCBOR_ERR_WRONG_TYPE);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (!value_extract(state, result, result_size)) {
|
|
179
|
-
ZCBOR_FAIL();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
#ifdef ZCBOR_BIG_ENDIAN
|
|
183
|
-
if (result_int8[0] < 0) {
|
|
184
|
-
#else
|
|
185
|
-
if (result_int8[result_size - 1] < 0) {
|
|
186
|
-
#endif
|
|
187
|
-
/* Value is too large to fit in a signed integer. */
|
|
188
|
-
ERR_RESTORE(ZCBOR_ERR_INT_SIZE);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (major_type == ZCBOR_MAJOR_TYPE_NINT) {
|
|
192
|
-
/* Convert from CBOR's representation by flipping all bits. */
|
|
193
|
-
for (unsigned int i = 0; i < result_size; i++) {
|
|
194
|
-
result_uint8[i] = (uint8_t)~result_uint8[i];
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
bool zcbor_int32_decode(zcbor_state_t *state, int32_t *result)
|
|
203
|
-
{
|
|
204
|
-
PRINT_FUNC();
|
|
205
|
-
return zcbor_int_decode(state, result, sizeof(*result));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
bool zcbor_int64_decode(zcbor_state_t *state, int64_t *result)
|
|
210
|
-
{
|
|
211
|
-
PRINT_FUNC();
|
|
212
|
-
return zcbor_int_decode(state, result, sizeof(*result));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
bool zcbor_uint_decode(zcbor_state_t *state, void *result, size_t result_size)
|
|
217
|
-
{
|
|
218
|
-
PRINT_FUNC();
|
|
219
|
-
INITIAL_CHECKS_WITH_TYPE(ZCBOR_MAJOR_TYPE_PINT);
|
|
220
|
-
|
|
221
|
-
if (!value_extract(state, result, result_size)) {
|
|
222
|
-
zcbor_log("uint with size %zu failed.\r\n", result_size);
|
|
223
|
-
ZCBOR_FAIL();
|
|
224
|
-
}
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
bool zcbor_uint32_decode(zcbor_state_t *state, uint32_t *result)
|
|
230
|
-
{
|
|
231
|
-
PRINT_FUNC();
|
|
232
|
-
return zcbor_uint_decode(state, result, sizeof(*result));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
bool zcbor_int32_expect_union(zcbor_state_t *state, int32_t result)
|
|
237
|
-
{
|
|
238
|
-
PRINT_FUNC();
|
|
239
|
-
if (!zcbor_union_elem_code(state)) {
|
|
240
|
-
ZCBOR_FAIL();
|
|
241
|
-
}
|
|
242
|
-
return zcbor_int32_expect(state, result);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
bool zcbor_int64_expect_union(zcbor_state_t *state, int64_t result)
|
|
247
|
-
{
|
|
248
|
-
PRINT_FUNC();
|
|
249
|
-
if (!zcbor_union_elem_code(state)) {
|
|
250
|
-
ZCBOR_FAIL();
|
|
251
|
-
}
|
|
252
|
-
return zcbor_int64_expect(state, result);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
bool zcbor_uint32_expect_union(zcbor_state_t *state, uint32_t result)
|
|
257
|
-
{
|
|
258
|
-
PRINT_FUNC();
|
|
259
|
-
if (!zcbor_union_elem_code(state)) {
|
|
260
|
-
ZCBOR_FAIL();
|
|
261
|
-
}
|
|
262
|
-
return zcbor_uint32_expect(state, result);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
bool zcbor_uint64_expect_union(zcbor_state_t *state, uint64_t result)
|
|
267
|
-
{
|
|
268
|
-
PRINT_FUNC();
|
|
269
|
-
if (!zcbor_union_elem_code(state)) {
|
|
270
|
-
ZCBOR_FAIL();
|
|
271
|
-
}
|
|
272
|
-
return zcbor_uint64_expect(state, result);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
bool zcbor_int32_expect(zcbor_state_t *state, int32_t expected)
|
|
277
|
-
{
|
|
278
|
-
PRINT_FUNC();
|
|
279
|
-
return zcbor_int64_expect(state, expected);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
bool zcbor_int32_pexpect(zcbor_state_t *state, int32_t *expected)
|
|
284
|
-
{
|
|
285
|
-
PRINT_FUNC();
|
|
286
|
-
return zcbor_int32_expect(state, *expected);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
bool zcbor_int64_expect(zcbor_state_t *state, int64_t expected)
|
|
291
|
-
{
|
|
292
|
-
PRINT_FUNC();
|
|
293
|
-
int64_t actual;
|
|
294
|
-
|
|
295
|
-
if (!zcbor_int64_decode(state, &actual)) {
|
|
296
|
-
ZCBOR_FAIL();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (actual != expected) {
|
|
300
|
-
zcbor_log("%" PRIi64 " != %" PRIi64 "\r\n", actual, expected);
|
|
301
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
302
|
-
}
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
bool zcbor_int64_pexpect(zcbor_state_t *state, int64_t *expected)
|
|
308
|
-
{
|
|
309
|
-
PRINT_FUNC();
|
|
310
|
-
return zcbor_int64_expect(state, *expected);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
bool zcbor_uint64_decode(zcbor_state_t *state, uint64_t *result)
|
|
315
|
-
{
|
|
316
|
-
PRINT_FUNC();
|
|
317
|
-
return zcbor_uint_decode(state, result, sizeof(*result));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
#ifdef ZCBOR_SUPPORTS_SIZE_T
|
|
322
|
-
bool zcbor_size_decode(zcbor_state_t *state, size_t *result)
|
|
323
|
-
{
|
|
324
|
-
PRINT_FUNC();
|
|
325
|
-
return zcbor_uint_decode(state, result, sizeof(*result));
|
|
326
|
-
}
|
|
327
|
-
#endif
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
bool zcbor_uint32_expect(zcbor_state_t *state, uint32_t expected)
|
|
331
|
-
{
|
|
332
|
-
PRINT_FUNC();
|
|
333
|
-
return zcbor_uint64_expect(state, expected);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
bool zcbor_uint32_pexpect(zcbor_state_t *state, uint32_t *expected)
|
|
338
|
-
{
|
|
339
|
-
PRINT_FUNC();
|
|
340
|
-
return zcbor_uint32_expect(state, *expected);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
bool zcbor_uint64_expect(zcbor_state_t *state, uint64_t expected)
|
|
345
|
-
{
|
|
346
|
-
PRINT_FUNC();
|
|
347
|
-
uint64_t actual;
|
|
348
|
-
|
|
349
|
-
if (!zcbor_uint64_decode(state, &actual)) {
|
|
350
|
-
ZCBOR_FAIL();
|
|
351
|
-
}
|
|
352
|
-
if (actual != expected) {
|
|
353
|
-
zcbor_log("%" PRIu64 " != %" PRIu64 "\r\n", actual, expected);
|
|
354
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
355
|
-
}
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
bool zcbor_uint64_pexpect(zcbor_state_t *state, uint64_t *expected)
|
|
361
|
-
{
|
|
362
|
-
PRINT_FUNC();
|
|
363
|
-
return zcbor_uint64_expect(state, *expected);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
#ifdef ZCBOR_SUPPORTS_SIZE_T
|
|
368
|
-
bool zcbor_size_expect(zcbor_state_t *state, size_t expected)
|
|
369
|
-
{
|
|
370
|
-
PRINT_FUNC();
|
|
371
|
-
return zcbor_uint64_expect(state, expected);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
bool zcbor_size_pexpect(zcbor_state_t *state, size_t *expected)
|
|
376
|
-
{
|
|
377
|
-
PRINT_FUNC();
|
|
378
|
-
return zcbor_size_expect(state, *expected);
|
|
379
|
-
}
|
|
380
|
-
#endif
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
static bool str_start_decode(zcbor_state_t *state,
|
|
384
|
-
struct zcbor_string *result, zcbor_major_type_t exp_major_type)
|
|
385
|
-
{
|
|
386
|
-
INITIAL_CHECKS_WITH_TYPE(exp_major_type);
|
|
387
|
-
|
|
388
|
-
if (!value_extract(state, &result->len, sizeof(result->len))) {
|
|
389
|
-
ZCBOR_FAIL();
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
result->value = state->payload;
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
static bool str_start_decode_with_overflow_check(zcbor_state_t *state,
|
|
397
|
-
struct zcbor_string *result, zcbor_major_type_t exp_major_type)
|
|
398
|
-
{
|
|
399
|
-
bool res = str_start_decode(state, result, exp_major_type);
|
|
400
|
-
|
|
401
|
-
if (!res) {
|
|
402
|
-
ZCBOR_FAIL();
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/* Casting to size_t is safe since str_start_decode() checks that
|
|
406
|
-
* payload_end is bigger that payload. */
|
|
407
|
-
if (result->len > (size_t)(state->payload_end - state->payload)) {
|
|
408
|
-
zcbor_log("error: 0x%zu > 0x%zu\r\n",
|
|
409
|
-
result->len,
|
|
410
|
-
(state->payload_end - state->payload));
|
|
411
|
-
ERR_RESTORE(ZCBOR_ERR_NO_PAYLOAD);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return true;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
bool zcbor_bstr_start_decode(zcbor_state_t *state, struct zcbor_string *result)
|
|
419
|
-
{
|
|
420
|
-
PRINT_FUNC();
|
|
421
|
-
struct zcbor_string dummy;
|
|
422
|
-
if (result == NULL) {
|
|
423
|
-
result = &dummy;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if(!str_start_decode_with_overflow_check(state, result, ZCBOR_MAJOR_TYPE_BSTR)) {
|
|
427
|
-
ZCBOR_FAIL();
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (!zcbor_new_backup(state, ZCBOR_MAX_ELEM_COUNT)) {
|
|
431
|
-
FAIL_RESTORE();
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
state->payload_end = result->value + result->len;
|
|
435
|
-
return true;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
bool zcbor_bstr_end_decode(zcbor_state_t *state)
|
|
440
|
-
{
|
|
441
|
-
ZCBOR_ERR_IF(state->payload != state->payload_end, ZCBOR_ERR_PAYLOAD_NOT_CONSUMED);
|
|
442
|
-
|
|
443
|
-
if (!zcbor_process_backup(state,
|
|
444
|
-
ZCBOR_FLAG_RESTORE | ZCBOR_FLAG_CONSUME | ZCBOR_FLAG_KEEP_PAYLOAD,
|
|
445
|
-
ZCBOR_MAX_ELEM_COUNT)) {
|
|
446
|
-
ZCBOR_FAIL();
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return true;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
static void partition_fragment(const zcbor_state_t *state,
|
|
454
|
-
struct zcbor_string_fragment *result)
|
|
455
|
-
{
|
|
456
|
-
result->fragment.len = MIN(result->fragment.len,
|
|
457
|
-
(size_t)state->payload_end - (size_t)state->payload);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
static bool start_decode_fragment(zcbor_state_t *state,
|
|
462
|
-
struct zcbor_string_fragment *result,
|
|
463
|
-
zcbor_major_type_t exp_major_type)
|
|
464
|
-
{
|
|
465
|
-
PRINT_FUNC();
|
|
466
|
-
if(!str_start_decode(state, &result->fragment, exp_major_type)) {
|
|
467
|
-
ZCBOR_FAIL();
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
result->offset = 0;
|
|
471
|
-
result->total_len = result->fragment.len;
|
|
472
|
-
partition_fragment(state, result);
|
|
473
|
-
state->payload_end = state->payload + result->fragment.len;
|
|
474
|
-
|
|
475
|
-
return true;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
bool zcbor_bstr_start_decode_fragment(zcbor_state_t *state,
|
|
479
|
-
struct zcbor_string_fragment *result)
|
|
480
|
-
{
|
|
481
|
-
PRINT_FUNC();
|
|
482
|
-
if (!start_decode_fragment(state, result, ZCBOR_MAJOR_TYPE_BSTR)) {
|
|
483
|
-
ZCBOR_FAIL();
|
|
484
|
-
}
|
|
485
|
-
if (!zcbor_new_backup(state, ZCBOR_MAX_ELEM_COUNT)) {
|
|
486
|
-
FAIL_RESTORE();
|
|
487
|
-
}
|
|
488
|
-
return true;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
void zcbor_next_fragment(zcbor_state_t *state,
|
|
493
|
-
struct zcbor_string_fragment *prev_fragment,
|
|
494
|
-
struct zcbor_string_fragment *result)
|
|
495
|
-
{
|
|
496
|
-
memcpy(result, prev_fragment, sizeof(*result));
|
|
497
|
-
result->fragment.value = state->payload_mut;
|
|
498
|
-
result->offset += prev_fragment->fragment.len;
|
|
499
|
-
result->fragment.len = result->total_len - result->offset;
|
|
500
|
-
|
|
501
|
-
partition_fragment(state, result);
|
|
502
|
-
zcbor_log("New fragment length %zu\r\n", result->fragment.len);
|
|
503
|
-
|
|
504
|
-
state->payload += result->fragment.len;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
void zcbor_bstr_next_fragment(zcbor_state_t *state,
|
|
509
|
-
struct zcbor_string_fragment *prev_fragment,
|
|
510
|
-
struct zcbor_string_fragment *result)
|
|
511
|
-
{
|
|
512
|
-
memcpy(result, prev_fragment, sizeof(*result));
|
|
513
|
-
result->fragment.value = state->payload_mut;
|
|
514
|
-
result->offset += prev_fragment->fragment.len;
|
|
515
|
-
result->fragment.len = result->total_len - result->offset;
|
|
516
|
-
|
|
517
|
-
partition_fragment(state, result);
|
|
518
|
-
zcbor_log("fragment length %zu\r\n", result->fragment.len);
|
|
519
|
-
state->payload_end = state->payload + result->fragment.len;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
bool zcbor_is_last_fragment(const struct zcbor_string_fragment *fragment)
|
|
524
|
-
{
|
|
525
|
-
return (fragment->total_len == (fragment->offset + fragment->fragment.len));
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
static bool str_decode(zcbor_state_t *state, struct zcbor_string *result,
|
|
530
|
-
zcbor_major_type_t exp_major_type)
|
|
531
|
-
{
|
|
532
|
-
if (!str_start_decode_with_overflow_check(state, result, exp_major_type)) {
|
|
533
|
-
ZCBOR_FAIL();
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
state->payload += result->len;
|
|
537
|
-
return true;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
static bool str_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result,
|
|
542
|
-
zcbor_major_type_t exp_major_type)
|
|
543
|
-
{
|
|
544
|
-
if (!start_decode_fragment(state, result, exp_major_type)) {
|
|
545
|
-
ZCBOR_FAIL();
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
(state->payload) += result->fragment.len;
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
static bool str_expect(zcbor_state_t *state, struct zcbor_string *result,
|
|
554
|
-
zcbor_major_type_t exp_major_type)
|
|
555
|
-
{
|
|
556
|
-
struct zcbor_string tmp_result;
|
|
557
|
-
|
|
558
|
-
if (!str_decode(state, &tmp_result, exp_major_type)) {
|
|
559
|
-
ZCBOR_FAIL();
|
|
560
|
-
}
|
|
561
|
-
if (!zcbor_compare_strings(&tmp_result, result)) {
|
|
562
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
563
|
-
}
|
|
564
|
-
return true;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
bool zcbor_bstr_decode(zcbor_state_t *state, struct zcbor_string *result)
|
|
569
|
-
{
|
|
570
|
-
PRINT_FUNC();
|
|
571
|
-
return str_decode(state, result, ZCBOR_MAJOR_TYPE_BSTR);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
bool zcbor_bstr_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result)
|
|
576
|
-
{
|
|
577
|
-
PRINT_FUNC();
|
|
578
|
-
return str_decode_fragment(state, result, ZCBOR_MAJOR_TYPE_BSTR);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
bool zcbor_bstr_expect(zcbor_state_t *state, struct zcbor_string *expected)
|
|
583
|
-
{
|
|
584
|
-
PRINT_FUNC();
|
|
585
|
-
return str_expect(state, expected, ZCBOR_MAJOR_TYPE_BSTR);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
bool zcbor_tstr_decode(zcbor_state_t *state, struct zcbor_string *result)
|
|
590
|
-
{
|
|
591
|
-
PRINT_FUNC();
|
|
592
|
-
return str_decode(state, result, ZCBOR_MAJOR_TYPE_TSTR);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
bool zcbor_tstr_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result)
|
|
597
|
-
{
|
|
598
|
-
PRINT_FUNC();
|
|
599
|
-
return str_decode_fragment(state, result, ZCBOR_MAJOR_TYPE_TSTR);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
bool zcbor_tstr_expect(zcbor_state_t *state, struct zcbor_string *expected)
|
|
604
|
-
{
|
|
605
|
-
PRINT_FUNC();
|
|
606
|
-
return str_expect(state, expected, ZCBOR_MAJOR_TYPE_TSTR);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
bool zcbor_bstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
611
|
-
{
|
|
612
|
-
PRINT_FUNC();
|
|
613
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
614
|
-
|
|
615
|
-
return zcbor_bstr_expect(state, &zs);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
bool zcbor_tstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
620
|
-
{
|
|
621
|
-
PRINT_FUNC();
|
|
622
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
623
|
-
|
|
624
|
-
return zcbor_tstr_expect(state, &zs);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
bool zcbor_bstr_expect_term(zcbor_state_t *state, char const *string, size_t maxlen)
|
|
629
|
-
{
|
|
630
|
-
PRINT_FUNC();
|
|
631
|
-
return zcbor_bstr_expect_ptr(state, string, strnlen(string, maxlen));
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
bool zcbor_tstr_expect_term(zcbor_state_t *state, char const *string, size_t maxlen)
|
|
636
|
-
{
|
|
637
|
-
PRINT_FUNC();
|
|
638
|
-
return zcbor_tstr_expect_ptr(state, string, strnlen(string, maxlen));
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
static bool list_map_start_decode(zcbor_state_t *state,
|
|
643
|
-
zcbor_major_type_t exp_major_type)
|
|
644
|
-
{
|
|
645
|
-
size_t new_elem_count;
|
|
646
|
-
bool indefinite_length_array = false;
|
|
647
|
-
|
|
648
|
-
INITIAL_CHECKS_WITH_TYPE(exp_major_type);
|
|
649
|
-
|
|
650
|
-
#ifndef ZCBOR_CANONICAL
|
|
651
|
-
if (ZCBOR_ADDITIONAL(*state->payload) == ZCBOR_VALUE_IS_INDEFINITE_LENGTH) {
|
|
652
|
-
/* Indefinite length array. */
|
|
653
|
-
new_elem_count = ZCBOR_LARGE_ELEM_COUNT;
|
|
654
|
-
ZCBOR_ERR_IF(state->elem_count == 0, ZCBOR_ERR_LOW_ELEM_COUNT);
|
|
655
|
-
indefinite_length_array = true;
|
|
656
|
-
state->payload_bak = state->payload++;
|
|
657
|
-
state->elem_count--;
|
|
658
|
-
} else
|
|
659
|
-
#endif
|
|
660
|
-
{
|
|
661
|
-
if (!value_extract(state, &new_elem_count, sizeof(new_elem_count))) {
|
|
662
|
-
ZCBOR_FAIL();
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
if (!zcbor_new_backup(state, new_elem_count)) {
|
|
667
|
-
FAIL_RESTORE();
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
state->decode_state.indefinite_length_array = indefinite_length_array;
|
|
671
|
-
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
bool zcbor_list_start_decode(zcbor_state_t *state)
|
|
677
|
-
{
|
|
678
|
-
PRINT_FUNC();
|
|
679
|
-
return list_map_start_decode(state, ZCBOR_MAJOR_TYPE_LIST);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
bool zcbor_map_start_decode(zcbor_state_t *state)
|
|
684
|
-
{
|
|
685
|
-
PRINT_FUNC();
|
|
686
|
-
bool ret = list_map_start_decode(state, ZCBOR_MAJOR_TYPE_MAP);
|
|
687
|
-
|
|
688
|
-
if (ret && !state->decode_state.indefinite_length_array) {
|
|
689
|
-
if (state->elem_count >= (ZCBOR_MAX_ELEM_COUNT / 2)) {
|
|
690
|
-
/* The new elem_count is too large. */
|
|
691
|
-
ERR_RESTORE(ZCBOR_ERR_INT_SIZE);
|
|
692
|
-
}
|
|
693
|
-
state->elem_count *= 2;
|
|
694
|
-
}
|
|
695
|
-
return ret;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
bool zcbor_array_at_end(zcbor_state_t *state)
|
|
700
|
-
{
|
|
701
|
-
#ifdef ZCBOR_CANONICAL
|
|
702
|
-
const bool indefinite_length_array = false;
|
|
703
|
-
#else
|
|
704
|
-
const bool indefinite_length_array = state->decode_state.indefinite_length_array;
|
|
705
|
-
#endif
|
|
706
|
-
return ((!indefinite_length_array && (state->elem_count == 0))
|
|
707
|
-
|| (indefinite_length_array
|
|
708
|
-
&& (state->payload < state->payload_end)
|
|
709
|
-
&& (*state->payload == 0xFF)));
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
static size_t update_map_elem_count(zcbor_state_t *state, size_t elem_count);
|
|
714
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
715
|
-
static bool allocate_map_flags(zcbor_state_t *state, size_t elem_count);
|
|
716
|
-
#endif
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
bool zcbor_unordered_map_start_decode(zcbor_state_t *state)
|
|
720
|
-
{
|
|
721
|
-
PRINT_FUNC();
|
|
722
|
-
ZCBOR_FAIL_IF(!zcbor_map_start_decode(state));
|
|
723
|
-
|
|
724
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
725
|
-
state->decode_state.map_search_elem_state
|
|
726
|
-
+= zcbor_flags_to_bytes(state->decode_state.map_elem_count);
|
|
727
|
-
#else
|
|
728
|
-
state->decode_state.map_elems_processed = 0;
|
|
729
|
-
#endif
|
|
730
|
-
state->decode_state.map_elem_count = 0;
|
|
731
|
-
state->decode_state.counting_map_elems = state->decode_state.indefinite_length_array;
|
|
732
|
-
|
|
733
|
-
if (!state->decode_state.counting_map_elems) {
|
|
734
|
-
size_t old_flags = update_map_elem_count(state, state->elem_count);
|
|
735
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
736
|
-
ZCBOR_FAIL_IF(!allocate_map_flags(state, old_flags));
|
|
737
|
-
#endif
|
|
738
|
-
(void)old_flags;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
/** Return the max (starting) elem_count of the current container.
|
|
746
|
-
*
|
|
747
|
-
* Should only be used for unordered maps (started with @ref zcbor_unordered_map_start_decode)
|
|
748
|
-
*/
|
|
749
|
-
static size_t zcbor_current_max_elem_count(zcbor_state_t *state)
|
|
750
|
-
{
|
|
751
|
-
return (state->decode_state.indefinite_length_array ? \
|
|
752
|
-
ZCBOR_LARGE_ELEM_COUNT : state->decode_state.map_elem_count * 2);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
static bool map_restart(zcbor_state_t *state)
|
|
757
|
-
{
|
|
758
|
-
if (!zcbor_process_backup(state, ZCBOR_FLAG_RESTORE | ZCBOR_FLAG_KEEP_DECODE_STATE,
|
|
759
|
-
ZCBOR_MAX_ELEM_COUNT)) {
|
|
760
|
-
ZCBOR_FAIL();
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
state->elem_count = zcbor_current_max_elem_count(state);
|
|
764
|
-
return true;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
__attribute__((used))
|
|
769
|
-
static size_t get_current_index(zcbor_state_t *state, uint32_t index_offset)
|
|
770
|
-
{
|
|
771
|
-
/* Subtract mode because for GET, you want the index you are pointing to, while for SET,
|
|
772
|
-
* you want the one you just processed. This only comes into play when elem_count is even. */
|
|
773
|
-
return ((zcbor_current_max_elem_count(state) - state->elem_count - index_offset) / 2);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
778
|
-
#define FLAG_MODE_GET_CURRENT 0
|
|
779
|
-
#define FLAG_MODE_CLEAR_CURRENT 1
|
|
780
|
-
#define FLAG_MODE_CLEAR_UNUSED 2
|
|
781
|
-
|
|
782
|
-
static bool manipulate_flags(zcbor_state_t *state, uint32_t mode)
|
|
783
|
-
{
|
|
784
|
-
const size_t last_index = (state->decode_state.map_elem_count - 1);
|
|
785
|
-
size_t index = (mode == FLAG_MODE_CLEAR_UNUSED) ? last_index : get_current_index(state, mode);
|
|
786
|
-
|
|
787
|
-
ZCBOR_ERR_IF((index >= state->decode_state.map_elem_count),
|
|
788
|
-
ZCBOR_ERR_MAP_FLAGS_NOT_AVAILABLE);
|
|
789
|
-
uint8_t *flag_byte = &state->decode_state.map_search_elem_state[index >> 3];
|
|
790
|
-
uint8_t flag_mask = (uint8_t)(1 << (index & 7));
|
|
791
|
-
|
|
792
|
-
switch(mode) {
|
|
793
|
-
case FLAG_MODE_GET_CURRENT:
|
|
794
|
-
return (!!(*flag_byte & flag_mask));
|
|
795
|
-
case FLAG_MODE_CLEAR_CURRENT:
|
|
796
|
-
*flag_byte &= ~flag_mask;
|
|
797
|
-
return true;
|
|
798
|
-
case FLAG_MODE_CLEAR_UNUSED:
|
|
799
|
-
*flag_byte &= (uint8_t)((flag_mask << 1) - 1);
|
|
800
|
-
return true;
|
|
801
|
-
}
|
|
802
|
-
return false;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
static bool should_try_key(zcbor_state_t *state)
|
|
807
|
-
{
|
|
808
|
-
return manipulate_flags(state, FLAG_MODE_GET_CURRENT);
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
bool zcbor_elem_processed(zcbor_state_t *state)
|
|
813
|
-
{
|
|
814
|
-
return manipulate_flags(state, FLAG_MODE_CLEAR_CURRENT);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
static bool allocate_map_flags(zcbor_state_t *state, size_t old_flags)
|
|
819
|
-
{
|
|
820
|
-
size_t new_bytes = zcbor_flags_to_bytes(state->decode_state.map_elem_count);
|
|
821
|
-
size_t old_bytes = zcbor_flags_to_bytes(old_flags);
|
|
822
|
-
size_t extra_bytes = new_bytes - old_bytes;
|
|
823
|
-
const uint8_t *flags_end = state->constant_state->map_search_elem_state_end;
|
|
824
|
-
|
|
825
|
-
if (extra_bytes) {
|
|
826
|
-
if ((state->decode_state.map_search_elem_state + new_bytes) > flags_end) {
|
|
827
|
-
state->decode_state.map_elem_count
|
|
828
|
-
= 8 * (size_t)(flags_end - state->decode_state.map_search_elem_state);
|
|
829
|
-
ZCBOR_ERR(ZCBOR_ERR_MAP_FLAGS_NOT_AVAILABLE);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
memset(&state->decode_state.map_search_elem_state[new_bytes - extra_bytes], 0xFF, extra_bytes);
|
|
833
|
-
}
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
#else
|
|
837
|
-
|
|
838
|
-
static bool should_try_key(zcbor_state_t *state)
|
|
839
|
-
{
|
|
840
|
-
return (state->decode_state.map_elems_processed < state->decode_state.map_elem_count);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
bool zcbor_elem_processed(zcbor_state_t *state)
|
|
845
|
-
{
|
|
846
|
-
if (should_try_key(state)) {
|
|
847
|
-
state->decode_state.map_elems_processed++;
|
|
848
|
-
}
|
|
849
|
-
return true;
|
|
850
|
-
}
|
|
851
|
-
#endif
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
static size_t update_map_elem_count(zcbor_state_t *state, size_t elem_count)
|
|
855
|
-
{
|
|
856
|
-
size_t old_map_elem_count = state->decode_state.map_elem_count;
|
|
857
|
-
|
|
858
|
-
state->decode_state.map_elem_count = MAX(old_map_elem_count, elem_count / 2);
|
|
859
|
-
return old_map_elem_count;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
static bool handle_map_end(zcbor_state_t *state)
|
|
864
|
-
{
|
|
865
|
-
state->decode_state.counting_map_elems = false;
|
|
866
|
-
return map_restart(state);
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
static bool try_key(zcbor_state_t *state, void *key_result, zcbor_decoder_t key_decoder)
|
|
871
|
-
{
|
|
872
|
-
uint8_t const *payload_bak2 = state->payload;
|
|
873
|
-
size_t elem_count_bak = state->elem_count;
|
|
874
|
-
|
|
875
|
-
if (!key_decoder(state, (uint8_t *)key_result)) {
|
|
876
|
-
state->payload = payload_bak2;
|
|
877
|
-
state->elem_count = elem_count_bak;
|
|
878
|
-
return false;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
zcbor_log("Found element at index %zu.\n", get_current_index(state, 1));
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
bool zcbor_unordered_map_search(zcbor_decoder_t key_decoder, zcbor_state_t *state, void *key_result)
|
|
887
|
-
{
|
|
888
|
-
PRINT_FUNC();
|
|
889
|
-
/* elem_count cannot be odd since the map consists of key-value-pairs.
|
|
890
|
-
* This might mean that this function was called while pointing at a value (instead
|
|
891
|
-
* of a key). */
|
|
892
|
-
ZCBOR_ERR_IF(state->elem_count & 1, ZCBOR_ERR_MAP_MISALIGNED);
|
|
893
|
-
|
|
894
|
-
uint8_t const *payload_bak = state->payload;
|
|
895
|
-
size_t elem_count = state->elem_count;
|
|
896
|
-
|
|
897
|
-
/* Loop once through all the elements of the map. */
|
|
898
|
-
do {
|
|
899
|
-
if (zcbor_array_at_end(state)) {
|
|
900
|
-
if (!handle_map_end(state)) {
|
|
901
|
-
goto error;
|
|
902
|
-
}
|
|
903
|
-
continue; /* This continue is needed so the loop stops both if elem_count is
|
|
904
|
-
* at the very start or the very end of the map. */
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
if (state->decode_state.counting_map_elems) {
|
|
908
|
-
size_t m_elem_count = ZCBOR_LARGE_ELEM_COUNT - state->elem_count + 2;
|
|
909
|
-
size_t old_flags = update_map_elem_count(state, m_elem_count);
|
|
910
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
911
|
-
ZCBOR_FAIL_IF(!allocate_map_flags(state, old_flags));
|
|
912
|
-
#endif
|
|
913
|
-
(void)old_flags;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
if (should_try_key(state) && try_key(state, key_result, key_decoder)) {
|
|
917
|
-
if (!state->constant_state->manually_process_elem) {
|
|
918
|
-
ZCBOR_FAIL_IF(!zcbor_elem_processed(state));
|
|
919
|
-
}
|
|
920
|
-
return true;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
/* Skip over both the key and the value. */
|
|
924
|
-
if (!zcbor_any_skip(state, NULL) || !zcbor_any_skip(state, NULL)) {
|
|
925
|
-
goto error;
|
|
926
|
-
}
|
|
927
|
-
} while (state->elem_count != elem_count);
|
|
928
|
-
|
|
929
|
-
zcbor_error(state, ZCBOR_ERR_ELEM_NOT_FOUND);
|
|
930
|
-
error:
|
|
931
|
-
state->payload = payload_bak;
|
|
932
|
-
state->elem_count = elem_count;
|
|
933
|
-
ZCBOR_FAIL();
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
bool zcbor_search_key_bstr_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
938
|
-
{
|
|
939
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
940
|
-
|
|
941
|
-
return zcbor_unordered_map_search((zcbor_decoder_t *)zcbor_bstr_expect, state, &zs);
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
bool zcbor_search_key_tstr_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
946
|
-
{
|
|
947
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
948
|
-
|
|
949
|
-
return zcbor_unordered_map_search((zcbor_decoder_t *)zcbor_tstr_expect, state, &zs);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
bool zcbor_search_key_bstr_term(zcbor_state_t *state, char const *str, size_t maxlen)
|
|
954
|
-
{
|
|
955
|
-
return zcbor_search_key_bstr_ptr(state, str, strnlen(str, maxlen));
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
bool zcbor_search_key_tstr_term(zcbor_state_t *state, char const *str, size_t maxlen)
|
|
960
|
-
{
|
|
961
|
-
return zcbor_search_key_tstr_ptr(state, str, strnlen(str, maxlen));
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
static bool array_end_expect(zcbor_state_t *state)
|
|
966
|
-
{
|
|
967
|
-
INITIAL_CHECKS();
|
|
968
|
-
ZCBOR_ERR_IF(*state->payload != 0xFF, ZCBOR_ERR_WRONG_TYPE);
|
|
969
|
-
|
|
970
|
-
state->payload++;
|
|
971
|
-
return true;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
static bool list_map_end_decode(zcbor_state_t *state)
|
|
976
|
-
{
|
|
977
|
-
size_t max_elem_count = 0;
|
|
978
|
-
|
|
979
|
-
#ifndef ZCBOR_CANONICAL
|
|
980
|
-
if (state->decode_state.indefinite_length_array) {
|
|
981
|
-
if (!array_end_expect(state)) {
|
|
982
|
-
ZCBOR_FAIL();
|
|
983
|
-
}
|
|
984
|
-
max_elem_count = ZCBOR_MAX_ELEM_COUNT;
|
|
985
|
-
state->decode_state.indefinite_length_array = false;
|
|
986
|
-
}
|
|
987
|
-
#endif
|
|
988
|
-
if (!zcbor_process_backup(state,
|
|
989
|
-
ZCBOR_FLAG_RESTORE | ZCBOR_FLAG_CONSUME | ZCBOR_FLAG_KEEP_PAYLOAD,
|
|
990
|
-
max_elem_count)) {
|
|
991
|
-
ZCBOR_FAIL();
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
return true;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
bool zcbor_list_end_decode(zcbor_state_t *state)
|
|
999
|
-
{
|
|
1000
|
-
PRINT_FUNC();
|
|
1001
|
-
return list_map_end_decode(state);
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
bool zcbor_map_end_decode(zcbor_state_t *state)
|
|
1006
|
-
{
|
|
1007
|
-
PRINT_FUNC();
|
|
1008
|
-
return list_map_end_decode(state);
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
bool zcbor_unordered_map_end_decode(zcbor_state_t *state)
|
|
1013
|
-
{
|
|
1014
|
-
/* Checking zcbor_array_at_end() ensures that check is valid.
|
|
1015
|
-
* In case the map is at the end, but state->decode_state.counting_map_elems isn't updated.*/
|
|
1016
|
-
ZCBOR_ERR_IF(!zcbor_array_at_end(state) && state->decode_state.counting_map_elems,
|
|
1017
|
-
ZCBOR_ERR_ELEMS_NOT_PROCESSED);
|
|
1018
|
-
|
|
1019
|
-
if (state->decode_state.map_elem_count > 0) {
|
|
1020
|
-
#ifdef ZCBOR_MAP_SMART_SEARCH
|
|
1021
|
-
manipulate_flags(state, FLAG_MODE_CLEAR_UNUSED);
|
|
1022
|
-
|
|
1023
|
-
for (size_t i = 0; i < zcbor_flags_to_bytes(state->decode_state.map_elem_count); i++) {
|
|
1024
|
-
if (state->decode_state.map_search_elem_state[i] != 0) {
|
|
1025
|
-
zcbor_log("unprocessed element(s) in map: [%zu] = 0x%02x\n",
|
|
1026
|
-
i, state->decode_state.map_search_elem_state[i]);
|
|
1027
|
-
ZCBOR_ERR(ZCBOR_ERR_ELEMS_NOT_PROCESSED);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
#else
|
|
1031
|
-
ZCBOR_ERR_IF(should_try_key(state), ZCBOR_ERR_ELEMS_NOT_PROCESSED);
|
|
1032
|
-
#endif
|
|
1033
|
-
}
|
|
1034
|
-
while (!zcbor_array_at_end(state)) {
|
|
1035
|
-
zcbor_any_skip(state, NULL);
|
|
1036
|
-
}
|
|
1037
|
-
return zcbor_map_end_decode(state);
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
bool zcbor_list_map_end_force_decode(zcbor_state_t *state)
|
|
1042
|
-
{
|
|
1043
|
-
if (!zcbor_process_backup(state,
|
|
1044
|
-
ZCBOR_FLAG_RESTORE | ZCBOR_FLAG_CONSUME | ZCBOR_FLAG_KEEP_PAYLOAD,
|
|
1045
|
-
ZCBOR_MAX_ELEM_COUNT)) {
|
|
1046
|
-
ZCBOR_FAIL();
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
return true;
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
bool zcbor_simple_decode(zcbor_state_t *state, uint8_t *result)
|
|
1054
|
-
{
|
|
1055
|
-
PRINT_FUNC();
|
|
1056
|
-
PRINT_FUNC();
|
|
1057
|
-
INITIAL_CHECKS_WITH_TYPE(ZCBOR_MAJOR_TYPE_SIMPLE);
|
|
1058
|
-
|
|
1059
|
-
/* Simple values must be 0-23 (additional is 0-23) or 24-255 (additional is 24).
|
|
1060
|
-
* Other additional values are not considered simple values. */
|
|
1061
|
-
ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(*state->payload) > 24, ZCBOR_ERR_WRONG_TYPE);
|
|
1062
|
-
|
|
1063
|
-
if (!value_extract(state, result, sizeof(*result))) {
|
|
1064
|
-
ZCBOR_FAIL();
|
|
1065
|
-
}
|
|
1066
|
-
return true;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
bool zcbor_simple_expect(zcbor_state_t *state, uint8_t expected)
|
|
1071
|
-
{
|
|
1072
|
-
PRINT_FUNC();
|
|
1073
|
-
uint8_t actual;
|
|
1074
|
-
|
|
1075
|
-
if (!zcbor_simple_decode(state, &actual)) {
|
|
1076
|
-
ZCBOR_FAIL();
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
if (actual != expected) {
|
|
1080
|
-
zcbor_log("simple value %u != %u\r\n", actual, expected);
|
|
1081
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
return true;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
bool zcbor_simple_pexpect(zcbor_state_t *state, uint8_t *expected)
|
|
1089
|
-
{
|
|
1090
|
-
PRINT_FUNC();
|
|
1091
|
-
return zcbor_simple_expect(state, *expected);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
bool zcbor_nil_expect(zcbor_state_t *state, void *unused)
|
|
1096
|
-
{
|
|
1097
|
-
PRINT_FUNC();
|
|
1098
|
-
(void)unused;
|
|
1099
|
-
return zcbor_simple_expect(state, 22);
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
bool zcbor_undefined_expect(zcbor_state_t *state, void *unused)
|
|
1104
|
-
{
|
|
1105
|
-
PRINT_FUNC();
|
|
1106
|
-
(void)unused;
|
|
1107
|
-
return zcbor_simple_expect(state, 23);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
bool zcbor_bool_decode(zcbor_state_t *state, bool *result)
|
|
1112
|
-
{
|
|
1113
|
-
PRINT_FUNC();
|
|
1114
|
-
uint8_t value;
|
|
1115
|
-
|
|
1116
|
-
if (!zcbor_simple_decode(state, &value)) {
|
|
1117
|
-
ZCBOR_FAIL();
|
|
1118
|
-
}
|
|
1119
|
-
value -= ZCBOR_BOOL_TO_SIMPLE;
|
|
1120
|
-
if (value > 1) {
|
|
1121
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_TYPE);
|
|
1122
|
-
}
|
|
1123
|
-
*result = value;
|
|
1124
|
-
|
|
1125
|
-
zcbor_log("boolval: %u\r\n", *result);
|
|
1126
|
-
return true;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
bool zcbor_bool_expect(zcbor_state_t *state, bool expected)
|
|
1131
|
-
{
|
|
1132
|
-
PRINT_FUNC();
|
|
1133
|
-
return zcbor_simple_expect(state, (uint8_t)(!!expected) + ZCBOR_BOOL_TO_SIMPLE);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
bool zcbor_bool_pexpect(zcbor_state_t *state, bool *expected)
|
|
1138
|
-
{
|
|
1139
|
-
PRINT_FUNC();
|
|
1140
|
-
return zcbor_bool_expect(state, *expected);
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
static bool float_check(zcbor_state_t *state, uint8_t additional_val)
|
|
1145
|
-
{
|
|
1146
|
-
INITIAL_CHECKS_WITH_TYPE(ZCBOR_MAJOR_TYPE_SIMPLE);
|
|
1147
|
-
ZCBOR_ERR_IF(ZCBOR_ADDITIONAL(*state->payload) != additional_val, ZCBOR_ERR_FLOAT_SIZE);
|
|
1148
|
-
return true;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
bool zcbor_float16_bytes_decode(zcbor_state_t *state, uint16_t *result)
|
|
1153
|
-
{
|
|
1154
|
-
PRINT_FUNC();
|
|
1155
|
-
ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_2_BYTES));
|
|
1156
|
-
|
|
1157
|
-
if (!value_extract(state, result, sizeof(*result))) {
|
|
1158
|
-
ZCBOR_FAIL();
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
return true;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
bool zcbor_float16_bytes_expect(zcbor_state_t *state, uint16_t expected)
|
|
1166
|
-
{
|
|
1167
|
-
PRINT_FUNC();
|
|
1168
|
-
uint16_t actual;
|
|
1169
|
-
|
|
1170
|
-
if (!zcbor_float16_bytes_decode(state, &actual)) {
|
|
1171
|
-
ZCBOR_FAIL();
|
|
1172
|
-
}
|
|
1173
|
-
if (actual != expected) {
|
|
1174
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1175
|
-
}
|
|
1176
|
-
return true;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
bool zcbor_float16_bytes_pexpect(zcbor_state_t *state, uint16_t *expected)
|
|
1181
|
-
{
|
|
1182
|
-
PRINT_FUNC();
|
|
1183
|
-
return zcbor_float16_bytes_expect(state, *expected);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
bool zcbor_float16_decode(zcbor_state_t *state, float *result)
|
|
1188
|
-
{
|
|
1189
|
-
PRINT_FUNC();
|
|
1190
|
-
uint16_t value16;
|
|
1191
|
-
|
|
1192
|
-
if (!zcbor_float16_bytes_decode(state, &value16)) {
|
|
1193
|
-
ZCBOR_FAIL();
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
*result = zcbor_float16_to_32(value16);
|
|
1197
|
-
return true;
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
bool zcbor_float16_expect(zcbor_state_t *state, float expected)
|
|
1202
|
-
{
|
|
1203
|
-
PRINT_FUNC();
|
|
1204
|
-
float actual;
|
|
1205
|
-
|
|
1206
|
-
if (!zcbor_float16_decode(state, &actual)) {
|
|
1207
|
-
ZCBOR_FAIL();
|
|
1208
|
-
}
|
|
1209
|
-
if (actual != expected) {
|
|
1210
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1211
|
-
}
|
|
1212
|
-
return true;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
bool zcbor_float16_pexpect(zcbor_state_t *state, float *expected)
|
|
1217
|
-
{
|
|
1218
|
-
PRINT_FUNC();
|
|
1219
|
-
return zcbor_float16_expect(state, *expected);
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
bool zcbor_float32_decode(zcbor_state_t *state, float *result)
|
|
1224
|
-
{
|
|
1225
|
-
PRINT_FUNC();
|
|
1226
|
-
ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_4_BYTES));
|
|
1227
|
-
|
|
1228
|
-
if (!value_extract(state, result, sizeof(*result))) {
|
|
1229
|
-
ZCBOR_FAIL();
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
return true;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
bool zcbor_float32_expect(zcbor_state_t *state, float expected)
|
|
1237
|
-
{
|
|
1238
|
-
PRINT_FUNC();
|
|
1239
|
-
float actual;
|
|
1240
|
-
|
|
1241
|
-
if (!zcbor_float32_decode(state, &actual)) {
|
|
1242
|
-
ZCBOR_FAIL();
|
|
1243
|
-
}
|
|
1244
|
-
if (actual != expected) {
|
|
1245
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1246
|
-
}
|
|
1247
|
-
return true;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
bool zcbor_float32_pexpect(zcbor_state_t *state, float *expected)
|
|
1252
|
-
{
|
|
1253
|
-
PRINT_FUNC();
|
|
1254
|
-
return zcbor_float32_expect(state, *expected);
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
bool zcbor_float16_32_decode(zcbor_state_t *state, float *result)
|
|
1259
|
-
{
|
|
1260
|
-
PRINT_FUNC();
|
|
1261
|
-
if (zcbor_float16_decode(state, result)) {
|
|
1262
|
-
/* Do nothing */
|
|
1263
|
-
} else if (!zcbor_float32_decode(state, result)) {
|
|
1264
|
-
ZCBOR_FAIL();
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
return true;
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
bool zcbor_float16_32_expect(zcbor_state_t *state, float expected)
|
|
1272
|
-
{
|
|
1273
|
-
PRINT_FUNC();
|
|
1274
|
-
if (zcbor_float16_expect(state, expected)) {
|
|
1275
|
-
/* Do nothing */
|
|
1276
|
-
} else if (!zcbor_float32_expect(state, expected)) {
|
|
1277
|
-
ZCBOR_FAIL();
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
return true;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
bool zcbor_float16_32_pexpect(zcbor_state_t *state, float *expected)
|
|
1285
|
-
{
|
|
1286
|
-
PRINT_FUNC();
|
|
1287
|
-
return zcbor_float16_32_expect(state, *expected);
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
bool zcbor_float64_decode(zcbor_state_t *state, double *result)
|
|
1292
|
-
{
|
|
1293
|
-
PRINT_FUNC();
|
|
1294
|
-
ZCBOR_FAIL_IF(!float_check(state, ZCBOR_VALUE_IS_8_BYTES));
|
|
1295
|
-
|
|
1296
|
-
if (!value_extract(state, result, sizeof(*result))) {
|
|
1297
|
-
ZCBOR_FAIL();
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
return true;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
bool zcbor_float64_expect(zcbor_state_t *state, double expected)
|
|
1305
|
-
{
|
|
1306
|
-
PRINT_FUNC();
|
|
1307
|
-
double actual;
|
|
1308
|
-
|
|
1309
|
-
if (!zcbor_float64_decode(state, &actual)) {
|
|
1310
|
-
ZCBOR_FAIL();
|
|
1311
|
-
}
|
|
1312
|
-
if (actual != expected) {
|
|
1313
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1314
|
-
}
|
|
1315
|
-
return true;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
bool zcbor_float64_pexpect(zcbor_state_t *state, double *expected)
|
|
1320
|
-
{
|
|
1321
|
-
PRINT_FUNC();
|
|
1322
|
-
return zcbor_float64_expect(state, *expected);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
bool zcbor_float32_64_decode(zcbor_state_t *state, double *result)
|
|
1327
|
-
{
|
|
1328
|
-
PRINT_FUNC();
|
|
1329
|
-
float float_result;
|
|
1330
|
-
|
|
1331
|
-
if (zcbor_float32_decode(state, &float_result)) {
|
|
1332
|
-
*result = (double)float_result;
|
|
1333
|
-
} else if (!zcbor_float64_decode(state, result)) {
|
|
1334
|
-
ZCBOR_FAIL();
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
return true;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
bool zcbor_float32_64_expect(zcbor_state_t *state, double expected)
|
|
1342
|
-
{
|
|
1343
|
-
PRINT_FUNC();
|
|
1344
|
-
if (zcbor_float64_expect(state, expected)) {
|
|
1345
|
-
/* Do nothing */
|
|
1346
|
-
} else if (!zcbor_float32_expect(state, (float)expected)) {
|
|
1347
|
-
ZCBOR_FAIL();
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
return true;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
bool zcbor_float32_64_pexpect(zcbor_state_t *state, double *expected)
|
|
1355
|
-
{
|
|
1356
|
-
PRINT_FUNC();
|
|
1357
|
-
return zcbor_float32_64_expect(state, *expected);
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
bool zcbor_float_decode(zcbor_state_t *state, double *result)
|
|
1362
|
-
{
|
|
1363
|
-
PRINT_FUNC();
|
|
1364
|
-
float float_result;
|
|
1365
|
-
|
|
1366
|
-
if (zcbor_float16_decode(state, &float_result)) {
|
|
1367
|
-
*result = (double)float_result;
|
|
1368
|
-
} else if (zcbor_float32_decode(state, &float_result)) {
|
|
1369
|
-
*result = (double)float_result;
|
|
1370
|
-
} else if (!zcbor_float64_decode(state, result)) {
|
|
1371
|
-
ZCBOR_FAIL();
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
return true;
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
bool zcbor_float_expect(zcbor_state_t *state, double expected)
|
|
1379
|
-
{
|
|
1380
|
-
PRINT_FUNC();
|
|
1381
|
-
if (zcbor_float16_expect(state, (float)expected)) {
|
|
1382
|
-
/* Do nothing */
|
|
1383
|
-
} else if (zcbor_float32_expect(state, (float)expected)) {
|
|
1384
|
-
/* Do nothing */
|
|
1385
|
-
} else if (!zcbor_float64_expect(state, expected)) {
|
|
1386
|
-
ZCBOR_FAIL();
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
return true;
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
bool zcbor_float_pexpect(zcbor_state_t *state, double *expected)
|
|
1394
|
-
{
|
|
1395
|
-
PRINT_FUNC();
|
|
1396
|
-
return zcbor_float_expect(state, *expected);
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
bool zcbor_any_skip(zcbor_state_t *state, void *result)
|
|
1401
|
-
{
|
|
1402
|
-
PRINT_FUNC();
|
|
1403
|
-
zcbor_assert_state(result == NULL,
|
|
1404
|
-
"'any' type cannot be returned, only skipped.\r\n");
|
|
1405
|
-
(void)result;
|
|
1406
|
-
|
|
1407
|
-
INITIAL_CHECKS();
|
|
1408
|
-
zcbor_major_type_t major_type = ZCBOR_MAJOR_TYPE(*state->payload);
|
|
1409
|
-
uint8_t additional = ZCBOR_ADDITIONAL(*state->payload);
|
|
1410
|
-
uint64_t value = 0; /* In case of indefinite_length_array. */
|
|
1411
|
-
zcbor_state_t state_copy;
|
|
1412
|
-
|
|
1413
|
-
memcpy(&state_copy, state, sizeof(zcbor_state_t));
|
|
1414
|
-
|
|
1415
|
-
while (major_type == ZCBOR_MAJOR_TYPE_TAG) {
|
|
1416
|
-
uint32_t tag_dummy;
|
|
1417
|
-
|
|
1418
|
-
if (!zcbor_tag_decode(&state_copy, &tag_dummy)) {
|
|
1419
|
-
ZCBOR_FAIL();
|
|
1420
|
-
}
|
|
1421
|
-
ZCBOR_ERR_IF(state_copy.payload >= state_copy.payload_end, ZCBOR_ERR_NO_PAYLOAD);
|
|
1422
|
-
major_type = ZCBOR_MAJOR_TYPE(*state_copy.payload);
|
|
1423
|
-
additional = ZCBOR_ADDITIONAL(*state_copy.payload);
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
#ifdef ZCBOR_CANONICAL
|
|
1427
|
-
const bool indefinite_length_array = false;
|
|
1428
|
-
#else
|
|
1429
|
-
const bool indefinite_length_array = ((additional == ZCBOR_VALUE_IS_INDEFINITE_LENGTH)
|
|
1430
|
-
&& ((major_type == ZCBOR_MAJOR_TYPE_LIST) || (major_type == ZCBOR_MAJOR_TYPE_MAP)));
|
|
1431
|
-
#endif
|
|
1432
|
-
|
|
1433
|
-
if (!indefinite_length_array && !value_extract(&state_copy, &value, sizeof(value))) {
|
|
1434
|
-
/* Can happen because of elem_count (or payload_end) */
|
|
1435
|
-
ZCBOR_FAIL();
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
switch (major_type) {
|
|
1439
|
-
case ZCBOR_MAJOR_TYPE_BSTR:
|
|
1440
|
-
case ZCBOR_MAJOR_TYPE_TSTR:
|
|
1441
|
-
/* 'value' is the length of the BSTR or TSTR.
|
|
1442
|
-
* The subtraction is safe because value_extract() above
|
|
1443
|
-
* checks that payload_end is greater than payload. */
|
|
1444
|
-
ZCBOR_ERR_IF(
|
|
1445
|
-
value > (uint64_t)(state_copy.payload_end - state_copy.payload),
|
|
1446
|
-
ZCBOR_ERR_NO_PAYLOAD);
|
|
1447
|
-
(state_copy.payload) += value;
|
|
1448
|
-
break;
|
|
1449
|
-
case ZCBOR_MAJOR_TYPE_MAP:
|
|
1450
|
-
ZCBOR_ERR_IF(value > (SIZE_MAX / 2), ZCBOR_ERR_INT_SIZE);
|
|
1451
|
-
value *= 2;
|
|
1452
|
-
/* fallthrough */
|
|
1453
|
-
case ZCBOR_MAJOR_TYPE_LIST:
|
|
1454
|
-
if (indefinite_length_array) {
|
|
1455
|
-
state_copy.payload++;
|
|
1456
|
-
value = ZCBOR_LARGE_ELEM_COUNT;
|
|
1457
|
-
}
|
|
1458
|
-
state_copy.elem_count = (size_t)value;
|
|
1459
|
-
state_copy.decode_state.indefinite_length_array = indefinite_length_array;
|
|
1460
|
-
while (!zcbor_array_at_end(&state_copy)) {
|
|
1461
|
-
if (!zcbor_any_skip(&state_copy, NULL)) {
|
|
1462
|
-
ZCBOR_FAIL();
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
if (indefinite_length_array && !array_end_expect(&state_copy)) {
|
|
1466
|
-
ZCBOR_FAIL();
|
|
1467
|
-
}
|
|
1468
|
-
break;
|
|
1469
|
-
default:
|
|
1470
|
-
/* Do nothing */
|
|
1471
|
-
break;
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
state->payload = state_copy.payload;
|
|
1475
|
-
state->elem_count--;
|
|
1476
|
-
|
|
1477
|
-
return true;
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
bool zcbor_tag_decode(zcbor_state_t *state, uint32_t *result)
|
|
1482
|
-
{
|
|
1483
|
-
PRINT_FUNC();
|
|
1484
|
-
INITIAL_CHECKS_WITH_TYPE(ZCBOR_MAJOR_TYPE_TAG);
|
|
1485
|
-
|
|
1486
|
-
if (!value_extract(state, result, sizeof(*result))) {
|
|
1487
|
-
ZCBOR_FAIL();
|
|
1488
|
-
}
|
|
1489
|
-
state->elem_count++;
|
|
1490
|
-
return true;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
bool zcbor_tag_expect(zcbor_state_t *state, uint32_t expected)
|
|
1495
|
-
{
|
|
1496
|
-
PRINT_FUNC();
|
|
1497
|
-
uint32_t actual;
|
|
1498
|
-
|
|
1499
|
-
if (!zcbor_tag_decode(state, &actual)) {
|
|
1500
|
-
ZCBOR_FAIL();
|
|
1501
|
-
}
|
|
1502
|
-
if (actual != expected) {
|
|
1503
|
-
ERR_RESTORE(ZCBOR_ERR_WRONG_VALUE);
|
|
1504
|
-
}
|
|
1505
|
-
return true;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
bool zcbor_tag_pexpect(zcbor_state_t *state, uint32_t *expected)
|
|
1510
|
-
{
|
|
1511
|
-
PRINT_FUNC();
|
|
1512
|
-
return zcbor_tag_expect(state, *expected);
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
bool zcbor_multi_decode(size_t min_decode,
|
|
1517
|
-
size_t max_decode,
|
|
1518
|
-
size_t *num_decode,
|
|
1519
|
-
zcbor_decoder_t decoder,
|
|
1520
|
-
zcbor_state_t *state,
|
|
1521
|
-
void *result,
|
|
1522
|
-
size_t result_len)
|
|
1523
|
-
{
|
|
1524
|
-
PRINT_FUNC();
|
|
1525
|
-
ZCBOR_CHECK_ERROR();
|
|
1526
|
-
for (size_t i = 0; i < max_decode; i++) {
|
|
1527
|
-
uint8_t const *payload_bak = state->payload;
|
|
1528
|
-
size_t elem_count_bak = state->elem_count;
|
|
1529
|
-
|
|
1530
|
-
if (!decoder(state,
|
|
1531
|
-
(uint8_t *)result + i*result_len)) {
|
|
1532
|
-
*num_decode = i;
|
|
1533
|
-
state->payload = payload_bak;
|
|
1534
|
-
state->elem_count = elem_count_bak;
|
|
1535
|
-
ZCBOR_ERR_IF(i < min_decode, ZCBOR_ERR_ITERATIONS);
|
|
1536
|
-
zcbor_log("Found %zu elements.\r\n", i);
|
|
1537
|
-
return true;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
zcbor_log("Found %zu elements.\r\n", max_decode);
|
|
1541
|
-
*num_decode = max_decode;
|
|
1542
|
-
return true;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
bool zcbor_present_decode(bool *present,
|
|
1547
|
-
zcbor_decoder_t decoder,
|
|
1548
|
-
zcbor_state_t *state,
|
|
1549
|
-
void *result)
|
|
1550
|
-
{
|
|
1551
|
-
PRINT_FUNC();
|
|
1552
|
-
size_t num_decode = 0;
|
|
1553
|
-
bool retval = zcbor_multi_decode(0, 1, &num_decode, decoder, state, result, 0);
|
|
1554
|
-
|
|
1555
|
-
zcbor_assert_state(retval, "zcbor_multi_decode should not fail with these parameters.\r\n");
|
|
1556
|
-
|
|
1557
|
-
*present = !!num_decode;
|
|
1558
|
-
return retval;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
void zcbor_new_decode_state(zcbor_state_t *state_array, size_t n_states,
|
|
1563
|
-
const uint8_t *payload, size_t payload_len, size_t elem_count,
|
|
1564
|
-
uint8_t *flags, size_t flags_bytes)
|
|
1565
|
-
{
|
|
1566
|
-
zcbor_new_state(state_array, n_states, payload, payload_len, elem_count, flags, flags_bytes);
|
|
1567
|
-
}
|