Attesto.SigningAlg (Attesto v0.6.12)

Copy Markdown View Source

Key-derived JOSE signing algorithm helpers.

Attesto treats the algorithm as metadata of the trusted key selected by kid, never as policy learned from the presented token. RSA keys infer RS256 (RSASSA-PKCS1-v1_5) as the JWA default for the RSA key type, while EC/OKP keys infer their JOSE algorithm from the public JWK curve. RSA deployments that intentionally use PS256 can label the key through the keystore's alg metadata.

Summary

Functions

Algorithms Attesto can sign/verify when backed by a matching key.

Default set of algorithms accepted for signatures a client presents (client assertions and request objects).

Signing algorithms permitted for FAPI 2 client authentication and request objects: PS256, ES256, EdDSA.

Resolve the algorithm for a key in keystore.

Return the digest algorithm used by an ID Token hash claim.

Return the number of left-most bytes used for OIDC hash claims.

Infer the default algorithm from a parsed JWK's public members.

Validate that alg is one of Attesto's supported asymmetric JOSE algorithms.

Types

alg()

@type alg() :: String.t()

Functions

allowed()

@spec allowed() :: [alg()]

Algorithms Attesto can sign/verify when backed by a matching key.

default_client_algs()

@spec default_client_algs() :: [alg()]

Default set of algorithms accepted for signatures a client presents (client assertions and request objects).

Equal to fapi_algs/0: PS256, ES256, EdDSA. A host with a non-FAPI profile can widen this by passing an explicit :accepted_algs opt to the relevant verifier; the default keeps the FAPI 2 gate.

fapi_algs()

@spec fapi_algs() :: [alg()]

Signing algorithms permitted for FAPI 2 client authentication and request objects: PS256, ES256, EdDSA.

RS256 (RSASSA-PKCS1-v1_5) is deliberately excluded - FAPI 2 mandates PS256 for RSA keys. This is the policy gate for verifying a signature a client presents; it is narrower than allowed/0, which still admits RS256 for the provider's own token signing.

for_key(keystore, pem, opts \\ [])

@spec for_key(module(), String.t(), keyword()) :: alg()

Resolve the algorithm for a key in keystore.

Resolution order:

  • per-key metadata from key_algs/0, keyed by RFC 7638 kid
  • signing_alg/0 for the current signing key only
  • inference from the JWK type/curve

hash_alg(alg)

@spec hash_alg(alg()) :: :sha256 | :sha384 | :sha512

Return the digest algorithm used by an ID Token hash claim.

hash_half_bytes(alg)

@spec hash_half_bytes(alg()) :: pos_integer()

Return the number of left-most bytes used for OIDC hash claims.

infer(jwk)

@spec infer(JOSE.JWK.t()) :: alg()

Infer the default algorithm from a parsed JWK's public members.

validate!(alg)

@spec validate!(term()) :: alg()

Validate that alg is one of Attesto's supported asymmetric JOSE algorithms.