package gapi-ocaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type pc =
  1. | Primitive
  2. | Constructed
type value =
  1. | Bool of bool
    (*

    Boolean (primitive)

    *)
  2. | Integer of int_value
    (*

    Integer (primitive)

    *)
  3. | Enum of int_value
    (*

    Enumeration (primitive)

    *)
  4. | Real of real_value
    (*

    Floating-point number, using either base 2 or base 10 (primitive)

    *)
  5. | Bitstring of bitstring_value
    (*

    Bit strings (primitive or constructed)

    *)
  6. | Octetstring of string
    (*

    Octet strings (primitive or constructed)

    *)
  7. | Null
    (*

    Null (primitive)

    *)
  8. | Seq of value list
    (*

    Sequences (records or arrays) (constructed)

    *)
  9. | Set of value list
    (*

    Sets (constructed)

    *)
  10. | Tagptr of tag_class * int * pc * Netstring_tstring.tstring_polybox * int * int
    (*

    Pointer to an undecoded value that was implicitly tagged. The tag_class can be Application, Context, or Private.

    *)
  11. | Tag of tag_class * int * pc * value
    (*

    Explicit tag (primitive or constructed depending on inner value)

    *)
  12. | ITag of tag_class * int * value
    (*

    Implicit tag (never returned by the decoder, but needed for encoding such tags)

    *)
  13. | OID of int array
  14. | ROID of int array
  15. | ObjectDescriptor of string
    (*

    A placeholder with a comment (primitive)

    *)
  16. | External of value list
    (*

    Something complex I don't understand (constructed)

    *)
  17. | Embedded_PDV of value list
    (*

    Something complex I don't understand (constructed)

    *)
  18. | NumericString of string
    (*

    String made of digits and spaces (primitive or constructed)

    *)
  19. | PrintableString of string
    (*

    A small subset of ASCII (primitive or constructed)

    *)
  20. | TeletexString of string
  21. | VideotexString of string
  22. | VisibleString of string
    (*

    7 bit ASCII w/o control characters (primitive or constructed)

    *)
  23. | IA5String of string
    (*

    7 bit ASCII (primitive or constructed)

    *)
  24. | GraphicString of string
    (*

    ISO-2022-encoded string w/o control characters

    *)
  25. | GeneralString of string
    (*

    ISO-2022-encoded string

    *)
  26. | UniversalString of string
    (*

    Any ISO-10646-1 character string represented as UTF-32-BE (primitive or constructed). Roughly, ISO-10646-1 equals to Unicode.

    *)
  27. | BMPString of string
    (*

    Any ISO-10646-1 character string from only the basic multilingual plane, i.e. with code points <= 65535, represented as UTF-16-BE (primitive or constructed)

    *)
  28. | UTF8String of string
    (*

    Any ISO-10646-1 character string represented as UTF-8 (primitive or constructed)

    *)
  29. | CharString of string
    (*

    A complicated description of an arbitrary charset encoding (primitive or constructed)

    *)
  30. | UTCTime of time_value
    (*

    Like GeneralizedTime but less precise, and with 2-digit year

    *)
  31. | GeneralizedTime of time_value
    (*

    Calendar date with time of day, including timezone (primitive)

    *)
and tag_class =
  1. | Universal
  2. | Application
  3. | Context
  4. | Private
and int_value
and real_value
and bitstring_value
and time_value
type time_subtype = [
  1. | `U
  2. | `G
]
val type_of_value : value -> Type_name.type_name option

Returns the type, or None for Tag, ITag and Tagptr

Integer

val get_int_repr : int_value -> string

Get an integer as bytes

val get_int_b256 : int_value -> int array

Get an integer as bytes

Get an integer in base 256 notation, big endian. Negative values are represented using two's complement (i.e. the first array element is >= 128). The empty array means 0.

val get_int : int_value -> int

Get an integer in base 256 notation, big endian. Negative values are represented using two's complement (i.e. the first array element is >= 128). The empty array means 0.

Get an integer as int if representable, or raise Out_of_range

val get_int32 : int_value -> int32

Get an integer as int if representable, or raise Out_of_range

Get an integer as int32 if representable, or raise Out_of_range

val get_int64 : int_value -> int64

Get an integer as int32 if representable, or raise Out_of_range

Get an integer as int64 if representable, or raise Out_of_range

val int : int -> int_value

Get an integer as int64 if representable, or raise Out_of_range

Create an int

val int32 : int32 -> int_value

Create an int

Create an int

val int64 : int64 -> int_value

Create an int

Create an int

val int_b256 : int array -> int_value

Create an int

Create an int from a base 256 number, big endian, signed

Real

Reals are not really supported ;-(

val get_real_repr : real_value -> string

Get the byte representation of the real

Bitstring

In some contexts it is usual that trailing zero bits are truncated.

val get_bitstring_size : bitstring_value -> int

Get the number of bits

val get_bitstring_data : bitstring_value -> string

Get the number of bits

Get the data. The last byte may be partial. The order of the bits in every byte: bit 7 (MSB) contains the first bit

val get_bitstring_bits : ?size:int -> bitstring_value -> bool array

Get the data. The last byte may be partial. The order of the bits in every byte: bit 7 (MSB) contains the first bit

Get the bitstring as bool array. If size is specified the array will have exactly this number of bits (by dropping exceeding data, or by adding false at the end)

val get_bitstring_repr : bitstring_value -> string

Get the bitstring as bool array. If size is specified the array will have exactly this number of bits (by dropping exceeding data, or by adding false at the end)

Get the representation

val bitstring_of_bits : bool array -> bitstring_value

Get the representation

Get the bitstring from a bool array

val bitstring_of_string : string -> int -> bitstring_value

Get the bitstring from a bool array

Get the bitstring from a string and the total number of bits. The bits are taken from the beginning of the string (MSB first). If the string is shorter than the number of bits suggests, the remaining bits are assumed to be zero. If the string is longer than the number of bits suggests, the exceeding data is ignored.

val truncate_trailing_zero_bits : bitstring_value -> bitstring_value

Get the bitstring from a string and the total number of bits. The bits are taken from the beginning of the string (MSB first). If the string is shorter than the number of bits suggests, the remaining bits are assumed to be zero. If the string is longer than the number of bits suggests, the exceeding data is ignored.

Truncates the biggest trailing part that only consist of 0 bits

Time

Time values referring to the local time zone are not supported

val get_time_subtype : time_value -> time_subtype

Whether this is for UTCTime (`U) or GeneralizedTime (`G)

val get_time_repr : time_value -> string

Whether this is for UTCTime (`U) or GeneralizedTime (`G)

Get the raw time string

val get_time : time_value -> Netdate.t

Get the raw time string

Get the time. Notes:

  • UTCTime years are two-digit years, and interpreted so that 0-49 is understood as 2000-2049, and 50-99 is understood as 1950-1999 (as required by X.509).
  • This function is restricted to the time formats occurring in DER (string terminates with "Z", i.e. UTC time zone)
val utctime : Netdate.t -> time_value

Get the time. Notes:

  • UTCTime years are two-digit years, and interpreted so that 0-49 is understood as 2000-2049, and 50-99 is understood as 1950-1999 (as required by X.509).
  • This function is restricted to the time formats occurring in DER (string terminates with "Z", i.e. UTC time zone)

Create a time value for UTCTime. This function is restricted to years between 1950 and 2049.

val gentime : digits:int -> Netdate.t -> time_value

Create a time value for UTCTime. This function is restricted to years between 1950 and 2049.

Create a time value for GeneralizedTime. digits is the number of fractional (subsecond) digits

Equality

val equal : value -> value -> bool

Checks for equality. Notes:

  • Tag and Tagptr are considered different
  • Tagptr is checked by comparing the equality of the substring
  • Set is so far not compared as set, but as sequence (i.e. order matters)
OCaml

Innovation. Community. Security.