com.ibm.opencard.crypto
Class DESCipher
java.lang.Object
|
+--com.ibm.opencard.crypto.DESCipher
- public class DESCipher
- extends java.lang.Object
- implements FeedbackCipher
DESCipher does enciphers/deciphers data using the DES algorithm.
- Version:
- $Id: DESCipher.java,v 1.1 1999/12/02 16:06:02 damke Exp $
|
Field Summary |
static int |
DECRYPT
Cipher is in decrypting mode |
static int |
ENCRYPT
Cipher is in encrypting mode |
static int |
UNINITIALIZED
Cipher is not initialized yet |
|
Constructor Summary |
protected |
DESCipher(java.lang.String algorithm)
Create a new DES cipher object. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
UNINITIALIZED
public static final int UNINITIALIZED
- Cipher is not initialized yet
ENCRYPT
public static final int ENCRYPT
- Cipher is in encrypting mode
DECRYPT
public static final int DECRYPT
- Cipher is in decrypting mode
DESCipher
protected DESCipher(java.lang.String algorithm)
- Create a new DES cipher object.
- Parameters:
algorithm - the algorithm to be used
getInstance
public static DESCipher getInstance(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException
- Get an instance of DESCipher.
- Throws:
- java.security.NoSuchAlgorithmException - The desired algorithm is not available.
getInitializationVector
public byte[] getInitializationVector()
- Get the initialization vector.
- Specified by:
- getInitializationVector in interface FeedbackCipher
- Returns:
- the initialization vector for this cipher object
getInitializationVectorLength
public int getInitializationVectorLength()
- Get the initialization vector length.
- Specified by:
- getInitializationVectorLength in interface FeedbackCipher
- Returns:
- the required size of the argument to setInitializationVector()
setInitializationVector
public void setInitializationVector(byte[] iv)
- Set the initialization vector.
- Specified by:
- setInitializationVector in interface FeedbackCipher
- Parameters:
iv - - intialization vector
engineBlockSize
public int engineBlockSize()
- Return the length of an input block in bytes.
engineOutBufferSize
public int engineOutBufferSize(int inLen,
boolean isFinal)
- Return the length of an input block in bytes.
- Parameters:
inLen - the input length for which the output length shall be calculated.isFinal - indicates whether the output length shall be calculated
for the final encryption/decryption step or not.
engineInitEncrypt
public void engineInitEncrypt(java.security.Key key)
throws java.security.InvalidKeyException
- Initialize for encryption.
- Parameters:
key - - the key to be used for encryption.- Throws:
- java.security.InvalidKeyException - The given key is invalid.
engineInitDecrypt
public void engineInitDecrypt(java.security.Key key)
throws java.security.InvalidKeyException
- Initialize for decryption.
- Parameters:
key - - the key to be used for encryption.- Throws:
- java.security.InvalidKeyException - The given key is invalid.
engineUpdate
public int engineUpdate(byte[] in,
int inOff,
int inLen,
byte[] out,
int outOff)
- Process a chunk of data.
- Parameters:
in - - byte array from which the data to be processed shall be takeninOff - - offset within the input arrayinLen - - length of the part of input data to be processedout - - byte array where output data shall be storedoutOff - - offset within the output array- Returns:
- 0 on success, 1 on error check this against JCE
|