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,289 @@
1
+ /**
2
+ * \file edhoc_common.h
3
+ * \author Kamil Kielbasa
4
+ * \brief EDHOC common implementations:
5
+ * - CBOR utilities.
6
+ * - MAC context.
7
+ * - MAC & Signature_or_MAC.
8
+ * \version 0.6
9
+ * \date 2024-08-05
10
+ *
11
+ * \copyright Copyright (c) 2024
12
+ *
13
+ */
14
+
15
+ /* Header guard ------------------------------------------------------------ */
16
+ #ifndef EDHOC_COMMON_H
17
+ #define EDHOC_COMMON_H
18
+
19
+ /* Include files ----------------------------------------------------------- */
20
+
21
+ /* EDHOC header: */
22
+ #include "edhoc_context.h"
23
+ #include "edhoc_ead.h"
24
+ #include "edhoc_credentials.h"
25
+
26
+ /* Standard library headers: */
27
+ #include <stdint.h>
28
+ #include <stddef.h>
29
+ #include <stdbool.h>
30
+
31
+ /* Defines ----------------------------------------------------------------- */
32
+ /* Types and type definitions ---------------------------------------------- */
33
+
34
+ /** \defgroup edhoc-common-structures EDHOC common structures
35
+ * @{
36
+ */
37
+
38
+ /**
39
+ * \brief RFC 9528:
40
+ * - 5.3.2. Responder Composition of Message 2.
41
+ * - context_2.
42
+ * - 5.4.2. Initiator Composition of Message 3.
43
+ * - context_3.
44
+ */
45
+ struct mac_context {
46
+ /** Buffer containing cborised connection identifier. */
47
+ uint8_t *conn_id;
48
+ /** Size of the \p conn_id buffer in bytes. */
49
+ size_t conn_id_len;
50
+
51
+ /** Buffer containing cborised credentials identifier. */
52
+ uint8_t *id_cred;
53
+ /** Size of the \p id_cred buffer in bytes. */
54
+ size_t id_cred_len;
55
+
56
+ /** Is compact encoding possible? */
57
+ bool id_cred_is_comp_enc;
58
+ /** Credentials identifer encoding type. */
59
+ enum edhoc_encode_type id_cred_enc_type;
60
+ /** Buffer containing credentials identifer integer representation. */
61
+ int32_t id_cred_int;
62
+ /** Buffer containing credentials identifer byte string representation. */
63
+ uint8_t id_cred_bstr[CONFIG_LIBEDHOC_MAX_LEN_OF_CRED_KEY_ID + 1];
64
+ /** Size of the \p id_cred_bstr buffer in bytes. */
65
+ size_t id_cred_bstr_len;
66
+
67
+ /** Buffer containing cborised transcript hash. */
68
+ uint8_t *th;
69
+ /** Size of the \p th buffer in bytes. */
70
+ size_t th_len;
71
+
72
+ /** Buffer containing cborised credentials. */
73
+ uint8_t *cred;
74
+ /** Size of the \p cred buffer in bytes. */
75
+ size_t cred_len;
76
+
77
+ /** Is EAD attached? */
78
+ bool is_ead;
79
+ /** Buffer containing cborised EAD. */
80
+ uint8_t *ead;
81
+ /** Size of the \p ead buffer in bytes. */
82
+ size_t ead_len;
83
+
84
+ /** Size of the \p buf buffer in bytes. */
85
+ size_t buf_len;
86
+ /** Flexible array member buffer. */
87
+ uint8_t buf[];
88
+ };
89
+
90
+ /**
91
+ * \brief RFC 9528:
92
+ * - 5.3.2. Responder Composition of Message 2.
93
+ * - PLAINTEXT_2.
94
+ * - 5.4.2. Initiator Composition of Message 3.
95
+ * - PLAINTEXT_3.
96
+ */
97
+ struct plaintext {
98
+ /** Authentication credentials. */
99
+ struct edhoc_auth_creds auth_cred;
100
+
101
+ /** Buffer containing cborised Signature_or_MAC (2/3). */
102
+ const uint8_t *sign_or_mac;
103
+ /** Size of the \p sign_or_mac buffer in bytes. */
104
+ size_t sign_or_mac_len;
105
+
106
+ /** Buffer containing cborised EAD (2/3). */
107
+ const uint8_t *ead;
108
+ /** Size of the \p ead buffer in bytes. */
109
+ size_t ead_len;
110
+ };
111
+
112
+ /**@}*/
113
+
114
+ /* Module interface variables and constants -------------------------------- */
115
+ /* Extern variables and constant declarations ------------------------------ */
116
+ /* Module interface function declarations ---------------------------------- */
117
+
118
+ /** \defgroup edhoc-common-cbor EDHOC common CBOR
119
+ * @{
120
+ */
121
+
122
+ /**
123
+ * \brief CBOR integer memory requirements.
124
+ *
125
+ * \param value Raw integer value.
126
+ *
127
+ * \return Number of bytes.
128
+ */
129
+ size_t edhoc_cbor_int_mem_req(int32_t value);
130
+
131
+ /**
132
+ * \brief CBOR text stream overhead.
133
+ *
134
+ * \param length Length of buffer to CBOR as tstr.
135
+ *
136
+ * \return Number of overhead bytes.
137
+ */
138
+ size_t edhoc_cbor_tstr_oh(size_t length);
139
+
140
+ /**
141
+ * \brief CBOR byte stream overhead.
142
+ *
143
+ * \param length Length of buffer to CBOR as bstr.
144
+ *
145
+ * \return Number of overhead bytes.
146
+ */
147
+ size_t edhoc_cbor_bstr_oh(size_t length);
148
+
149
+ /**
150
+ * \brief CBOR map overhead.
151
+ *
152
+ * \param items Number of items for map.
153
+ *
154
+ * \return Number of overhead bytes.
155
+ */
156
+ size_t edhoc_cbor_map_oh(size_t items);
157
+
158
+ /**
159
+ * \brief CBOR array overhead.
160
+ *
161
+ * \param items Number of items for array.
162
+ *
163
+ * \return Number of overhead bytes.
164
+ */
165
+ size_t edhoc_cbor_array_oh(size_t items);
166
+
167
+ /**@}*/
168
+
169
+ /** \defgroup edhoc-common-mac-context EDHOC common MAC context
170
+ * @{
171
+ */
172
+
173
+ /**
174
+ * \brief Compute required buffer length for MAC 2/3 context.
175
+ *
176
+ * \param[in] edhoc_context EDHOC context.
177
+ * \param[in] credentials Authentication credentials.
178
+ * \param[out] mac_context_length On success, number of bytes that make up MAC context.
179
+ *
180
+ * \return EDHOC_SUCCESS on success, otherwise failure.
181
+ */
182
+ int edhoc_comp_mac_context_length(const struct edhoc_context *edhoc_context,
183
+ const struct edhoc_auth_creds *credentials,
184
+ size_t *mac_context_length);
185
+
186
+ /**
187
+ * \brief Cborise items required by MAC 2/3 context.
188
+ *
189
+ * \param[in] edhoc_context EDHOC context.
190
+ * \param[in] credentials Authentication credentials.
191
+ * \param[out] mac_context On success, generated MAC context.
192
+ *
193
+ * \return EDHOC_SUCCESS on success, otherwise failure.
194
+ */
195
+ int edhoc_comp_mac_context(const struct edhoc_context *edhoc_context,
196
+ const struct edhoc_auth_creds *credentials,
197
+ struct mac_context *mac_context);
198
+
199
+ /**@}*/
200
+
201
+ /** \defgroup edhoc-common-sign-or-mac EDHOC common Signature_or_MAC
202
+ * @{
203
+ */
204
+
205
+ /**
206
+ * \brief Compute required buffer length for MAC 2/3.
207
+ *
208
+ * \param[in] edhoc_context EDHOC context.
209
+ * \param[out] mac_length On success, number of bytes that make up
210
+ * MAC 2/3 length requirements.
211
+ *
212
+ * \return EDHOC_SUCCESS on success, otherwise failure.
213
+ */
214
+ int edhoc_comp_mac_length(const struct edhoc_context *edhoc_context,
215
+ size_t *mac_length);
216
+
217
+ /**
218
+ * \brief Compute MAC 2/3 buffer.
219
+ *
220
+ * \param[in] edhoc_context EDHOC context.
221
+ * \param[in] mac_context MAC context.
222
+ * \param[out] mac Buffer where the generated MAC 2/3 is to be written.
223
+ * \param mac_length Size of the \p mac buffer in bytes.
224
+ *
225
+ * \return EDHOC_SUCCESS on success, otherwise failure.
226
+ */
227
+ int edhoc_comp_mac(const struct edhoc_context *edhoc_context,
228
+ const struct mac_context *mac_context, uint8_t *mac,
229
+ size_t mac_length);
230
+
231
+ /**
232
+ * \brief Compute required buffer length for Signature_or_MAC 2/3.
233
+ *
234
+ * \param[in] edhoc_context EDHOC context.
235
+ * \param[out] sign_or_mac_length On success, number of bytes that make up
236
+ * Signature_or_MAC 2/3 length requirements.
237
+ *
238
+ * \return EDHOC_SUCCESS on success, otherwise failure.
239
+ */
240
+ int edhoc_comp_sign_or_mac_length(const struct edhoc_context *edhoc_context,
241
+ size_t *sign_or_mac_length);
242
+
243
+ /**
244
+ * \brief Compute Signature_or_MAC 2/3 buffer.
245
+ *
246
+ * \param[in] edhoc_context EDHOC context.
247
+ * \param[in] cred Authentication credentials.
248
+ * \param[in] mac_context MAC context.
249
+ * \param[in] mac Buffer containing the MAC 2/3.
250
+ * \param[in] mac_len Size of the \p mac buffer in bytes.
251
+ * \param[out] signature Buffer where the generated
252
+ * Signature_or_MAC 2/3 is to be written.
253
+ * \param signature_size Size of the \p signature buffer in bytes.
254
+ * \param[out] signature_length On success, the number of bytes that make
255
+ * up the Signature_or_MAC 2/3.
256
+ *
257
+ * \return EDHOC_SUCCESS on success, otherwise failure.
258
+ */
259
+ int edhoc_comp_sign_or_mac(const struct edhoc_context *edhoc_context,
260
+ const struct edhoc_auth_creds *cred,
261
+ const struct mac_context *mac_context,
262
+ const uint8_t *mac, size_t mac_len,
263
+ uint8_t *signature, size_t signature_size,
264
+ size_t *signature_length);
265
+
266
+ /**
267
+ * \brief Verify Signature_or_MAC 2/3 buffer.
268
+ *
269
+ * \param[in] edhoc_context EDHOC context.
270
+ * \param[in] mac_context MAC context.
271
+ * \param[in] public_key Buffer containing authentication public key.
272
+ * \param public_key_length Size of the \p public_key buffer in bytes.
273
+ * \param[in] signature Buffer containing Signature_or_MAC 2/3.
274
+ * \param signature_length Size of the \p signature buffer in bytes.
275
+ * \param[in] mac Buffer containing MAC 2/3.
276
+ * \param mac_length Size of the \p mac buffer in bytes.
277
+ *
278
+ * \return EDHOC_SUCCESS on success, otherwise failure.
279
+ */
280
+ int edhoc_verify_sign_or_mac(const struct edhoc_context *edhoc_context,
281
+ const struct mac_context *mac_context,
282
+ const uint8_t *public_key,
283
+ size_t public_key_length, const uint8_t *signature,
284
+ size_t signature_length, const uint8_t *mac,
285
+ size_t mac_length);
286
+
287
+ /**@}*/
288
+
289
+ #endif /* EDHOC_COMMON_H */
@@ -2,8 +2,8 @@
2
2
  * \file edhoc_context.h
