|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.crypto.AbstractCipher tribble.crypto.AsymmetricCipher tribble.crypto.RSACipher
RSA, an asymmetric (public key) cipher.
RSA was invented in 1978 by Ron Rivest, Adi Shamir, and Leonard Adleman of Public Key Partners (PKP). Two weeks before the patent for RSA was due to expire in Sep 2000, PKP placed the algorithm into the public domain.
Copyright ©2003-2005 by David R. Tribble, all rights reserved.
THIS CODE MAY BE SUBJECT TO U.S. EXPORT RESTRICTIONS, AND SHOULD NOT BE
EXPORTED OUTSIDE THE BORDERS OF THE UNITED STATES OF AMERICA.
Within the confines of the U.S., however, permission is granted to
freely use and distribute this source code provided that the original
copyright and authorship notices remain intact.
Field Summary |
Fields inherited from class tribble.crypto.AbstractCipher |
m_alg, m_decrypt, m_init, m_keyLen |
Constructor Summary | |
RSACipher()
Constructor. |
Method Summary | |
protected void |
blockDecrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Decrypt a block of ciphertext. |
protected void |
blockEncrypt(byte[] in,
int inOff,
byte[] out,
int outOff)
Encrypt a block of plaintext. |
protected void |
clear()
Reset this cipher, wiping all sensitive information. |
int |
getCipherBlockSize()
Retrieve the ciphertext block size (in bytes) of this cipher. |
int |
getPlainBlockSize()
Retrieve the plaintext block size (in bytes) of this cipher. |
protected void |
initialize(byte[] key,
boolean decrypt)
Initialize this cipher. |
protected void |
initialize(java.security.spec.KeySpec key,
boolean decrypt)
Initialize this cipher. |
Methods inherited from class tribble.crypto.AbstractCipher |
finalize, getAlgorithm, getKeySize, getKeySizes |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RSACipher()
Method Detail |
public int getPlainBlockSize()
Due to the nature of the underlying arithmetic of the algorithm used, the plaintext block size is always one byte shorter than the ciphertext block size (which is the same size as the modulus).
getPlainBlockSize
in class AsymmetricCipher
getCipherBlockSize()
public int getCipherBlockSize()
Due to the nature of the underlying arithmetic of the algorithm used, the ciphertext block size is the same size as the modulus, and is always one byte longer than the plaintext block size.
getCipherBlockSize
in class AsymmetricCipher
getPlainBlockSize()
protected void initialize(byte[] key, boolean decrypt) throws java.security.InvalidKeyException
initialize
in class AbstractCipher
key
- The encryption key for this cipher.decrypt
- If true, this indicates that this cipher is to be initialized for
decrypting, otherwise it is to be initialized for encrypting.
java.security.InvalidKeyException
initialize()
,
clear()
protected void initialize(java.security.spec.KeySpec key, boolean decrypt) throws java.security.InvalidKeyException
initialize
in class AsymmetricCipher
key
- The asymmetric (public or private) key for this cipher.
This is an RSA public or private key.decrypt
- Specifies that this cipher is to be set up in decryption mode.
java.security.InvalidKeyException
clear()
protected void clear()
This method will be called after this cipher object is no longer needed. It should overwrite any sensitive data contained within this object (e.g., encryption key schedules). This cipher object can no longer be used after this method has been called.
clear
in class AbstractCipher
initialize()
protected void blockEncrypt(byte[] in, int inOff, byte[] out, int outOff)
blockEncrypt
in class AsymmetricCipher
in
- A block of bytes to encrypt.
The number of plaintext bytes read from the block is the length returned
by getPlainBlockSize()
.inOff
- The index of the first byte of array in to encrypt.out
- An array that will be filled with the encrypted bytes.
The number of ciphertext bytes written to the block is the length returned
by getCipherBlockSize()
.outOff
- The index of the first byte of array out to fill.blockDecrypt()
protected void blockDecrypt(byte[] in, int inOff, byte[] out, int outOff)
blockDecrypt
in class AsymmetricCipher
in
- A block of bytes to decrypt.
The number of ciphertext bytes read from the block is the length returned
by getCipherBlockSize()
.inOff
- The index of the first byte of array in to decrypt.out
- An array that will be filled with the decrypted bytes.
The number of plaintext bytes written to the block is the length returned
by getPlainBlockSize()
.outOff
- The index of the first byte of array out to fill.blockEncrypt()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |