|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.me.security.Cipher | +--iaik.me.security.cipher.ARCFOUR
This class implements the ARCFOUR cipher as specified by the IETF draft "A Stream Cipher Encryption Algorithm 'Arcfour'" (draft-kaukonen-cipher-arcfour-03.txt). It is believed to be compatible with RC4[TM] (described for example in Bruce Schneierīs Applied Cryptography), a proprietary cipher of RSA Security Inc.
The ARCFOUR algorithm is a stream cipher using a key of variable size.
Applications shall preferable use the Cipher.getInstance(String)
method from the Cipher
class:
For compatibility reasons, the alias RC4 is still supported.byte[] keydata = ..... CryptoBag key = CryptoBag.makeSecretKey(keydata); Cipher cipher = Cipher.getInstance("ARCFOUR"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] ciphertext = cipher.doFinal(data); cipher.init(Cipher.DECRYPT_MODE, key); data = cipher.doFinal(ciphertext);
Cipher
Fields inherited from class iaik.me.security.Cipher |
chainingMode, DECRYPT_MODE, ENCRYPT_MODE, iv, mode, MODE_CBC, MODE_ECB |
Constructor Summary | |
ARCFOUR()
Constructor for the ARCFOUR cipher. |
Method Summary | |
int[] |
getKeyLength()
Returns information about the ARCFOUR key lenghts. [0] is the minumum keykength (8 bit for ARCFOUR) [1] is the recommended default length (128 bit). |
void |
init(int mode,
CryptoBag keyb,
Object params,
SecureRandom random)
Initializes this ARCFOUR cipher with proper key and algorithm parameters, and some random seed. |
int |
update(byte[] in,
int inOff,
int inLen,
byte[] out,
int outOff)
Encrypts the given data bytes using the ARCFOUR algorithm. |
protected int |
updateInternal(byte[] input,
int inputOffset,
int inputLen,
byte[] output,
int outputOffset,
boolean doFinal)
This is method performs the actual en-/decipher opertion. |
Methods inherited from class iaik.me.security.Cipher |
cryptBlock, doFinal, doFinal, extractIV, getBlockSize, getInstance, getIV, init, register, setMode, setPadding, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ARCFOUR()
Cipher.getInstance(String)
factory method.
instead.Method Detail |
public int[] getKeyLength()
getKeyLength
in class Cipher
Cipher.getKeyLength()
public void init(int mode, CryptoBag keyb, Object params, SecureRandom random) throws CryptoException
opmode
parameter (either ENCRYPT_MODE or DECCRYPT_MODE).
The format of the key must be "RAW". An initialisation call may look like this:
Cipher cipher = Cipher.getInstance("ARCFOUR");
cipher.init(Cipher.ENCRYPT_MODE, key);
or
cipher.init(Cipher.ENCRYPT_MODE, key, null, null);
init
in class Cipher
mode
- the operation mode for which this cipher is used
(ENCRYPT_MODE or DECRYPT_MODE)keyb
- a CryptoBag
containing the secret keyparams
- the algorithm parameters (Actually this parameter is ignored as the ARCFOUR does not need additional parameters. For this reason, the parameter can be set to null)random
- the random seed (Actually this parameter is ignored as the ARCFOUR does not need additional parameters. For this reason, the paramter can be set to null)InvalidKeyException
- if the key is invalidpublic int update(byte[] in, int inOff, int inLen, byte[] out, int outOff) throws CryptoException
inOff
, only the first inLen
bytes are encrypted.
The result is stored within the given output byte array, beginning at
outOff
.update
in class Cipher
in
- the input datainOff
- the offset indicating where the subarray starts in the in arrayinLen
- the length of the subarrayout
- the output buffer.outOff
- the offset indicating where to start writing the result into the
output bufferinLen
CryptoException
- protected int updateInternal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset, boolean doFinal) throws CryptoException
Cipher
updateInternal
in class Cipher
iaik.me.security.Cipher
input
- input datainputOffset
- offset from which on the input data will be processedinputLen
- length of the input data that will be processedoutput
- the processed input dataoutputOffset
- doFinal
- flag indicates whether this method was invoked from Cipher.update or Cipher.doFinalCryptoException
- is thrown if an error occurs during cipher operation
|
This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |