1 /*
2  * Generated using zcbor version 0.8.0
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_th2.h"
13 #include "zcbor_print.h"
14 
15 #if DEFAULT_MAX_QTY != 3
16 #error "The type file was generated with a different default_max_qty than this file"
17 #endif
18 
19 static bool encode_th2(zcbor_state_t *state, const struct th2 *input);
20 
21 
encode_th2(zcbor_state_t * state,const struct th2 * input)22 static bool encode_th2(
23 		zcbor_state_t *state, const struct th2 *input)
24 {
25 	zcbor_log("%s\r\n", __func__);
26 
27 	bool tmp_result = (((((zcbor_bstr_encode(state, (&(*input).th2_G_Y))))
28 	&& ((((*input).th2_C_R_choice == th2_C_R_bstr_c) ? ((zcbor_bstr_encode(state, (&(*input).th2_C_R_bstr))))
29 	: (((*input).th2_C_R_choice == th2_C_R_int_c) ? ((zcbor_int32_encode(state, (&(*input).th2_C_R_int))))
30 	: false)))
31 	&& ((zcbor_bstr_encode(state, (&(*input).th2_hash_msg1)))))));
32 
33 	if (!tmp_result) {
34 		zcbor_trace_file(state);
35 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
36 	} else {
37 		zcbor_log("%s success\r\n", __func__);
38 	}
39 
40 	return tmp_result;
41 }
42 
43 
44 
cbor_encode_th2(uint8_t * payload,size_t payload_len,const struct th2 * input,size_t * payload_len_out)45 int cbor_encode_th2(
46 		uint8_t *payload, size_t payload_len,
47 		const struct th2 *input,
48 		size_t *payload_len_out)
49 {
50 	zcbor_state_t states[3];
51 
52 	return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
53 		(zcbor_decoder_t *)encode_th2, sizeof(states) / sizeof(zcbor_state_t), 3);
54 }
55