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_decode.h"
12 #include "cbor/edhoc_decode_cert.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 decode_cert(zcbor_state_t *state, struct cert *result);
20
21
decode_cert(zcbor_state_t * state,struct cert * result)22 static bool decode_cert(
23 zcbor_state_t *state, struct cert *result)
24 {
25 zcbor_log("%s\r\n", __func__);
26
27 bool tmp_result = (((((zcbor_int32_decode(state, (&(*result).cert_type))))
28 && ((zcbor_int32_decode(state, (&(*result).cert_serial_number))))
29 && ((zcbor_tstr_decode(state, (&(*result).cert_issuer))))
30 && ((zcbor_int32_decode(state, (&(*result).cert_validity_not_before))))
31 && ((zcbor_int32_decode(state, (&(*result).cert_validity_not_after))))
32 && ((zcbor_bstr_decode(state, (&(*result).cert_subject))))
33 && ((zcbor_int32_decode(state, (&(*result).cert_subject_public_key_algorithm))))
34 && ((zcbor_bstr_decode(state, (&(*result).cert_pk))))
35 && ((zcbor_int32_decode(state, (&(*result).cert_extensions))))
36 && ((zcbor_int32_decode(state, (&(*result).cert_issuer_signature_algorithm))))
37 && ((zcbor_bstr_decode(state, (&(*result).cert_signature)))))));
38
39 if (!tmp_result) {
40 zcbor_trace_file(state);
41 zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
42 } else {
43 zcbor_log("%s success\r\n", __func__);
44 }
45
46 return tmp_result;
47 }
48
49
50
cbor_decode_cert(const uint8_t * payload,size_t payload_len,struct cert * result,size_t * payload_len_out)51 int cbor_decode_cert(
52 const uint8_t *payload, size_t payload_len,
53 struct cert *result,
54 size_t *payload_len_out)
55 {
56 zcbor_state_t states[2];
57
58 return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
59 (zcbor_decoder_t *)decode_cert, sizeof(states) / sizeof(zcbor_state_t), 11);
60 }
61