public class RSAKeyEncapsulation extends Object implements KeyEncapsulation
Constructor and Description |
---|
RSAKeyEncapsulation(DerivationFunction kdf,
SecureRandom rnd)
Set up the RSA-KEM.
|
Modifier and Type | Method and Description |
---|---|
CipherParameters |
decrypt(byte[] in,
int keyLen)
Decrypt an encapsulated session key.
|
CipherParameters |
decrypt(byte[] in,
int inOff,
int inLen,
int keyLen)
Decrypt an encapsulated session key.
|
CipherParameters |
encrypt(byte[] out,
int keyLen)
Generate and encapsulate a random session key.
|
CipherParameters |
encrypt(byte[] out,
int outOff,
int keyLen)
Generate and encapsulate a random session key.
|
protected KeyParameter |
generateKey(BigInteger n,
BigInteger r,
int keyLen) |
void |
init(CipherParameters key)
Initialise the RSA-KEM.
|
public RSAKeyEncapsulation(DerivationFunction kdf, SecureRandom rnd)
kdf
- the key derivation function to be used.rnd
- the random source for the session key.public void init(CipherParameters key) throws IllegalArgumentException
init
in interface KeyEncapsulation
key
- the recipient's public (for encryption) or private (for decryption) key.IllegalArgumentException
public CipherParameters encrypt(byte[] out, int outOff, int keyLen) throws IllegalArgumentException
encrypt
in interface KeyEncapsulation
out
- the output buffer for the encapsulated key.outOff
- the offset for the output buffer.keyLen
- the length of the random session key.IllegalArgumentException
public CipherParameters encrypt(byte[] out, int keyLen)
out
- the output buffer for the encapsulated key.keyLen
- the length of the random session key.public CipherParameters decrypt(byte[] in, int inOff, int inLen, int keyLen) throws IllegalArgumentException
decrypt
in interface KeyEncapsulation
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.IllegalArgumentException
public CipherParameters decrypt(byte[] in, int keyLen)
in
- the input buffer for the encapsulated key.keyLen
- the length of the session key.protected KeyParameter generateKey(BigInteger n, BigInteger r, int keyLen)
Copyright © 2018 BouncyCastle.org. All rights reserved.