1 /*
2    Copyright (c) 2021 Fraunhofer AISEC. See the COPYRIGHT
3    file at the top-level directory of this distribution.
4 
5    Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6    http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7    <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8    option. This file may not be copied, modified, or distributed
9    except according to those terms.
10 */
11 
12 #include <string.h>
13 
14 #include "edhoc_internal.h"
15 
16 #include "edhoc/runtime_context.h"
17 
runtime_context_init(struct runtime_context * c)18 void runtime_context_init(struct runtime_context *c)
19 {
20 	c->msg.len = sizeof(c->msg_buf);
21 	c->msg.ptr = c->msg_buf;
22 
23 #if EAD_SIZE != 0
24 	c->ead.len = sizeof(c->ead_buf);
25 	c->ead.ptr = c->ead_buf;
26 #else
27 	c->ead.len = 0;
28 	c->ead.ptr = NULL;
29 #endif
30 	c->msg1_hash.ptr = c->msg1_hash_buf;
31 	c->msg1_hash.len = sizeof(c->msg1_hash_buf);
32 
33 	c->th3.ptr = c->th3_buf;
34 	c->th3.len = sizeof(c->th3_buf);
35 	c->prk_3e2m.ptr = c->prk_3e2m_buf;
36 	c->prk_3e2m.len = sizeof(c->prk_3e2m_buf);
37 
38 	c->th4.ptr = c->th4_buf;
39 	c->th4.len = sizeof(c->th4_buf);
40 	c->prk_4e3m.ptr = c->prk_4e3m_buf;
41 	c->prk_4e3m.len = sizeof(c->prk_4e3m_buf);
42 }
43