jose

package
v1.0.310 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func B64URLDecode(s string) ([]byte, error)

B64URLDecode decodes raw (unpadded) base64url.

func B64URLEncode

func B64URLEncode(b []byte) string

B64URLEncode encodes raw (unpadded) base64url.

func ConstantTimeEqual

func ConstantTimeEqual(a, b string) bool

ConstantTimeEqual reports whether two strings are equal in constant time.

func ParsePublicJWK

func ParsePublicJWK(n *canonical.Node) (crypto.PublicKey, error)

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

func SHA256B64URL(b []byte) string

SHA256B64URL returns base64url(sha256(b)) — used for DPoP `ath` and for hashing tokens into a sanitized correlation digest.

func SupportedAlg

func SupportedAlg(alg string) bool

SupportedAlg reports whether alg is in the allowlist. `none`, HMAC (HS*) and any unknown/missing alg return false.

func Thumbprint

func Thumbprint(n *canonical.Node) (string, error)

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.

func Verify

func Verify(alg string, key crypto.PublicKey, signingInput, sig []byte) error

Verify checks a compact-JWS signature over signingInput using key, dispatching by alg with a strict key-type match. A key whose type cannot serve alg (e.g. an RSA key presented for ES256) is an algorithm-confusion attempt and is rejected.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL