encode.bend checks
raw source on the hub · import 0xeb25eff332574f4f1d48668b83cdda30/encode.bend as Encode
bend-osdev-asn1, the encoder: elements as identifier octets, definite length octets in the fewest octets, and contents octets (ITU-T X.690 (02/2021) 8.1.1, 8.1.2, 8.1.3; 10.1), a constructed element's contents being its elements' encodings in order. The elements are written as given: a SET's order is the caller's (Asn1.set_of in build.bend sorts it).
Some values have no encoding, and Asn1.encode refuses them: a tag [UNIVERSAL 0], which X.680 (02/2021) Table 1 reserves for the encoding rules (Asn1ReservedTag); and, as this implementation bounds the numbers it reads (number.bend), a tag number of more than six base-128 octets (Asn1BadTag) and contents of 2^48 octets or more (Asn1TooLong).
6 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import ./error.bend as E import ./tag.bend as T import ./length.bend as L import ./node.bend as N
Definitions
def a1.app source · line 19 · raw
@xs:List<&2, U32> -> @ys:List<&2, U32> -> List<&2, U32>
def a1.tlv source · line 23 · raw
@c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @cons:Bool -> @+n:Nat -> @+cs:List<&2, U32> -> @rest:List<&2, U32> -> List<&2, U32>
an element's header, then its contents octets cs, then rest
def a1.enc_list source · line 27 · raw
@ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> @tail:List<&2, U32> -> List<&2, U32>
the encodings of elements ns, then tail
def a1.is_univ0 source · line 38 · raw
@c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @n:Nat -> Bool
def a1.node_err.pick source · line 49 · raw
@u0:Bool -> @idok:Bool -> @ok:Bool -> Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>
def a1.node_err source · line 60 · raw
@+c:0xeb25eff332574f4f1d48668b83cdda30/tag.Asn1Class -> @+n:Nat -> @+len:Nat -> Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>
def a1.first source · line 63 · raw
@a:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @b:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>
def a1.enc_err source · line 71 · raw
@ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error>
the first error of elements ns (None: they can be encoded)
def a1.encode.go source · line 80 · raw
@m:Maybe<&2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error> -> @+ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>
def Asn1.encode_all source · line 88 · raw
@+ns:List<&2, 0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node> -> Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>
the DER encodings of elements, one after another
def Asn1.encode source · line 93 · raw
@+n:0xeb25eff332574f4f1d48668b83cdda30/node.Asn1Node -> Result<&2, &2, 0xeb25eff332574f4f1d48668b83cdda30/error.Asn1Error, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>
an element's encoding (DER when its SETs are in order, and its universal types in their forms: conform.bend)