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.
Files changed (314) hide show
  1. package/README.md +170 -0
  2. package/binding.gyp +13 -11
  3. package/dist/bindings.d.ts +5 -0
  4. package/dist/bindings.d.ts.map +1 -0
  5. package/dist/bindings.js +10 -0
  6. package/dist/crypto.d.ts +29 -0
  7. package/dist/crypto.d.ts.map +1 -0
  8. package/dist/crypto.js +205 -0
  9. package/dist/edhoc.d.ts +368 -0
  10. package/dist/edhoc.d.ts.map +1 -0
  11. package/dist/edhoc.js +76 -0
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +19 -0
  15. package/dist/x509credentials.d.ts +20 -0
  16. package/dist/x509credentials.d.ts.map +1 -0
  17. package/dist/x509credentials.js +140 -0
  18. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
  19. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
  20. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
  21. package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
  22. package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
  23. package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
  24. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
  25. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
  26. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
  27. package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
  28. package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
  29. package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
  30. package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
  31. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
  32. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
  33. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
  34. package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
  35. package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
  36. package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
  37. package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
  38. package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
  39. package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
  40. package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
  41. package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
  42. package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
  43. package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
  44. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
  45. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
  46. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
  47. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
  48. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
  49. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
  50. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
  51. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
  52. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
  53. package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
  54. package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
  55. package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
  56. package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
  57. package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
  58. package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
  59. package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
  60. package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
  61. package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
  62. package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
  63. package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
  64. package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
  65. package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
  66. package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
  67. package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
  68. package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
  69. package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
  70. package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
  71. package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
  72. package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
  73. package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
  74. package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
  75. package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
  76. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
  77. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
  78. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
  79. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
  80. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
  81. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
  82. package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
  83. package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
  84. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
  85. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
  86. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
  87. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
  88. package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
  89. package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
  90. package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
  91. package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
  92. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
  93. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
  94. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
  95. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
  96. package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
  97. package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
  98. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
  99. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
  100. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
  101. package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
  102. package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
  103. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
  104. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
  105. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
  106. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
  107. package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
  108. package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
  109. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
  110. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
  111. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
  112. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
  113. package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
  114. package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
  115. package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
  116. package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
  117. package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
  118. package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
  119. package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
  120. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
  121. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
  122. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
  123. package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
  124. package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
  125. package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
  126. package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
  127. package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
  128. package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
  129. package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
  130. package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
  131. package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
  132. package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
  133. package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
  134. package/external/libedhoc/externals/Unity/src/unity.h +698 -0
  135. package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
  136. package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
  137. package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
  138. package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
  139. package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
  140. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
  141. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
  142. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
  143. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
  144. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
  145. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
  146. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
  147. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
  148. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
  149. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
  150. package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
  151. package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
  152. package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
  153. package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
  154. package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
  155. package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
  156. package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
  157. package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
  158. package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
  159. package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
  160. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
  161. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
  162. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
  163. package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
  164. package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
  165. package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
  166. package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
  167. package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
  168. package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
  169. package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
  170. package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
  171. package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
  172. package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
  173. package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
  174. package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
  175. package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
  176. package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
  177. package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
  178. package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
  179. package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
  180. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
  181. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
  182. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
  183. package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
  184. package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
  185. package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
  186. package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
  187. package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
  188. package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
  189. package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
  190. package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
  191. package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
  192. package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
  193. package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
  194. package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
  195. package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
  196. package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
  197. package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
  198. package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
  199. package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
  200. package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
  201. package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
  202. package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
  203. package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
  204. package/external/libedhoc/include/edhoc.h +348 -54
  205. package/external/libedhoc/include/edhoc_common.h +289 -0
  206. package/external/libedhoc/include/edhoc_context.h +60 -35
  207. package/external/libedhoc/include/edhoc_credentials.h +55 -7
  208. package/external/libedhoc/include/edhoc_crypto.h +10 -10
  209. package/external/libedhoc/include/edhoc_ead.h +13 -10
  210. package/external/libedhoc/include/edhoc_macros.h +20 -11
  211. package/external/libedhoc/include/edhoc_values.h +2 -2
  212. package/external/libedhoc/library/edhoc.c +70 -36
  213. package/external/libedhoc/library/edhoc_common.c +1314 -0
  214. package/external/libedhoc/library/edhoc_exporter.c +45 -46
  215. package/external/libedhoc/library/edhoc_message_1.c +107 -72
  216. package/external/libedhoc/library/edhoc_message_2.c +396 -1693
  217. package/external/libedhoc/library/edhoc_message_3.c +465 -1656
  218. package/external/libedhoc/library/edhoc_message_4.c +93 -91
  219. package/external/libedhoc/library/edhoc_message_error.c +41 -41
  220. package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
  221. package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
  222. package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
  223. package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
  224. 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
  225. 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
  226. 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
  227. 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
  228. package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
  229. package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
  230. package/external/libedhoc/tests/src/module_test_api.c +430 -0
  231. package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
  232. package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
  233. package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
  234. package/external/libedhoc/tests/src/module_test_main.c +49 -0
  235. package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
  236. package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
  237. package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
  238. package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
  239. package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
  240. package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
  241. package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
  242. package/include/EdhocComposeAsyncWorker.h +8 -6
  243. package/include/EdhocCredentialManager.h +16 -11
  244. package/include/EdhocCryptoManager.h +28 -21
  245. package/include/EdhocEadManager.h +3 -6
  246. package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
  247. package/include/EdhocKeyExporterAsyncWorker.h +76 -0
  248. package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
  249. package/include/EdhocProcessAsyncWorker.h +14 -10
  250. package/include/LibEDHOC.h +44 -20
  251. package/include/UserContext.h +7 -9
  252. package/include/Utils.h +31 -27
  253. package/package.json +14 -3
  254. package/prebuilds/android-arm/edhoc.armv7.node +0 -0
  255. package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
  256. package/prebuilds/darwin-arm64/edhoc.node +0 -0
  257. package/prebuilds/darwin-x64/edhoc.node +0 -0
  258. package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
  259. package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
  260. package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
  261. package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
  262. package/prebuilds/linux-x64/edhoc.musl.node +0 -0
  263. package/prebuilds/win32-ia32/edhoc.node +0 -0
  264. package/prebuilds/win32-x64/edhoc.node +0 -0
  265. package/src/EdhocComposeAsyncWorker.cpp +18 -35
  266. package/src/EdhocCredentialManager.cpp +160 -187
  267. package/src/EdhocCryptoManager.cpp +386 -586
  268. package/src/EdhocEadManager.cpp +10 -18
  269. package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
  270. package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
  271. package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
  272. package/src/EdhocProcessAsyncWorker.cpp +72 -19
  273. package/src/LibEDHOC.cpp +213 -174
  274. package/src/Suites.cpp +39 -72
  275. package/src/Utils.cpp +32 -56
  276. package/test/basic.test.ts +64 -0
  277. package/test/vectors.test.ts +111 -0
  278. package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
  279. package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
  280. package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
  281. package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
  282. package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
  283. package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
  284. package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
  285. package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
  286. package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
  287. package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
  288. package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
  289. package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
  290. package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
  291. package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
  292. package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
  293. package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
  294. package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
  295. package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
  296. package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
  297. package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
  298. package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
  299. package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
  300. package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
  301. package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
  302. package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
  303. package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
  304. package/external/libedhoc/tests/src/tests.c +0 -228
  305. package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
  306. package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
  307. package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
  308. package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
  309. package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
  310. package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
  311. package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
  312. package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
  313. package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
  314. package/src/EdhocExportAsyncWorker.cpp +0 -82
