Package com.yahoo.security
Record Class SealedSharedKey
java.lang.Object
java.lang.Record
com.yahoo.security.SealedSharedKey
public record SealedSharedKey(int version, KeyId keyId, byte[] enc, byte[] ciphertext)
extends Record
A SealedSharedKey represents the public part of a secure one-way ephemeral key exchange.
It is "sealed" in the sense that it is expected to be computationally infeasible
for anyone to derive the correct shared key from the sealed key without holding
the correct private key.
A SealedSharedKey can be converted to--and from--an opaque string token representation.
This token representation is expected to be used as a convenient serialization
form when communicating shared keys.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCurrent encoding version of opaque sealed key tokens.static final intEncryption context for v{1,2} tokens is always a 32-byte X25519 public keystatic final int -
Constructor Summary
ConstructorsConstructorDescriptionSealedSharedKey(int version, KeyId keyId, byte[] enc, byte[] ciphertext) Creates an instance of aSealedSharedKeyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the value of theciphertextrecord component.byte[]enc()Returns the value of theencrecord component.booleanIndicates whether some other object is "equal to" this one.static SealedSharedKeyfromTokenString(String tokenString) Attempts to unwrap a SealedSharedKey opaque token representation that was previously created by a call to toTokenString().inthashCode()Returns a hash code value for this object.keyId()Returns the value of thekeyIdrecord component.inttoString()Returns a string representation of this record class.Creates an opaque URL-safe string token that contains enough information to losslessly reconstruct the SealedSharedKey instance when passed verbatim to fromTokenString().intversion()Returns the value of theversionrecord component.
-
Field Details
-
CURRENT_TOKEN_VERSION
public static final int CURRENT_TOKEN_VERSIONCurrent encoding version of opaque sealed key tokens. Must be less than 256.- See Also:
-
MAX_ENC_CONTEXT_LENGTH
public static final int MAX_ENC_CONTEXT_LENGTHEncryption context for v{1,2} tokens is always a 32-byte X25519 public key- See Also:
-
MAX_TOKEN_STRING_LENGTH
public static final int MAX_TOKEN_STRING_LENGTH- See Also:
-
-
Constructor Details
-
SealedSharedKey
Creates an instance of aSealedSharedKeyrecord class.- Parameters:
version- the value for theversionrecord componentkeyId- the value for thekeyIdrecord componentenc- the value for theencrecord componentciphertext- the value for theciphertextrecord component
-
-
Method Details
-
toTokenString
Creates an opaque URL-safe string token that contains enough information to losslessly reconstruct the SealedSharedKey instance when passed verbatim to fromTokenString(). -
fromTokenString
Attempts to unwrap a SealedSharedKey opaque token representation that was previously created by a call to toTokenString(). -
tokenVersion
public int tokenVersion() -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
version
public int version()Returns the value of theversionrecord component.- Returns:
- the value of the
versionrecord component
-
keyId
Returns the value of thekeyIdrecord component.- Returns:
- the value of the
keyIdrecord component
-
enc
public byte[] enc()Returns the value of theencrecord component.- Returns:
- the value of the
encrecord component
-
ciphertext
public byte[] ciphertext()Returns the value of theciphertextrecord component.- Returns:
- the value of the
ciphertextrecord component
-