class

Beryl::Encoding::DistinguishedEncodingRules::Reader

Inherits Reference < Object

Reads the elements of one input, or of the contents of one constructed element, front to back.

Constructors

new(bytes : Bytes, limits : Limits = Limits.new)

Reads bytes (the outermost input). Raises LimitExceeded when it is larger than limits allow.

Source

Instance methods

at_end?
Source
bytes_left
Source
check_universal_contents(element : Element) : Nil

Checks element (already read), and everything inside it, for contents its universal type allows: a BOOLEAN of 0x00 or 0xFF, a minimal INTEGER or ENUMERATED, a valid BIT STRING, an empty NULL, a well-formed OBJECT IDENTIFIER, a UTCTime or GeneralizedTime in its DER form, SEQUENCE and SET constructed and every other universal type primitive. Tags of the other classes are left uninterpreted. For values Beryl keeps without reading, such as the parameters of a key algorithm it does not use. Raises MalformedEncoding.

Source
depth
Source
enter(element : Element, & : Reader -> T) : T forall T

Yields a reader over the contents of element (already read), one level deeper, and requires it to be read to the end.

Source
enter_encapsulated(element : Element, bytes : Bytes, & : Reader -> T) : T forall T

Yields a reader over bytes that sit inside an element read earlier (the contents of an OCTET STRING or BIT STRING that hold DER of their own), one level deeper.

Source
finish

Raises unless every byte has been read.

Source
limits
Source
next_is?(tag : Tag) : Bool

Returns whether the next element has tag.

Source
peek_tag

Returns the tag of the next element without reading it, or nil at the end.

Source
read_bit_string(tag : Tag = BIT_STRING) : BitString

Reads a BIT STRING.

Source
read_boolean(tag : Tag = BOOLEAN) : Bool

Reads a BOOLEAN (only 0x00 and 0xFF are DER).

Source
read_byte_aligned_bit_string(tag : Tag = BIT_STRING) : Bytes

Reads a BIT STRING that must hold whole bytes, such as a public key or a signature.

Source
read_constructed(tag : Tag, & : Reader -> T) : T forall T

Reads a constructed element with tag and yields a reader over its contents, which must be read to the end. Returns the block's value.

Source
read_element(tag : Tag) : Element

Reads the next element and raises unless its tag is tag.

Source
read_element

Reads the next element, whatever its tag.

Source
read_integer_bytes(tag : Tag = INTEGER) : Bytes

Reads an INTEGER and returns its two's-complement contents, checked to be minimal.

Source
read_null

Reads a NULL.

Source
read_object_identifier

Reads an OBJECT IDENTIFIER, checked to be minimal.

Source
read_octet_string(tag : Tag = OCTET_STRING) : Bytes

Reads an OCTET STRING.

Source
read_optional_element(tag : Tag) : Element | Nil

Reads the next element when its tag is tag; otherwise reads nothing and returns nil.

Source
read_sequence

Reads a SEQUENCE and yields a reader over its contents.

Source
read_small_integer(tag : Tag = INTEGER) : Int64

Reads an INTEGER that fits in an Int64.

Source
read_time

Reads a UTCTime or a GeneralizedTime in the forms RFC 5280 ยง4.1.2.5 allows, and returns it in UTC.

Source
read_unsigned_integer_bytes(tag : Tag = INTEGER) : Bytes

Reads an INTEGER that must be zero or positive and returns its magnitude without the sign byte.

Source