Expand description
Typed JWK/JWKS helpers for uselesskey fixture crates.
This crate is the canonical public owner for JWK and JWKS shape types, deterministic JWKS ordering, key identifiers, and shape-realistic negative JWK fixtures.
§Examples
Build a JWKS from individual JWK values:
use uselesskey_jwk::{JwksBuilder, RsaPublicJwk, PublicJwk};
let jwk = PublicJwk::Rsa(RsaPublicJwk {
kty: "RSA",
use_: "sig",
alg: "RS256",
kid: "key-1".to_string(),
n: "modulus".to_string(),
e: "AQAB".to_string(),
});
let jwks = JwksBuilder::new().add_public(jwk).build();
assert_eq!(jwks.keys.len(), 1);
assert_eq!(jwks.keys[0].kid(), "key-1");Serialize a JWK to JSON:
use uselesskey_jwk::RsaPublicJwk;
let jwk = RsaPublicJwk {
kty: "RSA",
use_: "sig",
alg: "RS256",
kid: "key-1".to_string(),
n: "modulus".to_string(),
e: "AQAB".to_string(),
};
assert_eq!(jwk.kid(), "key-1");Structs§
- EcPrivate
Jwk - Elliptic-curve private key in JWK format (P-256 / P-384, includes
d). - EcPublic
Jwk - Elliptic-curve public key in JWK format (P-256 / P-384).
- Jwks
- A JSON Web Key Set containing zero or more JWK entries.
- Jwks
Builder - Incrementally assembles a
Jwksset with deterministickid-based ordering. - OctJwk
- Symmetric (octet) key in JWK format (HMAC
HS256/HS384/HS512). - OkpPrivate
Jwk - OKP (Octet Key Pair) private key in JWK format (Ed25519, includes
d). - OkpPublic
Jwk - OKP (Octet Key Pair) public key in JWK format (Ed25519).
- RsaPrivate
Jwk - RSA private key in JWK format (includes CRT parameters
p,q,dp,dq,qi). - RsaPublic
Jwk - RSA public key in JWK format (contains
nande).
Enums§
- AnyJwk
- Either a public or private JWK.
- Negative
Jwk - Negative JWK shape variants for downstream parser and validator tests.
- Negative
Jwks - Negative JWKS shape variants for downstream key-set tests.
- Private
Jwk - A private (or symmetric) JWK of any supported key type.
- Public
Jwk - A public JWK of any supported key type.