Oracle Security Developer Tools Crypto Java API Reference
10g (10.1.4.0.1)

B28171-01


oracle.security.crypto.core
Class Arcfour

java.lang.Object
  extended byoracle.security.crypto.core.Coder
      extended byoracle.security.crypto.core.Cipher
          extended byoracle.security.crypto.core.Arcfour


public final class Arcfour
extends Cipher

The Arcfour stream cipher, as described in the IETF Internet Draft A Stream Cipher Encryption Algorithm "Arcfour" (Kaukonen, Thayer 1999), which is equivalent to the RC4 stream cipher.

Since:
2.0

Field Summary

 

Fields inherited from class oracle.security.crypto.core.Cipher
CBC, decryptionKey, ECB, encryptionKey, key, mode, NULL_PADDING, PKCS5_PADDING, rbs

 

Constructor Summary
Arcfour()
          Creates an uninitialized Arcfour instance.

 

Method Summary
 java.lang.String algName()
          Returns the name of the algorithm.
 int blockSize()
          Deprecated. Use getBlockSize()
 byte[] decrypt(byte[] input, int inOff, int len, boolean unpad)
          Decrypts a sequence of bytes of specified length.
 void decrypt(byte[] input, int inOff, int len, byte[] output, int outOff)
          Decrypts a sequence of bytes of specified length and places the original plaintext message in the given output buffer starting at the given offset.
 void decryptOp(byte[] input, int inOff, byte[] output, int outOff)
          Deprecated. Use a decrypt method instead.
 byte[] encrypt(byte[] input, int inOff, int len, boolean pad)
          Encrypts a sequence of bytes of specified length and, if specified, performs padding.
 void encrypt(byte[] input, int inOff, int len, byte[] output, int outOff)
          Encrypts a sequence of bytes of specified length and places the resulting ciphertext in the given output buffer starting at the given offset.
 void encryptOp(byte[] input, int inOff, byte[] output, int outOff)
          Deprecated. Use an encrypt method instead.
 void erase()
          Erases any sensitive information (such as buffers and subkey tables) stored in this cipher object.
 AlgorithmIdentifier getAlgID()
          Returns a clone of the AlgID.RC4 algorithm identifier.
 int getBlockSize()
          Returns 1, since Arcfour is a stream cipher.
 void initialize(AlgorithmIdentifier algID, Key key)
          This method may be used to initialize the Cipher for use.
 void initialize(SymmetricKey key)
          This method may be used to initialize the Arcfour instance for use.
 void setAlgID(AlgorithmIdentifier algID)
          Deprecated. Use an initialize method instead.
 void setDecryptionKey(Key key)
          Deprecated. Use an initialize method instead.
 void setEncryptionKey(Key key)
          Deprecated. Use an initialize method instead.
 void setIV(byte[] iv)
          Deprecated. Use an initialize method.
 void setKey(SymmetricKey key)
          Deprecated. Use an initialize method instead.
 void setMode(int mode)
          Deprecated. Use an initialize method.
 void setPadding(int padding)
          Deprecated. Use an initialize method.

 

Methods inherited from class oracle.security.crypto.core.Cipher
assertDecryption, assertEncryption, cloneKey, decodeOp, decrypt, decrypt, decrypt, decryptOp, encodeOp, encrypt, encrypt, encrypt, encryptOp, getDecryptionKey, getEncryptionKey, getInstance, getInstance, getInstance, getInstance, getInstance, getIV, getKey, getMode, getPadding, getPaddingID, initialize, pad, releaseOp, setRandomBitsSource, unpad

 

Methods inherited from class oracle.security.crypto.core.Coder
decode, decode, encode, encode, initialize

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

Arcfour

public Arcfour()
Creates an uninitialized Arcfour instance. To use the Cipher, it must be initialized with a Key and algorithm parameters, usually in the form of an AlgorithmIdentifier.

Method Detail

initialize

public void initialize(AlgorithmIdentifier algID,
                       Key key)
                throws AlgorithmIdentifierException,
                       InvalidKeyException
This method may be used to initialize the Cipher for use.
Specified by:
initialize in class Cipher
Parameters:
algID - is the AlgorithmIdentifier whose params will be used to configure the cipher.
key - is the Key instance that will be cloned and used by the cipher internally. The internal instance will be erased when Cipher.erase() is called.
Throws:
AlgorithmIdentifierException - is thrown if the algID's OID isn't valid for the Cipher instance being initialized or if the params are not valid for the algID's OID.
InvalidKeyException - is thrown if there is a problem with the Key instance the Cipher is being initialized with.

initialize

public void initialize(SymmetricKey key)
                throws InvalidKeyException
This method may be used to initialize the Arcfour instance for use.
Parameters:
key - is the Key instance that will be cloned and used by the cipher internally. The internal instance will be erased when Cipher.erase() is called.
Throws:
InvalidKeyException - is thrown if there is a problem with the Key instance the Cipher is being initialized with.

decrypt

public byte[] decrypt(byte[] input,
                      int inOff,
                      int len,
                      boolean unpad)
               throws CipherException
Decrypts a sequence of bytes of specified length. The padding parameter is meaningless for Arcfour.
Specified by:
decrypt in class Cipher
Parameters:
input - Buffer in which data to be decrypted is stored.
inOff - Offset within buffer of the start of data.
len - The length of the data
unpad - The padding parameter is meaningless for Arcfour.
Returns:
the decrypted bytes
Throws:
CipherException - if cipher not initialized, data is not a multiple of the block size and no padding is specified, etc.

decrypt

public void decrypt(byte[] input,
                    int inOff,
                    int len,
                    byte[] output,
                    int outOff)
             throws CipherException
Description copied from class: Cipher
Decrypts a sequence of bytes of specified length and places the original plaintext message in the given output buffer starting at the given offset. This method will not attempt to unpad the result.
Specified by:
decrypt in class Cipher
Parameters:
input - array of bytes to decrypt
inOff - offset of the start of the data to decrypt
len - the length of the data to decrypt
output - array to place the decrypted bytes
outOff - offset of the start of the decrypted bytes
Throws:
CipherException - is thrown if the Cipher was not initialized, if the Cipher was used for encryption without being re-initialized, if the data is not a multiple of the block size, or if an error occurred during the decryption process.

encrypt

public byte[] encrypt(byte[] input,
                      int inOff,
                      int len,
                      boolean pad)
               throws CipherException
Encrypts a sequence of bytes of specified length and, if specified, performs padding. The padding parameter is meaningless for Arcfour.
Specified by:
encrypt in class Cipher
Parameters:
input - buffer in which data to be encrypted is stored.
inOff - offset within buffer of the start of the data.
len - the length of the data.
pad - is meaningless for the Arcfour cipher.
Returns:
the encrypted bytes
Throws:
CipherException - is thrown if the Cipher is not initialized, data is not a multiple of the block size and no padding is specified, etc.

encrypt

public void encrypt(byte[] input,
                    int inOff,
                    int len,
                    byte[] output,
                    int outOff)
             throws CipherException
Description copied from class: Cipher
Encrypts a sequence of bytes of specified length and places the resulting ciphertext in the given output buffer starting at the given offset. This method will not attempt to unpad the result.
Specified by:
encrypt in class Cipher
Parameters:
input - array of bytes to encrypt
inOff - offset of the start of data to encrypt
len - the length of the data to encrypt
output - array to place the encrypted bytes
outOff - offset of the start of the encrypted bytes
Throws:
CipherException - is thrown if the Cipher was not initialized, if the Cipher was used for decryption without being re-initialized, if the data is not a multiple of the block size, or if an error occurred during the encryption process.

erase

public void erase()
Description copied from class: Cipher
Erases any sensitive information (such as buffers and subkey tables) stored in this cipher object. Additionally, this will erase the Cipher's internal copies of any keys it holds.
Overrides:
erase in class Cipher

algName

