Interface Recipient
- All Known Implementing Classes:
EncCtxRecipient, KemCtxRecipient, PasswordRecipient
Responsibilities
Implementations provide a stable identifier and produce an opaque binary blob that contains everything the matchingRecipientOpener needs to recover the CEK (for example, KEM
ciphertext, salts, nonces, or wrapped CEK bytes). The multi-recipient
envelope writes the identifier and a length-prefixed copy of the blob into
its header.
Typical usage
// RSA-OAEP recipient; the header will contain the id and the RSA-wrapped CEK
Recipient r = new MultiRecipientDataSourceBuilder.RsaOaepRecipient(rsaPublicKey);
byte[] entryBlob = r.buildRecipientEntry(cek);
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]buildRecipientEntry(byte[] cek) Builds the binary recipient entry for this recipient and the provided CEK.booleandecoy()Indicates whether this recipient entry is a decoy (fake recipient).id()Returns a stable, self-describing identifier for this recipient entry.
-
Method Details
-
decoy
boolean decoy()Indicates whether this recipient entry is a decoy (fake recipient).A decoy recipient is included in the envelope to obscure the actual number and identity of real recipients. Its entry is syntactically valid but intentionally unusable for recovering the content-encryption key (CEK).
Security considerations
- Decoys prevent traffic analysis from revealing how many legitimate recipients are present.
- They are indistinguishable from real recipients to outsiders until a
matching
RecipientOpenerattempts decryption and fails. - Applications should balance the number of decoys against performance and bandwidth overhead.
- Returns:
trueif this entry is a decoy and cannot be used to recover the CEK;falseif it is a real recipient entry
-
id
String id()Returns a stable, self-describing identifier for this recipient entry.The identifier is written as UTF-8 into the envelope header and allows fast routing to a suitable
RecipientOpener(for example,"RSA:OAEP-SHA256","KEM:ML-KEM:GCM-WRAP"). When the envelope is configured to suppress labels for hardening, it may write an empty string in place of this value; implementations should still return their normal identifier here.- Returns:
- non-null identifier string used in the envelope header; may be empty only when the caller chooses to suppress labels
-
buildRecipientEntry
Builds the binary recipient entry for this recipient and the provided CEK.The returned blob is an opaque byte array that the matching
RecipientOpenercan parse and use to recover the CEK. Implementations must not modify or retain thecekarray; copy it if needed. The multi-recipient envelope is responsible for framing and length-prefixing, so the blob itself must not include additional length headers.- Parameters:
cek- the content-encryption key to protect for this recipient; never null- Returns:
- an opaque blob encoding the data required to recover
cekfor this recipient - Throws:
GeneralSecurityException- if a cryptographic operation fails (for example, KEM, RSA-OAEP, or AEAD wrap)IOException- if serialization of the entry blob fails
-