public final class Arcfour extends Cipher
| Constructor and Description |
|---|
Arcfour()
Creates an uninitialized Arcfour instance.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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, releaseOppublic Arcfour()
public void initialize(AlgorithmIdentifier algID, Key key, RandomBitsSource rbs) throws AlgorithmIdentifierException, InvalidKeyException
initialize in class CipheralgID - 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 cipherAlgorithmIdentifierException - 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.public void initialize(SymmetricKey key) throws InvalidKeyException
key - The Key instance that will be used by the cipher internally.InvalidKeyException - If there is a problem with the Key instance the Cipher is being initialized with.
public byte[] decrypt(byte[] input,
int inOff,
int len,
boolean unpad)
throws CipherException
decrypt in class Cipherinput - Buffer in which data to be decrypted is stored.inOff - Offset within buffer of the start of data.len - The length of the dataunpad - The padding parameter is meaningless for Arcfour.CipherException - If cipher not initialized, data is not a multiple of the block size and no padding is specified, etc.
public void decrypt(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
throws CipherException
Cipherdecrypt in class Cipherinput - 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.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.
public byte[] encrypt(byte[] input,
int inOff,
int len,
boolean pad)
throws CipherException
encrypt in class Cipherinput - 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.CipherException - If the Cipher is not initialized, data is not a multiple of the block size and no padding is specified, etc.
public void encrypt(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
throws CipherException
Cipherencrypt in class Cipherinput - 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.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.public byte[] wrapKey(PrivateKey key) throws CipherException
wrapKey in class Cipherkey - The private key to wrap.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.public byte[] wrapKey(SymmetricKey key) throws CipherException
wrapKey in class Cipherkey - The symmetric key to wrap.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.public PrivateKey unwrapPrivateKey(byte[] encKey) throws CipherException
unwrapPrivateKey in class CipherencKey - The encrypted key.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.public SymmetricKey unwrapSymmetricKey(byte[] encKey, AlgorithmIdentifier algID) throws CipherException
unwrapSymmetricKey in class CipherencKey - The encrypted key.algID - The algorithm identifier of the wrapped symmetric key (optional).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.public void erase()
Cipherpublic java.lang.String algName()
public AlgorithmIdentifier getAlgID()
AlgID.RC4 algorithm identifier.public final int getBlockSize()
1, since Arcfour is a stream cipher.getBlockSize in class Cipher