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
@@ -7,7 +7,7 @@
7
7
  #include <zephyr/ztest.h>
8
8
  #include "manifest3_decode.h"
9
9
  #include "manifest3_encode.h"
10
- #include "zcbor_debug.h" // Enables use of print functions when debugging tests.
10
+ #include "zcbor_print.h"
11
11
 
12
12
  /* draft-ietf-suit-manifest-02 Example 0 */
13
13
  uint8_t test_vector0_02[] = {
@@ -244,7 +244,7 @@ void test_command_sequence(struct zcbor_string *sequence_str,
244
244
  return;
245
245
  }
246
246
 
247
- zcbor_print("\r\ntest %s\r\n", name);
247
+ zcbor_log("\r\ntest %s\r\n", name);
248
248
 
249
249
  memset(&sequence1, 0, sizeof(sequence1));
250
250
  int res = cbor_decode_SUIT_Command_Sequence(sequence_str->value,
@@ -263,48 +263,48 @@ void test_command_sequence(struct zcbor_string *sequence_str,
263
263
  sequence_str->len,
264
264
  NULL);
265
265
 
266
- for (uint32_t i = 0; i < sequence1._SUIT_Command_Sequence_union_count; i++) {
267
- struct SUIT_Directive_ *directive;
266
+ for (uint32_t i = 0; i < sequence1.SUIT_Command_Sequence_union_count; i++) {
267
+ struct SUIT_Directive_r *directive;
268
268
  bool directive_present;
269
269
  directive = &sequence1
270
- ._SUIT_Command_Sequence_union[i]
271
- ._SUIT_Command_Sequence_union__SUIT_Directive;
270
+ .SUIT_Command_Sequence_union[i]
271
+ .SUIT_Command_Sequence_union_SUIT_Directive_m;
272
272
  directive_present = sequence1
273
- ._SUIT_Command_Sequence_union[i]
274
- ._SUIT_Command_Sequence_union_choice
275
- == _SUIT_Command_Sequence_union__SUIT_Directive;
273
+ .SUIT_Command_Sequence_union[i]
274
+ .SUIT_Command_Sequence_union_choice
275
+ == SUIT_Command_Sequence_union_SUIT_Directive_m_c;
276
276
 
277
277
  run_seq = &directive
278
- ->_SUIT_Directive___suit_directive_run_sequence_SUIT_Command_Sequence_bstr;
278
+ ->SUIT_Directive_suit_directive_run_sequence_m_l_SUIT_Command_Sequence_bstr;
279
279
  run_seq_present = directive_present
280
280
  && directive
281
- ->_SUIT_Directive_choice
282
- == _SUIT_Directive___suit_directive_run_sequence;
281
+ ->SUIT_Directive_choice
282
+ == SUIT_Directive_suit_directive_run_sequence_m_l_c;
283
283
  test_command_sequence(run_seq, run_seq_present, "run_seq");
284
284
 
285
285
  for (uint32_t j = 0; j < directive
286
- ->_SUIT_Directive___suit_directive_try_each__SUIT_Directive_Try_Each_Argument
287
- ._SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr_count; j++) {
286
+ ->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
287
+ .SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr_count; j++) {
288
288
 
289
289
  try_each1 = &directive
290
- ->_SUIT_Directive___suit_directive_try_each__SUIT_Directive_Try_Each_Argument
291
- ._SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr[j];
290
+ ->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
291
+ .SUIT_Directive_Try_Each_Argument_SUIT_Command_Sequence_bstr[j];
292
292
  try_each1_present = directive_present
293
- && directive->_SUIT_Directive_choice
294
- == _SUIT_Directive___suit_directive_try_each;
293
+ && directive->SUIT_Directive_choice
294
+ == SUIT_Directive_suit_directive_try_each_m_l_c;
295
295
  test_command_sequence(try_each1, try_each1_present, "try_each1");
296
296
  }
297
297
 
298
298
  try_each2 = &directive
299
- ->_SUIT_Directive___suit_directive_try_each__SUIT_Directive_Try_Each_Argument
300
- ._SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr;
299
+ ->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
300
+ .SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr;
301
301
  try_each2_present = directive_present
302
- && directive->_SUIT_Directive_choice
303
- == _SUIT_Directive___suit_directive_try_each
302
+ && directive->SUIT_Directive_choice
303
+ == SUIT_Directive_suit_directive_try_each_m_l_c
304
304
  && directive
305
- ->_SUIT_Directive___suit_directive_try_each__SUIT_Directive_Try_Each_Argument
306
- ._SUIT_Directive_Try_Each_Argument_union_choice
307
- == _SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr;
305
+ ->SUIT_Directive_suit_directive_try_each_m_l_SUIT_Directive_Try_Each_Argument_m
306
+ .SUIT_Directive_Try_Each_Argument_union_choice
307
+ == SUIT_Directive_Try_Each_Argument_union_SUIT_Command_Sequence_bstr_c;
308
308
  test_command_sequence(try_each2, try_each2_present, "try_each2");
309
309
 
310
310
  }
@@ -338,102 +338,102 @@ void test_manifest(const uint8_t *input, uint32_t len)
338
338
  int res;
339
339
  size_t out_len;
340
340
 
341
- zcbor_print("test_vector at: 0x%zx\r\n", (size_t)input);
342
- zcbor_print("test_vector end at: 0x%zx\r\n",
341
+ zcbor_log("test_vector at: 0x%zx\r\n", (size_t)input);
342
+ zcbor_log("test_vector end at: 0x%zx\r\n",
343
343
  ((size_t)input) + len);
344
344
  res = cbor_decode_SUIT_Outer_Wrapper(input, len, &outerwrapper1, NULL);
345
345
  zassert_equal(ZCBOR_SUCCESS, res, "top-level decoding failed.");
346
346
 
347
347
  dependency1 = &outerwrapper1
348
- ._SUIT_Outer_Wrapper_suit_dependency_resolution
349
- ._SUIT_Outer_Wrapper_suit_dependency_resolution;
348
+ .SUIT_Outer_Wrapper_suit_dependency_resolution
349
+ .SUIT_Outer_Wrapper_suit_dependency_resolution;
350
350
  dependency1_present = outerwrapper1
351
- ._SUIT_Outer_Wrapper_suit_dependency_resolution_present;
351
+ .SUIT_Outer_Wrapper_suit_dependency_resolution_present;
352
352
  test_command_sequence(dependency1, dependency1_present, "dependency1");
353
353
 
354
354
  fetch1 = &outerwrapper1
355
- ._SUIT_Outer_Wrapper_suit_payload_fetch
356
- ._SUIT_Outer_Wrapper_suit_payload_fetch;
355
+ .SUIT_Outer_Wrapper_suit_payload_fetch
356
+ .SUIT_Outer_Wrapper_suit_payload_fetch;
357
357
  fetch1_present = outerwrapper1
358
- ._SUIT_Outer_Wrapper_suit_payload_fetch_present;
358
+ .SUIT_Outer_Wrapper_suit_payload_fetch_present;
359
359
  test_command_sequence(fetch1, fetch1_present, "fetch1");
360
360
 
361
361
  install1 = &outerwrapper1
362
- ._SUIT_Outer_Wrapper_suit_install
363
- ._SUIT_Outer_Wrapper_suit_install;
362
+ .SUIT_Outer_Wrapper_suit_install
363
+ .SUIT_Outer_Wrapper_suit_install;
364
364
  install1_present = outerwrapper1
365
- ._SUIT_Outer_Wrapper_suit_install_present;
365
+ .SUIT_Outer_Wrapper_suit_install_present;
366
366
  test_command_sequence(install1, install1_present, "install1");
367
367
 
368
368
  manifest = &outerwrapper1
369
- ._SUIT_Outer_Wrapper__SUIT_Manifest_Wrapped
370
- ._SUIT_Manifest_Wrapped_suit_manifest_cbor;
369
+ .SUIT_Outer_Wrapper_SUIT_Manifest_Wrapped_m
370
+ .SUIT_Manifest_Wrapped_suit_manifest_cbor;
371
371
 
372
372
  common_seq = &manifest
373
- ->_SUIT_Manifest_suit_common
374
- ._SUIT_Manifest_suit_common_cbor
375
- ._SUIT_Common_suit_common_sequence
376
- ._SUIT_Common_suit_common_sequence;
373
+ ->SUIT_Manifest_suit_common
374
+ .SUIT_Manifest_suit_common_cbor
375
+ .SUIT_Common_suit_common_sequence
376
+ .SUIT_Common_suit_common_sequence;
377
377
  common_seq_present = manifest
378
- ->_SUIT_Manifest_suit_common_present
378
+ ->SUIT_Manifest_suit_common_present
379
379
  && manifest
380
- ->_SUIT_Manifest_suit_common
381
- ._SUIT_Manifest_suit_common_cbor
382
- ._SUIT_Common_suit_common_sequence_present;
380
+ ->SUIT_Manifest_suit_common
381
+ .SUIT_Manifest_suit_common_cbor
382
+ .SUIT_Common_suit_common_sequence_present;
383
383
  test_command_sequence(common_seq, common_seq_present, "common_seq");
384
384
 
385
385
  dependency2 = &manifest
386
- ->_SUIT_Manifest_suit_dependency_resolution
387
- ._SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr;
386
+ ->SUIT_Manifest_suit_dependency_resolution
387
+ .SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr;
388
388
  dependency2_present = manifest
389
- ->_SUIT_Manifest_suit_dependency_resolution_present
389
+ ->SUIT_Manifest_suit_dependency_resolution_present
390
390
  && manifest
391
- ->_SUIT_Manifest_suit_dependency_resolution
392
- ._SUIT_Manifest_suit_dependency_resolution_choice ==
393
- _SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr;
391
+ ->SUIT_Manifest_suit_dependency_resolution
392
+ .SUIT_Manifest_suit_dependency_resolution_choice ==
393
+ SUIT_Manifest_suit_dependency_resolution_SUIT_Command_Sequence_bstr_c;
394
394
  test_command_sequence(dependency2, dependency2_present, "dependency2");
395
395
 
396
396
  fetch2 = &manifest
397
- ->_SUIT_Manifest_suit_payload_fetch
398
- ._SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr;
397
+ ->SUIT_Manifest_suit_payload_fetch
398
+ .SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr;
399
399
  fetch2_present = manifest
400
- ->_SUIT_Manifest_suit_payload_fetch_present
400
+ ->SUIT_Manifest_suit_payload_fetch_present
401
401
  && manifest
402
- ->_SUIT_Manifest_suit_payload_fetch
403
- ._SUIT_Manifest_suit_payload_fetch_choice ==
404
- _SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr;
402
+ ->SUIT_Manifest_suit_payload_fetch
403
+ .SUIT_Manifest_suit_payload_fetch_choice ==
404
+ SUIT_Manifest_suit_payload_fetch_SUIT_Command_Sequence_bstr_c;
405
405
  test_command_sequence(fetch2, fetch2_present, "fetch2");
406
406
 
407
407
  install2 = &manifest
408
- ->_SUIT_Manifest_suit_install
409
- ._SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr;
408
+ ->SUIT_Manifest_suit_install
409
+ .SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr;
410
410
  install2_present = manifest
411
- ->_SUIT_Manifest_suit_install_present
411
+ ->SUIT_Manifest_suit_install_present
412
412
  && manifest
413
- ->_SUIT_Manifest_suit_install
414
- ._SUIT_Manifest_suit_install_choice ==
415
- _SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr;
413
+ ->SUIT_Manifest_suit_install
414
+ .SUIT_Manifest_suit_install_choice ==
415
+ SUIT_Manifest_suit_install_SUIT_Command_Sequence_bstr_c;
416
416
  test_command_sequence(install2, install2_present, "install2");
417
417
 
418
418
  validate = &manifest
419
- ->_SUIT_Manifest_suit_validate
420
- ._SUIT_Manifest_suit_validate;
419
+ ->SUIT_Manifest_suit_validate
420
+ .SUIT_Manifest_suit_validate;
421
421
  validate_present = manifest
422
- ->_SUIT_Manifest_suit_validate_present;
422
+ ->SUIT_Manifest_suit_validate_present;
423
423
  test_command_sequence(validate, validate_present, "validate");
424
424
 
425
425
  load = &manifest
426
- ->_SUIT_Manifest_suit_load
427
- ._SUIT_Manifest_suit_load;
426
+ ->SUIT_Manifest_suit_load
427
+ .SUIT_Manifest_suit_load;
428
428
  load_present = manifest
429
- ->_SUIT_Manifest_suit_load_present;
429
+ ->SUIT_Manifest_suit_load_present;
430
430
  test_command_sequence(load, load_present, "load");
431
431
 
432
432
  run = &manifest
433
- ->_SUIT_Manifest_suit_run
434
- ._SUIT_Manifest_suit_run;
433
+ ->SUIT_Manifest_suit_run
434
+ .SUIT_Manifest_suit_run;
435
435
  run_present = manifest
436
- ->_SUIT_Manifest_suit_run_present;
436
+ ->SUIT_Manifest_suit_run_present;
437
437
  test_command_sequence(run, run_present, "run");
438
438
 
439
439
  res = cbor_encode_SUIT_Outer_Wrapper(output,
@@ -7,7 +7,6 @@
7
7
  #include <zephyr/ztest.h>
8
8
  #include <pet_encode.h>
9
9
  #include <zcbor_encode.h>
10
- #include <zcbor_debug.h> // Enables use of print functions when debugging tests.
11
10
 
12
11
 
13
12
  #define CONCAT_BYTE(a,b) a ## b
@@ -41,7 +40,7 @@ ZTEST(cbor_encode_test2, test_pet)
41
40
  .names = {{.value = "foo", .len = 3}, {.value = "bar", .len = 3}},
42
41
  .names_count = 2,
43
42
  .birthday = {.value = (uint8_t[]){1,2,3,4,5,6,7,8}, .len = 8},
44
- .species_choice = _Pet_species_dog
43
+ .species_choice = Pet_species_dog_c
45
44
  };
46
45
  uint8_t exp_output[] = {
47
46
  LIST(3),
@@ -6,7 +6,6 @@
6
6
 
7
7
  #include <zephyr/ztest.h>
8
8
  #include "corner_cases_encode.h"
9
- #include "zcbor_debug.h" // Enables use of print functions when debugging tests.
10
9
 
11
10
  #define CONCAT_BYTE(a,b) a ## b
12
11
 
@@ -87,8 +86,9 @@ ZTEST(cbor_encode_test3, test_numbers)
87
86
  ZTEST(cbor_encode_test3, test_numbers2)
88
87
  {
89
88
  const uint8_t exp_payload_numbers2[] = {
90
- LIST(7),
89
+ LIST(8),
91
90
  0x1A, 0x00, 0x12, 0x34, 0x56, // 0x123456
91
+ 0x3A, 0x7F, 0xFF, 0xFF, 0xFF, // -0x8000_0000
92
92
  0x1B, 0x01, 2, 3, 4, 5, 6, 7, 8, // 0x0102030405060708
93
93
  0x1B, 0x11, 2, 3, 4, 5, 6, 7, 9, // 0x1102030405060709
94
94
  0x00, // 0
@@ -99,6 +99,7 @@ ZTEST(cbor_encode_test3, test_numbers2)
99
99
  };
100
100
  struct Numbers2 numbers2 = {
101
101
  .threebytes = 0x123456,
102
+ .int32 = -0x80000000L,
102
103
  .big_int = 0x0102030405060708,
103
104
  .big_uint = 0x1102030405060709,
104
105
  .big_uint2 = 0,
@@ -122,9 +123,9 @@ ZTEST(cbor_encode_test3, test_tagged_union)
122
123
 
123
124
  uint8_t output[5];
124
125
 
125
- struct TaggedUnion_ input;
126
- input.TaggedUnion_choice = _TaggedUnion_bool;
127
- input._bool = true;
126
+ struct TaggedUnion_r input;
127
+ input.TaggedUnion_choice = TaggedUnion_bool_c;
128
+ input.Bool = true;
128
129
 
129
130
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_TaggedUnion(output,
130
131
  sizeof(output), &input, &encode_len), "%d\r\n");
@@ -132,7 +133,7 @@ ZTEST(cbor_encode_test3, test_tagged_union)
132
133
  zassert_equal(sizeof(exp_payload_tagged_union1), encode_len, NULL);
133
134
  zassert_mem_equal(exp_payload_tagged_union1, output, sizeof(exp_payload_tagged_union1), NULL);
134
135
 
135
- input.TaggedUnion_choice = _TaggedUnion_uint;
136
+ input.TaggedUnion_choice = TaggedUnion_uint_c;
136
137
  input.uint = 0x10;
137
138
 
138
139
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_TaggedUnion(output,
@@ -512,43 +513,43 @@ ZTEST(cbor_encode_test3, test_union)
512
513
  0x03, 0x23, 0x03, 0x23, 0x03, 0x23
513
514
  };
514
515
 
515
- struct Union_ _union1 = {.Union_choice = _Union__Group};
516
- struct Union_ _union2 = {.Union_choice = _Union__MultiGroup, ._MultiGroup.MultiGroup_count = 1};
517
- struct Union_ _union3 = {.Union_choice = _Union__uint3};
518
- struct Union_ _union4 = {.Union_choice = _Union_hello_tstr};
519
- struct Union_ _union5 = {.Union_choice = _Union__MultiGroup, ._MultiGroup.MultiGroup_count = 6};
520
- struct Union_ _union6_inv = {.Union_choice = _Union__MultiGroup, ._MultiGroup.MultiGroup_count = 7};
516
+ struct Union_r union1 = {.Union_choice = Union_Group_m_c};
517
+ struct Union_r union2 = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 1};
518
+ struct Union_r union3 = {.Union_choice = Union_uint3_l_c};
519
+ struct Union_r union4 = {.Union_choice = Union_hello_tstr_c};
520
+ struct Union_r union5 = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 6};
521
+ struct Union_r union6_inv = {.Union_choice = Union_MultiGroup_m_c, .MultiGroup_m.MultiGroup_count = 7};
521
522
 
522
523
  uint8_t output[15];
523
524
  size_t out_len;
524
525
 
525
526
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
526
- &_union1, &out_len), NULL);
527
+ &union1, &out_len), NULL);
527
528
  zassert_equal(sizeof(exp_payload_union1), out_len, NULL);
