1 #include <edhoc.h>
2 #include <zephyr/ztest.h>
3 #include <zephyr/debug/thread_analyzer.h>
4 #include "edhoc_test_vectors_exporter_v15.h"
5
test_exporter(void)6 void test_exporter(void)
7 {
8 enum err err;
9
10 uint8_t prk_exporter_buf[32];
11 struct byte_array prk_exporter = { .ptr = prk_exporter_buf,
12 .len = sizeof(prk_exporter_buf) };
13
14 uint8_t prk_out_new_buf[32];
15 struct byte_array prk_out_new = { .ptr = prk_out_new_buf,
16 .len = sizeof(prk_out_new_buf) };
17
18 uint8_t master_secret_buf[16];
19 struct byte_array master_secret = { .ptr = master_secret_buf,
20 .len = sizeof(master_secret_buf) };
21
22 uint8_t master_salt_buf[8];
23 struct byte_array master_salt = { .ptr = master_salt_buf,
24 .len = sizeof(master_salt_buf) };
25
26 struct byte_array prk_out = { .ptr = T1_PRK_OUT,
27 .len = sizeof(T1_PRK_OUT) };
28 struct byte_array context = { .ptr = T1_KEY_UPDATE_CONTEXT,
29 .len = sizeof(T1_KEY_UPDATE_CONTEXT) };
30 /***/
31 /***/
32 err = prk_out_update(SHA_256, &prk_out, &context, &prk_out_new);
33
34 zassert_true(err == 0, "prk_out_update failed");
35 zassert_mem_equal__(T1_PRK_OUT_NEW, prk_out_new.ptr, prk_out_new.len,
36 "wrong prk_out_new");
37 /***/
38 /***/
39 err = prk_out2exporter(SHA_256, &prk_out, &prk_exporter);
40
41 zassert_true(err == 0, "prk_out2exporter failed");
42 zassert_mem_equal__(T1_PRK_EXPORTER, prk_exporter.ptr, prk_exporter.len,
43 "wrong prk_exporter");
44 /***/
45 /***/
46 err = edhoc_exporter(SHA_256, OSCORE_MASTER_SECRET, &prk_exporter,
47 &master_secret);
48 zassert_true(err == 0, "edhoc_exporter failed");
49 zassert_mem_equal__(T1_OSCORE_MASTER_SECRET, master_secret.ptr,
50 master_secret.len, "wrong master_secret");
51 /***/
52 /***/
53 err = edhoc_exporter(SHA_256, OSCORE_MASTER_SALT, &prk_exporter,
54 &master_salt);
55 zassert_true(err == 0, "edhoc_exporter failed");
56 zassert_mem_equal__(T1_OSCORE_MASTER_SALT, master_salt.ptr,
57 master_salt.len, "wrong master_salt");
58
59 #ifdef REPORT_STACK_USAGE
60 thread_analyzer_print();
61 #endif
62 }
63