Expand description
Typed JWK and JWKS helpers for uselesskey test fixtures.
Provides structured JWK types (RsaPublicJwk, EcPublicJwk, OkpPublicJwk, etc.)
and Jwks for serializing collections of JWK values.
§Examples
Build an Ed25519 public JWK and serialize it to JSON:
use uselesskey_core_jwk_shape::{OkpPublicJwk, PublicJwk, Jwks, AnyJwk};
let jwk = OkpPublicJwk {
kty: "OKP",
use_: "sig",
alg: "EdDSA",
crv: "Ed25519",
kid: "my-key-1".to_string(),
x: "dGVzdC1wdWJsaWMta2V5".to_string(),
};
// Wrap in the enum and convert to a JSON value
let public = PublicJwk::Okp(jwk);
let value = public.to_value();
assert_eq!(value["kty"], "OKP");
assert_eq!(value["kid"], "my-key-1");
// Collect into a JWKS
let jwks = Jwks { keys: vec![AnyJwk::Public(public)] };
let json = jwks.to_value();
assert_eq!(json["keys"].as_array().unwrap().len(), 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.
- 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.
- Private
Jwk - A private (or symmetric) JWK of any supported key type.
- Public
Jwk - A public JWK of any supported key type.