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_decode.h"
12 #include "cbor/edhoc_decode_cert.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 
decode_cert(zcbor_state_t * state,struct cert * result)19 static bool decode_cert(
20 		zcbor_state_t *state, struct cert *result)
21 {
22 	zcbor_print("%s\r\n", __func__);
23 
24 	bool tmp_result = (((((zcbor_int32_decode(state, (&(*result)._cert_type))))
25 	&& ((zcbor_int32_decode(state, (&(*result)._cert_serial_number))))
26 	&& ((zcbor_tstr_decode(state, (&(*result)._cert_issuer))))
27 	&& ((zcbor_int32_decode(state, (&(*result)._cert_validity_not_before))))
28 	&& ((zcbor_int32_decode(state, (&(*result)._cert_validity_not_after))))
29 	&& ((zcbor_bstr_decode(state, (&(*result)._cert_subject))))
30 	&& ((zcbor_int32_decode(state, (&(*result)._cert_subject_public_key_algorithm))))
31 	&& ((zcbor_bstr_decode(state, (&(*result)._cert_pk))))
32 	&& ((zcbor_int32_decode(state, (&(*result)._cert_extensions))))
33 	&& ((zcbor_int32_decode(state, (&(*result)._cert_issuer_signature_algorithm))))
34 	&& ((zcbor_bstr_decode(state, (&(*result)._cert_signature)))))));
35 
36 	if (!tmp_result)
37 		zcbor_trace();
38 
39 	return tmp_result;
40 }
41 
42 
43 
cbor_decode_cert(const uint8_t * payload,size_t payload_len,struct cert * result,size_t * payload_len_out)44 bool cbor_decode_cert(
45 		const uint8_t *payload, size_t payload_len,
46 		struct cert *result,
47 		size_t *payload_len_out)
48 {
49 	zcbor_state_t states[2];
50 
51 	zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 11);
52 
53 	bool ret = decode_cert(states, result);
54 
55 	if (ret && (payload_len_out != NULL)) {
56 		*payload_len_out = MIN(payload_len,
57 				(size_t)states[0].payload - (size_t)payload);
58 	}
59 
60 	return ret;
61 }
62