Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


oracle.security.crypto.core
Class Arcfour

java.lang.Object
  extended by oracle.security.crypto.core.Coder
      extended by oracle.security.crypto.core.Cipher
          extended by oracle.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, ECB, key, mode, rbs

 

Constructor Summary
Arcfour()
          Creates an uninitialized Arcfour instance.

 

Method Summary
 java.lang.String algName()
          Returns the name of the algorithm.
 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.
 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 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, RandomBitsSource rbs)
          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.
 PrivateKey unwrapPrivateKey(byte[] encKey)
          Unwraps a private key using this cipher.
 SymmetricKey unwrapSymmetricKey(byte[] encKey, AlgorithmIdentifier algID)
          Unwraps a symmetric key using this cipher.
 byte[] wrapKey(PrivateKey key)
          Wraps a private key using this cipher.
 byte[] wrapKey(SymmetricKey key)
          Wraps a symmetric key using this cipher.

 

Methods inherited from class oracle.security.crypto.core.Cipher
assertDecryption, assertEncryption, assertKeyUnwrap, assertKeyWrap, cloneKey, decodeOp, decrypt, decrypt, decrypt, encodeOp, encrypt, encrypt, encrypt, finalize, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getIV, getMode, getPaddingID, initialize, initialize, initialize, releaseOp

 

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

 

Methods inherited from class java.lang.Object
clone, equals, 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,
                       RandomBitsSource rbs)
                throws AlgorithmIdentifierException,
                       InvalidKeyException
This method may be used to initialize the Cipher for use.
Specified by:
initialize in class Cipher
Parameters:
algID - The AlgorithmIdentifier whose params will be used to configure the cipher.
key - The Key instance that will be used by the cipher internally.
rbs - The RandomBitsSourfce to use in this cipher
Throws:
AlgorithmIdentifierException - 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 - 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 - The Key instance that will be used by the cipher internally.
Throws:
InvalidKeyException - 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 - The buffer in which data to be decrypted is stored.
inOff - The offset within buffer of the start of data.
len - The length of the data.
output - The array to place the decrypted bytes.
outOff - The offset of the start of the decrypted bytes.
Throws:
CipherException - 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 - Not used for the Arcfour cipher.
Returns:
The encrypted bytes
Throws:
CipherException - 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 - The array of bytes to encrypt.
inOff - The offset of the start of data to encrypt.
len - The length of the data to encrypt.
output - The array to place the encrypted bytes.
outOff - The offset of the start of the encrypted bytes.
Throws:
CipherException - 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.

wrapKey

public byte[] wrapKey(PrivateKey key)
               throws CipherException
Wraps a private key using this cipher.
Specified by:
wrapKey in class Cipher
Parameters:
key - The private key to wrap.
Returns:
The encrypted key.
Throws:
CipherException - If the Cipher was not initialized, if the Cipher was used for key-wrapping without being re-initialized or if an error occurred during the wrapping process.

wrapKey

public byte[] wrapKey(SymmetricKey key)
               throws CipherException
Wraps a symmetric key using this cipher.
Specified by:
wrapKey in class Cipher
Parameters:
key - The symmetric key to wrap.
Returns:
The encrypted key.
Throws:
CipherException - If the Cipher was not initialized, if the Cipher was used for key-wrapping without being re-initialized or if an error occurred during the wrapping process.

unwrapPrivateKey

public PrivateKey unwrapPrivateKey(byte[] encKey)
                            throws CipherException
Unwraps a private key using this cipher.
Specified by:
unwrapPrivateKey in class Cipher
Parameters:
encKey - The encrypted key.
Returns:
The unwrapped private key.
Throws:
CipherException - If the Cipher was not initialized, if the Cipher was used for unwrapping without being re-initialized, if an error occurred during the encryption process or if the decrypted key is not a PrivateKey.

unwrapSymmetricKey

public SymmetricKey unwrapSymmetricKey(byte[] encKey,
                                       AlgorithmIdentifier algID)
                                throws CipherException
Unwraps a symmetric key using this cipher.
Specified by:
unwrapSymmetricKey in class Cipher
Parameters:
encKey - The encrypted key.
algID - The algorithm identifier of the wrapped symmetric key (optional).
Returns:
The unwrapped symmetric key.
Throws:
CipherException - If the Cipher was not initialized, if the Cipher was used for unwrapping without being re-initialized 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 reference of the cipher's key.
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

Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


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