public java.lang.String algName()
Returns the name of the algorithm.
Specified by:
algName in class Coder
Returns:
"Arcfour"

getAlgID

public AlgorithmIdentifier getAlgID()
Returns a clone of the AlgID.RC4 algorithm identifier.
Specified by:
getAlgID in class Cipher
Returns:
A newly constructed AlgorithmIdentifier that is a "snapshot" of the Cipher's current configuration.

getBlockSize

public final int getBlockSize()
Returns 1, since Arcfour is a stream cipher.
Specified by:
getBlockSize in class Cipher

blockSize

public final int blockSize()
Deprecated. Use getBlockSize()
Returns 1, since Arcfour is a stream cipher.
Specified by:
blockSize in class Cipher

decryptOp

public void decryptOp(byte[] input,
                      int inOff,
                      byte[] output,
                      int outOff)
               throws CipherException
Deprecated. Use a decrypt method instead.
Decrypts a single byte.
Specified by:
decryptOp in class Cipher
Parameters:
input - buffer in which data to be decrypted is stored.
inOff - offset within input buffer of the start of data.
output - buffer to place the decrypted bytes in
outOff - offset within output buffer where the encrypted byte will be stored.
Throws:
CipherException - is thrown if the Cipher is not initialized, length of data is not equal to the block size, etc.

encryptOp

public void encryptOp(byte[] input,
                      int inOff,
                      byte[] output,
                      int outOff)
               throws CipherException
Deprecated. Use an encrypt method instead.
Encrypts a single byte.
Specified by:
encryptOp in class Cipher
Parameters:
inOff - offset within input buffer of the start of data
outOff - offset within output buffer where the encrypted bytes will be stored
input - buffer in which data to be encrypted is stored
output - buffer to place the encrypted bytes in
Throws:
CipherException - is thrown if the Cipher is not initialized, length of data is not equal to the block size, etc.

setAlgID

public void setAlgID(AlgorithmIdentifier algID)
              throws AlgorithmIdentifierException
Deprecated. Use an initialize method instead.
Initializes the cipher state.
Specified by:
setAlgID in class Cipher
Throws:
AlgorithmIdentifierException

setKey

public void setKey(SymmetricKey key)
            throws InvalidKeyException
Deprecated. Use an initialize method instead.
Sets the encryption/decryption key and initializes the cipher.
Overrides:
setKey in class Cipher
Parameters:
key - the encryption/decryption key
Throws:
InvalidKeyException - is thrown if the the key is not valid for the Cipher instance

setEncryptionKey

public void setEncryptionKey(Key key)
                      throws InvalidKeyException
Deprecated. Use an initialize method instead.
Sets the encryption key and initializes the cipher.
Overrides:
setEncryptionKey in class Cipher
Parameters:
key - the encryption key
Throws:
InvalidKeyException - is thrown if the the key is not valid for the Cipher instance

setDecryptionKey

public void setDecryptionKey(Key key)
                      throws InvalidKeyException
Deprecated. Use an initialize method instead.
Sets the decryption key and initializes the cipher.
Overrides:
setDecryptionKey in class Cipher
Parameters:
key - the decryption key
Throws:
InvalidKeyException - is thrown if the the key is not valid for the Cipher instance

setMode

public void setMode(int mode)
Deprecated. Use an initialize method.
Sets the mode.
Overrides:
setMode in class Cipher

setPadding

public void setPadding(int padding)
Deprecated. Use an initialize method.
Sets the padding type, default is Padding.NONE.
Overrides:
setPadding in class Cipher

setIV

public void setIV(byte[] iv)
           throws CipherException
Deprecated. Use an initialize method.
Sets the initialization vector(IV) used for CBC mode in block ciphers.
Overrides:
setIV in class Cipher
Parameters:
iv - the initialization vector
Throws:
CipherException

Oracle Security Developer Tools Crypto Java API Reference
10g (10.1.4.0.1)

B28171-01


Copyright © 2005 ,2006 , Oracle. All rights reserved.