Skip to main content

Crate uselesskey_core_jwk_shape

Crate uselesskey_core_jwk_shape 

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

EcPrivateJwk
Elliptic-curve private key in JWK format (P-256 / P-384, includes d).
EcPublicJwk
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).
OkpPrivateJwk
OKP (Octet Key Pair) private key in JWK format (Ed25519, includes d).
OkpPublicJwk
OKP (Octet Key Pair) public key in JWK format (Ed25519).
RsaPrivateJwk
RSA private key in JWK format (includes CRT parameters p, q, dp, dq, qi).
RsaPublicJwk
RSA public key in JWK format (contains n and e).

Enums§

AnyJwk
Either a public or private JWK.
PrivateJwk
A private (or symmetric) JWK of any supported key type.
PublicJwk
A public JWK of any supported key type.