edhoc 1.0.5 → 1.1.1

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 (313) hide show
  1. package/README.md +170 -0
  2. package/binding.gyp +13 -11
  3. package/dist/crypto.d.ts +9 -2
  4. package/dist/crypto.d.ts.map +1 -1
  5. package/dist/crypto.js +112 -84
  6. package/dist/edhoc.d.ts +31 -9
  7. package/dist/edhoc.d.ts.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/x509credentials.d.ts +20 -0
  12. package/dist/x509credentials.d.ts.map +1 -0
  13. package/dist/x509credentials.js +140 -0
  14. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_decode.h +1 -1
  15. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_encode.h +1 -1
  16. package/external/libedhoc/backends/cbor/include/backend_cbor_bstr_type_types.h +1 -1
  17. package/external/libedhoc/backends/cbor/include/backend_cbor_ead_decode.h +2 -2
  18. package/external/libedhoc/backends/cbor/include/backend_cbor_ead_encode.h +2 -2
  19. package/external/libedhoc/backends/cbor/include/backend_cbor_edhoc_types.h +48 -43
  20. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_decode.h +1 -1
  21. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_encode.h +1 -1
  22. package/external/libedhoc/backends/cbor/include/backend_cbor_enc_structure_types.h +3 -3
  23. package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_decode.h +1 -1
  24. package/external/libedhoc/backends/cbor/include/backend_cbor_id_cred_x_encode.h +1 -1
  25. package/external/libedhoc/backends/cbor/include/backend_cbor_info_decode.h +1 -1
  26. package/external/libedhoc/backends/cbor/include/backend_cbor_info_encode.h +1 -1
  27. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_decode.h +1 -1
  28. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_encode.h +1 -1
  29. package/external/libedhoc/backends/cbor/include/backend_cbor_int_type_types.h +1 -1
  30. package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_decode.h +1 -1
  31. package/external/libedhoc/backends/cbor/include/backend_cbor_message_1_encode.h +1 -1
  32. package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_decode.h +1 -1
  33. package/external/libedhoc/backends/cbor/include/backend_cbor_message_2_encode.h +1 -1
  34. package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_decode.h +1 -1
  35. package/external/libedhoc/backends/cbor/include/backend_cbor_message_3_encode.h +1 -1
  36. package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_decode.h +1 -1
  37. package/external/libedhoc/backends/cbor/include/backend_cbor_message_4_encode.h +1 -1
  38. package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_decode.h +1 -1
  39. package/external/libedhoc/backends/cbor/include/backend_cbor_message_error_encode.h +1 -1
  40. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_decode.h +1 -1
  41. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_2_encode.h +1 -1
  42. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_decode.h +1 -1
  43. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_3_encode.h +1 -1
  44. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_decode.h +3 -3
  45. package/external/libedhoc/backends/cbor/include/backend_cbor_plaintext_4_encode.h +3 -3
  46. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_decode.h +1 -1
  47. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_encode.h +1 -1
  48. package/external/libedhoc/backends/cbor/include/backend_cbor_sig_structure_types.h +4 -4
  49. package/external/libedhoc/backends/cbor/include/backend_cbor_x509_types.h +93 -83
  50. package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_decode.c +11 -20
  51. package/external/libedhoc/backends/cbor/src/backend_cbor_bstr_type_encode.c +11 -20
  52. package/external/libedhoc/backends/cbor/src/backend_cbor_ead_decode.c +27 -32
  53. package/external/libedhoc/backends/cbor/src/backend_cbor_ead_encode.c +27 -32
  54. package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_decode.c +14 -23
  55. package/external/libedhoc/backends/cbor/src/backend_cbor_enc_structure_encode.c +14 -23
  56. package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_decode.c +63 -52
  57. package/external/libedhoc/backends/cbor/src/backend_cbor_id_cred_x_encode.c +62 -51
  58. package/external/libedhoc/backends/cbor/src/backend_cbor_info_decode.c +14 -23
  59. package/external/libedhoc/backends/cbor/src/backend_cbor_info_encode.c +14 -23
  60. package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_decode.c +11 -20
  61. package/external/libedhoc/backends/cbor/src/backend_cbor_int_type_encode.c +11 -20
  62. package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_decode.c +54 -51
  63. package/external/libedhoc/backends/cbor/src/backend_cbor_message_1_encode.c +54 -51
  64. package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_decode.c +11 -20
  65. package/external/libedhoc/backends/cbor/src/backend_cbor_message_2_encode.c +11 -20
  66. package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_decode.c +11 -20
  67. package/external/libedhoc/backends/cbor/src/backend_cbor_message_3_encode.c +11 -20
  68. package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_decode.c +11 -20
  69. package/external/libedhoc/backends/cbor/src/backend_cbor_message_4_encode.c +11 -20
  70. package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_decode.c +36 -37
  71. package/external/libedhoc/backends/cbor/src/backend_cbor_message_error_encode.c +36 -37
  72. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_decode.c +103 -80
  73. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_2_encode.c +102 -79
  74. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_decode.c +99 -76
  75. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_3_encode.c +98 -75
  76. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_decode.c +40 -41
  77. package/external/libedhoc/backends/cbor/src/backend_cbor_plaintext_4_encode.c +40 -41
  78. package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_decode.c +15 -24
  79. package/external/libedhoc/backends/cbor/src/backend_cbor_sig_structure_encode.c +15 -24
  80. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.c +31 -0
  81. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode.h +10 -0
  82. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.c +18 -0
  83. package/external/libedhoc/externals/Unity/examples/example_1/src/ProductionCode2.h +9 -0
  84. package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode.c +69 -0
  85. package/external/libedhoc/externals/Unity/examples/example_1/test/TestProductionCode2.c +38 -0
  86. package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +53 -0
  87. package/external/libedhoc/externals/Unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +57 -0
  88. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.c +31 -0
  89. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode.h +10 -0
  90. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.c +18 -0
  91. package/external/libedhoc/externals/Unity/examples/example_2/src/ProductionCode2.h +9 -0
  92. package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode.c +71 -0
  93. package/external/libedhoc/externals/Unity/examples/example_2/test/TestProductionCode2.c +40 -0
  94. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode2_Runner.c +16 -0
  95. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/TestProductionCode_Runner.c +18 -0
  96. package/external/libedhoc/externals/Unity/examples/example_2/test/test_runners/all_tests.c +19 -0
  97. package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.c +17 -0
  98. package/external/libedhoc/externals/Unity/examples/example_3/helper/UnityHelper.h +19 -0
  99. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.c +31 -0
  100. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode.h +10 -0
  101. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.c +18 -0
  102. package/external/libedhoc/externals/Unity/examples/example_3/src/ProductionCode2.h +9 -0
  103. package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode.c +69 -0
  104. package/external/libedhoc/externals/Unity/examples/example_3/test/TestProductionCode2.c +38 -0
  105. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.c +31 -0
  106. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode.h +10 -0
  107. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.c +18 -0
  108. package/external/libedhoc/externals/Unity/examples/example_4/src/ProductionCode2.h +9 -0
  109. package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode.c +70 -0
  110. package/external/libedhoc/externals/Unity/examples/example_4/test/TestProductionCode2.c +42 -0
  111. package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode2_Runner.c +53 -0
  112. package/external/libedhoc/externals/Unity/examples/example_4/test/test_runners/TestProductionCode_Runner.c +57 -0
  113. package/external/libedhoc/externals/Unity/examples/unity_config.h +251 -0
  114. package/external/libedhoc/externals/Unity/extras/bdd/src/unity_bdd.h +44 -0
  115. package/external/libedhoc/externals/Unity/extras/bdd/test/test_bdd.c +129 -0
  116. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.c +310 -0
  117. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture.h +95 -0
  118. package/external/libedhoc/externals/Unity/extras/fixture/src/unity_fixture_internals.h +51 -0
  119. package/external/libedhoc/externals/Unity/extras/fixture/test/main/AllTests.c +20 -0
  120. package/external/libedhoc/externals/Unity/extras/fixture/test/template_fixture_tests.c +40 -0
  121. package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_Test.c +246 -0
  122. package/external/libedhoc/externals/Unity/extras/fixture/test/unity_fixture_TestRunner.c +33 -0
  123. package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.c +203 -0
  124. package/external/libedhoc/externals/Unity/extras/memory/src/unity_memory.h +61 -0
  125. package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_Test.c +326 -0
  126. package/external/libedhoc/externals/Unity/extras/memory/test/unity_memory_TestRunner.c +50 -0
  127. package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.c +57 -0
  128. package/external/libedhoc/externals/Unity/extras/memory/test/unity_output_Spy.h +17 -0
  129. package/external/libedhoc/externals/Unity/src/unity.c +2501 -0
  130. package/external/libedhoc/externals/Unity/src/unity.h +698 -0
  131. package/external/libedhoc/externals/Unity/src/unity_internals.h +1183 -0
  132. package/external/libedhoc/externals/Unity/test/expectdata/testsample_cmd.c +61 -0
  133. package/external/libedhoc/externals/Unity/test/expectdata/testsample_def.c +57 -0
  134. package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.c +55 -0
  135. package/external/libedhoc/externals/Unity/test/expectdata/testsample_head1.h +15 -0
  136. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_cmd.c +80 -0
  137. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_def.c +76 -0
  138. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.c +75 -0
  139. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_head1.h +13 -0
  140. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new1.c +89 -0
  141. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_new2.c +89 -0
  142. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_param.c +77 -0
  143. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run1.c +89 -0
  144. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_run2.c +89 -0
  145. package/external/libedhoc/externals/Unity/test/expectdata/testsample_mock_yaml.c +90 -0
  146. package/external/libedhoc/externals/Unity/test/expectdata/testsample_new1.c +67 -0
  147. package/external/libedhoc/externals/Unity/test/expectdata/testsample_new2.c +70 -0
  148. package/external/libedhoc/externals/Unity/test/expectdata/testsample_param.c +58 -0
  149. package/external/libedhoc/externals/Unity/test/expectdata/testsample_run1.c +67 -0
  150. package/external/libedhoc/externals/Unity/test/expectdata/testsample_run2.c +70 -0
  151. package/external/libedhoc/externals/Unity/test/expectdata/testsample_yaml.c +71 -0
  152. package/external/libedhoc/externals/Unity/test/testdata/CException.h +18 -0
  153. package/external/libedhoc/externals/Unity/test/testdata/Defs.h +16 -0
  154. package/external/libedhoc/externals/Unity/test/testdata/cmock.h +21 -0
  155. package/external/libedhoc/externals/Unity/test/testdata/mockMock.h +20 -0
  156. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGenerator.c +204 -0
  157. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorSmall.c +73 -0
  158. package/external/libedhoc/externals/Unity/test/testdata/testRunnerGeneratorWithMocks.c +200 -0
  159. package/external/libedhoc/externals/Unity/test/tests/self_assessment_utils.h +151 -0
  160. package/external/libedhoc/externals/Unity/test/tests/test_unity_arrays.c +2941 -0
  161. package/external/libedhoc/externals/Unity/test/tests/test_unity_core.c +375 -0
  162. package/external/libedhoc/externals/Unity/test/tests/test_unity_doubles.c +1285 -0
  163. package/external/libedhoc/externals/Unity/test/tests/test_unity_floats.c +1395 -0
  164. package/external/libedhoc/externals/Unity/test/tests/test_unity_integers.c +2863 -0
  165. package/external/libedhoc/externals/Unity/test/tests/test_unity_integers_64.c +783 -0
  166. package/external/libedhoc/externals/Unity/test/tests/test_unity_memory.c +82 -0
  167. package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterized.c +309 -0
  168. package/external/libedhoc/externals/Unity/test/tests/test_unity_parameterizedDemo.c +28 -0
  169. package/external/libedhoc/externals/Unity/test/tests/test_unity_strings.c +330 -0
  170. package/external/libedhoc/externals/Unity/test/tests/types_for_test.h +21 -0
  171. package/external/libedhoc/externals/zcbor/include/zcbor_common.h +147 -60
  172. package/external/libedhoc/externals/zcbor/include/zcbor_decode.h +291 -202
  173. package/external/libedhoc/externals/zcbor/include/zcbor_encode.h +100 -156
  174. package/external/libedhoc/externals/zcbor/include/zcbor_print.h +165 -0
  175. package/external/libedhoc/externals/zcbor/samples/hello_world/src/main.c +1 -1
  176. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_decode.h +1 -1
  177. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_encode.h +1 -1
  178. package/external/libedhoc/externals/zcbor/samples/pet/include/pet_types.h +4 -4
  179. package/external/libedhoc/externals/zcbor/samples/pet/src/main.c +4 -4
  180. package/external/libedhoc/externals/zcbor/samples/pet/src/pet_decode.c +15 -24
  181. package/external/libedhoc/externals/zcbor/samples/pet/src/pet_encode.c +14 -23
  182. package/external/libedhoc/externals/zcbor/src/zcbor_common.c +202 -29
  183. package/external/libedhoc/externals/zcbor/src/zcbor_decode.c +633 -173
  184. package/external/libedhoc/externals/zcbor/src/zcbor_encode.c +71 -184
  185. package/external/libedhoc/externals/zcbor/tests/decode/test1_suit_old_formats/src/main.c +152 -153
  186. package/external/libedhoc/externals/zcbor/tests/decode/test2_suit/src/main.c +64 -64
  187. package/external/libedhoc/externals/zcbor/tests/decode/test3_simple/src/main.c +15 -16
  188. package/external/libedhoc/externals/zcbor/tests/decode/test5_corner_cases/src/main.c +228 -84
  189. package/external/libedhoc/externals/zcbor/tests/decode/test7_suit9_simple/src/main.c +9 -9
  190. package/external/libedhoc/externals/zcbor/tests/decode/test8_suit12/src/main.c +0 -1
  191. package/external/libedhoc/externals/zcbor/tests/decode/test9_manifest14/src/main.c +172 -173
  192. package/external/libedhoc/externals/zcbor/tests/encode/test1_suit/src/main.c +73 -73
  193. package/external/libedhoc/externals/zcbor/tests/encode/test2_simple/src/main.c +1 -2
  194. package/external/libedhoc/externals/zcbor/tests/encode/test3_corner_cases/src/main.c +83 -56
  195. package/external/libedhoc/externals/zcbor/tests/encode/test4_senml/src/main.c +15 -16
  196. package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_everything.c +12 -0
  197. package/external/libedhoc/externals/zcbor/tests/fuzz/fuzz_manifest12.c +69 -69
  198. package/external/libedhoc/externals/zcbor/tests/unit/test1_unit_tests/src/main.c +448 -55
  199. package/external/libedhoc/externals/zcbor/tests/unit/test3_float16/src/main.c +49 -48
  200. package/external/libedhoc/include/edhoc.h +348 -54
  201. package/external/libedhoc/include/edhoc_common.h +289 -0
  202. package/external/libedhoc/include/edhoc_context.h +60 -35
  203. package/external/libedhoc/include/edhoc_credentials.h +55 -7
  204. package/external/libedhoc/include/edhoc_crypto.h +10 -10
  205. package/external/libedhoc/include/edhoc_ead.h +13 -10
  206. package/external/libedhoc/include/edhoc_macros.h +20 -11
  207. package/external/libedhoc/include/edhoc_values.h +2 -2
  208. package/external/libedhoc/library/edhoc.c +70 -36
  209. package/external/libedhoc/library/edhoc_common.c +1314 -0
  210. package/external/libedhoc/library/edhoc_exporter.c +45 -46
  211. package/external/libedhoc/library/edhoc_message_1.c +107 -72
  212. package/external/libedhoc/library/edhoc_message_2.c +396 -1693
  213. package/external/libedhoc/library/edhoc_message_3.c +465 -1656
  214. package/external/libedhoc/library/edhoc_message_4.c +93 -91
  215. package/external/libedhoc/library/edhoc_message_error.c +41 -41
  216. package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_0.h → cipher_suite_0.h} +131 -134
  217. package/external/libedhoc/tests/include/{cipher_suites/cipher_suite_2.h → cipher_suite_2.h} +139 -140
  218. package/external/libedhoc/tests/include/{edhoc_trace_1/test_vector_1.h → test_vector_rfc9529_chapter_2.h} +786 -738
  219. package/external/libedhoc/tests/include/{edhoc_trace_2/test_vector_2.h → test_vector_rfc9529_chapter_3.h} +14 -10
  220. 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
  221. 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
  222. 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
  223. 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
  224. package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_0.c → cipher_suite_0.c} +445 -447
  225. package/external/libedhoc/tests/src/{cipher_suites/cipher_suite_2.c → cipher_suite_2.c} +600 -600
  226. package/external/libedhoc/tests/src/module_test_api.c +430 -0
  227. package/external/libedhoc/tests/src/module_test_cipher_suite_0.c +395 -0
  228. package/external/libedhoc/tests/src/module_test_cipher_suite_2.c +392 -0
  229. package/external/libedhoc/tests/src/{error_message/test_edhoc_error_message.c → module_test_error_message.c} +94 -69
  230. package/external/libedhoc/tests/src/module_test_main.c +49 -0
  231. package/external/libedhoc/tests/src/{cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.c → module_test_rfc9528_suites_negotiation.c} +224 -227
  232. package/external/libedhoc/tests/src/module_test_rfc9529_chapter_2.c +2681 -0
  233. package/external/libedhoc/tests/src/module_test_rfc9529_chapter_3.c +1635 -0
  234. package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_0.c +1135 -0
  235. package/external/libedhoc/tests/src/module_test_x5chain_sign_keys_suite_2.c +1249 -0
  236. package/external/libedhoc/tests/src/module_test_x5chain_static_dh_keys_suite_2.c +798 -0
  237. package/external/libedhoc/tests/src/module_test_x5t_sign_keys_suite_2.c +956 -0
  238. package/include/EdhocComposeAsyncWorker.h +8 -6
  239. package/include/EdhocCredentialManager.h +16 -11
  240. package/include/EdhocCryptoManager.h +28 -21
  241. package/include/EdhocEadManager.h +3 -6
  242. package/include/{EdhocExportAsyncWorker.h → EdhocExportOscoreAsyncWorker.h} +20 -17
  243. package/include/EdhocKeyExporterAsyncWorker.h +76 -0
  244. package/include/EdhocKeyUpdateAsyncWorker.h +72 -0
  245. package/include/EdhocProcessAsyncWorker.h +14 -10
  246. package/include/LibEDHOC.h +44 -20
  247. package/include/UserContext.h +7 -9
  248. package/include/Utils.h +31 -27
  249. package/package.json +14 -3
  250. package/prebuilds/android-arm/edhoc.armv7.node +0 -0
  251. package/prebuilds/android-arm64/edhoc.armv8.node +0 -0
  252. package/prebuilds/darwin-arm64/edhoc.node +0 -0
  253. package/prebuilds/darwin-x64/edhoc.node +0 -0
  254. package/prebuilds/linux-arm/edhoc.armv6.node +0 -0
  255. package/prebuilds/linux-arm/edhoc.armv7.node +0 -0
  256. package/prebuilds/linux-arm64/edhoc.armv8.node +0 -0
  257. package/prebuilds/linux-x64/edhoc.glibc.node +0 -0
  258. package/prebuilds/linux-x64/edhoc.musl.node +0 -0
  259. package/prebuilds/win32-ia32/edhoc.node +0 -0
  260. package/prebuilds/win32-x64/edhoc.node +0 -0
  261. package/src/EdhocComposeAsyncWorker.cpp +18 -35
  262. package/src/EdhocCredentialManager.cpp +160 -187
  263. package/src/EdhocCryptoManager.cpp +386 -586
  264. package/src/EdhocEadManager.cpp +10 -18
  265. package/src/EdhocExportOscoreAsyncWorker.cpp +77 -0
  266. package/src/EdhocKeyExporterAsyncWorker.cpp +49 -0
  267. package/src/EdhocKeyUpdateAsyncWorker.cpp +41 -0
  268. package/src/EdhocProcessAsyncWorker.cpp +72 -19
  269. package/src/LibEDHOC.cpp +213 -174
  270. package/src/Suites.cpp +39 -72
  271. package/src/Utils.cpp +32 -56
  272. package/test/basic.test.ts +64 -0
  273. package/test/vectors.test.ts +111 -0
  274. package/dist/credentials.d.ts +0 -16
  275. package/dist/credentials.d.ts.map +0 -1
  276. package/dist/credentials.js +0 -84
  277. package/external/libedhoc/externals/zcbor/include/zcbor_debug.h +0 -69
  278. package/external/libedhoc/tests/include/cipher_suite_negotiation/test_edhoc_cipher_suite_negotiation.h +0 -37
  279. package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_0.h +0 -48
  280. package/external/libedhoc/tests/include/cipher_suites/test_cipher_suite_2.h +0 -48
  281. package/external/libedhoc/tests/include/edhoc_trace_1/authentication_credentials_1.h +0 -60
  282. package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_1.h +0 -208
  283. package/external/libedhoc/tests/include/edhoc_trace_1/test_edhoc_handshake_ead_1.h +0 -59
  284. package/external/libedhoc/tests/include/edhoc_trace_2/authentication_credentials_2.h +0 -60
  285. package/external/libedhoc/tests/include/edhoc_trace_2/test_edhoc_handshake_2.h +0 -199
  286. package/external/libedhoc/tests/include/error_message/test_edhoc_error_message.h +0 -48
  287. package/external/libedhoc/tests/include/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.h +0 -92
  288. package/external/libedhoc/tests/include/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.h +0 -96
  289. package/external/libedhoc/tests/include/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.h +0 -58
  290. package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.h +0 -56
  291. package/external/libedhoc/tests/include/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.h +0 -57
  292. package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.h +0 -59
  293. package/external/libedhoc/tests/include/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h +0 -57
  294. package/external/libedhoc/tests/include/x509_hash_cs_2/authentication_credentials_x5t_cs_2.h +0 -60
  295. package/external/libedhoc/tests/include/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.h +0 -57
  296. package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_0.c +0 -475
  297. package/external/libedhoc/tests/src/cipher_suites/test_cipher_suite_2.c +0 -473
  298. package/external/libedhoc/tests/src/edhoc_trace_1/authentication_credentials_1.c +0 -252
  299. package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_1.c +0 -1829
  300. package/external/libedhoc/tests/src/edhoc_trace_1/test_edhoc_handshake_ead_1.c +0 -1247
  301. package/external/libedhoc/tests/src/edhoc_trace_2/authentication_credentials_2.c +0 -170
  302. package/external/libedhoc/tests/src/edhoc_trace_2/test_edhoc_handshake_2.c +0 -1783
  303. package/external/libedhoc/tests/src/tests.c +0 -228
  304. package/external/libedhoc/tests/src/x509_chain_cs_0/authentication_credentials_x5chain_cs_0.c +0 -332
  305. package/external/libedhoc/tests/src/x509_chain_cs_0/test_edhoc_handshake_x5chain_cs_0.c +0 -936
  306. package/external/libedhoc/tests/src/x509_chain_cs_2/authentication_credentials_x5chain_cs_2.c +0 -166
  307. package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2.c +0 -587
  308. package/external/libedhoc/tests/src/x509_chain_cs_2/test_edhoc_handshake_x5chain_cs_2_ead.c +0 -917
  309. package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/authentication_credentials_x5chain_cs_2_static_dh.c +0 -186
  310. package/external/libedhoc/tests/src/x509_chain_cs_2_static_dh/test_edhoc_handshake_x5chain_cs_2_static_dh_ead.c +0 -743
  311. package/external/libedhoc/tests/src/x509_hash_cs_2/authentication_credentials_x5t_cs_2.c +0 -261
  312. package/external/libedhoc/tests/src/x509_hash_cs_2/test_edhoc_handshake_x5t_cs_2_ead.c +0 -854
  313. package/src/EdhocExportAsyncWorker.cpp +0 -82
