der.bend checks
raw source on the hub · import element-asn1@0.1.0.0/der.bend as Der
1 import
import Base
Types
type Tlv source · line 10 · raw
Data
Tlv@tag:U32 -> @body:List<&2, U32> -> @raw:List<&2, U32> -> Tlv
type Next source · line 13 · raw
Data
Got@tlv:Tlv -> @rest:List<&2, U32> -> Next
EndNext
Definitions
def or0 source · line 17 · raw
@m:Maybe<&2, U32> -> U32
def nth source · line 24 · raw
@xs:List<&2, U32> -> @n:Nat -> U32
def zeros source · line 27 · raw
@n:Nat -> List<&2, U32>
def empty source · line 34 · raw
Tlv
def got_if source · line 37 · raw
@ok:Bool -> @+bs:List<&2, U32> -> @+head:Nat -> @+len:Nat -> Next
def head_of source · line 46 · raw
@+l0:U32 -> Nat
The header size and contents length from the first length byte.
def len_of source · line 49 · raw
@+bs:List<&2, U32> -> @+l0:U32 -> U32
def read source · line 56 · raw
@+bs:List<&2, U32> -> Next
The first TLV of bs and what follows it.
def one source · line 62 · raw
@n:Next -> Tlv
def decode source · line 70 · raw
@+bs:List<&2, U32> -> Tlv
Exactly one TLV filling bs (a certificate, an extension value).
def items_go source · line 74 · raw
@fuel:Nat -> @n:Next -> List<&2, Tlv>
Every TLV in a row; fuel bounds the count (each TLV takes at least 2 bytes).
def items source · line 85 · raw
@+bs:List<&2, U32> -> List<&2, Tlv>
def tag source · line 88 · raw
@t:Tlv -> U32
def body source · line 93 · raw
@t:Tlv -> List<&2, U32>
def raw source · line 98 · raw
@t:Tlv -> List<&2, U32>
def kids source · line 104 · raw
@+t:Tlv -> List<&2, Tlv>
The children of a constructed value (SEQUENCE, SET, [n] EXPLICIT).
def or_empty source · line 107 · raw
@m:Maybe<&2, Tlv> -> Tlv
def at source · line 114 · raw
@+ts:List<&2, Tlv> -> @+i:Nat -> Tlv
def kid source · line 117 · raw
@+t:Tlv -> @+i:Nat -> Tlv
def count source · line 120 · raw
@+t:Tlv -> Nat
def same source · line 123 · raw
@xs:List<&2, U32> -> @ys:List<&2, U32> -> Bool
def is_oid source · line 133 · raw
@+t:Tlv -> @+oid:List<&2, U32> -> Bool
An OBJECT IDENTIFIER's contents equal to oid (its DER contents bytes).
def bits source · line 137 · raw
@+t:Tlv -> List<&2, U32>
A BIT STRING's bits as bytes (the leading unused-bits count dropped).
def digit source · line 147 · raw
@+b:U32 -> U32
A byte that is not a digit reads as 0. It used to wrap (b - 48 below '0' is near 2^32), and a certificate's time arrives before the certificate is verified: one malformed date grew past Bend's largest Nat (2^48 - 1) in the date arithmetic and stopped the whole process. Fields are 2 or 4 bytes, so every value now stays below 10^4.
def digits source · line 150 · raw
@bs:List<&2, U32> -> @+acc:Nat -> Nat
def field source · line 157 · raw
@+bs:List<&2, U32> -> @+at:Nat -> @+n:Nat -> Nat
def days_from_civil source · line 162 · raw
@+y0:Nat -> @+m:Nat -> @+d:Nat -> Nat
Days from 1970-01-01 to y-m-d (Howard Hinnant's days_from_civil), clamped at zero for dates before 1970.
def seconds source · line 173 · raw
@+y:Nat -> @+bs:List<&2, U32> -> @+at:Nat -> Nat
UTCTime (YYMMDDHHMMSSZ; YY < 50 is 20YY) or GeneralizedTime (YYYYMMDDHHMMSSZ) as seconds since 1970-01-01 UTC.
def time source · line 179 · raw
@+t:Tlv -> Nat