edhoc 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/crypto.d.ts +9 -2
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +112 -84
- package/dist/edhoc.d.ts +31 -9
- package/dist/edhoc.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/dist/credentials.d.ts +0 -16
- package/dist/credentials.d.ts.map +0 -1
- package/dist/credentials.js +0 -84
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -23,226 +23,222 @@ extern "C" {
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/** See @ref zcbor_new_state() */
|
|
27
|
+
void zcbor_new_decode_state(zcbor_state_t *state_array, size_t n_states,
|
|
28
|
+
const uint8_t *payload, size_t payload_len, size_t elem_count,
|
|
29
|
+
uint8_t *elem_state, size_t elem_state_bytes);
|
|
30
|
+
|
|
31
|
+
/** Convenience macro for declaring and initializing a decoding state with backups.
|
|
27
32
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
33
|
+
* This gives you a state variable named @p name. The variable functions like
|
|
34
|
+
* a pointer.
|
|
35
|
+
*
|
|
36
|
+
* @param[in] name The name of the new state variable.
|
|
37
|
+
* @param[in] num_backups The number of backup slots to keep in the state.
|
|
38
|
+
* @param[in] payload The payload to work on.
|
|
39
|
+
* @param[in] payload_size The size (in bytes) of @p payload.
|
|
40
|
+
* @param[in] elem_count The starting elem_count (typically 1).
|
|
41
|
+
* @param[in] n_flags For use if ZCBOR_MAP_SMART_SEARCH is enabled, ignored otherwise.
|
|
42
|
+
* The total number of unordered map search flags needed.
|
|
43
|
+
* I.e. the largest number of elements expected in an unordered map,
|
|
44
|
+
* including elements in nested unordered maps.
|
|
45
|
+
*/
|
|
46
|
+
#define ZCBOR_STATE_D(name, num_backups, payload, payload_size, elem_count, n_flags) \
|
|
47
|
+
zcbor_state_t name[((num_backups) + 2 + ZCBOR_FLAG_STATES(n_flags))]; \
|
|
48
|
+
do { \
|
|
49
|
+
zcbor_new_decode_state(name, ZCBOR_ARRAY_SIZE(name), payload, payload_size, elem_count, \
|
|
50
|
+
(uint8_t *)&name[(num_backups) + 1], ZCBOR_FLAG_STATES(n_flags) * sizeof(zcbor_state_t)); \
|
|
51
|
+
} while(0)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/** The following applies to all _decode() functions listed directly below.
|
|
55
|
+
*
|
|
56
|
+
* @param[inout] state The current state of the decoding.
|
|
57
|
+
* @param[out] result Where to place the decoded value.
|
|
58
|
+
* @param[in] result_size (if present) Size in bytes of the memory at @p result
|
|
30
59
|
*
|
|
31
60
|
* @retval true If the value was decoded correctly.
|
|
32
61
|
* @retval false If the value has the wrong type, the payload overflowed, the
|
|
33
62
|
* element count was exhausted, or the value was larger than can
|
|
34
63
|
* fit in the result variable.
|
|
64
|
+
* Use zcbor_peek_error() to see the error code.
|
|
35
65
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
bool
|
|
39
|
-
bool
|
|
40
|
-
bool
|
|
41
|
-
bool
|
|
42
|
-
bool
|
|
43
|
-
bool
|
|
44
|
-
bool
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
66
|
+
bool zcbor_int32_decode(zcbor_state_t *state, int32_t *result); /* pint/nint */
|
|
67
|
+
bool zcbor_int64_decode(zcbor_state_t *state, int64_t *result); /* pint/nint */
|
|
68
|
+
bool zcbor_uint32_decode(zcbor_state_t *state, uint32_t *result); /* pint */
|
|
69
|
+
bool zcbor_uint64_decode(zcbor_state_t *state, uint64_t *result); /* pint */
|
|
70
|
+
bool zcbor_size_decode(zcbor_state_t *state, size_t *result); /* pint */
|
|
71
|
+
bool zcbor_int_decode(zcbor_state_t *state, void *result, size_t result_size); /* pint/nint */
|
|
72
|
+
bool zcbor_uint_decode(zcbor_state_t *state, void *result, size_t result_size); /* pint */
|
|
73
|
+
bool zcbor_bstr_decode(zcbor_state_t *state, struct zcbor_string *result); /* bstr */
|
|
74
|
+
bool zcbor_tstr_decode(zcbor_state_t *state, struct zcbor_string *result); /* tstr */
|
|
75
|
+
bool zcbor_tag_decode(zcbor_state_t *state, uint32_t *result); /* CBOR tag */
|
|
76
|
+
bool zcbor_simple_decode(zcbor_state_t *state, uint8_t *result); /* CBOR simple value */
|
|
77
|
+
bool zcbor_bool_decode(zcbor_state_t *state, bool *result); /* boolean CBOR simple value */
|
|
78
|
+
bool zcbor_float16_decode(zcbor_state_t *state, float *result); /* IEEE754 float16 */
|
|
79
|
+
bool zcbor_float16_bytes_decode(zcbor_state_t *state, uint16_t *result); /* IEEE754 float16 raw bytes */
|
|
80
|
+
bool zcbor_float16_32_decode(zcbor_state_t *state, float *result); /* IEEE754 float16 or float32 */
|
|
81
|
+
bool zcbor_float32_decode(zcbor_state_t *state, float *result); /* IEEE754 float32 */
|
|
82
|
+
bool zcbor_float32_64_decode(zcbor_state_t *state, double *result); /* IEEE754 float32 or float64 */
|
|
83
|
+
bool zcbor_float64_decode(zcbor_state_t *state, double *result); /* IEEE754 float64 */
|
|
84
|
+
bool zcbor_float_decode(zcbor_state_t *state, double *result); /* IEEE754 float16, float32, or float64 */
|
|
85
|
+
|
|
86
|
+
/** The following applies to all _expect() and _pexpect() functions listed directly below.
|
|
87
|
+
*
|
|
88
|
+
* @param[inout] state The current state of the decoding.
|
|
89
|
+
* @param[in] expected The expected value.
|
|
50
90
|
*
|
|
51
91
|
* @retval true If the result was decoded correctly and has the expected value.
|
|
52
92
|
* @retval false If the decoding failed or the result doesn't have the
|
|
53
93
|
* expected value.
|
|
94
|
+
* Use zcbor_peek_error() to see the error code.
|
|
54
95
|
*/
|
|
55
|
-
|
|
56
|
-
bool
|
|
57
|
-
bool
|
|
58
|
-
bool
|
|
59
|
-
bool
|
|
60
|
-
bool
|
|
96
|
+
bool zcbor_int32_expect(zcbor_state_t *state, int32_t expected); /* pint/nint */
|
|
97
|
+
bool zcbor_int64_expect(zcbor_state_t *state, int64_t expected); /* pint/nint */
|
|
98
|
+
bool zcbor_uint32_expect(zcbor_state_t *state, uint32_t expected); /* pint */
|
|
99
|
+
bool zcbor_uint64_expect(zcbor_state_t *state, uint64_t expected); /* pint */
|
|
100
|
+
bool zcbor_size_expect(zcbor_state_t *state, size_t expected); /* pint */
|
|
101
|
+
bool zcbor_bstr_expect(zcbor_state_t *state, struct zcbor_string *expected); /* bstr */
|
|
102
|
+
bool zcbor_tstr_expect(zcbor_state_t *state, struct zcbor_string *expected); /* tstr */
|
|
103
|
+
bool zcbor_tag_expect(zcbor_state_t *state, uint32_t expected); /* CBOR tag */
|
|
104
|
+
bool zcbor_simple_expect(zcbor_state_t *state, uint8_t expected); /* CBOR simple value */
|
|
105
|
+
bool zcbor_bool_expect(zcbor_state_t *state, bool expected); /* boolean CBOR simple value */
|
|
106
|
+
bool zcbor_nil_expect(zcbor_state_t *state, void *unused); /* 'nil' CBOR simple value */
|
|
107
|
+
bool zcbor_undefined_expect(zcbor_state_t *state, void *unused); /* 'undefined' CBOR simple value */
|
|
108
|
+
bool zcbor_float16_expect(zcbor_state_t *state, float expected); /* IEEE754 float16 */
|
|
109
|
+
bool zcbor_float16_bytes_expect(zcbor_state_t *state, uint16_t expected); /* IEEE754 float16 raw bytes */
|
|
110
|
+
bool zcbor_float16_32_expect(zcbor_state_t *state, float expected); /* IEEE754 float16 or float32 */
|
|
111
|
+
bool zcbor_float32_expect(zcbor_state_t *state, float expected); /* IEEE754 float32 */
|
|
112
|
+
bool zcbor_float32_64_expect(zcbor_state_t *state, double expected); /* IEEE754 float32 or float64 */
|
|
113
|
+
bool zcbor_float64_expect(zcbor_state_t *state, double expected); /* IEEE754 float64 */
|
|
114
|
+
bool zcbor_float_expect(zcbor_state_t *state, double expected); /* IEEE754 float16, float32, or float64 */
|
|
115
|
+
|
|
116
|
+
/** Like the _expect() functions but the value is passed through a pointer.
|
|
117
|
+
* (for use as a zcbor_decoder_t function) */
|
|
118
|
+
bool zcbor_int32_pexpect(zcbor_state_t *state, int32_t *expected); /* pint/nint */
|
|
119
|
+
bool zcbor_int64_pexpect(zcbor_state_t *state, int64_t *expected); /* pint/nint */
|
|
120
|
+
bool zcbor_uint32_pexpect(zcbor_state_t *state, uint32_t *expected); /* pint */
|
|
121
|
+
bool zcbor_uint64_pexpect(zcbor_state_t *state, uint64_t *expected); /* pint */
|
|
122
|
+
bool zcbor_size_pexpect(zcbor_state_t *state, size_t *expected); /* pint */
|
|
123
|
+
bool zcbor_tag_pexpect(zcbor_state_t *state, uint32_t *expected); /* CBOR tag */
|
|
124
|
+
bool zcbor_simple_pexpect(zcbor_state_t *state, uint8_t *expected); /* CBOR simple value */
|
|
125
|
+
bool zcbor_bool_pexpect(zcbor_state_t *state, bool *expected); /* boolean CBOR simple value */
|
|
126
|
+
bool zcbor_float16_pexpect(zcbor_state_t *state, float *expected); /* IEEE754 float16 */
|
|
127
|
+
bool zcbor_float16_bytes_pexpect(zcbor_state_t *state, uint16_t *expected); /* IEEE754 float16 raw bytes */
|
|
128
|
+
bool zcbor_float16_32_pexpect(zcbor_state_t *state, float *expected); /* IEEE754 float16 or float32 */
|
|
129
|
+
bool zcbor_float32_pexpect(zcbor_state_t *state, float *expected); /* IEEE754 float32 */
|
|
130
|
+
bool zcbor_float32_64_pexpect(zcbor_state_t *state, double *expected); /* IEEE754 float32 or float64 */
|
|
131
|
+
bool zcbor_float64_pexpect(zcbor_state_t *state, double *expected); /* IEEE754 float64 */
|
|
132
|
+
bool zcbor_float_pexpect(zcbor_state_t *state, double *expected); /* IEEE754 float16, float32, or float64 */
|
|
61
133
|
|
|
62
134
|
/** Consume and expect a pint/nint with a certain value, within a union.
|
|
63
135
|
*
|
|
64
136
|
* Calls @ref zcbor_union_elem_code then @ref zcbor_[u]int[32|64]_expect.
|
|
65
137
|
*/
|
|
66
|
-
bool zcbor_int32_expect_union(zcbor_state_t *state, int32_t
|
|
67
|
-
bool zcbor_int64_expect_union(zcbor_state_t *state, int64_t
|
|
68
|
-
bool zcbor_uint32_expect_union(zcbor_state_t *state, uint32_t
|
|
69
|
-
bool zcbor_uint64_expect_union(zcbor_state_t *state, uint64_t
|
|
70
|
-
|
|
71
|
-
/** Decode and consume a bstr/tstr */
|
|
72
|
-
bool zcbor_bstr_decode(zcbor_state_t *state, struct zcbor_string *result);
|
|
73
|
-
bool zcbor_bstr_expect(zcbor_state_t *state, struct zcbor_string *result);
|
|
74
|
-
bool zcbor_tstr_decode(zcbor_state_t *state, struct zcbor_string *result);
|
|
75
|
-
bool zcbor_tstr_expect(zcbor_state_t *state, struct zcbor_string *result);
|
|
76
|
-
|
|
77
|
-
/** Consume and expect a bstr/tstr with the value of the provided string literal.
|
|
78
|
-
*
|
|
79
|
-
* @param[inout] state The current state of the encoding.
|
|
80
|
-
* @param[in] string The value to expect. A pointer to the string.
|
|
81
|
-
* @param[in] len The length of the string pointed to by @p string.
|
|
82
|
-
*/
|
|
83
|
-
static inline bool zcbor_bstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
84
|
-
{
|
|
85
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
86
|
-
|
|
87
|
-
return zcbor_bstr_expect(state, &zs);
|
|
88
|
-
}
|
|
89
|
-
static inline bool zcbor_tstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len)
|
|
90
|
-
{
|
|
91
|
-
struct zcbor_string zs = { .value = (const uint8_t *)ptr, .len = len };
|
|
138
|
+
bool zcbor_int32_expect_union(zcbor_state_t *state, int32_t expected);
|
|
139
|
+
bool zcbor_int64_expect_union(zcbor_state_t *state, int64_t expected);
|
|
140
|
+
bool zcbor_uint32_expect_union(zcbor_state_t *state, uint32_t expected);
|
|
141
|
+
bool zcbor_uint64_expect_union(zcbor_state_t *state, uint64_t expected);
|
|
92
142
|
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/** Consume and expect a bstr/tstr with the value of the provided string literal.
|
|
98
|
-
*
|
|
99
|
-
* @param[inout] state The current state of the encoding.
|
|
100
|
-
* @param[in] string The value to expect. A string literal, e.g. "Foo", so
|
|
101
|
-
* that sizeof(string) - 1 is the length of the string.
|
|
102
|
-
*/
|
|
103
|
-
#define zcbor_bstr_expect_lit(state, string) \
|
|
104
|
-
zcbor_bstr_expect_ptr(state, string, sizeof(string) - 1)
|
|
105
|
-
#define zcbor_tstr_expect_lit(state, string) \
|
|
106
|
-
zcbor_tstr_expect_ptr(state, string, sizeof(string) - 1)
|
|
107
|
-
|
|
108
|
-
/** Consume and expect a bstr/tstr with the value of the provided null-terminated string.
|
|
109
|
-
*
|
|
110
|
-
* @param[inout] state The current state of the encoding.
|
|
111
|
-
* @param[in] string The value to expect. Must be a null-terminated string,
|
|
112
|
-
* so that strlen can be used.
|
|
113
|
-
*/
|
|
114
|
-
#define zcbor_bstr_expect_term(state, string) \
|
|
115
|
-
zcbor_bstr_expect_ptr(state, string, strlen(string))
|
|
116
|
-
#define zcbor_tstr_expect_term(state, string) \
|
|
117
|
-
zcbor_tstr_expect_ptr(state, string, strlen(string))
|
|
118
|
-
|
|
119
|
-
/** Consume and expect a bstr/tstr with the value of the provided char array literal.
|
|
120
|
-
*
|
|
121
|
-
* @param[inout] state The current state of the encoding.
|
|
122
|
-
* @param[in] string The value to expect. An array literal, e.g. {'F', 'o', 'o'},
|
|
123
|
-
* so that sizeof(string) is the length of the string.
|
|
124
|
-
*/
|
|
125
|
-
#define zcbor_bstr_expect_arr(state, string) \
|
|
126
|
-
zcbor_bstr_expect_ptr(state, string, (sizeof(string)))
|
|
127
|
-
#define zcbor_tstr_expect_arr(state, string) \
|
|
128
|
-
zcbor_tstr_expect_ptr(state, string, (sizeof(string)))
|
|
129
|
-
|
|
130
|
-
/** Decode and consume a tag. */
|
|
131
|
-
bool zcbor_tag_decode(zcbor_state_t *state, uint32_t *result);
|
|
132
|
-
bool zcbor_tag_expect(zcbor_state_t *state, uint32_t result);
|
|
133
|
-
|
|
134
|
-
/** Decode and consume a simple value. */
|
|
135
|
-
bool zcbor_simple_decode(zcbor_state_t *state, uint8_t *result);
|
|
136
|
-
bool zcbor_simple_expect(zcbor_state_t *state, uint8_t result);
|
|
137
|
-
|
|
138
|
-
/** Decode and consume a boolean simple value. */
|
|
139
|
-
bool zcbor_bool_decode(zcbor_state_t *state, bool *result);
|
|
140
|
-
bool zcbor_bool_expect(zcbor_state_t *state, bool result);
|
|
141
|
-
|
|
142
|
-
/** Decode and consume an IEEE754 float */
|
|
143
|
-
bool zcbor_float16_decode(zcbor_state_t *state, float *result);
|
|
144
|
-
bool zcbor_float16_expect(zcbor_state_t *state, float result);
|
|
145
|
-
bool zcbor_float16_bytes_decode(zcbor_state_t *state, uint16_t *result);
|
|
146
|
-
bool zcbor_float16_bytes_expect(zcbor_state_t *state, uint16_t result);
|
|
147
|
-
bool zcbor_float16_32_decode(zcbor_state_t *state, float *result);
|
|
148
|
-
bool zcbor_float16_32_expect(zcbor_state_t *state, float result);
|
|
149
|
-
bool zcbor_float32_decode(zcbor_state_t *state, float *result);
|
|
150
|
-
bool zcbor_float32_expect(zcbor_state_t *state, float result);
|
|
151
|
-
bool zcbor_float32_64_decode(zcbor_state_t *state, double *result);
|
|
152
|
-
bool zcbor_float32_64_expect(zcbor_state_t *state, double result);
|
|
153
|
-
bool zcbor_float64_decode(zcbor_state_t *state, double *result);
|
|
154
|
-
bool zcbor_float64_expect(zcbor_state_t *state, double result);
|
|
155
|
-
bool zcbor_float_decode(zcbor_state_t *state, double *result);
|
|
156
|
-
bool zcbor_float_expect(zcbor_state_t *state, double result);
|
|
157
|
-
|
|
158
|
-
/** Consume and expect a "nil"/"undefined" simple value.
|
|
159
|
-
*
|
|
160
|
-
* @param[inout] state The current state of the encoding.
|
|
161
|
-
* @param[in] unused Unused parameter to maintain signature parity with
|
|
162
|
-
* @ref zcbor_decoder_t.
|
|
163
|
-
*/
|
|
164
|
-
bool zcbor_nil_expect(zcbor_state_t *state, void *unused);
|
|
165
|
-
bool zcbor_undefined_expect(zcbor_state_t *state, void *unused);
|
|
166
|
-
|
|
167
|
-
/** Skip a single element, regardless of type and value.
|
|
168
|
-
*
|
|
169
|
-
* @param[inout] state The current state of the encoding.
|
|
170
|
-
* @param[in] unused Unused parameter to maintain signature parity with
|
|
171
|
-
* @ref zcbor_decoder_t.
|
|
172
|
-
*/
|
|
173
|
-
bool zcbor_any_skip(zcbor_state_t *state, void *unused);
|
|
174
|
-
|
|
175
|
-
/** Decode and consume a bstr header.
|
|
143
|
+
/** Decode and consume a list/map header.
|
|
176
144
|
*
|
|
177
|
-
* The
|
|
145
|
+
* The contents of the list can be decoded via subsequent function calls.
|
|
178
146
|
* A state backup is created to keep track of the element count.
|
|
179
|
-
* Call @ref
|
|
147
|
+
* Call @ref zcbor_list_end_decode / @ref zcbor_map_end_decode when done
|
|
148
|
+
* decoding the contents of the list/map
|
|
180
149
|
*
|
|
181
150
|
* @retval true Header decoded correctly
|
|
182
151
|
* @retval false Header decoded incorrectly, or backup failed.
|
|
183
152
|
*/
|
|
184
|
-
bool
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
153
|
+
bool zcbor_list_start_decode(zcbor_state_t *state);
|
|
154
|
+
bool zcbor_map_start_decode(zcbor_state_t *state);
|
|
155
|
+
bool zcbor_unordered_map_start_decode(zcbor_state_t *state);
|
|
156
|
+
|
|
157
|
+
/** Search for a key in a map.
|
|
158
|
+
*
|
|
159
|
+
* The CBOR spec allows elements (key-value pairs) in maps to appear in any order.
|
|
160
|
+
* This function should be used when the order of elements is unknown.
|
|
161
|
+
*
|
|
162
|
+
* This must only be used while inside a map that has been entered via
|
|
163
|
+
* @ref zcbor_unordered_map_start_decode. Use @ref zcbor_unordered_map_end_decode
|
|
164
|
+
* when leaving the map.
|
|
165
|
+
*
|
|
166
|
+
* This function searches for keys. When this function returns successfully,
|
|
167
|
+
* the @p state is pointing to the value corresponding to the found key.
|
|
168
|
+
* Therefore, to be able to call this function again, the value must first be
|
|
169
|
+
* decoded or skipped.
|
|
170
|
+
*
|
|
171
|
+
* When searching unordered maps, the found elements must be kept track of.
|
|
172
|
+
* By default, this function automatically keeps track, which means it keeps a
|
|
173
|
+
* running count of the number of found elements, which is checked when exiting
|
|
174
|
+
* the map. You can do this manually instead, see @ref zcbor_elem_processed and
|
|
175
|
+
* @ref manually_process_elem. If ZCBOR_MAP_SMART_SEARCH is defined, a flag is
|
|
176
|
+
* kept for each element, instead of a rolling count.
|
|
177
|
+
*
|
|
178
|
+
* @note Unless ZCBOR_MAP_SMART_SEARCH is defined,
|
|
179
|
+
* elements are not individually marked as processed, so they may
|
|
180
|
+
* be returned again in a subsequent call to this function, if it is
|
|
181
|
+
* matched by the @p key_decoder of that call. Because of this, you should
|
|
182
|
+
* only use this function when you know the @p key_decoder matches no more
|
|
183
|
+
* than one of the keys. Typically this means all keys are known strings
|
|
184
|
+
* or integers, i.e. the @p key_decoder is typically a _pexpect() function.
|
|
185
|
+
*
|
|
186
|
+
* When searching for strings, there are convenience functions available,
|
|
187
|
+
* see the zcbor_search_key_* functions.
|
|
188
|
+
*
|
|
189
|
+
* @param[in] key_decoder A decoding function that will be tried against all
|
|
190
|
+
* keys in the map until it returns true, at which point
|
|
191
|
+
* @ref zcbor_unordered_map_search will return true.
|
|
192
|
+
* For example, a zcbor_*_pexpect() function.
|
|
193
|
+
* @param[inout] state The current state of decoding. Must be currently decoding
|
|
194
|
+
* the contents of a map, and pointing to one (any) of the
|
|
195
|
+
* keys, not one of the values. If successful, the @p state
|
|
196
|
+
* will be pointing to the value corresponding to the
|
|
197
|
+
* matched key. If unsuccessful, the @p state will be
|
|
198
|
+
* unchanged.
|
|
199
|
+
* @param[inout] key_result This will be passed as the second argument to the
|
|
200
|
+
* @p key_decoder.
|
|
201
|
+
*
|
|
202
|
+
* @retval true If the key was found, i.e. @p key_decoder returned true.
|
|
203
|
+
* @retval false If the key was not found after searching all map elements.
|
|
204
|
+
* Or the map was pointing to a value (not a key).
|
|
205
|
+
* Or an unexpected error happened while skipping elements or
|
|
206
|
+
* jumping from the end of the map to the start.
|
|
199
207
|
*/
|
|
200
|
-
bool
|
|
201
|
-
bool zcbor_tstr_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result);
|
|
208
|
+
bool zcbor_unordered_map_search(zcbor_decoder_t key_decoder, zcbor_state_t *state, void *key_result);
|
|
202
209
|
|
|
203
|
-
/**
|
|
210
|
+
/** Find a specific bstr/tstr key as part of a map with unknown element order.
|
|
204
211
|
*
|
|
205
|
-
*
|
|
212
|
+
* Uses @ref zcbor_unordered_map_search under the hood. Please refer to those docs
|
|
213
|
+
* for the conditions under which this can be called.
|
|
214
|
+
* Refer to the docs for zcbor_(t|b)str_expect_* (e.g. @ref zcbor_bstr_expect_ptr)
|
|
215
|
+
* for parameter docs.
|
|
206
216
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
217
|
+
bool zcbor_search_key_bstr_ptr(zcbor_state_t *state, char const *ptr, size_t len);
|
|
218
|
+
bool zcbor_search_key_tstr_ptr(zcbor_state_t *state, char const *ptr, size_t len);
|
|
219
|
+
bool zcbor_search_key_bstr_term(zcbor_state_t *state, char const *str, size_t maxlen);
|
|
220
|
+
bool zcbor_search_key_tstr_term(zcbor_state_t *state, char const *str, size_t maxlen);
|
|
221
|
+
#define zcbor_search_key_bstr_lit(state, str) zcbor_search_key_bstr_ptr(state, str, sizeof(str) - 1)
|
|
222
|
+
#define zcbor_search_key_tstr_lit(state, str) zcbor_search_key_tstr_ptr(state, str, sizeof(str) - 1)
|
|
223
|
+
#define zcbor_search_key_bstr_arr(state, str) zcbor_search_key_bstr_ptr(state, str, (sizeof(str)))
|
|
224
|
+
#define zcbor_search_key_tstr_arr(state, str) zcbor_search_key_tstr_ptr(state, str, (sizeof(str)))
|
|
210
225
|
|
|
211
|
-
/**
|
|
226
|
+
/** (Optional) Call this function to mark an (unordered map) element as processed.
|
|
212
227
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* the current payload has been exhausted.
|
|
217
|
-
* Call @ref zcbor_bstr_end_decode when done decoding the contents of the bstr.
|
|
218
|
-
*/
|
|
219
|
-
bool zcbor_bstr_start_decode_fragment(zcbor_state_t *state,
|
|
220
|
-
struct zcbor_string_fragment *result);
|
|
221
|
-
|
|
222
|
-
/** Start decoding the next fragment of a string.
|
|
228
|
+
* @note This should not be called unless the @ref manually_process_elem flag is set.
|
|
229
|
+
* By default, i.e. when @ref manually_process_elem is not set, this function is
|
|
230
|
+
* called internally by @ref zcbor_unordered_map_search whenever a key is found.
|
|
223
231
|
*
|
|
224
|
-
*
|
|
225
|
-
* bstr.
|
|
226
|
-
*/
|
|
227
|
-
void zcbor_bstr_next_fragment(zcbor_state_t *state,
|
|
228
|
-
struct zcbor_string_fragment *prev_fragment,
|
|
229
|
-
struct zcbor_string_fragment *result);
|
|
230
|
-
|
|
231
|
-
/** Can be used on any fragment to tell if it is the final fragment of the string. */
|
|
232
|
-
bool zcbor_is_last_fragment(const struct zcbor_string_fragment *fragment);
|
|
233
|
-
|
|
234
|
-
/** Decode and consume a list/map header.
|
|
232
|
+
* By default, this function increments the internal count @ref map_elems_processed.
|
|
235
233
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
* decoding the contents of the list/map
|
|
234
|
+
* If ZCBOR_MAP_SMART_SEARCH is defined, this function instead clears a flag for the
|
|
235
|
+
* element (key-value pair) that is currently being processed, or that has just been
|
|
236
|
+
* processed, meaning the element won't be found again via @ref zcbor_unordered_map_search.
|
|
240
237
|
*
|
|
241
|
-
* @
|
|
242
|
-
*
|
|
238
|
+
* @ref zcbor_unordered_map_end_decode will fail if @ref map_elems_processed does not
|
|
239
|
+
* match the number of elements in the map, or if any of the map element's flag is set.
|
|
243
240
|
*/
|
|
244
|
-
bool
|
|
245
|
-
bool zcbor_map_start_decode(zcbor_state_t *state);
|
|
241
|
+
bool zcbor_elem_processed(zcbor_state_t *state);
|
|
246
242
|
|
|
247
243
|
/** Finalize decoding a list/map
|
|
248
244
|
*
|
|
@@ -252,13 +248,33 @@ bool zcbor_map_start_decode(zcbor_state_t *state);
|
|
|
252
248
|
* Use @ref zcbor_list_map_end_force_decode to forcibly consume the backup if
|
|
253
249
|
* something has gone wrong.
|
|
254
250
|
*
|
|
251
|
+
* In all successful cases, the state is returned pointing to the byte/element
|
|
252
|
+
* after the list/map in the payload.
|
|
253
|
+
*
|
|
255
254
|
* @retval true Everything ok.
|
|
256
255
|
* @retval false Element count not correct.
|
|
257
256
|
*/
|
|
258
257
|
bool zcbor_list_end_decode(zcbor_state_t *state);
|
|
259
258
|
bool zcbor_map_end_decode(zcbor_state_t *state);
|
|
259
|
+
bool zcbor_unordered_map_end_decode(zcbor_state_t *state);
|
|
260
260
|
bool zcbor_list_map_end_force_decode(zcbor_state_t *state);
|
|
261
261
|
|
|
262
|
+
/** Find whether the state is at the end of a list or map.
|
|
263
|
+
*/
|
|
264
|
+
bool zcbor_array_at_end(zcbor_state_t *state);
|
|
265
|
+
|
|
266
|
+
/** Skip a single element, regardless of type and value.
|
|
267
|
+
*
|
|
268
|
+
* This means if the element is a map or list, this function will recursively
|
|
269
|
+
* skip all its contents.
|
|
270
|
+
* This function will also skip any tags preceeding the element.
|
|
271
|
+
*
|
|
272
|
+
* @param[inout] state The current state of the decoding.
|
|
273
|
+
* @param[in] unused Unused parameter to maintain signature parity with
|
|
274
|
+
* @ref zcbor_decoder_t.
|
|
275
|
+
*/
|
|
276
|
+
bool zcbor_any_skip(zcbor_state_t *state, void *unused);
|
|
277
|
+
|
|
262
278
|
/** Decode 0 or more elements with the same type and constraints.
|
|
263
279
|
*
|
|
264
280
|
* The decoded values will appear consecutively in the @p result array.
|
|
@@ -301,6 +317,8 @@ bool zcbor_list_map_end_force_decode(zcbor_state_t *state);
|
|
|
301
317
|
* The result pointer is moved @p result_len bytes for
|
|
302
318
|
* each call to @p decoder, i.e. @p result refers to
|
|
303
319
|
* an array of result variables.
|
|
320
|
+
* Should not be an _expect() function, use
|
|
321
|
+
* _pexpect() instead.
|
|
304
322
|
* @param[out] result Where to place the decoded values. Must be an array
|
|
305
323
|
* of at least @p max_decode elements.
|
|
306
324
|
* @param[in] result_len The length of each result variable. Must be the
|
|
@@ -330,26 +348,97 @@ bool zcbor_present_decode(bool *present,
|
|
|
330
348
|
zcbor_state_t *state,
|
|
331
349
|
void *result);
|
|
332
350
|
|
|
333
|
-
/** See @ref zcbor_new_state() */
|
|
334
|
-
void zcbor_new_decode_state(zcbor_state_t *state_array, size_t n_states,
|
|
335
|
-
const uint8_t *payload, size_t payload_len, size_t elem_count);
|
|
336
351
|
|
|
337
|
-
/**
|
|
352
|
+
/** Supplementary string (bstr/tstr) decoding functions: */
|
|
353
|
+
|
|
354
|
+
/** Consume and expect a bstr/tstr with the value of the provided char/uint8_t array.
|
|
338
355
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
356
|
+
* @param[inout] state The current state of the decoding.
|
|
357
|
+
* @param[in] str The value to expect. A pointer to the string/array.
|
|
358
|
+
* _term() uses strnlen(), so @p str must be null-terminated.
|
|
359
|
+
* _lit() uses sizeof()-1, so @p str must be a (null-terminated) string literal.
|
|
360
|
+
* _arr() uses sizeof(), so @p str must be a uint8_t array (not null-terminated).
|
|
361
|
+
* @param[in] len (if present) The length of the string pointed to by @p str
|
|
362
|
+
* @param[in] maxlen (if present) The maximum length of the string pointed to by @p str.
|
|
363
|
+
* This value is passed to strnlen.
|
|
364
|
+
*/
|
|
365
|
+
bool zcbor_bstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len);
|
|
366
|
+
bool zcbor_tstr_expect_ptr(zcbor_state_t *state, char const *ptr, size_t len);
|
|
367
|
+
bool zcbor_bstr_expect_term(zcbor_state_t *state, char const *str, size_t maxlen);
|
|
368
|
+
bool zcbor_tstr_expect_term(zcbor_state_t *state, char const *str, size_t maxlen);
|
|
369
|
+
#define zcbor_bstr_expect_lit(state, str) zcbor_bstr_expect_ptr(state, str, sizeof(str) - 1)
|
|
370
|
+
#define zcbor_tstr_expect_lit(state, str) zcbor_tstr_expect_ptr(state, str, sizeof(str) - 1)
|
|
371
|
+
#define zcbor_bstr_expect_arr(state, str) zcbor_bstr_expect_ptr(state, str, sizeof(str))
|
|
372
|
+
#define zcbor_tstr_expect_arr(state, str) zcbor_tstr_expect_ptr(state, str, sizeof(str))
|
|
373
|
+
|
|
374
|
+
/** Decode and consume a bstr header.
|
|
341
375
|
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
376
|
+
* The rest of the string can be decoded as CBOR.
|
|
377
|
+
* A state backup is created to keep track of the element count.
|
|
378
|
+
* Call @ref zcbor_bstr_end_decode when done decoding the contents of the bstr.
|
|
379
|
+
*
|
|
380
|
+
* @param[inout] state The current state of the decoding.
|
|
381
|
+
* @param[out] result The resulting string, for reference. The string should be decoded via
|
|
382
|
+
* functions from this API since state is pointing to the start of the string,
|
|
383
|
+
* not the end.
|
|
384
|
+
*
|
|
385
|
+
* @retval true Header decoded correctly
|
|
386
|
+
* @retval false Header decoded incorrectly, or backup failed, or payload is not large enough
|
|
387
|
+
* to contain the contents of the string. Use @ref zcbor_bstr_start_decode_fragment
|
|
388
|
+
* for decoding fragmented payloads.
|
|
347
389
|
*/
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
390
|
+
bool zcbor_bstr_start_decode(zcbor_state_t *state, struct zcbor_string *result);
|
|
391
|
+
|
|
392
|
+
/** Finalize decoding a CBOR-encoded bstr.
|
|
393
|
+
*
|
|
394
|
+
* Restore element count from backup.
|
|
395
|
+
*/
|
|
396
|
+
bool zcbor_bstr_end_decode(zcbor_state_t *state);
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
/** Supplementary string (bstr/tstr) decoding functions for fragmented payloads: */
|
|
400
|
+
|
|
401
|
+
/** Start decoding a bstr/tstr, even if the payload contains only part of it.
|
|
402
|
+
*
|
|
403
|
+
* This must be followed by a call to @ref zcbor_update_state, which can be
|
|
404
|
+
* followed by a call to @ref zcbor_next_fragment. Do not call this function
|
|
405
|
+
* again on subsequent fragments of the same string.
|
|
406
|
+
*
|
|
407
|
+
* This consumes the remaining payload as long as it belongs to the string.
|
|
408
|
+
*/
|
|
409
|
+
bool zcbor_bstr_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result);
|
|
410
|
+
bool zcbor_tstr_decode_fragment(zcbor_state_t *state, struct zcbor_string_fragment *result);
|
|
411
|
+
|
|
412
|
+
/** Extract the next fragment of a string.
|
|
413
|
+
*
|
|
414
|
+
* Use this function to extract all but the first fragment.
|
|
415
|
+
*/
|
|
416
|
+
void zcbor_next_fragment(zcbor_state_t *state,
|
|
417
|
+
struct zcbor_string_fragment *prev_fragment,
|
|
418
|
+
struct zcbor_string_fragment *result);
|
|
419
|
+
|
|
420
|
+
/** Decode and consume a bstr header, assuming the payload does not contain the whole bstr.
|
|
421
|
+
*
|
|
422
|
+
* The rest of the string can be decoded as CBOR.
|
|
423
|
+
* A state backup is created to keep track of the element count.
|
|
424
|
+
* Call @ref zcbor_update_state followed by @ref zcbor_bstr_next_fragment when
|
|
425
|
+
* the current payload has been exhausted.
|
|
426
|
+
* Call @ref zcbor_bstr_end_decode when done decoding the contents of the bstr.
|
|
427
|
+
*/
|
|
428
|
+
bool zcbor_bstr_start_decode_fragment(zcbor_state_t *state,
|
|
429
|
+
struct zcbor_string_fragment *result);
|
|
430
|
+
|
|
431
|
+
/** Start decoding the next fragment of a string.
|
|
432
|
+
*
|
|
433
|
+
* Use this function to extract all but the first fragment of a CBOR-encoded
|
|
434
|
+
* bstr.
|
|
435
|
+
*/
|
|
436
|
+
void zcbor_bstr_next_fragment(zcbor_state_t *state,
|
|
437
|
+
struct zcbor_string_fragment *prev_fragment,
|
|
438
|
+
struct zcbor_string_fragment *result);
|
|
439
|
+
|
|
440
|
+
/** Can be used on any fragment to tell if it is the final fragment of the string. */
|
|
441
|
+
bool zcbor_is_last_fragment(const struct zcbor_string_fragment *fragment);
|
|
353
442
|
|
|
354
443
|
#ifdef __cplusplus
|
|
355
444
|
}
|