Package org.conscrypt
Class DuckTypedHpkeSpi
- java.lang.Object
-
- org.conscrypt.DuckTypedHpkeSpi
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Objectdelegateprivate java.util.Map<java.lang.String,java.lang.reflect.Method>methods-
Fields inherited from interface org.conscrypt.HpkeSpi
DEFAULT_PSK, DEFAULT_PSK_ID
-
-
Constructor Summary
Constructors Modifier Constructor Description privateDuckTypedHpkeSpi(java.lang.Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]engineExport(int length, byte[] exporterContext)Exports secret key material from this SPI as described in RFC 9180.voidengineInitRecipient(byte[] encapsulated, java.security.PrivateKey key, byte[] info, java.security.PublicKey senderKey, byte[] psk, byte[] psk_id)Initialises an HPKE recipient SPI.voidengineInitSender(java.security.PublicKey recipientKey, byte[] info, java.security.PrivateKey senderKey, byte[] psk, byte[] pskId)Initialises an HPKE sender SPI.voidengineInitSenderForTesting(java.security.PublicKey recipientKey, byte[] info, java.security.PrivateKey senderKey, byte[] psk, byte[] pskId, byte[] sKe)Initialises an HPKE sender SPI.byte[]engineOpen(byte[] ciphertext, byte[] aad)Opens a message, using the internal key schedule maintained by an HPKE recipient.byte[]engineSeal(byte[] plaintext, byte[] aad)Seals a message, using the internal key schedule maintained by an HPKE sender.java.lang.ObjectgetDelegate()byte[]getEncapsulated()Returns the encapsulated key material for an HPKE sender.private java.lang.Objectinvoke(java.lang.String methodName, java.lang.Object... args)private java.lang.ObjectinvokeNoChecked(java.lang.String methodName, java.lang.Object... args)private java.lang.ObjectinvokeWithPossibleGeneralSecurity(java.lang.String methodName, java.lang.Object... args)private voidinvokeWithPossibleInvalidKey(java.lang.String methodName, java.lang.Object... args)static DuckTypedHpkeSpinewInstance(java.lang.Object delegate)
-
-
-
Method Detail
-
newInstance
public static DuckTypedHpkeSpi newInstance(java.lang.Object delegate)
-
invoke
private java.lang.Object invoke(java.lang.String methodName, java.lang.Object... args) throws java.lang.reflect.InvocationTargetException- Throws:
java.lang.reflect.InvocationTargetException
-
invokeWithPossibleInvalidKey
private void invokeWithPossibleInvalidKey(java.lang.String methodName, java.lang.Object... args) throws java.security.InvalidKeyException- Throws:
java.security.InvalidKeyException
-
invokeWithPossibleGeneralSecurity
private java.lang.Object invokeWithPossibleGeneralSecurity(java.lang.String methodName, java.lang.Object... args) throws java.security.GeneralSecurityException- Throws:
java.security.GeneralSecurityException
-
invokeNoChecked
private java.lang.Object invokeNoChecked(java.lang.String methodName, java.lang.Object... args)
-
getDelegate
public java.lang.Object getDelegate()
-
engineInitSender
public void engineInitSender(java.security.PublicKey recipientKey, byte[] info, java.security.PrivateKey senderKey, byte[] psk, byte[] pskId) throws java.security.InvalidKeyExceptionDescription copied from interface:HpkeSpiInitialises an HPKE sender SPI.- Specified by:
engineInitSenderin interfaceHpkeSpi- Parameters:
recipientKey- public key of the recipientinfo- application-supplied information, may be null or emptysenderKey- private key of the sender, for symmetric auth modes only, else nullpsk- pre-shared key, for PSK auth modes only, else nullpskId- pre-shared key ID, for PSK auth modes only, else null- Throws:
java.security.InvalidKeyException- if recipientKey is null or an unsupported key format
-
engineInitSenderForTesting
public void engineInitSenderForTesting(java.security.PublicKey recipientKey, byte[] info, java.security.PrivateKey senderKey, byte[] psk, byte[] pskId, byte[] sKe) throws java.security.InvalidKeyExceptionDescription copied from interface:HpkeSpiInitialises an HPKE sender SPI.- Specified by:
engineInitSenderForTestingin interfaceHpkeSpi- Parameters:
recipientKey- public key of the recipientinfo- application-supplied information, may be null or emptysenderKey- private key of the sender, for symmetric auth modes only, else nullpsk- pre-shared key, for PSK auth modes only, else nullpskId- pre-shared key ID, for PSK auth modes only, else nullsKe- optional random seed, should be null for all uses except for validation against known test vectors- Throws:
java.security.InvalidKeyException- if recipientKey is null or an unsupported key format or senderKey is an unsupported key format
-
engineInitRecipient
public void engineInitRecipient(byte[] encapsulated, java.security.PrivateKey key, byte[] info, java.security.PublicKey senderKey, byte[] psk, byte[] psk_id) throws java.security.InvalidKeyExceptionDescription copied from interface:HpkeSpiInitialises an HPKE recipient SPI.- Specified by:
engineInitRecipientin interfaceHpkeSpi- Parameters:
encapsulated- encapsulated ephemeral key from a senderkey- private key of the recipientinfo- application-supplied information, may be null or emptysenderKey- public key of sender, for asymmetric auth modes only, else nullpsk- pre-shared key, for PSK auth modes only, else nullpsk_id- pre-shared key ID, for PSK auth modes only, else null- Throws:
java.security.InvalidKeyException- if recipientKey is null or an unsupported key format or senderKey is an unsupported key format
-
engineSeal
public byte[] engineSeal(byte[] plaintext, byte[] aad)Description copied from interface:HpkeSpiSeals a message, using the internal key schedule maintained by an HPKE sender.- Specified by:
engineSealin interfaceHpkeSpi- Parameters:
plaintext- the plaintextaad- optional associated data, may be null or empty- Returns:
- the ciphertext
-
engineExport
public byte[] engineExport(int length, byte[] exporterContext)Description copied from interface:HpkeSpiExports secret key material from this SPI as described in RFC 9180.- Specified by:
engineExportin interfaceHpkeSpi- Parameters:
length- expected output lengthexporterContext- optional context string, may be null or empty- Returns:
- exported value
-
engineOpen
public byte[] engineOpen(byte[] ciphertext, byte[] aad) throws java.security.GeneralSecurityExceptionDescription copied from interface:HpkeSpiOpens a message, using the internal key schedule maintained by an HPKE recipient.- Specified by:
engineOpenin interfaceHpkeSpi- Parameters:
ciphertext- the ciphertextaad- optional associated data, may be null or empty- Returns:
- the plaintext
- Throws:
java.security.GeneralSecurityException- on decryption failures
-
getEncapsulated
public byte[] getEncapsulated()
Description copied from interface:HpkeSpiReturns the encapsulated key material for an HPKE sender.- Specified by:
getEncapsulatedin interfaceHpkeSpi- Returns:
- the key material
-
-