Class HpkeContextRecipient
java.lang.Object
org.conscrypt.HpkeContext
org.conscrypt.HpkeContextRecipient
Hybrid Public Key Encryption (HPKE) recipient APIs.
- See Also:
-
Field Summary
Fields inherited from class HpkeContext
spi -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HpkeContextRecipientgetInstance(String suite) Returns an uninitialised HpkeContextRecipient.static HpkeContextRecipientgetInstance(String suite, String providerName) Returns an uninitialised HpkeContextRecipient from a specificProviderstatic HpkeContextRecipientgetInstance(String suite, Provider provider) Returns an uninitialised HpkeContextRecipient from a specificProvidervoidinit(byte[] encapsulated, PrivateKey recipientKey, byte[] info) Initialises this HpkeContextRecipient in BASE mode, i.e.voidinit(byte[] encapsulated, PrivateKey recipientKey, byte[] info, byte[] psk, byte[] psk_id) Initialises this HpkeContextRecipient in PSK_AUTH mode, i.e.voidinit(byte[] encapsulated, PrivateKey recipientKey, byte[] info, PublicKey senderKey) Initialises this HpkeContextRecipient in AUTH mode, i.e.voidinit(byte[] encapsulated, PrivateKey recipientKey, byte[] info, PublicKey senderKey, byte[] psk, byte[] psk_id) Initialises this HpkeContextRecipient in PSK_AUTH mode, i.e.byte[]open(byte[] ciphertext, byte[] aad) Opens a message, using the internal key schedule maintained by this HpkeContextRecipient.
-
Constructor Details
-
HpkeContextRecipient
-
-
Method Details
-
open
Opens a message, using the internal key schedule maintained by this HpkeContextRecipient.- Parameters:
ciphertext- the ciphertextaad- optional associated data, may be null or empty- Returns:
- the plaintext
- Throws:
IllegalStateException- if this HpkeContextRecipient has not been initialisedGeneralSecurityException- on decryption failures
-
getInstance
Returns an uninitialised HpkeContextRecipient.- Parameters:
suite- the HPKE suite to use. @seeHpkeSuitefor details.- Returns:
- an uninitialised HpkeContextRecipient for the requested suite
- Throws:
NoSuchAlgorithmException- if no implementation could be found
-
getInstance
public static HpkeContextRecipient getInstance(String suite, String providerName) throws NoSuchAlgorithmException, NoSuchProviderException Returns an uninitialised HpkeContextRecipient from a specificProvider- Parameters:
suite- the HPKE suite to use. @seeHpkeSuitefor details.providerName- the name of the Provider to use- Returns:
- an uninitialised HpkeContextRecipient for the requested suite
- Throws:
NoSuchAlgorithmException- if no implementation could be foundNoSuchProviderException- if providerName is null or no such Provider exists
-
getInstance
public static HpkeContextRecipient getInstance(String suite, Provider provider) throws NoSuchAlgorithmException, NoSuchProviderException Returns an uninitialised HpkeContextRecipient from a specificProvider- Parameters:
suite- the HPKE suite to use. @seeHpkeSuitefor details.provider- the Provider to use- Returns:
- an uninitialised HpkeContextRecipient for the requested suite
- Throws:
NoSuchAlgorithmException- if no implementation could be foundNoSuchProviderException- if providerName is null or no such Provider exists
-
init
public void init(byte[] encapsulated, PrivateKey recipientKey, byte[] info) throws InvalidKeyException Initialises this HpkeContextRecipient in BASE mode, i.e. no sender authentication.- Parameters:
encapsulated- encapsulated ephemeral key from anHpkeContextSenderrecipientKey- private key of the recipientinfo- application-supplied information, may be null or empty- Throws:
InvalidKeyException- if recipientKey is null or an unsupported key formatUnsupportedOperationException- if mode is not a supported HPKE modeIllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, PrivateKey recipientKey, byte[] info, PublicKey senderKey) throws InvalidKeyException Initialises this HpkeContextRecipient in AUTH mode, i.e. messages are authenticated using the sender's public key.- Parameters:
encapsulated- encapsulated ephemeral key from anHpkeContextSenderrecipientKey- private key of the recipientinfo- application-supplied information, may be null or emptysenderKey- the public key of the sender- Throws:
InvalidKeyException- if either recipientKey or senderKey are null or an unsupported key formatUnsupportedOperationException- if mode is not a supported HPKE modeIllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, PrivateKey recipientKey, byte[] info, byte[] psk, byte[] psk_id) throws InvalidKeyException Initialises this HpkeContextRecipient in PSK_AUTH mode, i.e. messages are authenticated using a pre-shared secret key.- Parameters:
encapsulated- encapsulated ephemeral key from anHpkeContextSenderrecipientKey- private key of the recipientinfo- application-supplied information, may be null or emptypsk- the a pre-shared secret keypsk_id- the id of the pre-shared secret key- Throws:
NullPointerException- if psk or psk_id are nullInvalidKeyException- if recipientKey is null or an unsupported key formatUnsupportedOperationException- if mode is not a supported HPKE modeIllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, PrivateKey recipientKey, byte[] info, PublicKey senderKey, byte[] psk, byte[] psk_id) throws InvalidKeyException Initialises this HpkeContextRecipient in PSK_AUTH mode, i.e. messages are authenticated using both the sender's public key and a pre-shared secret key.- Parameters:
encapsulated- encapsulated ephemeral key from anHpkeContextSenderrecipientKey- private key of the recipientinfo- application-supplied information, may be null or emptysenderKey- the public key of the senderpsk- the a pre-shared secret keypsk_id- the id of the pre-shared secret key- Throws:
NullPointerException- if psk or psk_id are nullInvalidKeyException- if either recipientKey or senderKey are null or an unsupported key formatUnsupportedOperationException- if mode is not a supported HPKE modeIllegalStateException- if this HpkeContextRecipient has already been initialised
-