|
|||||||||
Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
cryptix.jce.provider.cipher
Class RC4

java.lang.Objectjavax.crypto.CipherSpi
cryptix.jce.provider.cipher.RC4
- public final class RC4
- extends javax.crypto.CipherSpi
This class implements the RC4TM stream cipher.
The source code (C version) from which this port was done, is the one posted to the sci.crypt, alt.security, comp.security.misc, and alt.privacy newsgroups on Wed, 14 Sep 1994 06:35:31 GMT by "David Sterndark" <sterndark@netcom.com> (Message-ID: <sternCvKL4B.Hyy@netcom.com>)
RC4 (TM) was designed by Ron Rivest, and was previously a trade secret of RSA Data Security, Inc. The algorithm is now in the public domain. The name "RC4" is a trademark of RSA Data Security, Inc.
References:
- Bruce Schneier, "Section 17.1 RC4," Applied Cryptography, 2nd edition, John Wiley & Sons, 1996.
- Since:
- Cryptix 2.2.2
- Version:
- $Revision: 1.6 $
Field Summary | |
private static int |
BLOCK_SIZE
The block size of this cipher. |
private int[] |
sBox
Contents of the current set S-box. |
private int |
x
The two indices for the S-box computation referred to as i and j in Schneier. |
private int |
y
The two indices for the S-box computation referred to as i and j in Schneier. |
Constructor Summary | |
RC4()
Constructs an RC4 cipher object, in the UNINITIALIZED state. |
Method Summary | |
java.lang.Object |
clone()
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons). |
protected byte[] |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen)
Finishes a multi-part transformation or transforms a portion of a byte array, and returns the transformed bytes. |
protected int |
engineDoFinal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Finishes a multi-part transformation or transforms a portion of a byte array, and stores the transformed bytes in the supplied array. |
int |
engineGetBlockSize()
Returns the length of an input block, in bytes. |
protected byte[] |
engineGetIV()
Returns the initializaiton vector this cipher was initialized with, if any. |
protected int |
engineGetKeySize(java.security.Key key)
Return the length of the given key in bits. |
protected int |
engineGetOutputSize(int inputLen)
Returns the size, in bytes, an output buffer must be for a call to engineUpdate(byte[],int,int,byte[],int) 55 or engineDoFinal(byte[],int,int,byte[],int) 55 to succeed. |
protected java.security.AlgorithmParameters |
engineGetParameters()
Returns the parameters that this cipher is using. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, parameters, and source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.AlgorithmParameters params,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, parameters, and source of randomness. |
protected void |
engineInit(int opmode,
java.security.Key key,
java.security.SecureRandom random)
Initializes this cipher with an operation mode, key, and source of randomness. |
protected void |
engineSetMode(java.lang.String mode)
Set the mode in which this cipher is to run. |
protected void |
engineSetPadding(java.lang.String padding)
Set the method with which the input is to be padded. |
protected byte[] |
engineUpdate(byte[] input,
int inputOffset,
int inputLen)
Continue with a multi-part transformation, returning a new array of the transformed bytes. |
protected int |
engineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
Continue with a multi-part transformation, storing the transformed bytes into the specified array. |
private void |
makeKey(java.security.Key key)
Expands a user-key to a working key schedule. |
private int |
privateEngineUpdate(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset)
|
private void |
rc4(byte[] in,
int inOffset,
int inLen,
byte[] out,
int outOffset)
RC4 encryption/decryption. |
Methods inherited from class javax.crypto.CipherSpi |
engineDoFinal, engineUnwrap, engineUpdate, engineWrap |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
sBox
private final int[] sBox
- Contents of the current set S-box.
x
private int x
- The two indices for the S-box computation referred to as i and j
in Schneier.
y
private int y
- The two indices for the S-box computation referred to as i and j
in Schneier.
BLOCK_SIZE
private static final int BLOCK_SIZE
- The block size of this cipher. Being a stream cipher this value
is 1!
- See Also:
- Constant Field Values
Constructor Detail |
RC4
public RC4()
- Constructs an RC4 cipher object, in the UNINITIALIZED state.
This calls the Cipher constructor with implBuffering false,
implPadding false and the provider set to "Cryptix".
Method Detail |
clone
public final java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Always throws a CloneNotSupportedException (cloning of ciphers is not
supported for security reasons).
engineSetMode
protected final void engineSetMode(java.lang.String mode) throws java.security.NoSuchAlgorithmException
- Description copied from class:
javax.crypto.CipherSpi
- Set the mode in which this cipher is to run.
engineSetPadding
protected final void engineSetPadding(java.lang.String padding) throws javax.crypto.NoSuchPaddingException
- Description copied from class:
javax.crypto.CipherSpi
- Set the method with which the input is to be padded.
engineGetBlockSize
public int engineGetBlockSize()
- Returns the length of an input block, in bytes.
engineGetKeySize
protected int engineGetKeySize(java.security.Key key) throws java.security.InvalidKeyException
- Description copied from class:
javax.crypto.CipherSpi
Return the length of the given key in bits.
For compatibility this method is not declared
abstract
, and the default implementation will throw an java.lang.UnsupportedOperationException. Concrete subclasses should override this method to return the correct value.
engineGetOutputSize
protected final int engineGetOutputSize(int inputLen)
- Description copied from class:
javax.crypto.CipherSpi
Returns the size, in bytes, an output buffer must be for a call to CipherSpi.engineUpdate(byte[],int,int,byte[],int)>
CipherSpi.engineUpdate(byte[],int,int,byte[],int)
55 or CipherSpi.engineDoFinal(byte[],int,int,byte[],int)>CipherSpi.engineDoFinal(byte[],int,int,byte[],int)
55 to succeed.The actual output length may be smaller than the value returned by this method, as it considers the padding length as well. The length considered is the argument plus the length of any buffered, unprocessed bytes.
engineGetIV
protected final byte[] engineGetIV()
- Description copied from class:
javax.crypto.CipherSpi
- Returns the initializaiton vector this cipher was initialized with,
if any.
engineGetParameters
protected final java.security.AlgorithmParameters engineGetParameters()
- Description copied from class:
javax.crypto.CipherSpi
- Returns the parameters that this cipher is using. This may be the
parameters used to initialize this cipher, or it may be parameters
that have been initialized with random values.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.SecureRandom random) throws java.security.InvalidKeyException
- Description copied from class:
javax.crypto.CipherSpi
- Initializes this cipher with an operation mode, key, and source of
randomness. If this cipher requires any other initializing data,
for example an initialization vector, then it should generate it
from the provided source of randomness.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
- Description copied from class:
javax.crypto.CipherSpi
- Initializes this cipher with an operation mode, key, parameters,
and source of randomness. If this cipher requires any other
initializing data, for example an initialization vector, then it should
generate it from the provided source of randomness.
engineInit
protected final void engineInit(int opmode, java.security.Key key, java.security.AlgorithmParameters params, java.security.SecureRandom random) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
- Description copied from class:
javax.crypto.CipherSpi
- Initializes this cipher with an operation mode, key, parameters,
and source of randomness. If this cipher requires any other
initializing data, for example an initialization vector, then it should
generate it from the provided source of randomness.
engineUpdate
protected final int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws javax.crypto.ShortBufferException
- Description copied from class:
javax.crypto.CipherSpi
- Continue with a multi-part transformation, storing the transformed
bytes into the specified array.
engineUpdate
protected final byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
- Description copied from class:
javax.crypto.CipherSpi
- Continue with a multi-part transformation, returning a new array of
the transformed bytes.
privateEngineUpdate
private final int privateEngineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
engineDoFinal
protected final int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws javax.crypto.ShortBufferException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
- Description copied from class:
javax.crypto.CipherSpi
- Finishes a multi-part transformation or transforms a portion of a
byte array, and stores the transformed bytes in the supplied array.
engineDoFinal
protected final byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) throws javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException
- Description copied from class:
javax.crypto.CipherSpi
- Finishes a multi-part transformation or transforms a portion of a
byte array, and returns the transformed bytes.
rc4
private void rc4(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
- RC4 encryption/decryption.
makeKey
private void makeKey(java.security.Key key) throws java.security.InvalidKeyException
- Expands a user-key to a working key schedule.
The key bytes are first extracted from the user-key and then used to build the contents of this key schedule.
The method's only exceptions are when the user-key's contents are null, or a byte array of zero length.
|
|||||||||
Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |