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/oscore_aad_array.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_aad_array(zcbor_state_t *state, const struct aad_array *input);
20 
21 
encode_aad_array(zcbor_state_t * state,const struct aad_array * input)22 static bool encode_aad_array(
23 		zcbor_state_t *state, const struct aad_array *input)
24 {
25 	zcbor_log("%s\r\n", __func__);
26 
27 	bool tmp_result = (((zcbor_list_start_encode(state, 5) && ((((zcbor_uint32_encode(state, (&(*input).aad_array_oscore_version))))
28 	&& ((zcbor_list_start_encode(state, 1) && ((((((*input).aad_array_algorithms_alg_aead_choice == aad_array_algorithms_alg_aead_int_c) ? ((zcbor_int32_encode(state, (&(*input).aad_array_algorithms_alg_aead_int))))
29 	: (((*input).aad_array_algorithms_alg_aead_choice == aad_array_algorithms_alg_aead_tstr_c) ? ((zcbor_tstr_encode(state, (&(*input).aad_array_algorithms_alg_aead_tstr))))
30 	: false)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 1)))
31 	&& ((zcbor_bstr_encode(state, (&(*input).aad_array_request_kid))))
32 	&& ((zcbor_bstr_encode(state, (&(*input).aad_array_request_piv))))
33 	&& ((zcbor_bstr_encode(state, (&(*input).aad_array_options))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5))));
34 
35 	if (!tmp_result) {
36 		zcbor_trace_file(state);
37 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
38 	} else {
39 		zcbor_log("%s success\r\n", __func__);
40 	}
41 
42 	return tmp_result;
43 }
44 
45 
46 
cbor_encode_aad_array(uint8_t * payload,size_t payload_len,const struct aad_array * input,size_t * payload_len_out)47 int cbor_encode_aad_array(
48 		uint8_t *payload, size_t payload_len,
49 		const struct aad_array *input,
50 		size_t *payload_len_out)
51 {
52 	zcbor_state_t states[5];
53 
54 	return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
55 		(zcbor_decoder_t *)encode_aad_array, sizeof(states) / sizeof(zcbor_state_t), 1);
56 }
57