edhoc 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -0
- package/binding.gyp +13 -11
- package/dist/bindings.d.ts +5 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +10 -0
- package/dist/crypto.d.ts +29 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +205 -0
- package/dist/edhoc.d.ts +368 -0
- package/dist/edhoc.d.ts.map +1 -0
- package/dist/edhoc.js +76 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/x509credentials.d.ts +20 -0
- package/dist/x509credentials.d.ts.map +1 -0
- package/dist/x509credentials.js +140 -0
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
- package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
- package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
- package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
- package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
- package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
- package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
- package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
- package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
- package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
- package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
- package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
- package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
- package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
- package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
- package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
- package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
- package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
- package/external/libedhoc/externals/Unity/src/unity.h +698 -0
- package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
- package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
- package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
- package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
- package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
- package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
- package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
- package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
- package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
- package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
- package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
- package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
- package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
- package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
- package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
- package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
- package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
- package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
- package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
- package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
- package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
- package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
- package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
- package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
- package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
- package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
- package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
- package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
- package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
- package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
- package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
- package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
- package/external/libedhoc/include/edhoc.h +348 -54
- package/external/libedhoc/include/edhoc_common.h +289 -0
- package/external/libedhoc/include/edhoc_context.h +60 -35
- package/external/libedhoc/include/edhoc_credentials.h +55 -7
- package/external/libedhoc/include/edhoc_crypto.h +10 -10
- package/external/libedhoc/include/edhoc_ead.h +13 -10
- package/external/libedhoc/include/edhoc_macros.h +20 -11
- package/external/libedhoc/include/edhoc_values.h +2 -2
- package/external/libedhoc/library/edhoc.c +70 -36
- package/external/libedhoc/library/edhoc_common.c +1314 -0
- package/external/libedhoc/library/edhoc_exporter.c +45 -46
- package/external/libedhoc/library/edhoc_message_1.c +107 -72
- package/external/libedhoc/library/edhoc_message_2.c +396 -1693
- package/external/libedhoc/library/edhoc_message_3.c +465 -1656
- package/external/libedhoc/library/edhoc_message_4.c +93 -91
- package/external/libedhoc/library/edhoc_message_error.c +41 -41
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
- package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
- package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
- package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
- package/external/libedhoc/tests/include/{x509_chain_cs_0/test_vector_x5chain_cs_0.h → test_vector_x5chain_sign_keys_suite_0.h} +137 -140
- package/external/libedhoc/tests/include/{x509_chain_cs_2/test_vector_x5chain_cs_2.h → test_vector_x5chain_sign_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_chain_cs_2_static_dh/test_vector_x5chain_cs_2_static_dh.h → test_vector_x5chain_static_dh_keys_suite_2.h} +7 -8
- package/external/libedhoc/tests/include/{x509_hash_cs_2/test_vector_x5t_cs_2.h → test_vector_x5t_sign_keys_suite_2.h} +6 -7
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
- package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
- package/external/libedhoc/tests/src/module_test_api.c +430 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
- package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
- package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
- package/external/libedhoc/tests/src/module_test_main.c +49 -0
- package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
- package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
- package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
- package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
- package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
- package/include/EdhocComposeAsyncWorker.h +8 -6
- package/include/EdhocCredentialManager.h +16 -11
- package/include/EdhocCryptoManager.h +28 -21
- package/include/EdhocEadManager.h +3 -6
- package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
- package/include/EdhocKeyExporterAsyncWorker.h +76 -0
- package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
- package/include/EdhocProcessAsyncWorker.h +14 -10
- package/include/LibEDHOC.h +44 -20
- package/include/UserContext.h +7 -9
- package/include/Utils.h +31 -27
- package/package.json +14 -3
- package/prebuilds/android-arm/edhoc.armv7.node +0 -0
- package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/darwin-arm64/edhoc.node +0 -0
- package/prebuilds/darwin-x64/edhoc.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
- package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
- package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
- package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
- package/prebuilds/linux-x64/edhoc.musl.node +0 -0
- package/prebuilds/win32-ia32/edhoc.node +0 -0
- package/prebuilds/win32-x64/edhoc.node +0 -0
- package/src/EdhocComposeAsyncWorker.cpp +18 -35
- package/src/EdhocCredentialManager.cpp +160 -187
- package/src/EdhocCryptoManager.cpp +386 -586
- package/src/EdhocEadManager.cpp +10 -18
- package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
- package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
- package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
- package/src/EdhocProcessAsyncWorker.cpp +72 -19
- package/src/LibEDHOC.cpp +213 -174
- package/src/Suites.cpp +39 -72
- package/src/Utils.cpp +32 -56
- package/test/basic.test.ts +64 -0
- package/test/vectors.test.ts +111 -0
- package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
- package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
- package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
- package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
- package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
- package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
- package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
- package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
- package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
- package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
- package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
- package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
- package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
- package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
- package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
- package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
- package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
- package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
- package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
- package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
- package/external/libedhoc/tests/src/tests.c +0 -228
- package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
- package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
- package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
- package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
- package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
- package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
- package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
- package/src/EdhocExportAsyncWorker.cpp +0 -82
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity.h"
|
|
9
|
+
#include "unity_memory.h"
|
|
10
|
+
#include "unity_output_Spy.h"
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
|
|
14
|
+
/* This test module includes the following tests: */
|
|
15
|
+
|
|
16
|
+
void test_ForceMallocFail(void);
|
|
17
|
+
void test_ReallocSmallerIsUnchanged(void);
|
|
18
|
+
void test_ReallocSameIsUnchanged(void);
|
|
19
|
+
void test_ReallocLargerNeeded(void);
|
|
20
|
+
void test_ReallocNullPointerIsLikeMalloc(void);
|
|
21
|
+
void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void);
|
|
22
|
+
void test_CallocFillsWithZero(void);
|
|
23
|
+
void test_FreeNULLSafety(void);
|
|
24
|
+
void test_DetectsLeak(void);
|
|
25
|
+
void test_BufferOverrunFoundDuringFree(void);
|
|
26
|
+
void test_BufferOverrunFoundDuringRealloc(void);
|
|
27
|
+
void test_BufferGuardWriteFoundDuringFree(void);
|
|
28
|
+
void test_BufferGuardWriteFoundDuringRealloc(void);
|
|
29
|
+
void test_MallocPastBufferFails(void);
|
|
30
|
+
void test_CallocPastBufferFails(void);
|
|
31
|
+
void test_MallocThenReallocGrowsMemoryInPlace(void);
|
|
32
|
+
void test_ReallocFailDoesNotFreeMem(void);
|
|
33
|
+
|
|
34
|
+
/* It makes use of the following features */
|
|
35
|
+
void setUp(void);
|
|
36
|
+
void tearDown(void);
|
|
37
|
+
|
|
38
|
+
/* Let's Go! */
|
|
39
|
+
void setUp(void)
|
|
40
|
+
{
|
|
41
|
+
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
|
42
|
+
UnityOutputCharSpy_Create(200);
|
|
43
|
+
#else
|
|
44
|
+
UnityOutputCharSpy_Create(1000);
|
|
45
|
+
#endif
|
|
46
|
+
UnityMalloc_StartTest();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void tearDown(void)
|
|
50
|
+
{
|
|
51
|
+
UnityMalloc_EndTest();
|
|
52
|
+
UnityOutputCharSpy_Destroy();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void test_ForceMallocFail(void)
|
|
56
|
+
{
|
|
57
|
+
void* m;
|
|
58
|
+
void* mfails;
|
|
59
|
+
UnityMalloc_MakeMallocFailAfterCount(1);
|
|
60
|
+
m = malloc(10);
|
|
61
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
62
|
+
mfails = malloc(10);
|
|
63
|
+
TEST_ASSERT_EQUAL_PTR(0, mfails);
|
|
64
|
+
free(m);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void test_ReallocSmallerIsUnchanged(void)
|
|
68
|
+
{
|
|
69
|
+
void* m1 = malloc(10);
|
|
70
|
+
void* m2 = realloc(m1, 5);
|
|
71
|
+
TEST_ASSERT_NOT_NULL(m1);
|
|
72
|
+
TEST_ASSERT_EQUAL_PTR(m1, m2);
|
|
73
|
+
free(m2);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void test_ReallocSameIsUnchanged(void)
|
|
77
|
+
{
|
|
78
|
+
void* m1 = malloc(10);
|
|
79
|
+
void* m2 = realloc(m1, 10);
|
|
80
|
+
TEST_ASSERT_NOT_NULL(m1);
|
|
81
|
+
TEST_ASSERT_EQUAL_PTR(m1, m2);
|
|
82
|
+
free(m2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void test_ReallocLargerNeeded(void)
|
|
86
|
+
{
|
|
87
|
+
void* m2;
|
|
88
|
+
void* m1 = malloc(10);
|
|
89
|
+
TEST_ASSERT_NOT_NULL(m1);
|
|
90
|
+
strcpy((char*)m1, "123456789");
|
|
91
|
+
m2 = realloc(m1, 15);
|
|
92
|
+
TEST_ASSERT_EQUAL_STRING("123456789", m2);
|
|
93
|
+
free(m2);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void test_ReallocNullPointerIsLikeMalloc(void)
|
|
97
|
+
{
|
|
98
|
+
void* m = realloc(0, 15);
|
|
99
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
100
|
+
free(m);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void)
|
|
104
|
+
{
|
|
105
|
+
void* m1 = malloc(10);
|
|
106
|
+
void* m2 = realloc(m1, 0);
|
|
107
|
+
TEST_ASSERT_EQUAL_PTR(0, m2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void test_CallocFillsWithZero(void)
|
|
111
|
+
{
|
|
112
|
+
void* m = calloc(3, sizeof(char));
|
|
113
|
+
char* s = (char*)m;
|
|
114
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
115
|
+
TEST_ASSERT_EQUAL_HEX8(0, s[0]);
|
|
116
|
+
TEST_ASSERT_EQUAL_HEX8(0, s[1]);
|
|
117
|
+
TEST_ASSERT_EQUAL_HEX8(0, s[2]);
|
|
118
|
+
free(m);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void test_FreeNULLSafety(void)
|
|
122
|
+
{
|
|
123
|
+
free(NULL);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/*------------------------------------------------------------ */
|
|
127
|
+
|
|
128
|
+
#define EXPECT_ABORT_BEGIN \
|
|
129
|
+
{ \
|
|
130
|
+
jmp_buf TestAbortFrame; \
|
|
131
|
+
memcpy(TestAbortFrame, Unity.AbortFrame, sizeof(jmp_buf)); \
|
|
132
|
+
if (TEST_PROTECT()) \
|
|
133
|
+
{
|
|
134
|
+
|
|
135
|
+
#define EXPECT_ABORT_END \
|
|
136
|
+
} \
|
|
137
|
+
memcpy(Unity.AbortFrame, TestAbortFrame, sizeof(jmp_buf)); \
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* This tricky set of defines lets us see if we are using the Spy, returns 1 if true */
|
|
141
|
+
#ifdef __STDC_VERSION__
|
|
142
|
+
|
|
143
|
+
#ifdef UNITY_SUPPORT_VARIADIC_MACROS
|
|
144
|
+
#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0)
|
|
145
|
+
#define ASSIGN_VALUE(a) VAL_##a
|
|
146
|
+
#define VAL_UnityOutputCharSpy_OutputChar 0, 1
|
|
147
|
+
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
|
|
148
|
+
#define SECOND_PARAM(a, b, ...) b
|
|
149
|
+
#if USING_SPY_AS(UNITY_OUTPUT_CHAR)
|
|
150
|
+
#define USING_OUTPUT_SPY /* UNITY_OUTPUT_CHAR = UnityOutputCharSpy_OutputChar */
|
|
151
|
+
#endif
|
|
152
|
+
#endif /* UNITY_SUPPORT_VARIADIC_MACROS */
|
|
153
|
+
|
|
154
|
+
#else /* __STDC_VERSION__ else */
|
|
155
|
+
|
|
156
|
+
#define UnityOutputCharSpy_OutputChar 42
|
|
157
|
+
#if UNITY_OUTPUT_CHAR == UnityOutputCharSpy_OutputChar /* Works if no -Wundef -Werror */
|
|
158
|
+
#define USING_OUTPUT_SPY
|
|
159
|
+
#endif
|
|
160
|
+
#undef UnityOutputCharSpy_OutputChar
|
|
161
|
+
|
|
162
|
+
#endif /* __STDC_VERSION__ */
|
|
163
|
+
|
|
164
|
+
void test_DetectsLeak(void)
|
|
165
|
+
{
|
|
166
|
+
#ifdef USING_OUTPUT_SPY
|
|
167
|
+
void* m = malloc(10);
|
|
168
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
169
|
+
UnityOutputCharSpy_Enable(1);
|
|
170
|
+
EXPECT_ABORT_BEGIN
|
|
171
|
+
UnityMalloc_EndTest();
|
|
172
|
+
EXPECT_ABORT_END
|
|
173
|
+
UnityOutputCharSpy_Enable(0);
|
|
174
|
+
Unity.CurrentTestFailed = 0;
|
|
175
|
+
TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "This test leaks!"));
|
|
176
|
+
free(m);
|
|
177
|
+
#else
|
|
178
|
+
TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test");
|
|
179
|
+
#endif
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void test_BufferOverrunFoundDuringFree(void)
|
|
183
|
+
{
|
|
184
|
+
#ifdef USING_OUTPUT_SPY
|
|
185
|
+
void* m = malloc(10);
|
|
186
|
+
char* s = (char*)m;
|
|
187
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
188
|
+
s[10] = (char)0xFF;
|
|
189
|
+
UnityOutputCharSpy_Enable(1);
|
|
190
|
+
EXPECT_ABORT_BEGIN
|
|
191
|
+
free(m);
|
|
192
|
+
EXPECT_ABORT_END
|
|
193
|
+
UnityOutputCharSpy_Enable(0);
|
|
194
|
+
Unity.CurrentTestFailed = 0;
|
|
195
|
+
TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()"));
|
|
196
|
+
#else
|
|
197
|
+
TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test");
|
|
198
|
+
#endif
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
void test_BufferOverrunFoundDuringRealloc(void)
|
|
202
|
+
{
|
|
203
|
+
#ifdef USING_OUTPUT_SPY
|
|
204
|
+
void* m = malloc(10);
|
|
205
|
+
char* s = (char*)m;
|
|
206
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
207
|
+
s[10] = (char)0xFF;
|
|
208
|
+
UnityOutputCharSpy_Enable(1);
|
|
209
|
+
EXPECT_ABORT_BEGIN
|
|
210
|
+
m = realloc(m, 100);
|
|
211
|
+
EXPECT_ABORT_END
|
|
212
|
+
UnityOutputCharSpy_Enable(0);
|
|
213
|
+
Unity.CurrentTestFailed = 0;
|
|
214
|
+
TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()"));
|
|
215
|
+
#else
|
|
216
|
+
TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test");
|
|
217
|
+
#endif
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void test_BufferGuardWriteFoundDuringFree(void)
|
|
221
|
+
{
|
|
222
|
+
#ifdef USING_OUTPUT_SPY
|
|
223
|
+
void* m = malloc(10);
|
|
224
|
+
char* s = (char*)m;
|
|
225
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
226
|
+
s[-1] = (char)0x00; /* Will not detect 0 */
|
|
227
|
+
s[-2] = (char)0x01;
|
|
228
|
+
UnityOutputCharSpy_Enable(1);
|
|
229
|
+
EXPECT_ABORT_BEGIN
|
|
230
|
+
free(m);
|
|
231
|
+
EXPECT_ABORT_END
|
|
232
|
+
UnityOutputCharSpy_Enable(0);
|
|
233
|
+
Unity.CurrentTestFailed = 0;
|
|
234
|
+
TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during free()"));
|
|
235
|
+
#else
|
|
236
|
+
TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test");
|
|
237
|
+
#endif
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
void test_BufferGuardWriteFoundDuringRealloc(void)
|
|
241
|
+
{
|
|
242
|
+
#ifdef USING_OUTPUT_SPY
|
|
243
|
+
void* m = malloc(10);
|
|
244
|
+
char* s = (char*)m;
|
|
245
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
246
|
+
s[-1] = (char)0x0A;
|
|
247
|
+
UnityOutputCharSpy_Enable(1);
|
|
248
|
+
EXPECT_ABORT_BEGIN
|
|
249
|
+
m = realloc(m, 100);
|
|
250
|
+
EXPECT_ABORT_END
|
|
251
|
+
UnityOutputCharSpy_Enable(0);
|
|
252
|
+
Unity.CurrentTestFailed = 0;
|
|
253
|
+
TEST_ASSERT_NOT_NULL(strstr(UnityOutputCharSpy_Get(), "Buffer overrun detected during realloc()"));
|
|
254
|
+
#else
|
|
255
|
+
TEST_IGNORE_MESSAGE("Enable USING_OUTPUT_SPY To Run This Test");
|
|
256
|
+
#endif
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/*------------------------------------------------------------ */
|
|
260
|
+
|
|
261
|
+
#define TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(first_mem_ptr, ptr) \
|
|
262
|
+
ptr = malloc(10); free(ptr); \
|
|
263
|
+
TEST_ASSERT_EQUAL_PTR_MESSAGE(first_mem_ptr, ptr, "Memory was stranded, free in LIFO order");
|
|
264
|
+
|
|
265
|
+
void test_MallocPastBufferFails(void)
|
|
266
|
+
{
|
|
267
|
+
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
|
268
|
+
void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1);
|
|
269
|
+
void* n = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2);
|
|
270
|
+
free(m);
|
|
271
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
272
|
+
TEST_ASSERT_NULL(n);
|
|
273
|
+
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n);
|
|
274
|
+
#else
|
|
275
|
+
TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test");
|
|
276
|
+
#endif
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
void test_CallocPastBufferFails(void)
|
|
280
|
+
{
|
|
281
|
+
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
|
282
|
+
void* m = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1);
|
|
283
|
+
void* n = calloc(1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2);
|
|
284
|
+
free(m);
|
|
285
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
286
|
+
TEST_ASSERT_NULL(n);
|
|
287
|
+
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n);
|
|
288
|
+
#else
|
|
289
|
+
TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test");
|
|
290
|
+
#endif
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
void test_MallocThenReallocGrowsMemoryInPlace(void)
|
|
294
|
+
{
|
|
295
|
+
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
|
296
|
+
void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1);
|
|
297
|
+
void* n = realloc(m, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 9);
|
|
298
|
+
free(n);
|
|
299
|
+
TEST_ASSERT_NOT_NULL(m);
|
|
300
|
+
TEST_ASSERT_EQUAL(m, n);
|
|
301
|
+
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n);
|
|
302
|
+
#else
|
|
303
|
+
TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test");
|
|
304
|
+
#endif
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
void test_ReallocFailDoesNotFreeMem(void)
|
|
308
|
+
{
|
|
309
|
+
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC
|
|
310
|
+
void* m = malloc(UNITY_INTERNAL_HEAP_SIZE_BYTES/2);
|
|
311
|
+
void* n1 = malloc(10);
|
|
312
|
+
void* out_of_mem = realloc(n1, UNITY_INTERNAL_HEAP_SIZE_BYTES/2 + 1);
|
|
313
|
+
void* n2 = malloc(10);
|
|
314
|
+
|
|
315
|
+
free(n2);
|
|
316
|
+
if (out_of_mem == NULL) free(n1);
|
|
317
|
+
free(m);
|
|
318
|
+
|
|
319
|
+
TEST_ASSERT_NOT_NULL(m); /* Got a real memory location */
|
|
320
|
+
TEST_ASSERT_NULL(out_of_mem); /* The realloc should have failed */
|
|
321
|
+
TEST_ASSERT_NOT_EQUAL(n2, n1); /* If n1 != n2 then realloc did not free n1 */
|
|
322
|
+
TEST_ASSERT_MEMORY_ALL_FREE_LIFO_ORDER(m, n2);
|
|
323
|
+
#else
|
|
324
|
+
TEST_IGNORE_MESSAGE("Enable UNITY_EXCLUDE_STDLIB_MALLOC to Run This Test");
|
|
325
|
+
#endif
|
|
326
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity.h"
|
|
9
|
+
#include "unity_memory.h"
|
|
10
|
+
|
|
11
|
+
extern void test_ForceMallocFail(void);
|
|
12
|
+
extern void test_ReallocSmallerIsUnchanged(void);
|
|
13
|
+
extern void test_ReallocSameIsUnchanged(void);
|
|
14
|
+
extern void test_ReallocLargerNeeded(void);
|
|
15
|
+
extern void test_ReallocNullPointerIsLikeMalloc(void);
|
|
16
|
+
extern void test_ReallocSizeZeroFreesMemAndReturnsNullPointer(void);
|
|
17
|
+
extern void test_CallocFillsWithZero(void);
|
|
18
|
+
extern void test_FreeNULLSafety(void);
|
|
19
|
+
extern void test_DetectsLeak(void);
|
|
20
|
+
extern void test_BufferOverrunFoundDuringFree(void);
|
|
21
|
+
extern void test_BufferOverrunFoundDuringRealloc(void);
|
|
22
|
+
extern void test_BufferGuardWriteFoundDuringFree(void);
|
|
23
|
+
extern void test_BufferGuardWriteFoundDuringRealloc(void);
|
|
24
|
+
extern void test_MallocPastBufferFails(void);
|
|
25
|
+
extern void test_CallocPastBufferFails(void);
|
|
26
|
+
extern void test_MallocThenReallocGrowsMemoryInPlace(void);
|
|
27
|
+
extern void test_ReallocFailDoesNotFreeMem(void);
|
|
28
|
+
|
|
29
|
+
int main(void)
|
|
30
|
+
{
|
|
31
|
+
UnityBegin("unity_memory_Test.c");
|
|
32
|
+
RUN_TEST(test_ForceMallocFail);
|
|
33
|
+
RUN_TEST(test_ReallocSmallerIsUnchanged);
|
|
34
|
+
RUN_TEST(test_ReallocSameIsUnchanged);
|
|
35
|
+
RUN_TEST(test_ReallocLargerNeeded);
|
|
36
|
+
RUN_TEST(test_ReallocNullPointerIsLikeMalloc);
|
|
37
|
+
RUN_TEST(test_ReallocSizeZeroFreesMemAndReturnsNullPointer);
|
|
38
|
+
RUN_TEST(test_CallocFillsWithZero);
|
|
39
|
+
RUN_TEST(test_FreeNULLSafety);
|
|
40
|
+
RUN_TEST(test_DetectsLeak);
|
|
41
|
+
RUN_TEST(test_BufferOverrunFoundDuringFree);
|
|
42
|
+
RUN_TEST(test_BufferOverrunFoundDuringRealloc);
|
|
43
|
+
RUN_TEST(test_BufferGuardWriteFoundDuringFree);
|
|
44
|
+
RUN_TEST(test_BufferGuardWriteFoundDuringRealloc);
|
|
45
|
+
RUN_TEST(test_MallocPastBufferFails);
|
|
46
|
+
RUN_TEST(test_CallocPastBufferFails);
|
|
47
|
+
RUN_TEST(test_MallocThenReallocGrowsMemoryInPlace);
|
|
48
|
+
RUN_TEST(test_ReallocFailDoesNotFreeMem);
|
|
49
|
+
return UnityEnd();
|
|
50
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#include "unity.h"
|
|
9
|
+
#include "unity_output_Spy.h"
|
|
10
|
+
|
|
11
|
+
#include <stdio.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
#include <stdlib.h>
|
|
14
|
+
|
|
15
|
+
static int size;
|
|
16
|
+
static int count;
|
|
17
|
+
static char* buffer;
|
|
18
|
+
static int spy_enable;
|
|
19
|
+
|
|
20
|
+
void UnityOutputCharSpy_Create(int s)
|
|
21
|
+
{
|
|
22
|
+
size = (s > 0) ? s : 0;
|
|
23
|
+
count = 0;
|
|
24
|
+
spy_enable = 0;
|
|
25
|
+
buffer = malloc((size_t)size);
|
|
26
|
+
TEST_ASSERT_NOT_NULL_MESSAGE(buffer, "Internal malloc failed in Spy Create():" __FILE__);
|
|
27
|
+
memset(buffer, 0, (size_t)size);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void UnityOutputCharSpy_Destroy(void)
|
|
31
|
+
{
|
|
32
|
+
size = 0;
|
|
33
|
+
free(buffer);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void UnityOutputCharSpy_OutputChar(int c)
|
|
37
|
+
{
|
|
38
|
+
if (spy_enable)
|
|
39
|
+
{
|
|
40
|
+
if (count < (size-1))
|
|
41
|
+
buffer[count++] = (char)c;
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
{
|
|
45
|
+
putchar(c);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const char * UnityOutputCharSpy_Get(void)
|
|
50
|
+
{
|
|
51
|
+
return buffer;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void UnityOutputCharSpy_Enable(int enable)
|
|
55
|
+
{
|
|
56
|
+
spy_enable = enable;
|
|
57
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
Unity - A Test Framework for C
|
|
3
|
+
ThrowTheSwitch.org
|
|
4
|
+
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
SPDX-License-Identifier: MIT
|
|
6
|
+
========================================================================= */
|
|
7
|
+
|
|
8
|
+
#ifndef UNITY_OUTPUT_SPY_H
|
|
9
|
+
#define UNITY_OUTPUT_SPY_H
|
|
10
|
+
|
|
11
|
+
void UnityOutputCharSpy_Create(int s);
|
|
12
|
+
void UnityOutputCharSpy_Destroy(void);
|
|
13
|
+
void UnityOutputCharSpy_OutputChar(int c);
|
|
14
|
+
const char * UnityOutputCharSpy_Get(void);
|
|
15
|
+
void UnityOutputCharSpy_Enable(int enable);
|
|
16
|
+
|
|
17
|
+
#endif
|