3
3
  * \author Kamil Kielbasa
4
4
  * \brief EDHOC context.
5
- * \version 0.4
6
- * \date 2024-01-01
5
+ * \version 0.6
6
+ * \date 2024-08-05
7
7
  *
8
8
  * \copyright Copyright (c) 2024
9
9
  *
@@ -29,39 +29,36 @@
29
29
 
30
30
  /* Defines ----------------------------------------------------------------- */
31
31
 
32
- /* Maximum length in bytes of key identifier used for cryptographics keys. */
33
- #ifndef EDHOC_KID_LEN
34
- #error "Lack of defined key ID length"
32
+ #ifndef CONFIG_LIBEDHOC_ENABLE
33
+ #error "Library has not been enabled."
35
34
  #endif
36
35
 
37
- /* Maximum number of cipher suites available to store in context. */
38
- #ifndef EDHOC_MAX_CSUITES_LEN
39
- #error "Lack of defined cipher suites length"
36
+ #ifndef CONFIG_LIBEDHOC_KEY_ID_LEN
37
+ #error "Lack of defined key identifier length in bytes."
40
38
  #endif
41
39
 
42
- /* Maximum length in bytes of connection identifier encoded as byte string. */
43
- #ifndef EDHOC_MAX_CID_LEN
44
- #error "Lack of defined connection ID length"
40
+ #ifndef CONFIG_LIBEDHOC_MAX_NR_OF_CIPHER_SUITES
41
+ #error "Lack of defined maximum number of cipher suites in chain for negotiation."
45
42
  #endif
