Package org.bouncycastle.crypto.kems
Class RSAKeyEncapsulation
java.lang.Object
org.bouncycastle.crypto.kems.RSAKeyEncapsulation
- All Implemented Interfaces:
KeyEncapsulation
The RSA Key Encapsulation Mechanism (RSA-KEM) from ISO 18033-2.
-
Constructor Summary
ConstructorsConstructorDescriptionSet up the RSA-KEM. -
Method Summary
Modifier and TypeMethodDescriptiondecrypt(byte[] in, int keyLen) Decrypt an encapsulated session key.decrypt(byte[] in, int inOff, int inLen, int keyLen) Decrypt an encapsulated session key.encrypt(byte[] out, int keyLen) Generate and encapsulate a random session key.encrypt(byte[] out, int outOff, int keyLen) Generate and encapsulate a random session key.protected KeyParametergenerateKey(BigInteger n, BigInteger r, int keyLen) voidinit(CipherParameters key) Initialise the RSA-KEM.
-
Constructor Details
-
RSAKeyEncapsulation
Set up the RSA-KEM.- Parameters:
kdf- the key derivation function to be used.rnd- the random source for the session key.
-
-
Method Details
-
init
Initialise the RSA-KEM.- Specified by:
initin interfaceKeyEncapsulation- Parameters:
key- the recipient's public (for encryption) or private (for decryption) key.- Throws:
IllegalArgumentException
-
encrypt
Generate and encapsulate a random session key.- Specified by:
encryptin interfaceKeyEncapsulation- Parameters:
out- the output buffer for the encapsulated key.outOff- the offset for the output buffer.keyLen- the length of the random session key.- Returns:
- the random session key.
- Throws:
IllegalArgumentException
-
encrypt
Generate and encapsulate a random session key.- Parameters:
out- the output buffer for the encapsulated key.keyLen- the length of the random session key.- Returns:
- the random session key.
-
decrypt
public CipherParameters decrypt(byte[] in, int inOff, int inLen, int keyLen) throws IllegalArgumentException Decrypt an encapsulated session key.- Specified by:
decryptin interfaceKeyEncapsulation- Parameters:
in- the input buffer for the encapsulated key.inOff- the offset for the input buffer.inLen- the length of the encapsulated key.keyLen- the length of the session key.- Returns:
- the session key.
- Throws:
IllegalArgumentException
-
decrypt
Decrypt an encapsulated session key.- Parameters:
in- the input buffer for the encapsulated key.keyLen- the length of the session key.- Returns:
- the session key.
-
generateKey
-