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_th4.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_th4(zcbor_state_t * state,const struct th4 * input)19 static bool encode_th4(
20 		zcbor_state_t *state, const struct th4 *input)
21 {
22 	zcbor_print("%s\r\n", __func__);
23 
24 	bool tmp_result = (((((zcbor_bstr_encode(state, (&(*input)._th4_th_3))))
25 	&& ((zcbor_bstr_encode(state, (&(*input)._th4_CIPHERTEXT_3)))))));
26 
27 	if (!tmp_result)
28 		zcbor_trace();
29 
30 	return tmp_result;
31 }
32 
33 
34 
cbor_encode_th4(uint8_t * payload,size_t payload_len,const struct th4 * input,size_t * payload_len_out)35 bool cbor_encode_th4(
36 		uint8_t *payload, size_t payload_len,
37 		const struct th4 *input,
38 		size_t *payload_len_out)
39 {
40 	zcbor_state_t states[2];
41 
42 	zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 2);
43 
44 	bool ret = encode_th4(states, input);
45 
46 	if (ret && (payload_len_out != NULL)) {
47 		*payload_len_out = MIN(payload_len,
48 				(size_t)states[0].payload - (size_t)payload);
49 	}
50 
51 	return ret;
52 }
53