blob: 1359b93aef0bc56d0c3c8b3c3fb95b16b5ed7f99 [file] [log] [blame]
AKASHI Takahiro111dc6f2019-11-13 09:44:56 +09001ASN1
2====
3
4Abstract Syntax Notation One (or ASN1) is a standard by ITU-T and ISO/IEC
5and used as a description language for defining data structure in
6an independent manner.
7Any data described in ASN1 notation can be serialized (or encoded) and
8de-serialized (or decoded) with well-defined encoding rules.
9
10A combination of ASN1 compiler and ASN1 decoder library function will
11provide a function interface for parsing encoded binary into specific
12data structure:
131) define data structure in a text file (*.asn1)
142) define "action" routines for specific "tags" defined in (1)
153) generate bytecode as a C file (*.asn1.[ch]) from *.asn1 file
16 with ASN1 compiler (tools/asn1_compiler)
174) call a ASN1 decoder (asn1_ber_decoder()) with bytecode and data
18
19Usage of ASN1 compiler
20----------------------
21 asn1_compiler [-v] [-d] <grammar-file> <c-file> <hdr-file>
22
23 <grammar-file>: ASN1 input file
24 <c-file>: generated C file
25 <hdr-file>: generated include file
26
27Usage of ASN1 decoder
28---------------------
29 int asn1_ber_decoder(const struct asn1_decoder *decoder, void *context,
30 const unsigned char *data, size_t datalen);
31
32 @decoder: bytecode binary
33 @context: context for decoder
34 @data: data to be parsed
35 @datalen: size of data
36
37
38As of writing this, ASN1 compiler and decoder are used to implement
39X509 certificate parser, pcks7 message parser and RSA public key parser
40for UEFI secure boot.