# `Attesto.SigningAlg`
[🔗](https://github.com/XukuLLC/attesto/blob/v0.13.0/lib/attesto/signing_alg.ex#L1)

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.

# `alg`

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

# `allowed`

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

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

# `default_client_algs`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

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

# `hash_half_bytes`

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

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

# `infer`

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

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

# `keystore_algs`

```elixir
@spec keystore_algs(module()) :: [alg()]
```

The unique signing algorithms across a keystore's verification keys.

Used to advertise the algorithms the server itself signs with (the
`id_token_signing_alg_values_supported` and the JARM
`authorization_signing_alg_values_supported`, which share the same keys).
Returns `[]` when the keystore exposes no verification keys (or resolution
fails), leaving the caller to apply any default.

# `validate!`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
