Skip to main content

Crate uselesskey_core_jwk

Crate uselesskey_core_jwk 

Source
Expand description

Re-export of JWK model types and helpers.

This crate is a thin compatibility façade over uselesskey-core-jwk-shape for API stability.

§Examples

Build an Ed25519 public JWK:

use uselesskey_core_jwk::{OkpPublicJwk, PublicJwk};

let jwk = OkpPublicJwk {
    kty: "OKP",
    use_: "sig",
    alg: "EdDSA",
    crv: "Ed25519",
    kid: "my-key-1".into(),
    x: "dGVzdC1wdWJsaWMta2V5".into(),
};
let public = PublicJwk::Okp(jwk);
assert_eq!(public.to_value()["kty"], "OKP");

Assemble a JWKS with deterministic ordering via JwksBuilder:

use uselesskey_core_jwk::{JwksBuilder, RsaPublicJwk, PublicJwk};

let jwks = JwksBuilder::new()
    .add_public(PublicJwk::Rsa(RsaPublicJwk {
        kty: "RSA", use_: "sig", alg: "RS256",
        kid: "b-key".into(), n: "modulus".into(), e: "AQAB".into(),
    }))
    .add_public(PublicJwk::Rsa(RsaPublicJwk {
        kty: "RSA", use_: "sig", alg: "RS256",
        kid: "a-key".into(), n: "modulus".into(), e: "AQAB".into(),
    }))
    .build();

// Keys are sorted by kid
assert_eq!(jwks.keys[0].kid(), "a-key");
assert_eq!(jwks.keys[1].kid(), "b-key");

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.
PrivateJwk
A private (or symmetric) JWK of any supported key type.
PublicJwk
A public JWK of any supported key type.