cert.bend checks
raw source on the hub · import element-x509@0.1.0.0/cert.bend as Cert
6 imports
import Base import element-asn1@0.1.0.0/der.bend as Der import element-math@0.1.0.0/big.bend as Big import element-crypto@0.1.0.0/hash.bend as Hash import element-crypto@0.1.0.0/rsa.bend as Rsa import element-crypto@0.1.0.0/ecdsa.bend as Ecdsa
Types
type Cert source · line 20 · raw
Data
Cert@ok:Bool -> @tbs:List<&2, U32> -> @sig_alg:List<&2, U32> -> @sig:List<&2, U32> -> @issuer:List<&2, U32> -> @subject:List<&2, U32> -> @not_before:Nat -> @not_after:Nat -> @key_alg:List<&2, U32> -> @curve:List<&2, U32> -> @key:List<&2, U32> -> @ca:Bool -> @eku:Bool -> @crit:Bool -> @names:List<&2, String> -> Cert
type Key source · line 221 · raw
Data
KRsa@n:List<&2, U32> -> @e:List<&2, U32> -> Key
KEc@curve:0x29d6f1ff259add9ea6c8f213fda12377/ecdsa.Curve -> @point:List<&2, U32> -> Key
KNoneKey
type Alg source · line 269 · raw
Data
ARsa@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> Alg
AEc@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> Alg
ANoneAlg
type Check source · line 377 · raw
Data
Check@ok:Bool -> @msg:String -> Check
type Scheme source · line 454 · raw
Data
SEc@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @curve:List<&2, U32> -> Scheme
SPss@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> Scheme
SPkcs@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> Scheme
SEcAny@h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> Scheme
SNoneScheme
Definitions
def oid_rsa source · line 30 · raw
List<&2, U32>
def oid_rsa_sha source · line 33 · raw
@+n:U32 -> List<&2, U32>
def oid_ec source · line 36 · raw
List<&2, U32>
def oid_p256 source · line 39 · raw
List<&2, U32>
def oid_p384 source · line 42 · raw
List<&2, U32>
def oid_ecdsa_sha source · line 45 · raw
@+n:U32 -> List<&2, U32>
def oid_ext source · line 48 · raw
@+n:U32 -> List<&2, U32>
def oid_server_auth source · line 51 · raw
List<&2, U32>
def oid_any_eku source · line 54 · raw
List<&2, U32>
def same source · line 57 · raw
@+a:List<&2, U32> -> @+b:List<&2, U32> -> Bool
def ext_id source · line 62 · raw
@+e:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> List<&2, U32>
def ext_value source · line 66 · raw
@+e:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> List<&2, U32>
The extnValue OCTET STRING's contents (itself DER).
def ext_critical source · line 69 · raw
@+e:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> Bool
def is_ext source · line 73 · raw
@+e:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> @+n:U32 -> Bool
def known source · line 77 · raw
@+e:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> Bool
keyUsage, subjectAltName, basicConstraints, certificatePolicies, extKeyUsage.
def any_unknown_critical source · line 80 · raw
@es:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> Bool
def ca_value source · line 87 · raw
@+v:List<&2, U32> -> Bool
def is_ca source · line 91 · raw
@es:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> Bool
def has_purpose source · line 98 · raw
@ps:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> Bool
def eku_ok source · line 106 · raw
@es:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> Bool
extendedKeyUsage, when present, must allow TLS server authentication.
def ascii source · line 113 · raw
@bs:List<&2, U32> -> String
def dotted source · line 120 · raw
@+bs:List<&2, U32> -> String
def general_names source · line 124 · raw
@gs:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> List<&2, String>
GeneralNames: dNSName [2] and 4-byte iPAddress [7]; others are skipped.
def names_of source · line 135 · raw
@es:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> List<&2, String>
def find_exts source · line 143 · raw
@ts:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv>
The [3] EXPLICIT extensions after the six fixed TBS fields.
def drop1 source · line 152 · raw
@ts:List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv> -> List<&2, 0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv>
def curve_of source · line 159 · raw
@+p:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> List<&2, U32>
def parse source · line 162 · raw
@+der:List<&2, U32> -> Cert
def ok_of source · line 183 · raw
@c:Cert -> Bool
def issuer_of source · line 188 · raw
@c:Cert -> List<&2, U32>
def subject_of source · line 193 · raw
@c:Cert -> List<&2, U32>
def names_in source · line 198 · raw
@c:Cert -> List<&2, String>
def usable source · line 204 · raw
@c:Cert -> @+now:Nat -> Bool
Well formed, in its validity period, and without unknown critical extensions.
def is_ca_cert source · line 209 · raw
@c:Cert -> Bool
def server_ok source · line 214 · raw
@c:Cert -> Bool
def ec_key source · line 226 · raw
@+curve:List<&2, U32> -> @+point:List<&2, U32> -> Key
def rsa_key source · line 230 · raw
@+k:0xdb0941eac21e6b9f90ed667d7e262d56/der.Tlv -> Key
def key_pick source · line 233 · raw
@rsa:Bool -> @ec:Bool -> @+curve:List<&2, U32> -> @+key:List<&2, U32> -> Key
def key_of source · line 245 · raw
@c:Cert -> Key
The subject public key.
def check_rsa source · line 251 · raw
@k:Key -> @+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool
A signature by key over msg: RSA PKCS #1 v1.5 or ECDSA (r, s) in DER.
def check_ec source · line 260 · raw
@k:Key -> @+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool
def alg_of source · line 274 · raw
@+oid:List<&2, U32> -> Alg
def check_alg source · line 282 · raw
@a:Alg -> @+k:Key -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool
def signed_by source · line 292 · raw
@+child:Cert -> @+parent:Cert -> Bool
child carries a valid signature by parent's key.
def after_dot source · line 299 · raw
@s:String -> String
def name_matches source · line 307 · raw
@+pat:String -> @+host:String -> Bool
"*.example.com" matches exactly one non-empty leftmost label.
def any_name source · line 314 · raw
@ns:List<&2, String> -> @+host:String -> Bool
def host_matches source · line 321 · raw
@+c:Cert -> @+host:String -> Bool
def issued source · line 326 · raw
@+child:Cert -> @+parent:Cert -> Bool
def issuers source · line 330 · raw
@xs:List<&2, Cert> -> @+child:Cert -> List<&2, Cert>
The candidates whose subject is the child's issuer.
def any_signed source · line 339 · raw
@rs:List<&2, Cert> -> @+child:Cert -> Bool
A trusted root signed the child.
def trusted source · line 346 · raw
@+roots:List<&2, Cert> -> @+child:Cert -> Bool
def first_signed source · line 350 · raw
@cs:List<&2, Cert> -> @+child:Cert -> @+now:Nat -> Maybe<&2, Cert>
The first server-sent CA certificate, usable now, that signed the child.
def next_up source · line 357 · raw
@+pool:List<&2, Cert> -> @+child:Cert -> @+now:Nat -> Maybe<&2, Cert>
def walk source · line 362 · raw
@fuel:Nat -> @done:Bool -> @next:Maybe<&2, Cert> -> @+pool:List<&2, Cert> -> @+roots:List<&2, Cert> -> @+now:Nat -> String
Climb from the leaf: stop at a certificate a root signed, else step to the
server-sent certificate that signed it. At most fuel links.
def first_error source · line 380 · raw
@ps:List<&2, Check> -> String
def parse_all source · line 389 · raw
@ds:List<&2, List<&2, U32>> -> List<&2, Cert>
def or_leaf source · line 396 · raw
@m:Maybe<&2, Cert> -> Cert
def first_cert source · line 403 · raw
@+cs:List<&2, Cert> -> Cert
def drop1c source · line 406 · raw
@cs:List<&2, Cert> -> List<&2, Cert>
def verify_chain source · line 415 · raw
@+ders:List<&2, List<&2, U32>> -> @+roots:List<&2, Cert> -> @+host:String -> @+now:Nat -> String
Verify the server's certificates (DER, leaf first) for host at now
(seconds since 1970) against parsed roots: "" when trusted, else the reason.
def cv_pss source · line 432 · raw
@k:Key -> @+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool
def cv_label source · line 441 · raw
List<&2, U32>
def cv_msg source · line 446 · raw
@+th:List<&2, U32> -> List<&2, U32>
The signed content (RFC 8446 4.4.3): 64 spaces, the context string, 0, and the transcript hash.
def curve_is source · line 449 · raw
@+c:Cert -> @+oid:List<&2, U32> -> Bool
def scheme_of source · line 461 · raw
@+code:U32 -> Scheme
def cv_check source · line 468 · raw
@s:Scheme -> @+leaf:Cert -> @+sig:List<&2, U32> -> @+m:List<&2, U32> -> Bool
def certificate_verify source · line 484 · raw
@+leaf:Cert -> @+scheme:U32 -> @+sig:List<&2, U32> -> @+th:List<&2, U32> -> Bool
The leaf's signature over the handshake transcript hash th, by scheme:
ecdsa_secp256r1_sha256 0x0403, ecdsa_secp384r1_sha384 0x0503,
rsa_pss_rsae_sha256/384/512 0x0804/5/6.
def first_cert_der source · line 487 · raw
@ds:List<&2, List<&2, U32>> -> List<&2, U32>
def scheme12_of source · line 500 · raw
@+code:U32 -> Scheme
In TLS 1.2 (RFC 5246 7.4.1.4.1, RFC 8422 5.4) a scheme names the hash and the signature algorithm only: rsa_pkcs1_sha256/384/512 0x0401/0x0501/0x0601 are allowed, and an ECDSA code does not bind the curve (the key's own curve is used). PSS as in TLS 1.3.
def ske_verify source · line 509 · raw
@+leaf:Cert -> @+scheme:U32 -> @+sig:List<&2, U32> -> @+signed:List<&2, U32> -> Bool
The leaf's signature over client_random | server_random | ECDH params.