All Packages Class Hierarchy This Package Previous Next Index
Class cryptix.provider.rsa.RawRSACipher
java.lang.Object
|
+----java.security.IJCE_Traceable
|
+----java.security.Cipher
|
+----cryptix.provider.rsa.RawRSACipher
- public class RawRSACipher
- extends Cipher
- implements AsymmetricCipher, Cloneable
The raw RSA encryption algorithm, without any block framing.
If the number of bits in the modulus is bitlength, the plaintext and
ciphertext block sizes will both be (int) ((bitlength+7)/8)
.
When in ENCRYPT mode, if the value of any plaintext block, considered as a
BigInteger with Big-Endian byte order, is greater than or equal to the
modulus, a CryptixException will be thrown.
This class is designed to allow any input to the RSA encryption algorithm,
in order to facilitate implementation of standards which use a block framing
format not otherwise supported by Cryptix. Note that using raw RSA directly on
application data is potentially insecure; wherever possible a higher level
algorithm such as "RSA/PKCS#1" should be used.
(Note: RSA/PKCS#1 is not implemented in this version of Cryptix.)
References:
- Bruce Schneier,
"Section 19.3 RSA,"
Applied Cryptography, 2nd edition,
John Wiley & Sons, 1996.
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.5 $
- Author:
- Raif S. Naffah, David Hopwood
-
RawRSACipher()
- Constructs a RawRSA cipher object, in the UNINITIALIZED state.
-
engineBlockSize()
- SPI: Return the block size, in bytes.
-
engineInitDecrypt(Key)
- SPI: Initializes this cipher object for decryption, using the
given private key.
-
engineInitEncrypt(Key)
- SPI: Initializes this cipher object for encryption, using the
given public key.
-
engineUpdate(byte[], int, int, byte[], int)
- SPI: This is the main engine method for updating data.
-
main(String[])
- Entry point for very basic
self_test
.
-
self_test(PrintWriter)
-
RawRSACipher
public RawRSACipher()
- Constructs a RawRSA cipher object, in the UNINITIALIZED state.
This calls the Cipher constructor with implBuffering false,
implPadding false and the provider set to "Cryptix".
engineInitEncrypt
protected void engineInitEncrypt(Key key) throws InvalidKeyException
- SPI: Initializes this cipher object for encryption, using the
given public key.
- Parameters:
- key - the public key to be used for encryption.
- Throws: InvalidKeyException
- if the key class does not implement
java.security.interfaces.RSAPublicKey.
- Overrides:
- engineInitEncrypt in class Cipher
engineInitDecrypt
protected void engineInitDecrypt(Key key) throws InvalidKeyException
- SPI: Initializes this cipher object for decryption, using the
given private key.
- Parameters:
- key - the private key to be used for decryption.
- Throws: InvalidKeyException
- if the key class does not implement
java.security.interfaces.RSAPrivateKey.
- Overrides:
- engineInitDecrypt in class Cipher
engineBlockSize
protected int engineBlockSize()
- SPI: Return the block size, in bytes. For RawRSA this is the number
of bytes needed to represent the modulus, n.
- Returns:
- the block size in bytes.
- Throws: CryptixException
- if the cipher object is uninitialized.
- Overrides:
- engineBlockSize in class Cipher
engineUpdate
protected int engineUpdate(byte in[],
int inOffset,
int inLen,
byte out[],
int outOffset)
- SPI: This is the main engine method for updating data.
- Overrides:
- engineUpdate in class Cipher
main
public static final void main(String args[])
- Entry point for very basic
self_test
.
self_test
public static void self_test(PrintWriter out) throws Exception
All Packages Class Hierarchy This Package Previous Next Index