nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
asn1_decode.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7/* A minimalistic ASN.1 BER/DER decoder (X.690).
8 *
9 * Supported types:
10 * OCTET STRING
11 * SEQUENCE / SEQUENCE OF
12 */
13
14#ifndef ASN1_DECODE_H_
15#define ASN1_DECODE_H_
16
17#include <stdlib.h>
18#include <stdint.h>
19#include <stdbool.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
26#define UP4 0x04
27#define UP6 0x06
28#define UC16 0x30
29#define AP15 0x4F
30#define AP16 0x50
31#define CC1 0xA1
32#define CC7 0xA7
33
35typedef struct {
36 const uint8_t *asnbuf;
37 size_t length;
38 uint32_t offset;
39 bool error;
41
43typedef void (*asn1_sequence_func_t)(asn1_ctx_t *ctx, void *data);
44
54bool asn1_dec_head(asn1_ctx_t *ctx, uint8_t *tag, size_t *len);
55
64void asn1_dec_octet_string(asn1_ctx_t *ctx, size_t len, uint8_t *value, size_t max_len);
65
74void asn1_dec_sequence(asn1_ctx_t *ctx, size_t len, void *data, asn1_sequence_func_t sequence_func);
75
83void asn1_dec_skip(asn1_ctx_t *ctx, size_t len);
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif /* ASN1_DECODE_H_ */
bool asn1_dec_head(asn1_ctx_t *ctx, uint8_t *tag, size_t *len)
Decode ASN.1 header.
void(* asn1_sequence_func_t)(asn1_ctx_t *ctx, void *data)
Definition asn1_decode.h:43
void asn1_dec_sequence(asn1_ctx_t *ctx, size_t len, void *data, asn1_sequence_func_t sequence_func)
Decode ASN.1 SEQUENCE.
void asn1_dec_skip(asn1_ctx_t *ctx, size_t len)
Skip a subset of ASN.1 content. This is used to skip parts of the content which is not of interest.
void asn1_dec_octet_string(asn1_ctx_t *ctx, size_t len, uint8_t *value, size_t max_len)
Decode ASN.1 OCTET STRING.
size_t length
Definition asn1_decode.h:37
const uint8_t * asnbuf
Definition asn1_decode.h:36
uint32_t offset
Definition asn1_decode.h:38
bool error
Definition asn1_decode.h:39
Definition asn1_decode.h:35