Class SealingKey
StateSealer, with its key ID.
A key is exactly 32 random bytes, given as their canonical, padded standard Base64 encoding: 44 characters with
one = at the end and no whitespace, such as the output of openssl rand -base64 32. A key whose 32
bytes are all the same, such as all zeros, is rejected as a placeholder. Generate each key from a cryptographically
secure random source, keep it out of source control, and use one key per application.
The key ID names the key inside every value it seals, so a sealer finds the right key without trying each one. It
is 1 to 64 characters of A-Z, a-z, 0-9, ., _, ~ and -, such
as 2026-09. It is not secret: every sealed value carries it in the clear.
The key's bytes are never exposed. toString() renders SealingKey{keyId=..., key=<redacted>}, and
equals is reference identity, so no key material takes part in a comparison: two keys are equal only if they
are the same instance.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull SealingKeyfromBase64(@NonNull String keyId, @NonNull String base64Key) Returns a sealing key from its key ID and its Base64 encoding.getKeyId()Returns the key ID.toString()ReturnsSealingKey{keyId=..., key=<redacted>}; the key's bytes are never rendered.
-
Method Details
-
fromBase64
Returns a sealing key from its key ID and its Base64 encoding.Neither argument appears in an exception message, in case the two were swapped and the "key ID" is the key.
- Parameters:
keyId- the key ID: 1 to 64 characters ofA-Z,a-z,0-9,.,_,~and-base64Key- the key: 32 bytes as canonical, padded standard Base64 (44 characters, no whitespace)- Returns:
- a new sealing key
- Throws:
NullPointerException- if either argument isnullIllegalArgumentException- if the key ID is not valid, the key is not the canonical Base64 encoding of exactly 32 bytes, or its 32 bytes are all the same- Since:
- 1.0.0
-
getKeyId
-
toString
-