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§
- 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.
- Private
Jwk - A private (or symmetric) JWK of any supported key type.
- Public
Jwk - A public JWK of any supported key type.