Interface HpkeKem
-
@Immutable public interface HpkeKemInterface for Hybrid Public Key Encryption (HPKE) key encapsulation mechanism (KEM).HPKE RFC is available at https://www.rfc-editor.org/rfc/rfc9180.html.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]authDecapsulate(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, byte[] senderPublicKey)Extracts the shared secret fromencapsulatedKeyusingrecipientPrivateKey.com.google.crypto.tink.hybrid.internal.HpkeKemEncapOutputauthEncapsulate(byte[] recipientPublicKey, HpkeKemPrivateKey senderPrivateKey)Similar toencapsulate(byte[]), but the output additionally encodes an assurance that the KEM shared secret was generated by the holder ofsenderPrivateKey.byte[]decapsulate(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey)Extracts the shared secret fromencapsulatedKeyusingrecipientPrivateKey.com.google.crypto.tink.hybrid.internal.HpkeKemEncapOutputencapsulate(byte[] recipientPublicKey)Generates and encapsulates a shared secret using therecipientPublicKey.byte[]getKemId()Returns the HPKE KEM algorithm identifier for the underlying KEM implementation.
-
-
-
Method Detail
-
encapsulate
com.google.crypto.tink.hybrid.internal.HpkeKemEncapOutput encapsulate(byte[] recipientPublicKey) throws java.security.GeneralSecurityExceptionGenerates and encapsulates a shared secret using therecipientPublicKey. Returns aHpkeKemEncapOutputobject that contains the raw shared secret and the encapsulated key. The HPKE RFC refers to this method as Encap(), which is used by the sender.- Throws:
java.security.GeneralSecurityException- when either the shared secret cannot be generated or the shared secret cannot be encapsulated.
-
decapsulate
byte[] decapsulate(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey) throws java.security.GeneralSecurityExceptionExtracts the shared secret fromencapsulatedKeyusingrecipientPrivateKey. Returns the raw shared secret. The HPKE RFC refers to this method as Decap(), which is used by the recipient.- Throws:
java.security.GeneralSecurityException- if the shared secret cannot be extracted.
-
authEncapsulate
com.google.crypto.tink.hybrid.internal.HpkeKemEncapOutput authEncapsulate(byte[] recipientPublicKey, HpkeKemPrivateKey senderPrivateKey) throws java.security.GeneralSecurityExceptionSimilar toencapsulate(byte[]), but the output additionally encodes an assurance that the KEM shared secret was generated by the holder ofsenderPrivateKey. Returns aHpkeKemEncapOutputobject that contains the raw shared secret and the encapsulated key. The HPKE RFC refers to this method as AuthEncap(), which is used by the sender.- Throws:
java.security.GeneralSecurityException- when either the shared secret cannot be generated or the shared secret cannot be encapsulated.
-
authDecapsulate
byte[] authDecapsulate(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey, byte[] senderPublicKey) throws java.security.GeneralSecurityExceptionExtracts the shared secret fromencapsulatedKeyusingrecipientPrivateKey. The recipient is assured that the KEM shared secret was generated by the holder of the private key corresponding tosenderPublicKey. Returns the raw shared secret. The HPKE RFC refers to this method as AuthDecap(), which is used by the recipient.- Throws:
java.security.GeneralSecurityException- if the shared secret cannot be extracted.
-
getKemId
byte[] getKemId() throws java.security.GeneralSecurityExceptionReturns the HPKE KEM algorithm identifier for the underlying KEM implementation.More details at https://www.rfc-editor.org/rfc/rfc9180.html#name-key-encapsulation-mechanism.
- Throws:
java.security.GeneralSecurityException
-
-