1 #include <edhoc.h>
2 #include <zephyr/ztest.h>
3 #include "edhoc_test_vectors_exporter_v15.h"
4 
test_exporter(void)5 void test_exporter(void)
6 {
7 	enum err err;
8 	uint8_t prk_exporter[32];
9 	uint8_t master_secret[16];
10 	uint8_t master_salt[8];
11 	uint8_t prk_out_new[32];
12 
13 	err = prk_out_update(SHA_256, T1_PRK_OUT, sizeof(T1_PRK_OUT),
14 			     T1_KEY_UPDATE_CONTEXT,
15 			     sizeof(T1_KEY_UPDATE_CONTEXT), prk_out_new);
16 	zassert_true(err == 0, "prk_out_update failed");
17 	zassert_mem_equal__(T1_PRK_OUT_NEW, prk_out_new, sizeof(prk_out_new),
18 			    "wrong prk_out_new");
19 	/***/
20 	/***/
21 	err = prk_out2exporter(SHA_256, T1_PRK_OUT, sizeof(T1_PRK_OUT),
22 			       prk_exporter);
23 	zassert_true(err == 0, "prk_out2exporter failed");
24 	zassert_mem_equal__(T1_PRK_EXPORTER, prk_exporter, sizeof(prk_exporter),
25 			    "wrong prk_exporter");
26 	/***/
27 	/***/
28 	err = edhoc_exporter(SHA_256, OSCORE_MASTER_SECRET, prk_exporter,
29 			     sizeof(prk_exporter), master_secret,
30 			     sizeof(master_secret));
31 	zassert_true(err == 0, "edhoc_exporter failed");
32 	zassert_mem_equal__(T1_OSCORE_MASTER_SECRET, master_secret,
33 			    sizeof(master_secret), "wrong master_secret");
34 	/***/
35 	/***/
36 	err = edhoc_exporter(SHA_256, OSCORE_MASTER_SALT, prk_exporter,
37 			     sizeof(prk_exporter), master_salt,
38 			     sizeof(master_salt));
39 	zassert_true(err == 0, "edhoc_exporter failed");
40 	zassert_mem_equal__(T1_OSCORE_MASTER_SALT, master_salt,
41 			    sizeof(master_salt), "wrong master_salt");
42 }