1 /*
2  * Generated using zcbor version 0.3.99
3  * https://github.com/NordicSemiconductor/zcbor
4  * Generated with a --default-max-qty of 3
5  */
6 
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <string.h>
11 #include "zcbor_encode.h"
12 #include "cbor/edhoc_encode_sig_structure.h"
13 
14 #if DEFAULT_MAX_QTY != 3
15 #error "The type file was generated with a different default_max_qty than this file"
16 #endif
17 
18 
encode_sig_structure(zcbor_state_t * state,const struct sig_structure * input)19 static bool encode_sig_structure(
20 		zcbor_state_t *state, const struct sig_structure *input)
21 {
22 	zcbor_print("%s\r\n", __func__);
23 	bool int_res;
24 
25 	bool tmp_result = (((zcbor_list_start_encode(state, 4) && (int_res = (((zcbor_tstr_encode(state, (&(*input)._sig_structure_context))))
26 	&& ((zcbor_bstr_encode(state, (&(*input)._sig_structure_protected))))
27 	&& ((zcbor_bstr_encode(state, (&(*input)._sig_structure_external_aad))))
28 	&& ((zcbor_bstr_encode(state, (&(*input)._sig_structure_payload))))), ((zcbor_list_end_encode(state, 4)) && int_res)))));
29 
30 	if (!tmp_result)
31 		zcbor_trace();
32 
33 	return tmp_result;
34 }
35 
36 
37 
cbor_encode_sig_structure(uint8_t * payload,size_t payload_len,const struct sig_structure * input,size_t * payload_len_out)38 bool cbor_encode_sig_structure(
39 		uint8_t *payload, size_t payload_len,
40 		const struct sig_structure *input,
41 		size_t *payload_len_out)
42 {
43 	zcbor_state_t states[3];
44 
45 	zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1);
46 
47 	bool ret = encode_sig_structure(states, input);
48 
49 	if (ret && (payload_len_out != NULL)) {
50 		*payload_len_out = MIN(payload_len,
51 				(size_t)states[0].payload - (size_t)payload);
52 	}
53 
54 	return ret;
55 }
56