46
43
 
47
- /* Maximum length in bytes of ECC point. */
48
- #ifndef EDHOC_MAX_ECC_KEY_LEN
49
- #error "Lack of defined length for ellipic curve point X coordinate"
44
+ #ifndef CONFIG_LIBEDHOC_MAX_LEN_OF_CONN_ID
45
+ #error "Lack of defined maximum length of connection identifier in bytes."
50
46
  #endif
51
47
 
52
- /* Maximum length in bytes of PRK and TH buffer. */
53
- #ifndef EDHOC_MAX_MAC_LEN
54
- #error "Lack of defined hash length"
48
+ #ifndef CONFIG_LIBEDHOC_MAX_LEN_OF_ECC_KEY
49
+ #error "Lack of defined maximum length of ECC (Elliptic Curve Cryptography) key in bytes."
55
50
  #endif
56
51
 
57
- /* Maximum number of EAD tokens available to store in context. */
58
- #ifndef EDHOC_MAX_NR_OF_EAD_TOKENS
59
- #error "Lack of defined external authorization data"
52
+ #ifndef CONFIG_LIBEDHOC_MAX_LEN_OF_MAC
53
+ #error "Lack of defined maximum length of hash in bytes."
60
54
  #endif
61
55
 
62
- /* Maximum number of certifices in COSE X.509 chain. */
63
- #ifndef EDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN
64
- #error "Lack of defined maximum number of certificates in COSE X.509 chain"
56
+ #ifndef CONFIG_LIBEDHOC_MAX_NR_OF_EAD_TOKENS
57
+ #error "Lack of defined maximum number of EAD (External Authorization Data) tokens."
58
+ #endif
59
+
60
+ #ifndef CONFIG_LIBEDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN
61
+ #error "Lack of defined maximum number of certificates in X.509 chain."
65
62
  #endif
