Documentation
¶
Overview ¶
Package jose is the listener-independent JWS/JWK primitive shared by the MCP token-validation (authn) and sender-constraint (DPoP) layers. It parses PUBLIC JWKs, verifies compact-JWS signatures against a supported asymmetric-algorithm allowlist with a strict key-type match (closing algorithm confusion), and computes RFC 7638 JWK thumbprints.
It performs no network I/O and holds no private key material: ParsePublicJWK rejects any JWK carrying a private component. `alg=none`, HMAC, and any alg outside the allowlist are rejected — there is no symmetric path, so an asymmetric public key can never be coerced into an HMAC secret.
Index ¶
- Constants
- func B64URLDecode(s string) ([]byte, error)
- func B64URLEncode(b []byte) string
- func ConstantTimeEqual(a, b string) bool
- func ParsePublicJWK(n *canonical.Node) (crypto.PublicKey, error)
- func SHA256B64URL(b []byte) string
- func SupportedAlg(alg string) bool
- func Thumbprint(n *canonical.Node) (string, error)
- func Verify(alg string, key crypto.PublicKey, signingInput, sig []byte) error
Constants ¶
const ( ES256 = "ES256" // ECDSA P-256 + SHA-256 RS256 = "RS256" // RSASSA-PKCS1-v1_5 + SHA-256 PS256 = "PS256" // RSASSA-PSS + SHA-256 EdDSA = "EdDSA" // Ed25519 )
Supported JWS algorithms (asymmetric only).
Variables ¶
This section is empty.
Functions ¶
func B64URLDecode ¶
B64URLDecode decodes raw (unpadded) base64url.
func B64URLEncode ¶
B64URLEncode encodes raw (unpadded) base64url.
func ConstantTimeEqual ¶
ConstantTimeEqual reports whether two strings are equal in constant time.
func ParsePublicJWK ¶
ParsePublicJWK parses a canonical JWK object node into a crypto.PublicKey. It supports EC P-256, RSA and OKP Ed25519, and REJECTS any JWK that carries a private component ("d"), so a proof/JWK can never smuggle private key material.
func SHA256B64URL ¶
SHA256B64URL returns base64url(sha256(b)) — used for DPoP `ath` and for hashing tokens into a sanitized correlation digest.
func SupportedAlg ¶
SupportedAlg reports whether alg is in the allowlist. `none`, HMAC (HS*) and any unknown/missing alg return false.
func Thumbprint ¶
Thumbprint computes the RFC 7638 JWK SHA-256 thumbprint (base64url) of a public JWK. The required members are emitted in lexicographic order with no whitespace, deterministically, so the same key always yields the same thumbprint.
Types ¶
This section is empty.