Package org.conscrypt
Class HpkeContextRecipient
- java.lang.Object
-
- org.conscrypt.HpkeContext
-
- org.conscrypt.HpkeContextRecipient
-
public class HpkeContextRecipient extends HpkeContext
Hybrid Public Key Encryption (HPKE) recipient APIs.- See Also:
- HPKE RFC 9180 Recipient subclass of HpkeContext. See base class for details.
-
-
Field Summary
-
Fields inherited from class org.conscrypt.HpkeContext
spi
-
-
Constructor Summary
Constructors Modifier Constructor Description privateHpkeContextRecipient(HpkeSpi spi)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HpkeContextRecipientgetInstance(java.lang.String suite)Returns an uninitialised HpkeContextRecipient.static HpkeContextRecipientgetInstance(java.lang.String suite, java.lang.String providerName)Returns an uninitialised HpkeContextRecipient from a specificProviderstatic HpkeContextRecipientgetInstance(java.lang.String suite, java.security.Provider provider)Returns an uninitialised HpkeContextRecipient from a specificProvidervoidinit(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info)Initialises this HpkeContextRecipient in BASE mode, i.e.voidinit(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, byte[] psk, byte[] psk_id)Initialises this HpkeContextRecipient in PSK_AUTH mode, i.e.voidinit(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, java.security.PublicKey senderKey)Initialises this HpkeContextRecipient in AUTH mode, i.e.voidinit(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, java.security.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 Detail
-
HpkeContextRecipient
private HpkeContextRecipient(HpkeSpi spi)
-
-
Method Detail
-
open
public byte[] open(byte[] ciphertext, byte[] aad) throws java.security.GeneralSecurityExceptionOpens 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:
java.lang.IllegalStateException- if this HpkeContextRecipient has not been initialisedjava.security.GeneralSecurityException- on decryption failures
-
getInstance
public static HpkeContextRecipient getInstance(java.lang.String suite) throws java.security.NoSuchAlgorithmException
Returns an uninitialised HpkeContextRecipient.- Parameters:
suite- the HPKE suite to use. @seeHpkeSuitefor details.- Returns:
- an uninitialised HpkeContextRecipient for the requested suite
- Throws:
java.security.NoSuchAlgorithmException- if no implementation could be found
-
getInstance
public static HpkeContextRecipient getInstance(java.lang.String suite, java.lang.String providerName) throws java.security.NoSuchAlgorithmException, java.security.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:
java.security.NoSuchAlgorithmException- if no implementation could be foundjava.security.NoSuchProviderException- if providerName is null or no such Provider exists
-
getInstance
public static HpkeContextRecipient getInstance(java.lang.String suite, java.security.Provider provider) throws java.security.NoSuchAlgorithmException, java.security.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:
java.security.NoSuchAlgorithmException- if no implementation could be foundjava.security.NoSuchProviderException- if providerName is null or no such Provider exists
-
init
public void init(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info) throws java.security.InvalidKeyExceptionInitialises 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:
java.security.InvalidKeyException- if recipientKey is null or an unsupported key formatjava.lang.UnsupportedOperationException- if mode is not a supported HPKE modejava.lang.IllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, java.security.PublicKey senderKey) throws java.security.InvalidKeyExceptionInitialises 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:
java.security.InvalidKeyException- if either recipientKey or senderKey are null or an unsupported key formatjava.lang.UnsupportedOperationException- if mode is not a supported HPKE modejava.lang.IllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, byte[] psk, byte[] psk_id) throws java.security.InvalidKeyExceptionInitialises 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:
java.lang.NullPointerException- if psk or psk_id are nulljava.security.InvalidKeyException- if recipientKey is null or an unsupported key formatjava.lang.UnsupportedOperationException- if mode is not a supported HPKE modejava.lang.IllegalStateException- if this HpkeContextRecipient has already been initialised
-
init
public void init(byte[] encapsulated, java.security.PrivateKey recipientKey, byte[] info, java.security.PublicKey senderKey, byte[] psk, byte[] psk_id) throws java.security.InvalidKeyExceptionInitialises 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:
java.lang.NullPointerException- if psk or psk_id are nulljava.security.InvalidKeyException- if either recipientKey or senderKey are null or an unsupported key formatjava.lang.UnsupportedOperationException- if mode is not a supported HPKE modejava.lang.IllegalStateException- if this HpkeContextRecipient has already been initialised
-
-