66
63
 
67
64
  /* Types and type definitions ---------------------------------------------- */
@@ -70,6 +67,16 @@
70
67
  * @{
71
68
  */
72
69
 
70
+ /**
71
+ * \brief RFC 9528: 2. EDHOC Outline.
72
+ */
73
+ enum edhoc_role {
74
+ /** EDHOC role - initiator. */
75
+ EDHOC_INITIATOR,
76
+ /** EDHOC role - responder. */
77
+ EDHOC_RESPONDER,
78
+ };
79
+
73
80
  /**
74
81
  * \brief RFC 9528: Appendix I. Example Protocol State Machine.
75
82
  */
@@ -125,6 +132,8 @@ enum edhoc_method {
125
132
  EDHOC_METHOD_2 = 2,
126
133
  /** Initiator static DH Key to responder static DH Key. */
127
134
  EDHOC_METHOD_3 = 3,
135
+ /** Sanity check maximum. */
136
+ EDHOC_METHOD_MAX,
128
137
  };
129
138
 
130
139
  /**
@@ -190,7 +199,7 @@ struct edhoc_connection_id {
190
199
  int8_t int_value;
191
200
 
192
201
  /** Connection identifier as cbor byte string buffer. */
193
- uint8_t bstr_value[EDHOC_MAX_CID_LEN + 1];
202
+ uint8_t bstr_value[CONFIG_LIBEDHOC_MAX_LEN_OF_CONN_ID + 1];
194
203
  /** Size of the \p bstr_value buffer in bytes. */
195
204
  size_t bstr_length;
196
205
  };
