au.net.aba.crypto.provider
Class RSA
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--au.net.aba.crypto.provider.BlockCipher
|
+--au.net.aba.crypto.provider.RSA
- public class RSA
- extends BlockCipher
A class that provides RSA public/private key encryption and
decryption as specified in PKCS#1.
By default this cipher will use PKCS#1 padding however it
also supports NoPadding.
Field Summary |
static java.lang.String |
ident
|
Fields inherited from class au.net.aba.crypto.provider.BlockCipher |
BLOCK_SIZE,
buffer,
bufferPos,
CBC,
cbcV,
ECB,
firstBlock,
ident,
ivec,
ivEncrypted,
ivInline,
key,
mode,
paddedStream,
random,
streamMode |
Constructor Summary |
RSA()
|
Method Summary |
protected int |
decryptBlock(byte[] src,
int srcIndex,
int len,
byte[] dst,
int dstIndex)
This method decrypts the specified array, placing the plain text
data into the destination array. |
protected java.math.BigInteger |
encrypt(java.math.BigInteger plainText)
Encrypt a data block. |
protected int |
encryptBlock(byte[] src,
int srcIndex,
int len,
byte[] dst,
int dstIndex)
This method encrypts the specified array, placing the
ciphered data into the destination array. |
protected int |
engineGetBlockSize()
Returns the block size. |
protected int |
engineGetOutputSize(int inputLen)
Returns the length in bytes that an output buffer would need to be
in order to hold the result of the next update or doFinal operation,
given the input length inputLen (in bytes). |
void |
engineSetMode(java.lang.String mode)
Sets the mode of this cipher. |
void |
engineSetPadding(java.lang.String padding)
Sets the padding mechanism of this cipher. |
protected void |
setKey(java.security.Key key)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ident
public static final java.lang.String ident
RSA
public RSA()
setKey
protected void setKey(java.security.Key key)
throws java.security.InvalidKeyException
- Overrides:
- setKey in class BlockCipher
engineSetMode
public void engineSetMode(java.lang.String mode)
throws java.security.NoSuchAlgorithmException
- Sets the mode of this cipher.
- Parameters:
mode
- the mode of the cipher (ECB, CBC). Currently only
ECB is supported.- Throws:
- java.security.NoSuchAlgorithmException - if the mode is not supported.
- Overrides:
- engineSetMode in class BlockCipher
engineSetPadding
public void engineSetPadding(java.lang.String padding)
throws NoSuchPaddingException
- Sets the padding mechanism of this cipher.
- Parameters:
padding
- the name of the type of padding to be applied,
currently "PKCS1Padding", and "NoPadding" will
be accepted.- Throws:
- NoSuchPaddingException - if the padding type is unknown.
- Overrides:
- engineSetPadding in class BlockCipher
engineGetBlockSize
protected int engineGetBlockSize()
- Returns the block size. In encryption mode this will be
the size of the key less the header bytes, in decryption
mode it will be the size of the key.
- Overrides:
- engineGetBlockSize in class BlockCipher
engineGetOutputSize
protected int engineGetOutputSize(int inputLen)
- Returns the length in bytes that an output buffer would need to be
in order to hold the result of the next update or doFinal operation,
given the input length inputLen (in bytes).
- Overrides:
- engineGetOutputSize in class BlockCipher
encryptBlock
protected final int encryptBlock(byte[] src,
int srcIndex,
int len,
byte[] dst,
int dstIndex)
throws IllegalBlockSizeException
- This method encrypts the specified array, placing the
ciphered data into the destination array.
- Parameters:
src
- The plain text.srcIndex
- The index from which to read.len
- The length of the plain text.dst
- The cipher text.dstIndex
- The index at which to write.- Returns:
- The number of bytes processed.
- Overrides:
- encryptBlock in class BlockCipher
decryptBlock
protected final int decryptBlock(byte[] src,
int srcIndex,
int len,
byte[] dst,
int dstIndex)
throws BadPaddingException
- This method decrypts the specified array, placing the plain text
data into the destination array.
- Parameters:
src
- The cipher text.srcIndex
- The index from which to read.len
- The lenght of the cipher text.dst
- The plain text.dstIndex
- The index at which to write.- Returns:
- The number of bytes of plaintext.
- Overrides:
- decryptBlock in class BlockCipher
encrypt
protected java.math.BigInteger encrypt(java.math.BigInteger plainText)
- Encrypt a data block.
- Parameters:
plainText
- The plain text block to encrypt.- Returns:
- The encrypted data.