public class CkiRSApkcs1
extends Cipher
Constructor and Description |
---|
CkiRSApkcs1()
Creates a new CkiRSApkcs1 object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
algName()
The algorithm for which this key is used.
|
int |
blockSize()
Deprecated.
|
byte[] |
decrypt(byte[] bytes)
Decrypts the given encrypted block with the decryption key.
|
byte[] |
decrypt(byte[] bytes,
int inOff,
int len,
boolean unpad)
Decrypts a sequence of bytes of specified length.
|
void |
decrypt(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
Decrypts a sequence of bytes of specified length and places the original
plaintext message in the given output buffer starting at the given
offset.
|
void |
decryptOp(byte[] in,
int inOff,
byte[] out,
int outOff)
Deprecated.
|
byte[] |
encrypt(byte[] bytes)
Encrypts the given data with the encryption key.
|
byte[] |
encrypt(byte[] bytes,
int inOff,
int len,
boolean pad)
Encrypts a sequence of bytes of specified length.
|
void |
encrypt(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
Encrypts a sequence of bytes of specified length and places the
resulting ciphertext in the given output buffer starting at the given
offset.
|
void |
encryptOp(byte[] in,
int inOff,
byte[] out,
int outOff)
Deprecated.
|
void |
erase()
Erase the keys.
|
void |
finalize() |
AlgorithmIdentifier |
getAlgID()
Returns the algorithm identifier for this key.
|
int |
getBlockSize()
The blocksize returns 0.
|
void |
initialize(AlgorithmIdentifier algID,
Key key)
This method initializes the cipher with the given AlgorithmIdentifier and
then configures itself with the given key.
|
void |
setAlgID(AlgorithmIdentifier algID)
Deprecated.
Use an initialize method.
|
void |
setDecryptionKey(Key key)
Deprecated.
Use an initialize method instead.
|
void |
setEncryptionKey(Key key)
Deprecated.
Use an initialize method instead.
|
void |
setKey(SymmetricKey key)
Deprecated.
Use an initialize method instead.
|
void |
setSession(CkiMgtSession session)
Sets the session to be used within this Cipher object.
|
public void initialize(AlgorithmIdentifier algID, Key key) throws AlgorithmIdentifierException, InvalidKeyException, CipherException
algID
- is the AlgorithmIdentifier whose params will be used
to configure the cipher.key
- is the Key instance that will be used by the cipher
internally. This instance will be erased when the
Cipher.erase()
is called.^MAlgorithmIdentifierException
- is thrown if the algID's OID isn't
valid for the Cipher instance being initialized or
if the params are not valid for the algID's OID.InvalidKeyException
- is thrown if there is a problem with the Key
instance the Cipher is being initialized with.CipherException
- is thrown if the op argument is null.public void setSession(CkiMgtSession session)
public void setAlgID(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
AlgorithmIdentifierException
public AlgorithmIdentifier getAlgID()
public java.lang.String algName()
public int blockSize()
public int getBlockSize()
public void setKey(SymmetricKey key) throws InvalidKeyException
InvalidKeyException
- is always thrown here.public void setDecryptionKey(Key key) throws InvalidKeyException
InvalidKeyException
- is thrown if the the key is not valid for
the Cipher instancepublic void setEncryptionKey(Key key) throws InvalidKeyException
InvalidKeyException
- is thrown if the the key is not valid for
the Cipher instancepublic byte[] decrypt(byte[] bytes) throws CipherException
bytes
- the data block to decrypt.CipherException
- if the given block is not the right size or is incorrectly formatted,
or uses a block type which is not supported.
An exception is also thrown if the key cannot be found on the token.public byte[] decrypt(byte[] bytes, int inOff, int len, boolean unpad) throws CipherException
bytes
- Buffer in which data to be decrypted is stored.inOff
- Offset within buffer of the start of data.len
- The length of the dataunpad
- is an ignored parameter because encoding data is not
optional in RSA Encryption.CipherException
- if cipher not initialized,
data is not a multiple of the block size and no padding is specified, etc.public void decrypt(byte[] input, int inOff, int len, byte[] output, int outOff) throws CipherException
input
- array of bytes to decryptinOff
- offset of the start of the data to decryptlen
- the length of the data to decryptoutput
- array to place the decrypted bytesoutOff
- offset of the start of the decrypted bytesCipherException
- is thrown if there is a problem with
the decryption process or if the cipher was initialized for
encryption.public byte[] encrypt(byte[] bytes) throws CipherException
bytes
- the data to encrypt.CipherException
- if the given data is too long, or if the key cannot be found on the token.public byte[] encrypt(byte[] bytes, int inOff, int len, boolean pad) throws CipherException
bytes
- buffer in which data to be encrypted is stored.inOff
- offset within buffer of the start of the data.len
- the length of the data.pad
- is an ignored parameter because encoding data is not
optional in RSA Encryption.CipherException
- if cipher not initialized, data is not
a multiple of the block size and no padding is specified, etc.public void encrypt(byte[] input, int inOff, int len, byte[] output, int outOff) throws CipherException
input
- array of bytes to encryptinOff
- offset of the start of data to encryptlen
- the length of the data to encryptoutput
- array to place the encrypted bytesoutOff
- offset of the start of the encrypted bytesCipherException
- is thrown if there are problems with the
encryption operation or if the Cipher was initialized
for decryption.public void encryptOp(byte[] in, int inOff, byte[] out, int outOff) throws CipherException
CipherException
public void decryptOp(byte[] in, int inOff, byte[] out, int outOff) throws CipherException
CipherException
public void erase()
public void finalize()