Branch data Line data Source code
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 <edhoc.h>
13 : : #include <stdbool.h>
14 : : #include <string.h>
15 : : #include "edhoc_tests.h"
16 : : bool rx_initiator_switch = false;
17 : :
18 : : static uint8_t msg_cnt;
19 : :
20 : 0 : void rx_init(void)
21 : : {
22 : 0 : msg_cnt = 1;
23 : 0 : }
24 : :
25 : 0 : enum err rx(void *sock, uint8_t *data, uint32_t *data_len)
26 : : {
27 [ # # ]: 0 : if (rx_initiator_switch) {
28 : 0 : PRINTF("TXRX wrapper test vectors\n");
29 : : /*The initiator must get msg2 and msg4*/
30 [ # # ]: 0 : if (msg_cnt == 1) {
31 : : /*message 2*/
32 [ # # ]: 0 : TRY(_memcpy_s(data, *data_len, m.m2, m.m2_len));
33 : 0 : *data_len = m.m2_len;
34 : 0 : msg_cnt++;
35 : : } else {
36 : : /*message 4*/
37 [ # # ]: 0 : TRY(_memcpy_s(data, *data_len, m.m4, m.m4_len));
38 : 0 : *data_len = m.m4_len;
39 : 0 : msg_cnt = 1;
40 : : }
41 : : } else {
42 : 0 : PRINTF("TXRX wrapper test vectors\n");
43 : :
44 : : /*The responder must get msg1 and msg3*/
45 [ # # ]: 0 : if (msg_cnt == 1) {
46 : : /*message 1 */
47 [ # # ]: 0 : TRY(_memcpy_s(data, *data_len, m.m1, m.m1_len));
48 : 0 : *data_len = m.m1_len;
49 : 0 : msg_cnt++;
50 : : } else {
51 : : /*message 3*/
52 [ # # ]: 0 : TRY(_memcpy_s(data, *data_len, m.m3, m.m3_len));
53 : 0 : *data_len = m.m3_len;
54 : 0 : msg_cnt = 1;
55 : : }
56 : : }
57 : : return ok;
58 : : }
59 : :
60 : 0 : enum err tx(void *sock, uint8_t *data, uint32_t data_len)
61 : : { //todo add here a test
62 : 0 : return ok;
63 : : }
|