Package io.jans.lock.trace.crypto.bc
Class Ed25519PublicKeys
java.lang.Object
io.jans.lock.trace.crypto.bc.Ed25519PublicKeys
Builds Ed25519
PublicKeys from RFC 8037 OKP JWKs
({"kty":"OKP","crv":"Ed25519","x":"<32 raw bytes, base64url>"}) through the JCA
KeyFactory of the installed BouncyCastle provider (standard or FIPS), so no BC-internal
class is referenced.
The raw 32-byte key is wrapped in the RFC 8410 SubjectPublicKeyInfo DER structure
(30 2a 30 05 06 03 2b 65 70 03 21 00 || raw), the only public-key encoding every JCA
provider is required to understand.
Not reused on purpose: io.jans.as.model.crypto.AbstractCryptoProvider and
EDDSASigner treat x as a full SPKI blob (non-RFC-8037) and refuse FIPS mode.
- Author:
- Yuriy Movchan
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic PublicKeyfromJwk(com.fasterxml.jackson.databind.JsonNode jwk) Builds the public key from a JWK given as a Jackson object node (the shape received by the admin API).static PublicKeyBuilds the public key from a JWK given as a string map (the shape stored injansTracePublicKeyJwk).static PublicKeyfromRaw(byte[] raw) Builds the public key from its raw 32 bytes (RFC 8032 encoding, as carried in JWKx).static Stringthumbprint(Map<String, String> jwk) RFC 7638 / RFC 8037 §A.3 JWK thumbprint of an Ed25519 key in the TRACE hash format :"sha256:" + lowercaseHex(SHA-256(UTF-8( '{"crv":"Ed25519","kty":"OKP","x":"<x>"}'))).
-
Field Details
-
ALGORITHM
- See Also:
-
JWK_KTY_OKP
JWK key type of Edwards-curve keys (RFC 8037 §2).- See Also:
-
JWK_CRV_ED25519
JWK curve name (RFC 8037 §3.1).- See Also:
-
RAW_KEY_LENGTH
public static final int RAW_KEY_LENGTHLength of a raw Ed25519 public key (RFC 8032 §5.1.5).- See Also:
-
-
Method Details
-
thumbprint
RFC 7638 / RFC 8037 §A.3 JWK thumbprint of an Ed25519 key in the TRACE hash format :"sha256:" + lowercaseHex(SHA-256(UTF-8( '{"crv":"Ed25519","kty":"OKP","x":"<x>"}'))). The required members are written in lexicographic order with no whitespace; the JWK'sxis used exactly as stored, and no other member can influence the result (the input is not built from the map).- Throws:
TraceCryptoException- with reasonjwk_formatwhen the JWK isnullor has nox, orjwk_x_encodingwhenxis not an unpadded base64url encoding of 32 bytes
-
fromJwk
Builds the public key from a JWK given as a string map (the shape stored injansTracePublicKeyJwk). Members other thankty,crv,xanddare ignored.- Throws:
TraceCryptoException- with reasonjwk_format,jwk_kty,jwk_crv,jwk_private_material,jwk_x_encoding,jwk_x_length,invalid_keyorcrypto_unavailable
-
fromJwk
Builds the public key from a JWK given as a Jackson object node (the shape received by the admin API). Members other thankty,crv,xanddare ignored.- Throws:
TraceCryptoException- seefromJwk(Map)
-
fromRaw
Builds the public key from its raw 32 bytes (RFC 8032 encoding, as carried in JWKx).- Throws:
TraceCryptoException- with reasonjwk_x_length,invalid_keyorcrypto_unavailable
-