package asn1-combinators

  1. Overview
  2. Docs
Embed typed ASN.1 grammars in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

asn1-combinators-0.3.2.tbz
sha256=2b26985f6e2722073dcd9f84355bd6757e12643b5a48e30b3c07ff7cfb0d8a7f
sha512=8ca5a9dfa080cd2e6c3ef05a232e90916df921b09e8445728c6b46438d39056ccb8cd61325f3858490f032a17620a0de17f9d910fd8f0cabe961b02bc76a2eca

doc/asn1-combinators/Asn/index.html

Module AsnSource

Embed typed ASN.1 grammars in OCaml

Skip the notation part of Abstract Syntax Notation, and embed the abstract syntax directly in OCaml.

References

v0.3.2 — homepage

Object identifiers

Sourcetype oid

ASN.1 OBJECT IDENTIFIER.

Sourcemodule OID : sig ... end

Object identifiers.

ASN.1 Abstract Syntax

Sourcetype 'a t

Abstract syntax of values of type 'a.

Sourcemodule S : sig ... end

ASN.1 Abstract Syntax.

Encoding formats

Sourcetype encoding
Sourceval ber : encoding

ber is ASN.1 Basic Encoding Rules (BER).

Sourceval der : encoding

der is ASN.1 Distinguished Encoding Rules (DER).

Encoding and decoding

Sourcetype 'a codec
Sourceexception Ambiguous_syntax
Sourceval codec : encoding -> 'a t -> 'a codec

codec enc asn represents the syntax asn encoded under the rules enc.

This function performs work up-front, and is generally expected to be called in the static context on statically known syntaxes.

  • raises Ambiguous_syntax

    if asn contains CHOICE constructs over sub-syntaxes with the same tags.

Sourceval encode : 'a codec -> 'a -> string

encode codec x is the encoding of x, using codec.

Sourceval encode_into : 'a codec -> 'a -> int * (bytes -> unit)

encode_into codec x is the pair (n, f), where n is the length of x encoded with codec, and f is a function that will write the encoded x to the first n bytes of the provided bytes.

Sourcetype error = [
  1. | `Parse of string
]

Parse errors.

Sourceval pp_error : Format.formatter -> error -> unit

pp_error ppf err pretty-prints err on ppf.

Sourceval decode : 'a codec -> string -> ('a * string, error) result

decode codec cs is the pair (x, cs'), where x is the result of decoding the prefix of cs with codec and cs' are the trailing bytes, or an error.

Misc

Sourceval random : 'a t -> 'a

random asn is a random inhabitant of 'a.

OCaml

Innovation. Community. Security.