Class HpkeContext
- java.lang.Object
-
- com.google.crypto.tink.hybrid.internal.HpkeContext
-
@ThreadSafe public final class HpkeContext extends java.lang.ObjectHybrid Public Key Encryption (HPKE) context for either a sender or a recipient.https://www.rfc-editor.org/rfc/rfc9180.html#name-creating-the-encryption-con
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HpkeContextcreateAuthRecipientContext(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info, HpkePublicKey senderPublicKey)Creates HPKE recipient context with authentication according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.3.static HpkeContextcreateAuthSenderContext(HpkePublicKey recipientPublicKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info, HpkeKemPrivateKey senderPrivateKey)Creates HPKE sender context with authentication according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.3.static HpkeContextcreateRecipientContext(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info)Creates HPKE sender recipient context according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1-9.byte[]getEncapsulatedKey()byte[]open(byte[] ciphertext, byte[] associatedData)Performs AEAD decryption ofciphertextwithassociatedDataaccording to ContextR.Open() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2-10.byte[]seal(byte[] plaintext, byte[] associatedData)Performs AEAD encryption ofplaintextwithassociatedDataaccording to ContextS.Seal() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2-8.
-
-
-
Method Detail
-
createAuthSenderContext
public static HpkeContext createAuthSenderContext(HpkePublicKey recipientPublicKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info, HpkeKemPrivateKey senderPrivateKey) throws java.security.GeneralSecurityException
Creates HPKE sender context with authentication according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.3.- Parameters:
recipientPublicKey- recipient's public key (pkR)kem- key encapsulation mechanism primitivekdf- key derivation function primitiveaead- authenticated encryption with associated data primitiveinfo- application-specific information parameter to influence key generationsenderPrivateKey- sender's private key (skS)- Throws:
java.security.GeneralSecurityException
-
createRecipientContext
public static HpkeContext createRecipientContext(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info) throws java.security.GeneralSecurityException
Creates HPKE sender recipient context according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1-9.- Parameters:
encapsulatedKey- encapsulated key (enc)recipientPrivateKey- recipient's private key (skR)kem- key encapsulation mechanism primitivekdf- key derivation function primitiveaead- authenticated encryption with associated data primitiveinfo- application-specific information parameter to influence key generation- Throws:
java.security.GeneralSecurityException
-
createAuthRecipientContext
public static HpkeContext createAuthRecipientContext(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, HpkeKem kem, HpkeKdf kdf, HpkeAead aead, byte[] info, HpkePublicKey senderPublicKey) throws java.security.GeneralSecurityException
Creates HPKE recipient context with authentication according to KeySchedule() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.3.- Parameters:
encapsulatedKey- encapsulated key (enc)recipientPrivateKey- recipient's private key (skR)kem- key encapsulation mechanism primitivekdf- key derivation function primitiveaead- authenticated encryption with associated data primitiveinfo- application-specific information parameter to influence key generationsenderPublicKey- sender's public key (pkS)- Throws:
java.security.GeneralSecurityException
-
getEncapsulatedKey
public byte[] getEncapsulatedKey()
-
seal
public byte[] seal(byte[] plaintext, byte[] associatedData) throws java.security.GeneralSecurityExceptionPerforms AEAD encryption ofplaintextwithassociatedDataaccording to ContextS.Seal() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2-8.- Returns:
- ciphertext
- Throws:
java.security.GeneralSecurityException
-
open
public byte[] open(byte[] ciphertext, byte[] associatedData) throws java.security.GeneralSecurityExceptionPerforms AEAD decryption ofciphertextwithassociatedDataaccording to ContextR.Open() defined in https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2-10.- Returns:
- plaintext
- Throws:
java.security.GeneralSecurityException
-
-