Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
xjava.security.IJCE_Traceable
xjava.security.Cipher
cryptix.provider.rsa.RawRSACipher
(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:
Field Summary |
Fields inherited from class xjava.security.Cipher | |
DECRYPT , ENCRYPT , UNINITIALIZED |
Fields inherited from class xjava.security.IJCE_Traceable | |
tracing |
Constructor Summary | |
|
Method Summary | |
protected int |
|
protected void |
|
protected void |
|
protected int |
|
protected int |
|
static void |
|
static void |
|
Methods inherited from class xjava.security.IJCE_Traceable | |
disableTracing , enableTracing , traceMethod , traceResult , traceResult , traceVoidMethod |
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".
protected int engineCiphertextBlockSize()
SPI: Returns the length of a ciphertext block, in bytes. For byte-oriented stream ciphers, this method should return 1. The value may change wheninitEncrypt
orinitDecrypt
is called, but it should not change at other times. The default implementation returnsengineBlockSize()
.
- Overrides:
- engineCiphertextBlockSize in interface Cipher
- Returns:
- the length in bytes of a ciphertext block for this cipher.
protected void engineInitDecrypt(Key key) throws InvalidKeyException
SPI: Initializes this cipher object for decryption, using the given private key.
- Overrides:
- engineInitDecrypt in interface Cipher
- Parameters:
key
- the private key to be used for decryption.
protected void engineInitEncrypt(Key key) throws InvalidKeyException
SPI: Initializes this cipher object for encryption, using the given public key.
- Overrides:
- engineInitEncrypt in interface Cipher
- Parameters:
key
- the public key to be used for encryption.
protected int enginePlaintextBlockSize()
SPI: Return the block size, in bytes. For RawRSA this is the number of bytes needed to represent the modulus, n.
- Overrides:
- enginePlaintextBlockSize in interface Cipher
- Returns:
- the block size in bytes.
protected int engineUpdate(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
SPI: This is the main engine method for updating data. WhenimplBuffering
is true, this method will be called with the same data that is passed toupdate
orcrypt
(i.e. there will be exactly one call toengineUpdate
for each call toupdate
orcrypt
). WhenimplBuffering
is false, the Cipher superclass will ensure that when it calls this method, inLen is a non-negative multiple ofgetInputBlockSize()
. in and out may be the same array, and the input and output regions may overlap. A cipher implementation should not use any part of in or out as working storage for intermediate steps of the algorithm. It should copy only the final result into the out array. SECURITY: if array arguments are passed to native code, the implementation must ensure that a buffer overflow or illegal memory access cannot occur, regardless of the arguments passed to this method. I.e. the native library should not be called if:in == null || out == null || inLen <320 || inLen % (block size) != 0 || inOffset <320 || (long)inOffset + inLen > in.length || outOffset <320 || (long)outOffset + (number of bytes to be written) > out.lengthNote that the(long)
casts are essential, because inOffset or outOffset could be close toInteger.MAX_VALUE
. The native method being called should be private. This is important because untrusted code could subclass the cipher implementation, and call this method directly with any arguments.
- Overrides:
- engineUpdate in interface Cipher
- Parameters:
in
- the input data.inOffset
- the offset into in specifying where the data starts.inLen
- the length of the subarray.out
- the output array.outOffset
- the offset indicating where to start writing into the out array.
- Returns:
- the number of bytes written.
public static final void main(String[] args)
Entry point for very basicself_test
.
public static void self_test(PrintWriter out) throws Exception