528
529
  zassert_mem_equal(exp_payload_union1, output, sizeof(exp_payload_union1), NULL);
529
530
 
530
531
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
531
- &_union2, &out_len), NULL);
532
+ &union2, &out_len), NULL);
532
533
  zassert_equal(sizeof(exp_payload_union2), out_len, NULL);
533
534
  zassert_mem_equal(exp_payload_union2, output, sizeof(exp_payload_union2), NULL);
534
535
 
535
536
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
536
- &_union3, &out_len), NULL);
537
+ &union3, &out_len), NULL);
537
538
  zassert_equal(sizeof(exp_payload_union3), out_len, NULL);
538
539
  zassert_mem_equal(exp_payload_union3, output, sizeof(exp_payload_union3), NULL);
539
540
 
540
541
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
541
- &_union4, &out_len), NULL);
542
+ &union4, &out_len), NULL);
542
543
  zassert_equal(sizeof(exp_payload_union4), out_len, NULL);
543
544
  zassert_mem_equal(exp_payload_union4, output, sizeof(exp_payload_union4), NULL);
544
545
 
545
546
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_Union(output, sizeof(output),
546
- &_union5, &out_len), NULL);
547
+ &union5, &out_len), NULL);
547
548
  zassert_equal(sizeof(exp_payload_union5), out_len, NULL);
548
549
  zassert_mem_equal(exp_payload_union5, output, sizeof(exp_payload_union5), NULL);
549
550
 
550
551
  zassert_equal(ZCBOR_ERR_ITERATIONS, cbor_encode_Union(output, sizeof(output),
551
- &_union6_inv, &out_len), NULL);
552
+ &union6_inv, &out_len), NULL);
552
553
  }
553
554
 
554
555
  ZTEST(cbor_encode_test3, test_levels)
@@ -572,8 +573,8 @@ ZTEST(cbor_encode_test3, test_levels)
572
573
  uint8_t output[32];
573
574
  size_t out_len;
574
575
 
575
- struct Level2 level1 = {._Level3_count = 2, ._Level3 = {
576
- {._Level4_count = 4}, {._Level4_count = 4}
576
+ struct Level2 level1 = {.Level3_m_count = 2, .Level3_m = {
577
+ {.Level4_m_count = 4}, {.Level4_m_count = 4}
577
578
  }};
578
579
  _Static_assert(sizeof(exp_payload_levels1) <= sizeof(output),
579
580
  "Payload is larger than output");
@@ -613,7 +614,7 @@ ZTEST(cbor_encode_test3, test_map)
613
614
  };
614
615
 
615
616
  struct Map map1 = {
616
- .union_choice = _union_uint7uint,
617
+ .union_choice = union_uint7uint_c,
617
618
  .uint7uint = 1,
618
619
  .twotothree_count = 2,
619
620
  .twotothree = {
@@ -623,7 +624,7 @@ ZTEST(cbor_encode_test3, test_map)
623
624
  };
624
625
  struct Map map2 = {
625
626
  .listkey = true,
626
- .union_choice = _union_uint7uint,
627
+ .union_choice = union_uint7uint_c,
627
628
  .uint7uint = 1,
628
629
  .twotothree_count = 3,
629
630
  .twotothree = {
@@ -633,7 +634,7 @@ ZTEST(cbor_encode_test3, test_map)
633
634
  }
634
635
  };
635
636
  struct Map map3 = {
636
- .union_choice = _union_nintuint,
637
+ .union_choice = union_nintuint_c,
637
638
  .nintuint = 1,
638
639
  .twotothree_count = 2,
639
640
  .twotothree = {
@@ -740,31 +741,31 @@ ZTEST(cbor_encode_test3, test_nested_map_list_map)
740
741
  const uint8_t exp_payload_nested_mlm4[] = {MAP(2), LIST(0), END LIST(0), END LIST(0), END LIST(0), END END};
741
742
  const uint8_t exp_payload_nested_mlm5[] = {MAP(3), LIST(0), END LIST(0), END LIST(0), END LIST(0), END LIST(0), END LIST(2), MAP(0), END MAP(0), END END END};
742
743
  struct NestedMapListMap maplistmap1 = {
743
- ._map_count = 1,
744
- ._map = {{0}}
744
+ .map_l_count = 1,
745
+ .map_l = {{0}}
745
746
  };
746
747
  struct NestedMapListMap maplistmap2 = {
747
- ._map_count = 1,
748
- ._map = {
748
+ .map_l_count = 1,
749
+ .map_l = {
749
750
  {.map_count = 1}
750
751
  }
751
752
  };
752
753
  struct NestedMapListMap maplistmap3 = {
753
- ._map_count = 1,
754
- ._map = {
754
+ .map_l_count = 1,
755
+ .map_l = {
755
756
  {.map_count = 2}
756
757
  }
757
758
  };
758
759
  struct NestedMapListMap maplistmap4 = {
759
- ._map_count = 2,
760
- ._map = {
760
+ .map_l_count = 2,
761
+ .map_l = {
761
762
  {.map_count = 0},
762
763
  {.map_count = 0},
763
764
  }
764
765
  };
765
766
  struct NestedMapListMap maplistmap5 = {
766
- ._map_count = 3,
767
- ._map = {
767
+ .map_l_count = 3,
768
+ .map_l = {
768
769
  {.map_count = 0},
769
770
  {.map_count = 0},
770
771
  {.map_count = 2},
@@ -1072,12 +1073,12 @@ ZTEST(cbor_encode_test3, test_unabstracted)
1072
1073
  uint8_t exp_payload_unabstracted0[] = {LIST(2), 0x01, 0x03, END};
1073
1074
  uint8_t exp_payload_unabstracted1[] = {LIST(2), 0x02, 0x04, END};
1074
1075
  struct Unabstracted result_unabstracted0 = {
1075
- .unabstractedunion1_choice = _Unabstracted_unabstractedunion1_choice1,
1076
- .unabstractedunion2_choice = _Unabstracted_unabstractedunion2_uint3,
1076
+ .unabstractedunion1_choice = Unabstracted_unabstractedunion1_choice1_c,
1077
+ .unabstractedunion2_choice = Unabstracted_unabstractedunion2_uint3_c,
1077
1078
  };
1078
1079
  struct Unabstracted result_unabstracted1 = {
1079
- .unabstractedunion1_choice = _Unabstracted_unabstractedunion1_choice2,
1080
- .unabstractedunion2_choice = _Unabstracted_unabstractedunion2_choice4,
1080
+ .unabstractedunion1_choice = Unabstracted_unabstractedunion1_choice2_c,
1081
+ .unabstractedunion2_choice = Unabstracted_unabstractedunion2_choice4_c,
1081
1082
  };
1082
1083
  uint8_t output[4];
1083
1084
  size_t out_len;
@@ -1153,14 +1154,14 @@ ZTEST(cbor_encode_test3, test_doublemap)
1153
1154
  .uintmap = {
1154
1155
  {
1155
1156
  .uintmap_key = 1,
1156
- ._MyKeys = {
1157
+ .MyKeys_m = {
1157
1158
  .uint1int_present = true,
1158
1159
  .uint1int = {.uint1int = 1},
1159
1160
  }
1160
1161
  },
1161
1162
  {
1162
1163
  .uintmap_key = 2,
1163
- ._MyKeys = {
1164
+ .MyKeys_m = {
1164
1165
  .uint2int_present = true,
1165
1166
  .uint2int = {.uint2int = 2},
1166
1167
  }
@@ -1351,7 +1352,7 @@ ZTEST(cbor_encode_test3, test_map_length)
1351
1352
  uint8_t output[60];
1352
1353
 
1353
1354
  uint8_t mac[] = {1, 2, 3, 4, 5, 6};
1354
- uint8_t uuid[] = {8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 0};
1355
+ uint8_t uuid_m[] = {8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 0};
1355
1356
 
1356
1357
  input.result = 1;
1357
1358
  input.mac_addr.len = 6;
@@ -1364,23 +1365,23 @@ ZTEST(cbor_encode_test3, test_map_length)
1364
1365
  zassert_mem_equal(exp_map_length_payload1, output, num_encode, NULL);
1365
1366
 
1366
1367
  input.end_device_array_present = true;
1367
- input.end_device_array._uuid_count = 0;
1368
+ input.end_device_array.uuid_m_count = 0;
1368
1369
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_MapLength(output,
1369
1370
  sizeof(output), &input, &num_encode), NULL);
1370
1371
  zassert_equal(sizeof(exp_map_length_payload2), num_encode, "%d != %d\r\n", sizeof(exp_map_length_payload2), num_encode);
1371
1372
  zassert_mem_equal(exp_map_length_payload2, output, num_encode, NULL);
1372
1373
 
1373
- input.end_device_array._uuid_count = 1;
1374
- input.end_device_array._uuid[0].len = 16;
1375
- input.end_device_array._uuid[0].value = uuid;
1374
+ input.end_device_array.uuid_m_count = 1;
1375
+ input.end_device_array.uuid_m[0].len = 16;
1376
+ input.end_device_array.uuid_m[0].value = uuid_m;
1376
1377
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_MapLength(output,
1377
1378
  sizeof(output), &input, &num_encode), NULL);
1378
1379
  zassert_equal(sizeof(exp_map_length_payload3), num_encode, "%d != %d\r\n", sizeof(exp_map_length_payload3), num_encode);
1379
1380
  zassert_mem_equal(exp_map_length_payload3, output, num_encode, NULL);
1380
1381
 
1381
- input.end_device_array._uuid_count = 2;
1382
- input.end_device_array._uuid[1].len = 16;
1383
- input.end_device_array._uuid[1].value = uuid;
1382
+ input.end_device_array.uuid_m_count = 2;
1383
+ input.end_device_array.uuid_m[1].len = 16;
1384
+ input.end_device_array.uuid_m[1].value = uuid_m;
1384
1385
  int err = cbor_encode_MapLength(output,
1385
1386
  sizeof(output), &input, &num_encode);
1386
1387
  zassert_equal(ZCBOR_SUCCESS, err, "%d\r\b", err);
@@ -1392,7 +1393,7 @@ ZTEST(cbor_encode_test3, test_map_length)
1392
1393
  sizeof(output), &input, &num_encode), NULL);
1393
1394
 
1394
1395
  input.mac_addr.len++;
1395
- input.end_device_array._uuid[1].len++;
1396
+ input.end_device_array.uuid_m[1].len++;
1396
1397
  err = cbor_encode_MapLength(output,
1397
1398
  sizeof(output), &input, &num_encode);
1398
1399
  zassert_equal(ZCBOR_ERR_WRONG_RANGE, err, "%d\r\b", err);
@@ -1421,13 +1422,13 @@ ZTEST(cbor_encode_test3, test_union_int)
1421
1422
  size_t num_encode;
1422
1423
  uint8_t output[60];
1423
1424
 
1424
- input.union_choice = _union__uint5;
1425
+ input.union_choice = union_uint5_l_c;
1425
1426
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
1426
1427
  &input, &num_encode), NULL);
1427
1428
  zassert_equal(sizeof(exp_union_int_payload1), num_encode, NULL);
1428
1429
  zassert_mem_equal(exp_union_int_payload1, output, num_encode, NULL);
1429
1430
 
1430
- input.union_choice = _union__uint1000;
1431
+ input.union_choice = union_uint1000_l_c;
1431
1432
  input.bstr.len = 16;
1432
1433
  input.bstr.value = (uint8_t *)&"This is thousand";
1433
1434
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
@@ -1435,17 +1436,17 @@ ZTEST(cbor_encode_test3, test_union_int)
1435
1436
  zassert_equal(sizeof(exp_union_int_payload2), num_encode, NULL);
1436
1437
  zassert_mem_equal(exp_union_int_payload2, output, num_encode, NULL);
1437
1438
 
1438
- input.union_choice = _union__nint;
1439
- input._number.number_choice = _number_int;
1440
- input._number._int = 1;
1439
+ input.union_choice = union_nint_l_c;
1440
+ input.number_m.number_choice = number_int_c;
1441
+ input.number_m.Int = 1;
1441
1442
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
1442
1443
  &input, &num_encode), NULL);
1443
1444
  zassert_equal(sizeof(exp_union_int_payload3), num_encode, NULL);
1444
1445
  zassert_mem_equal(exp_union_int_payload3, output, num_encode, NULL);
1445
1446
 
1446
- input.union_choice = _UnionInt2_union__Structure_One;
1447
- input._Structure_One.some_array.value = (uint8_t *)&"hi";
1448
- input._Structure_One.some_array.len = 2;
1447
+ input.union_choice = UnionInt2_union_Structure_One_m_c;
1448
+ input.Structure_One_m.some_array.value = (uint8_t *)&"hi";
1449
+ input.Structure_One_m.some_array.len = 2;
1449
1450
  zassert_equal(ZCBOR_SUCCESS, cbor_encode_UnionInt2(output, sizeof(output),
1450
1451
  &input, &num_encode), NULL);
1451
1452
  zassert_equal(sizeof(exp_union_int_payload4), num_encode, NULL);
@@ -1524,4 +1525,30 @@ ZTEST(cbor_encode_test3, test_intmax)
1524
1525
  zassert_mem_equal(exp_intmax2_payload2, output, num_encode, NULL);
1525
1526
  }
1526
1527
 
1528
+
1529
+ /* Test that zcbor generates variable names that don't contain unsupported characters. */
1530
+ ZTEST(cbor_encode_test3, test_invalid_identifiers)
1531
+ {
1532
+ uint8_t exp_invalid_identifiers_payload1[] = {
1533
+ LIST(3),
1534
+ 0x64, '1', 'o', 'n', 'e',
1535
+ 0x02, /* Ø */
1536
+ 0x67, '{', '[', 'a', '-', 'z', ']', '}',
1537
+ END
1538
+ };
1539
+ struct InvalidIdentifiers input;
1540
+ size_t num_encode;
1541
+ uint8_t output[100];
1542
+
1543
+ input._1one_tstr_present = true;
1544
+ input.__present = true;
1545
+ input.a_z_tstr_present = true;
1546
+
1547
+ zassert_equal(ZCBOR_SUCCESS, cbor_encode_InvalidIdentifiers(output,
1548
+ sizeof(output), &input, &num_encode), NULL);
1549
+ zassert_equal(sizeof(exp_invalid_identifiers_payload1), num_encode, NULL);
1550
+ zassert_mem_equal(exp_invalid_identifiers_payload1, output, num_encode, NULL);
1551
+ }
1552
+
1553
+
1527
1554
  ZTEST_SUITE(cbor_encode_test3, NULL, NULL, NULL, NULL, NULL);
@@ -6,7 +6,6 @@
6
6
 
7
7
  #include <zephyr/ztest.h>
8
8
  #include "senml_encode.h"
9
- #include "zcbor_debug.h" // Enables use of print functions when debugging tests.
10
9
 
11
10
 
12
11
 
@@ -33,23 +32,23 @@
33
32
  ZTEST(cbor_encode_test4, test_senml)
34
33
  {
35
34
  struct lwm2m_senml input = {
36
- ._lwm2m_senml__record[0] = {
37
- ._record_bn = {._record_bn = {.value = "Foo", .len = 3}},
38
- ._record_bn_present = 1,
39
- ._record_bt = {._record_bt = 42},
40
- ._record_bt_present = 1,
41
- ._record_n = {._record_n = {.value = "Bar", .len = 3}},
42
- ._record_n_present = 1,
43
- ._record_t = {._record_t = 7},
44
- ._record_t_present = 1,
45
- ._record_union = {
46
- ._union_vb = true,
47
- ._record_union_choice = _union_vb,
35
+ .lwm2m_senml_record_m[0] = {
36
+ .record_bn = {.record_bn = {.value = "Foo", .len = 3}},
37
+ .record_bn_present = 1,
38
+ .record_bt = {.record_bt = 42},
39
+ .record_bt_present = 1,
40
+ .record_n = {.record_n = {.value = "Bar", .len = 3}},
41
+ .record_n_present = 1,
42
+ .record_t = {.record_t = 7},
43
+ .record_t_present = 1,
44
+ .record_union = {
45
+ .union_vb = true,
46
+ .record_union_choice = union_vb_c,
48
47
  },
49
- ._record_union_present = 1,
50
- ._record__key_value_pair_count = 0,
48
+ .record_union_present = 1,
49
+ .record_key_value_pair_m_count = 0,
51
50
  },
52
- ._lwm2m_senml__record_count = 1,
51
+ .lwm2m_senml_record_m_count = 1,
53
52
  };
54
53
  uint8_t payload[100];
55
54
  size_t encode_len;
@@ -0,0 +1,12 @@
1
+ #include "everything_decode.h"
2
+ #include "main_entry.h"
3
+
4
+ bool fuzz_one_input(const uint8_t *data, size_t size)
5
+ {
6
+ size_t payload_len_out = 0;
7
+ struct EverythingUnion_r result;
8
+ bool ret = cbor_decode_EverythingUnion(data, size,
9
+ &result,
10
+ &payload_len_out);
11
+ return ret;
12
+ }