@@ -1,57 +0,0 @@
1
- /**
2
- * \file test_edhoc_handshake_x5chain_cs_2_static_dh_ead.h
3
- * \author Kamil Kielbasa
4
- * \brief EDHOC handshake unit test for X.509 chain authentication method
5
- * for cipher suite 2 with static DH keys and single EAD token.
6
- * \version 0.4
7
- * \date 2024-01-01
8
- *
9
- * \copyright Copyright (c) 2024
10
- *
11
- */
12
-
13
- /* Header guard ------------------------------------------------------------ */
14
- #ifndef TEST_EDHOC_HANDSHAKE_X5CHAIN_CS_2_STATIC_DH_EAD_H
15
- #define TEST_EDHOC_HANDSHAKE_X5CHAIN_CS_2_STATIC_DH_EAD_H
16
-
17
- /* Include files ----------------------------------------------------------- */
18
- /* Defines ----------------------------------------------------------------- */
19
- /* Types and type definitions ---------------------------------------------- */
20
- /* Module interface variables and constants -------------------------------- */
21
- /* Extern variables and constant declarations ------------------------------ */
22
- /* Module interface function declarations ---------------------------------- */
23
-
24
- /**
25
- * \brief Test scenario:
26
- * 1) use test vector as input for EDHOC context's.
27
- * 2) perform full EDHOC handshake:
28
- * (message 1 -> message 2 -> mesage 3 -> message 4)
29
- * - verify:
30
- * - internal context.
31
- * - TH state.
32
- * - PRK state.
33
- * - DH key agreement.
34
- * - C_I / C_R.
35
- * - EAD.
36
- * 3) export OSCORE sessions:
37
- * - verify by cross-check:
38
- * - internal context.
39
- * - master secret.
40
- * - master salt.
41
- * - sender ID.
42
- * - recipient ID.
43
- * 4) perform key update on EDHOC session
44
- * - verify:
45
- * - internal context.
46
- * - PRK state.
47
- * 5) export new OSCORE sessions:
48
- * - verify by cross-check:
49
- * - internal context.
50
- * - master secret.
51
- * - master salt.
52
- * - sender ID.
53
- * - recipient ID.
54
- */
55
- void test_edhoc_handshake_x5chain_cs_2_static_dh_keys_ead_e2e(void);
56
-
57
- #endif /* TEST_EDHOC_HANDSHAKE_X5CHAIN_CS_2_STATIC_DH_EAD_H */
@@ -1,60 +0,0 @@
1
- /**
2
- * \file authentication_credentials_x5t_cs_2.h
3
- * \author Kamil Kielbasa
4
- * \brief Example implementation of authentication credentials callbacks
5
- * for X.509 hash authentication method for cipher suite 2.
6
- * \version 0.4
7
- * \date 2024-01-01
8
- *
9
- * \copyright Copyright (c) 2024
10
- *
11
- */
12
-
13
- /* Header guard ------------------------------------------------------------ */
14
- #ifndef AUTHENTICATION_CREDENTIALS_X5T_CS_2_H
15
- #define AUTHENTICATION_CREDENTIALS_X5T_CS_2_H
16
-
17
- /* Include files ----------------------------------------------------------- */
18
-
19
- /* Standard library headers: */
20
- #include <stdint.h>
21
- #include <stddef.h>
22
-
23
- /* EDHOC header: */
24
- #include "edhoc_credentials.h"
25
-
26
- /* Defines ----------------------------------------------------------------- */
27
- /* Types and type definitions ---------------------------------------------- */
28
- /* Module interface variables and constants -------------------------------- */
29
- /* Extern variables and constant declarations ------------------------------ */
30
- /* Module interface function declarations ---------------------------------- */
31
-
32
- /**
33
- * \brief Authentication credentials fetch callback for initiator.
34
- */
35
- int auth_cred_fetch_init_x5t_cs_2(void *user_context,
36
- struct edhoc_auth_creds *credentials);
37
-
38
- /**
39
- * \brief Authentication credentials fetch callback for responder.
40
- */
41
- int auth_cred_fetch_resp_x5t_cs_2(void *user_context,
42
- struct edhoc_auth_creds *credentials);
43
-
44
- /**
45
- * \brief Authentication credentials verify callback for initiator.
46
- */
47
- int auth_cred_verify_init_x5t_cs_2(void *user_context,
48
- struct edhoc_auth_creds *credentials,
49
- const uint8_t **public_key_reference,
50
- size_t *public_key_length);
51
-
52
- /**
53
- * \brief Authentication credentials verify callback for responder.
54
- */
55
- int auth_cred_verify_resp_x5t_cs_2(void *user_context,
56
- struct edhoc_auth_creds *credentials,
57
- const uint8_t **public_key_reference,
58
- size_t *public_key_length);
59
-
60
- #endif /* AUTHENTICATION_CREDENTIALS_X5T_CS_2_H */
@@ -1,57 +0,0 @@
1
- /**
2
- * \file test_edhoc_handshake_x5t_cs_2_ead.h
3
- * \author Kamil Kielbasa
4
- * \brief EDHOC handshake unit test for X.509 hash authentication method
5
- * for cipher suite 2 with single EAD token.
6
- * \version 0.4
7
- * \date 2024-01-01
8
- *
9
- * \copyright Copyright (c) 2024
10
- *
11
- */
12
-
13
- /* Header guard ------------------------------------------------------------ */
14
- #ifndef TEST_EDHOC_HANDSHAKE_X5T_CS_2_EAD_H
15
- #define TEST_EDHOC_HANDSHAKE_X5T_CS_2_EAD_H
16
-
17
- /* Include files ----------------------------------------------------------- */
18
- /* Defines ----------------------------------------------------------------- */
19
- /* Types and type definitions ---------------------------------------------- */
20
- /* Module interface variables and constants -------------------------------- */
21
- /* Extern variables and constant declarations ------------------------------ */
22
- /* Module interface function declarations ---------------------------------- */
23
-
24
- /**
25
- * \brief Test scenario:
26
- * 1) use test vector as input for EDHOC context's.
27
- * 2) perform full EDHOC handshake:
28
- * (message 1 -> message 2 -> mesage 3 -> message 4)
29
- * - verify:
30
- * - internal context.
31
- * - TH state.
32
- * - PRK state.
33
- * - DH key agreement.
34
- * - C_I / C_R.
35
- * - EAD.
36
- * 3) export OSCORE sessions:
37
- * - verify by cross-check:
38
- * - internal context.
39
- * - master secret.
40
- * - master salt.
41
- * - sender ID.
42
- * - recipient ID.
43
- * 4) perform key update on EDHOC session
44
- * - verify:
45
- * - internal context.
46
- * - PRK state.
47
- * 5) export new OSCORE sessions:
48
- * - verify by cross-check:
49
- * - internal context.
50
- * - master secret.
51
- * - master salt.
52
- * - sender ID.
53
- * - recipient ID.
54
- */
55
- void test_edhoc_handshake_x5t_cs_2_e2e_single_ead_token(void);
56
-
57
- #endif /* TEST_EDHOC_HANDSHAKE_X5T_CS_2_EAD_H */
@@ -1,475 +0,0 @@
1
- /**
2
- * \file test_cipher_suite_0.c
3
- * \author Kamil Kielbasa
4
- * \brief Unit tests for cipher suite 0.
5
- * \version 0.4
6
- * \date 2024-01-01
7
- *
8
- * \copyright Copyright (c) 2024
9
- *
10
- */
11
-
12
- /* Include files ----------------------------------------------------------- */
13
-
14
- /* Internal test header: */
15
- #include "cipher_suites/cipher_suite_0.h"
16
- #include "cipher_suites/test_cipher_suite_0.h"
17
-
18
- /* Standard library headers: */
19
- #include <stdio.h>
20
- #include <stdint.h>
21
- #include <stddef.h>
22
- #include <string.h>
23
- #include <assert.h>
24
-
25
- /* EDHOC headers: */
26
- #include "edhoc_crypto.h"
27
- #include "edhoc_values.h"
28
- #include "edhoc_macros.h"
29
-
30
- /* PSA crypto header: */
31
- #include <psa/crypto.h>
32
-
33
- /* Compact25519 crypto headers: */
34
- #include <compact_x25519.h>
35
- #include <compact_ed25519.h>
36
-
37
- /* Module defines ---------------------------------------------------------- */
38
- #define INPUT_TO_SIGN_LEN ((size_t)128)
39
-
40
- /* Module types and type definitiones -------------------------------------- */
41
- /* Module interface variables and constants -------------------------------- */
42
- /* Static variables and constants ------------------------------------------ */
43
-
44
- static const struct edhoc_keys keys = {
45
- .generate_key = cipher_suite_0_key_generate,
46
- .destroy_key = cipher_suite_0_key_destroy,
47
- };
48
-
49
- static const struct edhoc_crypto crypto = {
50
- .make_key_pair = cipher_suite_0_make_key_pair,
51
- .key_agreement = cipher_suite_0_key_agreement,
52
- .signature = cipher_suite_0_signature,
53
- .verify = cipher_suite_0_verify,
54
- .extract = cipher_suite_0_extract,
55
- .expand = cipher_suite_0_expand,
56
- .encrypt = cipher_suite_0_encrypt,
57
- .decrypt = cipher_suite_0_decrypt,
58
- .hash = cipher_suite_0_hash,
59
- };
60
-
61
- /* Static function declarations -------------------------------------------- */
62
-
63
- /**
64
- * \brief Helper function for printing arrays.
65
- */
66
- static inline void print_array(const char *name, const uint8_t *buffer,
67
- size_t buffer_length);
68
-
69
- /* Static function definitions --------------------------------------------- */
70
-
71
- static inline void print_array(const char *name, const uint8_t *buffer,
72
- size_t buffer_length)
73
- {
74
- printf("%s:\tLEN( %zu )\n", name, buffer_length);
75
-
76
- for (size_t i = 0; i < buffer_length; ++i) {
77
- if (0 == i % 16 && i > 0) {
78
- printf("\n");
79
- }
80
-
81
- printf("%02x ", buffer[i]);
82
- }
83
-
84
- printf("\n\n");
85
- }
86
-
87
- /* Module interface function definitions ----------------------------------- */
88
-
89
- void test_cipher_suite_0_ecdsa(void)
90
- {
91
- int ret = PSA_ERROR_GENERIC_ERROR;
92
- psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
93
-
94
- const struct edhoc_keys *edhoc_keys = &keys;
95
- const struct edhoc_crypto *edhoc_crypto = &crypto;
96
-
97
- const uint8_t priv_key[ED25519_PRIVATE_KEY_SIZE] = {
98
- 0xef, 0x14, 0x0f, 0xf9, 0x00, 0xb0, 0xab, 0x03,
99
- 0xf0, 0xc0, 0x8d, 0x87, 0x9c, 0xbb, 0xd4, 0xb3,
100
- 0x1e, 0xa7, 0x1e, 0x6e, 0x7e, 0xe7, 0xff, 0xcb,
101
- 0x7e, 0x79, 0x55, 0x77, 0x7a, 0x33, 0x27, 0x99,
102
-
103
- 0xa1, 0xdb, 0x47, 0xb9, 0x51, 0x84, 0x85, 0x4a,
104
- 0xd1, 0x2a, 0x0c, 0x1a, 0x35, 0x4e, 0x41, 0x8a,
105
- 0xac, 0xe3, 0x3a, 0xa0, 0xf2, 0xc6, 0x62, 0xc0,
106
- 0x0b, 0x3a, 0xc5, 0x5d, 0xe9, 0x2f, 0x93, 0x59,
107
- };
108
-
109
- const uint8_t pub_key[ED25519_PUBLIC_KEY_SIZE] = {
110
- 0xa1, 0xdb, 0x47, 0xb9, 0x51, 0x84, 0x85, 0x4a,
111
- 0xd1, 0x2a, 0x0c, 0x1a, 0x35, 0x4e, 0x41, 0x8a,
112
- 0xac, 0xe3, 0x3a, 0xa0, 0xf2, 0xc6, 0x62, 0xc0,
113
- 0x0b, 0x3a, 0xc5, 0x5d, 0xe9, 0x2f, 0x93, 0x59,
114
- };
115
-
116
- /**
117
- * \brief Random input for signature.
118
- */
119
- uint8_t input[INPUT_TO_SIGN_LEN] = { 0 };
120
- ret = psa_generate_random(input, ARRAY_SIZE(input));
121
- assert(PSA_SUCCESS == ret);
122
-
123
- print_array("Input for signature", input, ARRAY_SIZE(input));
124
-
125
- /**
126
- * \brief Generate signature.
127
- */
128
- size_t sign_len = 0;
129
- uint8_t sign[ED25519_SIGNATURE_SIZE] = { 0 };
130
-
131
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_SIGNATURE, priv_key,
132
- ARRAY_SIZE(priv_key), &key_id);
133
- assert(EDHOC_SUCCESS == ret);
134
-
135
- ret = edhoc_crypto->signature(NULL, &key_id, input, ARRAY_SIZE(input),
136
- sign, ARRAY_SIZE(sign), &sign_len);
137
- assert(EDHOC_SUCCESS == ret);
138
-
139
- ret = edhoc_keys->destroy_key(NULL, &key_id);
140
- assert(EDHOC_SUCCESS == ret);
141
-
142
- print_array("Signature", sign, sign_len);
143
-
144
- /**
145
- * \brief Verify signature.
146
- */
147
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_VERIFY, pub_key,
148
- ARRAY_SIZE(pub_key), &key_id);
149
- assert(EDHOC_SUCCESS == ret);
150
-
151
- ret = edhoc_crypto->verify(NULL, &key_id, input, ARRAY_SIZE(input),
152
- sign, sign_len);
153
- assert(EDHOC_SUCCESS == ret);
154
-
155
- ret = edhoc_keys->destroy_key(NULL, &key_id);
156
- assert(EDHOC_SUCCESS == ret);
157
- }
158
-
159
- void test_cipher_suite_0_ecdh(void)
160
- {
161
- int ret = PSA_ERROR_GENERIC_ERROR;
162
- psa_key_id_t key_id_a = PSA_KEY_HANDLE_INIT;
163
- psa_key_id_t key_id_b = PSA_KEY_HANDLE_INIT;
164
-
165
- const struct edhoc_keys *edhoc_keys = &keys;
166
- const struct edhoc_crypto *edhoc_crypto = &crypto;
167
-
168
- /**
169
- * \brief Alice ECDH public and private keys.
170
- */
171
- size_t priv_key_len_a = 0;
172
- uint8_t priv_key_a[X25519_KEY_SIZE] = { 0 };
173
-
174
- size_t pub_key_len_a = 0;
175
- uint8_t pub_key_a[X25519_KEY_SIZE] = { 0 };
176
-
177
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_MAKE_KEY_PAIR, NULL, 0,
178
- &key_id_a);
179
- assert(EDHOC_SUCCESS == ret);
180
-
181
- ret = edhoc_crypto->make_key_pair(NULL, &key_id_a, priv_key_a,
182
- ARRAY_SIZE(priv_key_a),
183
- &priv_key_len_a, pub_key_a,
184
- ARRAY_SIZE(pub_key_a),
185
- &pub_key_len_a);
186
- assert(EDHOC_SUCCESS == ret);
187
- assert(ARRAY_SIZE(priv_key_a) == priv_key_len_a);
188
- assert(ARRAY_SIZE(pub_key_a) == pub_key_len_a);
189
-
190
- ret = edhoc_keys->destroy_key(NULL, &key_id_a);
191
- assert(EDHOC_SUCCESS == ret);
192
-
193
- print_array("Alice private key", priv_key_a, ARRAY_SIZE(priv_key_a));
194
- print_array("Alice public key", pub_key_a, ARRAY_SIZE(pub_key_a));
195
-
196
- /**
197
- * \brief Bob ECDH public and private keys.
198
- */
199
- size_t priv_key_len_b = 0;
200
- uint8_t priv_key_b[X25519_KEY_SIZE] = { 0 };
201
-
202
- size_t pub_key_len_b = 0;
203
- uint8_t pub_key_b[X25519_KEY_SIZE] = { 0 };
204
-
205
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_MAKE_KEY_PAIR, NULL, 0,
206
- &key_id_b);
207
- assert(EDHOC_SUCCESS == ret);
208
-
209
- ret = edhoc_crypto->make_key_pair(NULL, &key_id_b, priv_key_b,
210
- ARRAY_SIZE(priv_key_b),
211
- &priv_key_len_b, pub_key_b,
212
- ARRAY_SIZE(pub_key_b),
213
- &pub_key_len_b);
214
- assert(EDHOC_SUCCESS == ret);
215
- assert(ARRAY_SIZE(priv_key_b) == priv_key_len_b);
216
- assert(ARRAY_SIZE(pub_key_b) == pub_key_len_b);
217
-
218
- ret = edhoc_keys->destroy_key(NULL, &key_id_b);
219
- assert(EDHOC_SUCCESS == ret);
220
-
221
- print_array("Bob private key", priv_key_b, ARRAY_SIZE(priv_key_b));
222
- print_array("Bob public key", pub_key_b, ARRAY_SIZE(pub_key_b));
223
-
224
- /**
225
- * \brief Shared secret for Alice:
226
- * - Alice ECDH private key.
227
- * - Bob ECDH public key.
228
- */
229
- size_t shr_sec_len_a = 0;
230
- uint8_t shr_sec_a[X25519_SHARED_SIZE] = { 0 };
231
-
232
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_KEY_AGREEMENT, priv_key_a,
233
- priv_key_len_a, &key_id_a);
234
- assert(EDHOC_SUCCESS == ret);
235
-
236
- ret = edhoc_crypto->key_agreement(NULL, &key_id_a, pub_key_b,
237
- pub_key_len_b, shr_sec_a,
238
- ARRAY_SIZE(shr_sec_a),
239
- &shr_sec_len_a);
240
- assert(EDHOC_SUCCESS == ret);
241
- assert(ARRAY_SIZE(shr_sec_a) == shr_sec_len_a);
242
-
243
- ret = edhoc_keys->destroy_key(NULL, &key_id_a);
244
- assert(EDHOC_SUCCESS == ret);
245
-
246
- print_array("Alice shared secret", shr_sec_a, shr_sec_len_a);
247
-
248
- /**
249
- * \brief Shared secret for Bob:
250
- * - Bob ECDH private key.
251
- * - Alice ECDH public key.
252
- */
253
- size_t shr_sec_len_b = 0;
254
- uint8_t shr_sec_b[X25519_SHARED_SIZE] = { 0 };
255
-
256
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_KEY_AGREEMENT, priv_key_b,
257
- priv_key_len_b, &key_id_b);
258
- assert(EDHOC_SUCCESS == ret);
259
-
260
- ret = edhoc_crypto->key_agreement(NULL, &key_id_b, pub_key_a,
261
- pub_key_len_a, shr_sec_b,
262
- ARRAY_SIZE(shr_sec_b),
263
- &shr_sec_len_b);
264
- assert(EDHOC_SUCCESS == ret);
265
- assert(ARRAY_SIZE(shr_sec_b) == shr_sec_len_b);
266
-
267
- ret = edhoc_keys->destroy_key(NULL, &key_id_b);
268
- assert(PSA_SUCCESS == ret);
269
-
270
- print_array("Bob shared secret", shr_sec_b, shr_sec_len_b);
271
-
272
- /**
273
- * \brief Compare if Alice and Bob has the same shared secrets.
274
- */
275
- assert(shr_sec_len_a == shr_sec_len_b);
276
- assert(0 == memcmp(shr_sec_a, shr_sec_b, shr_sec_len_a));
277
-
278
- /**
279
- * \brief Compare if Alice and Bob has not the same ECDH keys.
280
- */
281
- assert(priv_key_len_a == priv_key_len_b);
282
- assert(0 != memcmp(priv_key_a, priv_key_b, priv_key_len_a));
283
-
284
- assert(pub_key_len_a == pub_key_len_b);
285
- assert(0 != memcmp(pub_key_a, pub_key_b, pub_key_len_a));
286
- }
287
-
288
- void test_cipher_suite_0_hkdf(void)
289
- {
290
- int ret = PSA_ERROR_GENERIC_ERROR;
291
- psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
292
-
293
- const struct edhoc_keys *edhoc_keys = &keys;
294
- const struct edhoc_crypto *edhoc_crypto = &crypto;
295
-
296
- /**
297
- * \brief Test vectors taken from RFC 5869: A.1. Test Case 1.
298
- */
299
- const uint8_t ikm[] = {
300
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
301
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
302
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
303
- };
304
-
305
- const uint8_t salt[] = {
306
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
307
- 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
308
- };
309
-
310
- const uint8_t info[] = {
311
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
312
- };
313
-
314
- const size_t L = 42;
315
-
316
- const uint8_t prk[] = {
317
- 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf,
318
- 0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63,
319
- 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31,
320
- 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5,
321
- };
322
-
323
- const uint8_t okm[] = {
324
- 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90,
325
- 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d,
326
- 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, 0x5d, 0xb0, 0x2d,
327
- 0x56, 0xec, 0xc4, 0xc5, 0xbf, 0x34, 0x00, 0x72, 0x08,
328
- 0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65,
329
- };
330
-
331
- /**
332
- * \brief HDFK extract part.
333
- */
334
- size_t comp_prk_len = 0;
335
- uint8_t comp_prk[32] = { 0 };
336
-
337
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_EXTRACT, ikm,
338
- ARRAY_SIZE(ikm), &key_id);
339
- assert(EDHOC_SUCCESS == ret);
340
-
341
- ret = edhoc_crypto->extract(NULL, &key_id, salt, ARRAY_SIZE(salt),
342
- comp_prk, ARRAY_SIZE(comp_prk),
343
- &comp_prk_len);
344
- assert(EDHOC_SUCCESS == ret);
345
- assert(ARRAY_SIZE(comp_prk) == comp_prk_len);
346
-
347
- ret = edhoc_keys->destroy_key(NULL, &key_id);
348
- assert(EDHOC_SUCCESS == ret);
349
-
350
- assert(comp_prk_len == ARRAY_SIZE(prk));
351
- assert(0 == memcmp(comp_prk, prk, comp_prk_len));
352
-
353
- /**
354
- * \brief HDFK expand part.
355
- */
356
- uint8_t comp_okm[L];
357
- memset(comp_okm, 0, sizeof(comp_okm));
358
-
359
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_EXPAND, comp_prk,
360
- ARRAY_SIZE(comp_prk), &key_id);
361
- assert(EDHOC_SUCCESS == ret);
362
-
363
- ret = edhoc_crypto->expand(NULL, &key_id, info, ARRAY_SIZE(info),
364
- comp_okm, ARRAY_SIZE(comp_okm));
365
- assert(EDHOC_SUCCESS == ret);
366
-
367
- ret = edhoc_keys->destroy_key(NULL, &key_id);
368
- assert(EDHOC_SUCCESS == ret);
369
-
370
- assert(0 == memcmp(comp_okm, okm, ARRAY_SIZE(okm)));
371
- }
372
-
373
- void test_cipher_suite_0_aead(void)
374
- {
375
- int ret = PSA_ERROR_GENERIC_ERROR;
376
- psa_key_id_t key_id = PSA_KEY_HANDLE_INIT;
377
-
378
- const struct edhoc_keys *edhoc_keys = &keys;
379
- const struct edhoc_crypto *edhoc_crypto = &crypto;
380
-
381
- /**
382
- * \brief AEAD key, iv and aad.
383
- */
384
- const uint8_t key[16] = {
385
- 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
386
- };
387
- const uint8_t iv[13] = {
388
- 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2,
389
- };
390
- const uint8_t aad[4] = {
391
- 0,
392
- 1,
393
- 2,
394
- 3,
395
- };
396
-
397
- /**
398
- * \brief AEAD encryption.
399
- */
400
- const uint8_t ptxt[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
401
-
402
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_ENCRYPT, key,
403
- ARRAY_SIZE(key), &key_id);
404
- assert(EDHOC_SUCCESS == ret);
405
-
406
- size_t ctxt_len = 0;
407
- uint8_t ctxt[18] = { 0 };
408
- ret = edhoc_crypto->encrypt(NULL, &key_id, iv, ARRAY_SIZE(iv), aad,
409
- ARRAY_SIZE(aad), ptxt, ARRAY_SIZE(ptxt),
410
- ctxt, ARRAY_SIZE(ctxt), &ctxt_len);
411
- assert(EDHOC_SUCCESS == ret);
412
- assert(ARRAY_SIZE(ctxt) == ctxt_len);
413
-
414
- ret = edhoc_keys->destroy_key(NULL, &key_id);
415
- assert(EDHOC_SUCCESS == ret);
416
-
417
- /**
418
- * \brief AEAD decryption.
419
- */
420
- size_t dec_ctxt_len = 0;
421
- uint8_t dec_ctxt[ARRAY_SIZE(ptxt)] = { 0 };
422
-
423
- ret = edhoc_keys->generate_key(NULL, EDHOC_KT_DECRYPT, key,
424
- ARRAY_SIZE(key), &key_id);
425
- assert(EDHOC_SUCCESS == ret);
426
-
427
- ret = edhoc_crypto->decrypt(NULL, &key_id, iv, ARRAY_SIZE(iv), aad,
428
- ARRAY_SIZE(aad), ctxt, ctxt_len, dec_ctxt,
429
- ARRAY_SIZE(dec_ctxt), &dec_ctxt_len);
430
- assert(EDHOC_SUCCESS == ret);
431
- assert(ARRAY_SIZE(ptxt) == dec_ctxt_len);
432
-
433
- ret = edhoc_keys->destroy_key(NULL, &key_id);
434
- assert(EDHOC_SUCCESS == ret);
435
-
436
- /**
437
- * \brief Verify if plaintext is equal to decrypted ciphertext.
438
- */
439
- assert(0 == memcmp(ptxt, dec_ctxt, ARRAY_SIZE(ptxt)));
440
- }
441
-
442
- void test_cipher_suite_0_hash(void)
443
- {
444
- int ret = PSA_ERROR_GENERIC_ERROR;
445
-
446
- const struct edhoc_crypto *edhoc_crypto = &crypto;
447
-
448
- /**
449
- * \brief Input for hash function and expected hash.
450
- */
451
- const uint8_t input[] = { 'A' };
452
-
453
- const uint8_t exp_hash[32] = {
454
- 0x55, 0x9a, 0xea, 0xd0, 0x82, 0x64, 0xd5, 0x79,
455
- 0x5d, 0x39, 0x09, 0x71, 0x8c, 0xdd, 0x05, 0xab,
456
- 0xd4, 0x95, 0x72, 0xe8, 0x4f, 0xe5, 0x55, 0x90,
457
- 0xee, 0xf3, 0x1a, 0x88, 0xa0, 0x8f, 0xdf, 0xfd,
458
- };
459
-
460
- /**
461
- * \brief Hash operation.
462
- */
463
- size_t hash_len = 0;
464
- uint8_t hash[32] = { 0 };
465
-
466
- ret = edhoc_crypto->hash(NULL, input, ARRAY_SIZE(input), hash,
467
- ARRAY_SIZE(hash), &hash_len);
468
- assert(EDHOC_SUCCESS == ret);
469
- assert(ARRAY_SIZE(hash) == hash_len);
470
-
471
- /**
472
- * \brief Verify if hashes are equals.
473
- */
474
- assert(0 == memcmp(hash, exp_hash, ARRAY_SIZE(exp_hash)));
475
- }