|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.core.Coder
oracle.security.crypto.core.Cipher
oracle.security.crypto.core.BlockCipher
Defines the functionality and properties common to block ciphers such that subclasses should only have to override the initialize()
, encryptBlock()
and decryptBlock()
methods.
Field Summary | |
protected int |
blockSize Block size of the wrapping BlockCipher. |
protected byte[] |
iv Initialization vector that the current processes are based off of (equivalent to the old iv from Cipher), for use in CBC mode. |
protected Padding.ID |
paddingID Holds the padding constant that will be used to determine the algorithm for to padding and unpadding data. |
Fields inherited from class oracle.security.crypto.core.Cipher |
CBC, decryptionKey, ECB, encryptionKey, key, mode, NULL_PADDING, PKCS5_PADDING, rbs |
Constructor Summary | |
protected |
BlockCipher() Instantiates the BlockCipher with no block size. |
protected |
BlockCipher(int blockSize) Instantiates the BlockCipher with the block size of the actual instance. |
Method Summary | |
int |
blockSize() Deprecated. Use getBlockSize() |
byte[] |
decrypt(byte[] input, int inOff, int len, boolean unpad) Decrypts a sequence of bytes of specified length, and, if specified, returns the unpadded plaintext. |
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. |
protected abstract void |
decryptBlock(byte[] input, int inOff, byte[] output, int outOff) Performs the block cipher's basic decryption operation on one block of ciphertext placing the result in the output buffer. |
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. |
protected abstract void |
encryptBlock(byte[] input, int inOff, byte[] output, int outOff) Performs the block cipher's basic encryption operation on one block of plaintext placing the result in the output buffer. |
void |
erase() Erases any sensitive information stored in this BlockCipher object. |
int |
getBlockSize() Returns the block size of the cipher. |
byte[] |
getIV() Returns a clone of the initialization vector or null, if the IV is null. |
int |
getPadding() Deprecated. Use getPaddingID() instead. |
Padding.ID |
getPaddingID() Returns the Padding.ID constant value for this instance. |
abstract void |
initialize(AlgorithmIdentifier algID, SymmetricKey key, Padding.ID paddingID) This method may be used to initialize a BlockCipher with the given algorithm parameters, symmetric key, and padding descriptor. |
void |
setIV(byte[] iv) Deprecated. IV's should only be set when a BlockCipher is initialized. Use one of the initialize(...) methods instead. |
void |
setPadding(int padding) Deprecated. Padding should only be set when a BlockCipher is initialized. Use one of the initialize(...) methods instead. |
Methods inherited from class oracle.security.crypto.core.Cipher |
assertDecryption, assertEncryption, cloneKey, decodeOp, decrypt, decrypt, decrypt, decryptOp, decryptOp, encodeOp, encrypt, encrypt, encrypt, encryptOp, encryptOp, getAlgID, getDecryptionKey, getEncryptionKey, getInstance, getInstance, getInstance, getInstance, getInstance, getKey, getMode, initialize, pad, releaseOp, setAlgID, setDecryptionKey, setEncryptionKey, setKey, setMode, setRandomBitsSource, unpad |
Methods inherited from class oracle.security.crypto.core.Coder |
algName, decode, decode, encode, encode, initialize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected byte[] iv
protected int blockSize
protected Padding.ID paddingID
Constructor Detail |
protected BlockCipher()
AES
.
By default, a BlockCipher is instantiated with mode of Cipher.ECB and padding scheme of Padding.NONE
protected BlockCipher(int blockSize)
By default, a BlockCipher is instantiated with mode of Cipher.ECB and padding scheme of Padding.NONE
Method Detail |
public abstract void initialize(AlgorithmIdentifier algID, SymmetricKey key, Padding.ID paddingID) throws AlgorithmIdentifierException, InvalidKeyException, CipherException
Cipher
BlockCipher
with the given algorithm parameters, symmetric key, and padding descriptor.initialize
in class Cipher
algID
- is the AlgorithmIdentifier whose params will be used to configure the cipher.key
- is the SymmetricKey instance that will be cloned and used by the cipher internally. The internal instance will be erased when Cipher.erase()
is called.paddingID
- is used to indicate the type of padding that the Cipher should use. Options are Padding.NONE or Padding.PKCS5. A Cipher must be re-initialized before being used with the other Padding type.CipherException
- is thrown if there's a problem initializing the Cipher with the given parameters.InvalidKeyException
- is thrown if there is a problem with the Key instance the Cipher is being initialized with.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.public byte[] decrypt(byte[] input, int inOff, int len, boolean unpad) throws CipherException
Cipher
decrypt
in class Cipher
input
- Buffer in which data to be decrypted is stored.inOff
- Offset within buffer of the start of data.len
- The length of the dataunpad
- specifies whether the plaintext should have padding removed.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 and no padding is specified, or if an error occurred during the decryption process.public void decrypt(byte[] input, int inOff, int len, byte[] output, int outOff) throws CipherException
Cipher
decrypt
in class Cipher
input
- array of bytes to decryptinOff
- offset of the start of the data to decryptlen
- the length of the data to decryptoutput
- array to place the decrypted bytesoutOff
- offset of the start of the decrypted bytesCipherException
- 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.protected abstract void decryptBlock(byte[] input, int inOff, byte[] output, int outOff) throws CipherException
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 inoutOff
- offset within output buffer where the encrypted bytes will be stored.CipherException
- is thrown if the Cipher is not initialized, length of data is not equal to the block size, etc.public byte[] encrypt(byte[] input, int inOff, int len, boolean pad) throws CipherException
Cipher
encrypt
in class Cipher
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
- true if padding is to be used, false otherwise.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 and no padding is specified, or if an error occurred during the encryption process.public void encrypt(byte[] input, int inOff, int len, byte[] output, int outOff) throws CipherException
Cipher
encrypt
in class Cipher
input
- array of bytes to encryptinOff
- offset of the start of data to encryptlen
- the length of the data to encryptoutput
- array to place the encrypted bytesoutOff
- offset of the start of the encrypted bytesCipherException
- 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.protected abstract void encryptBlock(byte[] input, int inOff, byte[] output, int outOff) throws CipherException
input
- buffer in which data to be encrypted is storedinOff
- offset within input buffer of the start of dataoutput
- buffer to place the encrypted bytes inoutOff
- offset within output buffer where the encrypted bytes will be storedCipherException
- is thrown if the Cipher is not initialized, length of data is not equal to the block size, etc.public void erase()
erase
in class Cipher
public final int getBlockSize()
getBlockSize
in class Cipher
public final byte[] getIV()
getIV
in class Cipher
public final Padding.ID getPaddingID()
getPaddingID
in class Cipher
Padding.ID
public final int blockSize()
getBlockSize()
blockSize
in class Cipher
public int getPadding()
getPaddingID()
instead.Padding.NONE
.getPadding
in class Cipher
public void setPadding(int padding)
Padding.NONE
.setPadding
in class Cipher
public void setIV(byte[] iv) throws CipherException
If the given IV is not null, the internal IV will be set to a clone of the given IV and the last cipher block value will also be set equal to the given IV.
setIV
in class Cipher
iv
- is the initialization vector to configure the BlockCipher with.CipherException
- is thrown if the given IV's length is not equal to the block size.
|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |