JWS signing algorithms (RFC 7518 §3.1). $$\text{JWSAlgorithm} \in \{\text{HS256}, \text{RS256}, \text{ES256}, \ldots\}$$
- HS256 : JWSAlgorithm
- HS384 : JWSAlgorithm
- HS512 : JWSAlgorithm
- RS256 : JWSAlgorithm
- RS384 : JWSAlgorithm
- RS512 : JWSAlgorithm
- ES256 : JWSAlgorithm
- ES384 : JWSAlgorithm
- ES512 : JWSAlgorithm
- PS256 : JWSAlgorithm
- PS384 : JWSAlgorithm
- PS512 : JWSAlgorithm
- EdDSA : JWSAlgorithm
Instances For
Equations
Equations
- Crypto.JOSE.instBEqJWSAlgorithm.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Convert algorithm name to JWSAlgorithm.
Equations
- Crypto.JOSE.JWSAlgorithm.fromString "HS256" = some Crypto.JOSE.JWSAlgorithm.HS256
- Crypto.JOSE.JWSAlgorithm.fromString "HS384" = some Crypto.JOSE.JWSAlgorithm.HS384
- Crypto.JOSE.JWSAlgorithm.fromString "HS512" = some Crypto.JOSE.JWSAlgorithm.HS512
- Crypto.JOSE.JWSAlgorithm.fromString "RS256" = some Crypto.JOSE.JWSAlgorithm.RS256
- Crypto.JOSE.JWSAlgorithm.fromString "RS384" = some Crypto.JOSE.JWSAlgorithm.RS384
- Crypto.JOSE.JWSAlgorithm.fromString "RS512" = some Crypto.JOSE.JWSAlgorithm.RS512
- Crypto.JOSE.JWSAlgorithm.fromString "ES256" = some Crypto.JOSE.JWSAlgorithm.ES256
- Crypto.JOSE.JWSAlgorithm.fromString "ES384" = some Crypto.JOSE.JWSAlgorithm.ES384
- Crypto.JOSE.JWSAlgorithm.fromString "ES512" = some Crypto.JOSE.JWSAlgorithm.ES512
- Crypto.JOSE.JWSAlgorithm.fromString "PS256" = some Crypto.JOSE.JWSAlgorithm.PS256
- Crypto.JOSE.JWSAlgorithm.fromString "PS384" = some Crypto.JOSE.JWSAlgorithm.PS384
- Crypto.JOSE.JWSAlgorithm.fromString "PS512" = some Crypto.JOSE.JWSAlgorithm.PS512
- Crypto.JOSE.JWSAlgorithm.fromString "EdDSA" = some Crypto.JOSE.JWSAlgorithm.EdDSA
- Crypto.JOSE.JWSAlgorithm.fromString x✝ = none
Instances For
Equations
- One or more equations did not get rendered due to their size.
Is this an HMAC (symmetric) algorithm?
Equations
Instances For
Roundtrip: fromString (toString a) = some a for all algorithms.
isSymmetric returns true if and only if the algorithm is HS256, HS384, or HS512.
Equations
- Crypto.JOSE.instBEqECCurve.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- Crypto.JOSE.instReprECCurve.repr Crypto.JOSE.ECCurve.P256 prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Crypto.JOSE.ECCurve.P256")).group prec✝
- Crypto.JOSE.instReprECCurve.repr Crypto.JOSE.ECCurve.P384 prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Crypto.JOSE.ECCurve.P384")).group prec✝
- Crypto.JOSE.instReprECCurve.repr Crypto.JOSE.ECCurve.P521 prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Crypto.JOSE.ECCurve.P521")).group prec✝
Instances For
Equations
- Crypto.JOSE.instReprECCurve = { reprPrec := Crypto.JOSE.instReprECCurve.repr }
Equations
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Roundtrip: fromString (toString c) = some c for all EC curves.
Key material for a JSON Web Key (RFC 7517). $$\text{JWKKeyMaterial} = \text{RSA}\ n\ e\ |\ \text{EC}\ \text{crv}\ x\ y\ |\ \text{Oct}\ k$$
- rsa
(n e : ByteArray)
(d : Option ByteArray)
: JWKKeyMaterial
RSA public key: modulus
n, exponente, optional private exponentd. - ec
(crv : ECCurve)
(x y : ByteArray)
(d : Option ByteArray)
: JWKKeyMaterial
EC public key: curve, x-coordinate, y-coordinate, optional private key
d. - oct
(k : ByteArray)
: JWKKeyMaterial
Symmetric (octet) key.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Crypto.JOSE.instBEqJWKKeyType.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Parse a key type string.
Equations
Instances For
Roundtrip: fromString (toString k) = some k for all key types.
Valid JWK public key usage values per RFC 7517 §4.2.
Instances For
Equations
- Crypto.JOSE.instBEqJWKUse.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- Crypto.JOSE.instReprJWKUse = { reprPrec := Crypto.JOSE.instReprJWKUse.repr }
Equations
- Crypto.JOSE.instReprJWKUse.repr Crypto.JOSE.JWKUse.sig prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Crypto.JOSE.JWKUse.sig")).group prec✝
- Crypto.JOSE.instReprJWKUse.repr Crypto.JOSE.JWKUse.enc prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "Crypto.JOSE.JWKUse.enc")).group prec✝
Instances For
Equations
- Crypto.JOSE.instToStringJWKUse = { toString := fun (x : Crypto.JOSE.JWKUse) => match x with | Crypto.JOSE.JWKUse.sig => "sig" | Crypto.JOSE.JWKUse.enc => "enc" }
A JSON Web Key (RFC 7517). $$\text{JWK} = \{ \text{kty}, \text{kid}?, \text{alg}?, \text{use}?, \text{material} \}$$
The kty field is a JWKKeyType (not a raw String), constraining it
to the valid values "RSA", "EC", "oct" per RFC 7518 §6.1.
The kty_material_coherent proof ensures the key type matches the key material.
- kty : JWKKeyType
Key type: constrained to valid values per RFC 7518 §6.1.
Key ID (optional).
- alg : Option JWSAlgorithm
Algorithm (optional).
Public key use: "sig" or "enc" (optional), now typed.
- material : JWKKeyMaterial
The key material.
- kty_material_coherent : (self.kty = JWKKeyType.RSA → ∃ (n : ByteArray), ∃ (e : ByteArray), ∃ (d : Option ByteArray), self.material = JWKKeyMaterial.rsa n e d) ∧ (self.kty = JWKKeyType.EC → ∃ (crv : ECCurve), ∃ (x : ByteArray), ∃ (y : ByteArray), ∃ (d : Option ByteArray), self.material = JWKKeyMaterial.ec crv x y d) ∧ (self.kty = JWKKeyType.oct → ∃ (k : ByteArray), self.material = JWKKeyMaterial.oct k)
The key type must be coherent with the key material.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- Crypto.JOSE.instReprJWKSet = { reprPrec := fun (s : Crypto.JOSE.JWKSet) (x : Nat) => Std.Format.text (toString "JWKSet(keys=" ++ toString (repr s.keys) ++ toString ")") }
Registered claim names for JWTs (RFC 7519 §4.1).
Issuer claim.
Subject claim.
Audience claim (can be a single string or array).
Expiration time (Unix timestamp).
Not before (Unix timestamp).
Issued at (Unix timestamp).
JWT ID.
Unregistered (custom) claims as key-value pairs. Values are stored as their JSON string representation.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Look up a custom claim value by name.
Equations
- claims.lookupClaim key = List.lookup key claims.unregisteredClaims
Instances For
Equations
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Configuration for JWT validation.
allowedSkew is bounded to at most 600 seconds (10 minutes) to prevent
dangerously permissive clock skew that could accept expired/future tokens.
- allowedSkew : Nat
Allowed clock skew in seconds (max 600 = 10 minutes).
The clock skew must not exceed 10 minutes (600 seconds).
- checkExpiry : Bool
Whether to check the
expclaim. - checkNotBefore : Bool
Whether to check the
nbfclaim. If set, the
audclaim must contain one of these values.If set, the
issclaim must be one of these values.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Crypto.JOSE.instInhabitedJWTValidationSettings = { default := { allowedSkew_bounded := Crypto.JOSE.instInhabitedJWTValidationSettings._proof_2 } }
Errors that can occur during JWT validation.
- malformedToken
(msg : String)
: JwtError
The JWT string has an invalid format (not 3 dot-separated parts).
- headerParseError
(msg : String)
: JwtError
The header JSON cannot be parsed.
- claimsParseError
(msg : String)
: JwtError
The claims JSON cannot be parsed.
- unsupportedAlgorithm
(alg : String)
: JwtError
The algorithm in the header is not supported.
- signatureVerificationFailed : JwtError
Signature verification failed.
- tokenExpired
(exp now : Nat)
: JwtError
The token has expired.
- tokenNotYetValid
(nbf now : Nat)
: JwtError
The token is not yet valid.
- audienceMismatch : JwtError
The audience claim does not match.
- issuerMismatch : JwtError
The issuer claim does not match.
- noMatchingKey : JwtError
No matching key found in the key set.
- noneAlgorithmNotAllowed : JwtError
The "none" algorithm is not allowed.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Crypto.JOSE.instReprJwtError = { reprPrec := Crypto.JOSE.instReprJwtError.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.