@@ -230,15 +239,26 @@ struct edhoc_error_info {
230
239
  * \brief EDHOC context.
231
240
  */
232
241
  struct edhoc_context {
233
- /** EDHOC method. */
234
- enum edhoc_method EDHOC_PRIVATE(method);
242
+ /** EDHOC chosen method. */
243
+ enum edhoc_method EDHOC_PRIVATE(chosen_method);
244
+
245
+ /** EDHOC supported methods. */
246
+ enum edhoc_method EDHOC_PRIVATE(method[EDHOC_METHOD_MAX]);
247
+ /** Length of the \p method buffer. */
248
+ size_t EDHOC_PRIVATE(method_len);
235
249
 
236
250
  /** EDHOC cipher suite chosen index. */
237
251
  size_t EDHOC_PRIVATE(chosen_csuite_idx);
238
252
  /** EDHOC cipher suite buffer. */
239
- struct edhoc_cipher_suite EDHOC_PRIVATE(csuite)[EDHOC_MAX_CSUITES_LEN];
253
+ struct edhoc_cipher_suite
254
+ EDHOC_PRIVATE(csuite)[CONFIG_LIBEDHOC_MAX_NR_OF_CIPHER_SUITES];
240
255
  /** Length of the \p csuite buffer. */
241
256
  size_t EDHOC_PRIVATE(csuite_len);
257
+ /** EDHOC peer cipher suite buffer. */
258
+ struct edhoc_cipher_suite EDHOC_PRIVATE(
259
+ peer_csuite)[CONFIG_LIBEDHOC_MAX_NR_OF_CIPHER_SUITES];
260
+ /** Length of the \p peer_csuite buffer. */
261
+ size_t EDHOC_PRIVATE(peer_csuite_len);
242
262
 
243
263
  /** EDHOC connection identifier. */
244
264
  struct edhoc_connection_id EDHOC_PRIVATE(cid);
@@ -246,20 +266,21 @@ struct edhoc_context {
246
266
  struct edhoc_connection_id EDHOC_PRIVATE(peer_cid);
247
267
 
248
268
  /** EDHOC ephemeral Diffie-Hellman public key. */
249
- uint8_t EDHOC_PRIVATE(dh_pub_key)[EDHOC_MAX_ECC_KEY_LEN];
269
+ uint8_t EDHOC_PRIVATE(dh_pub_key)[CONFIG_LIBEDHOC_MAX_LEN_OF_ECC_KEY];
250
270
  /** Size of the \p dh_pub_key buffer in bytes. */
251
271
  size_t EDHOC_PRIVATE(dh_pub_key_len);
252
272
  /** EDHOC ephemeral Diffie-Hellman private key. */
253
- uint8_t EDHOC_PRIVATE(dh_priv_key)[EDHOC_MAX_ECC_KEY_LEN];
273
+ uint8_t EDHOC_PRIVATE(dh_priv_key)[CONFIG_LIBEDHOC_MAX_LEN_OF_ECC_KEY];
254
274
  /** Size of the \p dh_priv_key buffer in bytes. */
255
275
  size_t EDHOC_PRIVATE(dh_priv_key_len);
256
276
 
257
277
  /** EDHOC ephemeral Diffie-Hellman peer public key. */
258
- uint8_t EDHOC_PRIVATE(dh_peer_pub_key)[EDHOC_MAX_ECC_KEY_LEN];
278
+ uint8_t EDHOC_PRIVATE(
279
+ dh_peer_pub_key)[CONFIG_LIBEDHOC_MAX_LEN_OF_ECC_KEY];
259
280
  /** Size of the \p dh_peer_pub_key buffer in bytes. */
260
281
  size_t EDHOC_PRIVATE(dh_peer_pub_key_len);
261
282
  /** EDHOC ephemeral Diffie-Hellman key agreement. */
262
- uint8_t EDHOC_PRIVATE(dh_secret)[EDHOC_MAX_ECC_KEY_LEN];
283
+ uint8_t EDHOC_PRIVATE(dh_secret)[CONFIG_LIBEDHOC_MAX_LEN_OF_ECC_KEY];
263
284
  /** Size of the \p dh_secret buffer in bytes. */
264
285
  size_t EDHOC_PRIVATE(dh_secret_len);
265
286
 
@@ -269,18 +290,22 @@ struct edhoc_context {
269
290
  bool EDHOC_PRIVATE(is_oscore_export_allowed);
270
291
  /** EDHOC context state machine. */
271
292
  enum edhoc_state_machine EDHOC_PRIVATE(status);
293
+ /** Current processing EDHOC message. */
294
+ enum edhoc_message EDHOC_PRIVATE(message);
295
+ /** EDHOC role. */
296
+ enum edhoc_role EDHOC_PRIVATE(role);
272
297
 
273
298
  /** EDHOC context transcript hash state. */
274
299
  enum edhoc_th_state EDHOC_PRIVATE(th_state);
275
300
  /** EDHOC context transcript hash buffer. */
276
- uint8_t EDHOC_PRIVATE(th)[EDHOC_MAX_MAC_LEN];
301
+ uint8_t EDHOC_PRIVATE(th)[CONFIG_LIBEDHOC_MAX_LEN_OF_MAC];
277
302
  /** Size of the \p th buffer in bytes. */
278
303
  size_t EDHOC_PRIVATE(th_len);
279
304
 
280
305
  /** EDHOC context pseudorandom key state. */
281
306
  enum edhoc_prk_state EDHOC_PRIVATE(prk_state);
282
307
  /** EDHOC context pseudorandom key buffer. */
283
- uint8_t EDHOC_PRIVATE(prk)[EDHOC_MAX_MAC_LEN];
308
+ uint8_t EDHOC_PRIVATE(prk)[CONFIG_LIBEDHOC_MAX_LEN_OF_MAC];
284
309
  /** Size of the \p prk buffer in bytes. */
285
310
  size_t EDHOC_PRIVATE(prk_len);
286
311
 
@@ -294,8 +319,8 @@ struct edhoc_context {
294
319
  struct edhoc_credentials EDHOC_PRIVATE(cred);
295
320
 
296
321
  /** EDHOC EAD tokens buffer. */
297
- struct edhoc_ead_token
298
- EDHOC_PRIVATE(ead_token)[EDHOC_MAX_NR_OF_EAD_TOKENS + 1];
322
+ struct edhoc_ead_token EDHOC_PRIVATE(
323
+ ead_token)[CONFIG_LIBEDHOC_MAX_NR_OF_EAD_TOKENS + 1];
299
324
  /** Length of the \p ead_token buffer. */
300
325
  size_t EDHOC_PRIVATE(nr_of_ead_tokens);
301
326
 
@@ -2,8 +2,8 @@
2
2
  * \file edhoc_credentials.h
3
3
  * \author Kamil Kielbasa
4
4
  * \brief EDHOC authentication credentials interface.
5
- * \version 0.4
6
- * \date 2024-01-01
5
+ * \version 0.6
6
+ * \date 2024-08-05
7
7
  *
8
8
  * \copyright Copyright (c) 2024
9
9
  *
@@ -19,6 +19,19 @@
19
19
  #include <stdbool.h>
20
20
 
21
21
  /* Defines ----------------------------------------------------------------- */
22
+
23
+ #ifndef CONFIG_LIBEDHOC_ENABLE
24
+ #error "Library has not been enabled."
25
+ #endif
26
+
27
+ #ifndef CONFIG_LIBEDHOC_MAX_LEN_OF_CRED_KEY_ID
28
+ #error "Lack of defined maximum length of authentication credentials key identifier in bytes."
29
+ #endif
30
+
31
+ #ifndef CONFIG_LIBEDHOC_MAX_LEN_OF_HASH_ALG
32
+ #error "Lack of defined maximum length of authentication credentials hash algorithm in bytes."
33
+ #endif
34
+
22
35
  /* Types and type definitions ---------------------------------------------- */
23
36
 
24
37
  /** \defgroup edhoc-interface-credentials EDHOC interface credentials
@@ -41,6 +54,8 @@ enum edhoc_encode_type {
41
54
  * \ref https://www.iana.org/assignments/cose/cose.xhtml
42
55
  */
43
56
  enum edhoc_cose_header {
57
+ /** Any authentication credentials. */
58
+ EDHOC_COSE_ANY = -65537,
44
59
  /** Authentication credentials identified by key identifier. */
45
60
  EDHOC_COSE_HEADER_KID = 4,
46
61
  /** Authentication credentials identified by an ordered chain of X.509 certificates. */
@@ -84,7 +99,7 @@ struct edhoc_auth_cred_key_id {
84
99
  int32_t key_id_int;
85
100
 
86
101
  /** Key identifier as cbor byte string buffer. */
87
- uint8_t key_id_bstr[EDHOC_CRED_KEY_ID_LEN + 1];
102
+ uint8_t key_id_bstr[CONFIG_LIBEDHOC_MAX_LEN_OF_CRED_KEY_ID + 1];
88
103
  /** Size of the \p key_id_bstr buffer in bytes. */
89
104
  size_t key_id_bstr_length;
90
105
  };
@@ -106,9 +121,9 @@ struct edhoc_auth_cred_x509_chain {
106
121
  /** Number of certificates in chain. */
107
122
  size_t nr_of_certs;
108
123
  /** Certificates references. */
109
- const uint8_t *cert[EDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN];
124
+ const uint8_t *cert[CONFIG_LIBEDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN];
110
125
  /** Sizes of the \p cert references in bytes. */
111
- size_t cert_len[EDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN];
126
+ size_t cert_len[CONFIG_LIBEDHOC_MAX_NR_OF_CERTS_IN_X509_CHAIN];
112
127
  };
113
128
 
114
129
  /**
@@ -148,17 +163,48 @@ struct edhoc_auth_cred_x509_hash {
148
163
  int32_t alg_int;
149
164
 
150
165
  /** Fingerprint algorithm as cbor byte string buffer. */
151
- uint8_t alg_bstr[EDHOC_CRED_X509_HASH_ALG_LEN + 1];
166
+ uint8_t alg_bstr[CONFIG_LIBEDHOC_MAX_LEN_OF_HASH_ALG + 1];
152
167
  /** Size of the \p alg_bstr buffer in bytes. */
153
168
  size_t alg_bstr_length;
154
169
  };
155
170
 
171
+ /**
172
+ * \brief Any authentication credentials.
173
+ *
174
+ * \note Application developer is responsible for correct
175
+ * CBOR encoding (compact if required) and decoding.
176
+ */
177
+ struct edhoc_auth_cred_any {
178
+ /** Buffer containing identification and optionally transport the credentials.
179
+ * RFC 9528: 2. EDHOC Outline: ID_CRED_I & ID_CRED_R. */
180
+ const uint8_t *id_cred;
181
+ /** Size of the \p id_cred buffer in bytes. */
182
+ size_t id_cred_len;
183
+
184
+ /** Is compact encoding of ID_CRED ?
185
+ * RFC 9528: 3.5.3.2. Compact Encoding of ID_CRED Fields for 'kid'. */
186
+ bool is_id_cred_comp_enc;
187
+ /** Encoding type of ID_CRED. */
188
+ enum edhoc_encode_type encode_type;
189
+
190
+ /** Buffer containing compact encoded identification. */
191
+ const uint8_t *id_cred_comp_enc;
192
+ /** Size of the \p id_cred_comp_enc buffer in bytes. */
193
+ size_t id_cred_comp_enc_length;
194
+
195
+ /** Buffer containing authentication credentials containing the public authentication keys.
196
+ * RFC 9528: 2. EDHOC Outline: CRED_I & CRED_R. */
197
+ const uint8_t *cred;
198
+ /** Size of the \p cred buffer in bytes. */
199
+ size_t cred_len;
200
+ };
201
+
156
202
  /**
157
203
  * \brief Common structure for different authentication credentials methods.
158
204
  */
159
205
  struct edhoc_auth_creds {
160
206
  /** Private signature or static DH key. */
161
- uint8_t priv_key_id[EDHOC_KID_LEN];
207
+ uint8_t priv_key_id[CONFIG_LIBEDHOC_KEY_ID_LEN];
162
208
 
163
209
  /** COSE IANA label. */
164
210
  enum edhoc_cose_header label;
@@ -169,6 +215,8 @@ struct edhoc_auth_creds {
169
215
  struct edhoc_auth_cred_x509_chain x509_chain;
170
216
  /** X.509 hash authentication structure. */
171
217
  struct edhoc_auth_cred_x509_hash x509_hash;
218
+ /** User defined authentication credentials structure. */
219
+ struct edhoc_auth_cred_any any;
172
220
  };
173
221
  };
174
222
 
@@ -2,8 +2,8 @@
2
2
  * \file edhoc_crypto.h
3
3
  * \author Kamil Kielbasa
4
4
  * \brief EDHOC cryptographic interface.
5
- * \version 0.4
6
- * \date 2024-01-01
5
+ * \version 0.6
6
+ * \date 2024-08-05
7
7
  *
8
8
  * \copyright Copyright (c) 2024
9
9
  *
@@ -50,7 +50,7 @@ enum edhoc_key_type {
50
50
  };
51
51
 
52
52
  /**
53
- * \brief Cryptographic function for key identifier generation.
53
+ * \brief Cryptographic function for import of key identifier.
54
54
  *
55
55
  * \param[in] user_context User context.
56
56
  * \param key_type Requested key type.
@@ -60,13 +60,13 @@ enum edhoc_key_type {
60
60
  *
61
61
  * \return EDHOC_SUCCESS on success, otherwise failure.
62
62
  */
63
- typedef int (*edhoc_generate_key_t)(void *user_context,
64
- enum edhoc_key_type key_type,
65
- const uint8_t *raw_key,
66
- size_t raw_key_length, void *key_id);
63
+ typedef int (*edhoc_import_key_t)(void *user_context,
64
+ enum edhoc_key_type key_type,
65
+ const uint8_t *raw_key, size_t raw_key_length,
66
+ void *key_id);
67
67
 
68
68
  /**
69
- * \brief Cryptographic function for key identifier destroying.
69
+ * \brief Cryptographic function for destroy of key identifier.
70
70
  *
71
71
  * \param[in] user_context User context.
72
72
  * \param[in] key_id Key identifier.
@@ -79,8 +79,8 @@ typedef int (*edhoc_destroy_key_t)(void *user_context, void *key_id);
79
79
  * \brief Bind structure for cryptographic key identifiers.
80
80
  */
81
81
  struct edhoc_keys {
82
- /** Generate cryptographic key callback. */
83
- edhoc_generate_key_t generate_key;
82
+ /** Import cryptographic key callback. */
83
+ edhoc_import_key_t import_key;
84
84
  /** Destroy cryptographic key callback. */
85
85
  edhoc_destroy_key_t destroy_key;
86
86
  };