Skip to main content

Crate uselesskey_jwk

Crate uselesskey_jwk 

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

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.
JwksBuilder
Incrementally assembles a Jwks set with deterministic kid-based ordering.
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.
NegativeJwk
Negative JWK shape variants for downstream parser and validator tests.
NegativeJwks
Negative JWKS shape variants for downstream key-set tests.
PrivateJwk
A private (or symmetric) JWK of any supported key type.
PublicJwk
A public JWK of any supported key type.