refactors +parse:der
:: +de:der: decode atom to +spec:asn1
::
++ de
- =< |= [len=@ud dat=@ux]
+ |= [len=@ud dat=@ux]
^- (unit spec:asn1)
:: XX refactor into +parse
=/ a (rip 3 dat)
=/ b ~| %der-invalid-len
(sub len (lent a))
(rust `(list @D)`(weld a (reap b 0)) parse)
- |%
- :: +parse:de:der: DER parser combinator
+ :: +parse:der: DER parser combinator
::
++ parse
- %+ cook |*(a=* `spec:asn1`a) :: XX fix
- :: ^- $-(nail (like spec:asn1))
+ =< ^- $-(nail (like spec:asn1))
;~ pose
(stag %int (bass 256 (sear int ;~(pfix (tag 2) till))))
(stag %bit (^boss 256 (cook tail ;~(pfix (tag 3) till)))) :: XX test
(stag %set (sear recur ;~(pfix (tag 49) till)))
(stag %con ;~(plug (sear context next) till))
==
- :: +tag:de:der: parse tag byte
+ |%
+ :: +tag:parse:der: parse tag byte
::
++ tag
|=(a=@D (just a))
- :: +int:de:der: sear unsigned big-endian bytes
+ :: +int:parse:der: sear unsigned big-endian bytes
::
++ int
|= a=(list @D)
?: ?=([@ ~] a) `a
?. =(0 i.a) `a
?.((gth i.t.a 127) ~ `t.a)
- :: +recur:de:der: parse bytes for a list of +spec:asn1
+ :: +recur:parse:der: parse bytes for a list of +spec:asn1
::
++ recur
|=(a=(list @) (rust a (star parse)))
- :: +context:de:der: decode context-specific tag byte
+ :: +context:parse:der: decode context-specific tag byte
::
++ context
|= a=@D
:+ ~
=(1 (cut 0 [5 1] a))
(dis 0x1f a)
- :: +boss:de:der: shadowed to count as well
+ :: +boss:parse:der: shadowed to count as well
::
:: Use for parsing +octs more broadly?
::
:- (lent waq)
(reel waq |=([p=@ q=@] (add p (mul wuc q))))
tyd
- :: +till:de:der: parser combinator for len-prefixed bytes
+ :: +till:parse:der: parser combinator for len-prefixed bytes
::
:: advance until
::