@@ -0,0 +1,21 @@
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 CMOCK_H
9
+ #define CMOCK_H
10
+
11
+ int CMockMemFreeFinalCounter = 0;
12
+ int mockMock_Init_Counter = 0;
13
+ int mockMock_Verify_Counter = 0;
14
+ int mockMock_Destroy_Counter = 0;
15
+
16
+ void CMock_Guts_MemFreeFinal(void) { CMockMemFreeFinalCounter++; }
17
+ void mockMock_Init(void) { mockMock_Init_Counter++; }
18
+ void mockMock_Verify(void) { mockMock_Verify_Counter++; }
19
+ void mockMock_Destroy(void) { mockMock_Destroy_Counter++; }
20
+
21
+ #endif
@@ -0,0 +1,20 @@
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 MOCK_MOCK_H
9
+ #define MOCK_MOCK_H
10
+
11
+ extern int mockMock_Init_Counter;
12
+ extern int mockMock_Verify_Counter;
13
+ extern int mockMock_Destroy_Counter;
14
+ extern int CMockMemFreeFinalCounter;
15
+
16
+ void mockMock_Init(void);
17
+ void mockMock_Verify(void);
18
+ void mockMock_Destroy(void);
19
+
20
+ #endif
@@ -0,0 +1,204 @@
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
+ /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
9
+
10
+ #include <stdio.h>
11
+ #include "unity.h"
12
+ #include "Defs.h"
13
+
14
+ #ifdef USE_CEXCEPTION
15
+ #include "CException.h"
16
+ #endif
17
+
18
+ /* Notes about prefixes:
19
+ test - normal default prefix. these are "always run" tests for this procedure
20
+ spec - normal default prefix. required to run default setup/teardown calls.
21
+ should - normal default prefix.
22
+ qwiktest - custom prefix for when tests skip all setup/teardown calls.
23
+ custtest - custom prefix for when tests use custom setup/teardown calls.
24
+ paratest - custom prefix for when we want to verify parameterized tests.
25
+ extest - custom prefix only used during cexception
26
+ suitetest- custom prefix for when we want to use custom suite setup/teardown
27
+ */
28
+
29
+ /* Include Passthroughs for Linking Tests */
30
+ void putcharSpy(int c) { (void)putchar(c);}
31
+ void flushSpy(void) {}
32
+
33
+ /* Global Variables Used During These Tests */
34
+ int CounterSetup = 0;
35
+ int CounterTeardown = 0;
36
+ int CounterSuiteSetup = 0;
37
+
38
+ void setUp(void)
39
+ {
40
+ CounterSetup = 1;
41
+ }
42
+
43
+ void tearDown(void)
44
+ {
45
+ CounterTeardown = 1;
46
+ }
47
+
48
+ void custom_setup(void)
49
+ {
50
+ CounterSetup = 2;
51
+ }
52
+
53
+ void custom_teardown(void)
54
+ {
55
+ CounterTeardown = 2;
56
+ }
57
+
58
+ /*
59
+ void test_OldSchoolCommentsShouldBeIgnored(void)
60
+ {
61
+ TEST_ASSERT_FAIL("Old-School Comments Should Be Ignored");
62
+ }
63
+ */
64
+
65
+ void test_ThisTestAlwaysPasses(void)
66
+ {
67
+ TEST_PASS();
68
+ }
69
+
70
+ void test_ThisTestAlwaysFails(void)
71
+ {
72
+ TEST_FAIL_MESSAGE("This Test Should Fail");
73
+ }
74
+
75
+ void test_ThisTestAlwaysIgnored(void)
76
+ {
77
+ TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
78
+ }
79
+
80
+ void qwiktest_ThisTestPassesWhenNoSetupRan(void)
81
+ {
82
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterSetup, "Setup Was Unexpectedly Run");
83
+ }
84
+
85
+ void qwiktest_ThisTestPassesWhenNoTeardownRan(void)
86
+ {
87
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterTeardown, "Teardown Was Unexpectedly Run");
88
+ }
89
+
90
+ void spec_ThisTestPassesWhenNormalSuiteSetupAndTeardownRan(void)
91
+ {
92
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterSuiteSetup, "Suite Setup Was Unexpectedly Run");
93
+ }
94
+
95
+ void spec_ThisTestPassesWhenNormalSetupRan(void)
96
+ {
97
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
98
+ }
99
+
100
+ void spec_ThisTestPassesWhenNormalTeardownRan(void)
101
+ {
102
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
103
+ }
104
+
105
+ void custtest_ThisTestPassesWhenCustomSetupRan(void)
106
+ {
107
+ TEST_ASSERT_EQUAL_MESSAGE(2, CounterSetup, "Custom Setup Wasn't Run");
108
+ }
109
+
110
+ void custtest_ThisTestPassesWhenCustomTeardownRan(void)
111
+ {
112
+ TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run");
113
+ }
114
+
115
+ #ifndef UNITY_EXCLUDE_TESTING_NEW_COMMENTS
116
+ //void test_NewStyleCommentsShouldBeIgnored(void)
117
+ //{
118
+ // TEST_ASSERT_FAIL("New Style Comments Should Be Ignored");
119
+ //}
120
+ #endif
121
+
122
+ void test_NotBeConfusedByLongComplicatedStrings(void)
123
+ {
124
+ const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
125
+
126
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same");
127
+ }
128
+
129
+ /* The next test should still appear even though we have this confusing nested comment thing going on http://looks_like_comments.com */
130
+ void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void)
131
+ {
132
+ TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
133
+ /* still should not break anything */
134
+ }
135
+ /* nor should this */
136
+
137
+ void test_StillNotBeConfusedByLongComplicatedStrings(void)
138
+ {
139
+ const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
140
+
141
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are Still The Same");
142
+ }
143
+
144
+ void should_RunTestsStartingWithShouldByDefault(void)
145
+ {
146
+ TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
147
+ }
148
+
149
+ TEST_CASE(25)
150
+ TEST_CASE(125)
151
+ TEST_CASE(5)
152
+ void paratest_ShouldHandleParameterizedTests(int Num)
153
+ {
154
+ TEST_ASSERT_EQUAL_MESSAGE(0, (Num % 5), "All The Values Are Divisible By 5");
155
+ }
156
+
157
+ TEST_CASE(7)
158
+ void paratest_ShouldHandleParameterizedTests2(int Num)
159
+ {
160
+ TEST_ASSERT_EQUAL_MESSAGE(7, Num, "The Only Call To This Passes");
161
+ }
162
+
163
+ void paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid(void)
164
+ {
165
+ TEST_PASS();
166
+ }
167
+
168
+ TEST_CASE(17)
169
+ void paratest_ShouldHandleParameterizedTestsThatFail(int Num)
170
+ {
171
+ TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail");
172
+ }
173
+
174
+ int isArgumentOne(int i)
175
+ {
176
+ return i == 1;
177
+ }
178
+
179
+ TEST_CASE(isArgumentOne)
180
+ void paratest_WorksWithFunctionPointers(int function(int))
181
+ {
182
+ TEST_ASSERT_TRUE_MESSAGE(function(1), "Function should return True");
183
+ }
184
+
185
+ #ifdef USE_CEXCEPTION
186
+ void extest_ShouldHandleCExceptionInTest(void)
187
+ {
188
+ TEST_ASSERT_EQUAL_MESSAGE(1, CEXCEPTION_BEING_USED, "Should be pulling in CException");
189
+ }
190
+ #endif
191
+
192
+ #ifdef USE_ANOTHER_MAIN
193
+ int custom_main(void);
194
+
195
+ int main(void)
196
+ {
197
+ return custom_main();
198
+ }
199
+ #endif
200
+
201
+ void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
202
+ {
203
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run");
204
+ }
@@ -0,0 +1,73 @@
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
+ /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
9
+
10
+ #include <stdio.h>
11
+ #include "unity.h"
12
+ #include "Defs.h"
13
+
14
+ TEST_SOURCE_FILE("some_file.c")
15
+
16
+ /* Notes about prefixes:
17
+ test - normal default prefix. these are "always run" tests for this procedure
18
+ spec - normal default prefix. required to run default setup/teardown calls.
19
+ */
20
+
21
+ /* Include Passthroughs for Linking Tests */
22
+ void putcharSpy(int c) { (void)putchar(c);}
23
+ void flushSpy(void) {}
24
+
25
+ /* Global Variables Used During These Tests */
26
+ int CounterSetup = 0;
27
+ int CounterTeardown = 0;
28
+ int CounterSuiteSetup = 0;
29
+
30
+ void setUp(void)
31
+ {
32
+ CounterSetup = 1;
33
+ }
34
+
35
+ void tearDown(void)
36
+ {
37
+ CounterTeardown = 1;
38
+ }
39
+
40
+ void custom_setup(void)
41
+ {
42
+ CounterSetup = 2;
43
+ }
44
+
45
+ void custom_teardown(void)
46
+ {
47
+ CounterTeardown = 2;
48
+ }
49
+
50
+ void test_ThisTestAlwaysPasses(void)
51
+ {
52
+ TEST_PASS();
53
+ }
54
+
55
+ void test_ThisTestAlwaysFails(void)
56
+ {
57
+ TEST_FAIL_MESSAGE("This Test Should Fail");
58
+ }
59
+
60
+ void test_ThisTestAlwaysIgnored(void)
61
+ {
62
+ TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
63
+ }
64
+
65
+ void spec_ThisTestPassesWhenNormalSetupRan(void)
66
+ {
67
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
68
+ }
69
+
70
+ void spec_ThisTestPassesWhenNormalTeardownRan(void)
71
+ {
72
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
73
+ }
@@ -0,0 +1,200 @@
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
+ /* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
9
+
10
+ #include <stdio.h>
11
+ #include "unity.h"
12
+ #include "Defs.h"
13
+ #include "mockMock.h"
14
+
15
+ #ifdef USE_CEXCEPTION
16
+ #include "CException.h"
17
+ #endif
18
+
19
+ /* Notes about prefixes:
20
+ test - normal default prefix. these are "always run" tests for this procedure
21
+ spec - normal default prefix. required to run default setup/teardown calls.
22
+ should - normal default prefix.
23
+ qwiktest - custom prefix for when tests skip all setup/teardown calls.
24
+ custtest - custom prefix for when tests use custom setup/teardown calls.
25
+ paratest - custom prefix for when we want to verify parameterized tests.
26
+ extest - custom prefix only used during cexception
27
+ suitetest- custom prefix for when we want to use custom suite setup/teardown
28
+ */
29
+
30
+ /* Include Passthroughs for Linking Tests */
31
+ void putcharSpy(int c) { (void)putchar(c);}
32
+ void flushSpy(void) {}
33
+
34
+ /* Global Variables Used During These Tests */
35
+ int CounterSetup = 0;
36
+ int CounterTeardown = 0;
37
+ int CounterSuiteSetup = 0;
38
+
39
+ void setUp(void)
40
+ {
41
+ CounterSetup = 1;
42
+ }
43
+
44
+ void tearDown(void)
45
+ {
46
+ CounterTeardown = 1;
47
+ }
48
+
49
+ void custom_setup(void)
50
+ {
51
+ CounterSetup = 2;
52
+ }
53
+
54
+ void custom_teardown(void)
55
+ {
56
+ CounterTeardown = 2;
57
+ }
58
+
59
+ /*
60
+ void test_OldSchoolCommentsShouldBeIgnored(void)
61
+ {
62
+ TEST_ASSERT_FAIL("Old-School Comments Should Be Ignored");
63
+ }
64
+ */
65
+
66
+ void test_ThisTestAlwaysPasses(void)
67
+ {
68
+ TEST_PASS();
69
+ }
70
+
71
+ void test_ThisTestAlwaysFails(void)
72
+ {
73
+ TEST_FAIL_MESSAGE("This Test Should Fail");
74
+ }
75
+
76
+ void test_ThisTestAlwaysIgnored(void)
77
+ {
78
+ TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
79
+ }
80
+
81
+ void qwiktest_ThisTestPassesWhenNoSetupRan(void)
82
+ {
83
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterSetup, "Setup Was Unexpectedly Run");
84
+ }
85
+
86
+ void qwiktest_ThisTestPassesWhenNoTeardownRan(void)
87
+ {
88
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterTeardown, "Teardown Was Unexpectedly Run");
89
+ }
90
+
91
+ void spec_ThisTestPassesWhenNormalSuiteSetupAndTeardownRan(void)
92
+ {
93
+ TEST_ASSERT_EQUAL_MESSAGE(0, CounterSuiteSetup, "Suite Setup Was Unexpectedly Run");
94
+ }
95
+
96
+ void spec_ThisTestPassesWhenNormalSetupRan(void)
97
+ {
98
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
99
+ }
100
+
101
+ void spec_ThisTestPassesWhenNormalTeardownRan(void)
102
+ {
103
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
104
+ }
105
+
106
+ void custtest_ThisTestPassesWhenCustomSetupRan(void)
107
+ {
108
+ TEST_ASSERT_EQUAL_MESSAGE(2, CounterSetup, "Custom Setup Wasn't Run");
109
+ }
110
+
111
+ void custtest_ThisTestPassesWhenCustomTeardownRan(void)
112
+ {
113
+ TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run");
114
+ }
115
+
116
+ #ifndef UNITY_EXCLUDE_TESTING_NEW_COMMENTS
117
+ //void test_NewStyleCommentsShouldBeIgnored(void)
118
+ //{
119
+ // TEST_ASSERT_FAIL("New Style Comments Should Be Ignored");
120
+ //}
121
+ #endif
122
+
123
+ void test_NotBeConfusedByLongComplicatedStrings(void)
124
+ {
125
+ const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
126
+
127
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same");
128
+ }
129
+
130
+ void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void)
131
+ {
132
+ TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
133
+ }
134
+
135
+ void test_StillNotBeConfusedByLongComplicatedStrings(void)
136
+ {
137
+ const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
138
+
139
+ TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are Still The Same");
140
+ }
141
+
142
+ void should_RunTestsStartingWithShouldByDefault(void)
143
+ {
144
+ TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
145
+ }
146
+
147
+ TEST_CASE(25)
148
+ TEST_CASE(125)
149
+ TEST_CASE(5)
150
+ void paratest_ShouldHandleParameterizedTests(int Num)
151
+ {
152
+ TEST_ASSERT_EQUAL_MESSAGE(0, (Num % 5), "All The Values Are Divisible By 5");
153
+ }
154
+
155
+ TEST_CASE(7)
156
+ void paratest_ShouldHandleParameterizedTests2(int Num)
157
+ {
158
+ TEST_ASSERT_EQUAL_MESSAGE(7, Num, "The Only Call To This Passes");
159
+ }
160
+
161
+ void paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid(void)
162
+ {
163
+ TEST_PASS();
164
+ }
165
+
166
+ TEST_CASE(17)
167
+ void paratest_ShouldHandleParameterizedTestsThatFail(int Num)
168
+ {
169
+ TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail");
170
+ }
171
+
172
+ #ifdef USE_CEXCEPTION
173
+ void extest_ShouldHandleCExceptionInTest(void)
174
+ {
175
+ TEST_ASSERT_EQUAL_MESSAGE(1, CEXCEPTION_BEING_USED, "Should be pulling in CException");
176
+ }
177
+ #endif
178
+
179
+ #ifdef USE_ANOTHER_MAIN
180
+ int custom_main(void);
181
+
182
+ int main(void)
183
+ {
184
+ return custom_main();
185
+ }
186
+ #endif
187
+
188
+ void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
189
+ {
190
+ TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run");
191
+ }
192
+
193
+ void test_ShouldCallMockInitAndVerifyFunctionsForEachTest(void)
194
+ {
195
+ int passesOrIgnores = (int)(Unity.NumberOfTests - Unity.TestFailures);
196
+ TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests, mockMock_Init_Counter, "Mock Init Should Be Called Once Per Test Started");
197
+ TEST_ASSERT_EQUAL_MESSAGE(passesOrIgnores, mockMock_Verify_Counter, "Mock Verify Should Be Called Once Per Test Passed");
198
+ TEST_ASSERT_EQUAL_MESSAGE(Unity.NumberOfTests - 1, mockMock_Destroy_Counter, "Mock Destroy Should Be Called Once Per Test Completed");
199
+ TEST_ASSERT_EQUAL_MESSAGE(0, CMockMemFreeFinalCounter, "Mock MemFreeFinal Should Not Be Called Until End");
200
+ }
@@ -0,0 +1,151 @@
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
+ #ifdef TEST_INSTANCES
9
+
10
+ #include <string.h>
11
+ #include <stdint.h>
12
+
13
+ /* Dividing by these constants produces +/- infinity.
14
+ * The rationale is given in UnityAssertFloatIsInf's body.
15
+ */
16
+ #ifndef UNITY_EXCLUDE_FLOAT
17
+ static const UNITY_FLOAT f_zero = 0.0f;
18
+ #endif
19
+
20
+ #ifndef UNITY_EXCLUDE_DOUBLE
21
+ static const UNITY_DOUBLE d_zero = 0.0;
22
+ #endif
23
+
24
+ /* Macros for Catching An Expected Failure or Ignore */
25
+ #define EXPECT_ABORT_BEGIN \
26
+ startPutcharSpy(); \
27
+ if (TEST_PROTECT()) \
28
+ {
29
+
30
+ #define VERIFY_FAILS_END \
31
+ } \
32
+ endPutcharSpy(); /* start/end Spy to suppress output of failure message */ \
33
+ Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \
34
+ if (Unity.CurrentTestFailed == 1) { \
35
+ SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
36
+ UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
37
+ UNITY_OUTPUT_CHAR(':'); \
38
+ UnityPrint(Unity.CurrentTestName); \
39
+ UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
40
+ UNITY_OUTPUT_CHAR('\n'); \
41
+ }
42
+
43
+ #define VERIFY_IGNORES_END \
44
+ } \
45
+ endPutcharSpy(); /* start/end Spy to suppress output of ignore message */ \
46
+ Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \
47
+ Unity.CurrentTestIgnored = 0; \
48
+ if (Unity.CurrentTestFailed == 1) { \
49
+ SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
50
+ UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
51
+ UNITY_OUTPUT_CHAR(':'); \
52
+ UnityPrint(Unity.CurrentTestName); \
53
+ UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
54
+ UNITY_OUTPUT_CHAR('\n'); \
55
+ }
56
+
57
+ /* Tricky series of macros to set USING_OUTPUT_SPY */
58
+ #define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0)
59
+ #define ASSIGN_VALUE(a) VAL_##a
60
+ #define VAL_putcharSpy 0, 1
61
+ #define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
62
+ #define SECOND_PARAM(a, b, ...) b
63
+ #if USING_SPY_AS(UNITY_OUTPUT_CHAR)
64
+ #define USING_OUTPUT_SPY /* true only if UNITY_OUTPUT_CHAR = putcharSpy */
65
+ #endif
66
+
67
+ #ifdef USING_OUTPUT_SPY
68
+ #include <stdio.h>
69
+ #define SPY_BUFFER_MAX 40
70
+ static char putcharSpyBuffer[SPY_BUFFER_MAX];
71
+ #endif
72
+ static UNITY_COUNTER_TYPE indexSpyBuffer;
73
+ static UNITY_COUNTER_TYPE putcharSpyEnabled;
74
+
75
+ void startPutcharSpy(void)
76
+ {
77
+ indexSpyBuffer = 0;
78
+ putcharSpyEnabled = 1;
79
+ }
80
+
81
+ void endPutcharSpy(void)
82
+ {
83
+ putcharSpyEnabled = 0;
84
+ }
85
+
86
+ char* getBufferPutcharSpy(void)
87
+ {
88
+ #ifdef USING_OUTPUT_SPY
89
+ putcharSpyBuffer[indexSpyBuffer] = '\0';
90
+ return putcharSpyBuffer;
91
+ #else
92
+ return NULL;
93
+ #endif
94
+ }
95
+
96
+ void putcharSpy(int c)
97
+ {
98
+ #ifdef USING_OUTPUT_SPY
99
+ if (putcharSpyEnabled)
100
+ {
101
+ if (indexSpyBuffer < SPY_BUFFER_MAX - 1)
102
+ putcharSpyBuffer[indexSpyBuffer++] = (char)c;
103
+ } else
104
+ putchar((char)c);
105
+ #else
106
+ (void)c;
107
+ #endif
108
+ }
109
+
110
+ /* This is for counting the calls to the flushSpy */
111
+ static UNITY_COUNTER_TYPE flushSpyEnabled;
112
+ static UNITY_COUNTER_TYPE flushSpyCalls = 0;
113
+
114
+ void startFlushSpy(void)
115
+ {
116
+ flushSpyCalls = 0;
117
+ flushSpyEnabled = 1;
118
+ }
119
+
120
+ void endFlushSpy(void)
121
+ {
122
+ flushSpyCalls = 0;
123
+ flushSpyEnabled = 0;
124
+ }
125
+
126
+ UNITY_COUNTER_TYPE getFlushSpyCalls(void)
127
+ {
128
+ return flushSpyCalls;
129
+ }
130
+
131
+ void flushSpy(void)
132
+ {
133
+ if (flushSpyEnabled){ flushSpyCalls++; }
134
+ }
135
+
136
+ #define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \
137
+ startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
138
+ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
139
+ }
140
+
141
+ #define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \
142
+ startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \
143
+ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
144
+ }
145
+
146
+ #define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \
147
+ startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
148
+ TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
149
+ }
150
+
151
+ #endif