README.asn1 1.4 KB

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