|
Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10696-03 |
||||||||
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
public abstract class 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, ECB, key, mode, 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 | |
---|---|
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. |
Padding.ID |
getPaddingID() Returns the Padding.ID constant value for this instance. |
void |
initialize(AlgorithmIdentifier algID, Key key, RandomBitsSource rbs) This method verifies the AlgorithmIdentifier's Object ID and configures the DES instance appropriately with the params of the AlgorithmIdentifier in addition to the Key. |
protected void |
setIV(byte[] iv) Sets the initialization vector for this block cipher. |
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, getAlgID, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getMode, initialize, initialize, initialize, releaseOp |
Methods inherited from class oracle.security.crypto.core.Coder |
---|
algName, decode, decode, encode, encode |
Methods inherited from class java.lang.Object |
---|
clone, equals, 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 void initialize(AlgorithmIdentifier algID, Key key, RandomBitsSource rbs) throws AlgorithmIdentifierException, InvalidKeyException
initialize
in class Cipher
algID
- The AlgorithmIdentifier whose params will be used to configure the cipher.key
- The SymmetricKey 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 byte[] decrypt(byte[] input, int inOff, int len, boolean unpad) throws CipherException
Cipher
decrypt
in class Cipher
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.unpad
- Specifies whether the plaintext should have padding removed.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 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
- 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.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
- 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
- The buffer in which data to be encrypted is stored.inOff
- The 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
- 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
- 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.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
- If the Cipher is not initialized, length of data is not equal to the block size, etc.public byte[] wrapKey(PrivateKey key) throws CipherException
wrapKey
in class Cipher
key
- The private key to wrap.CipherException
- If the Cipher was not initialized, if the Cipher was used for wrapping without being re-initialized or if an error occurred during the wrapping process.public byte[] wrapKey(SymmetricKey key) throws CipherException
wrapKey
in class Cipher
key
- The symmetric key to wrap.CipherException
- If the Cipher was not initialized, if the Cipher was used for wrapping without being re-initialized or if an error occurred during the wrapping process.public PrivateKey unwrapPrivateKey(byte[] encKey) throws CipherException
unwrapPrivateKey
in class Cipher
encKey
- The encrypted key.If
- the Cipher was not initialized, if the Cipher was used for wrapping without being re-initialized, if the key is not a private key or if an error occurred during the wrapping process.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 decryption process.public SymmetricKey unwrapSymmetricKey(byte[] encKey, AlgorithmIdentifier algID) throws CipherException
unwrapSymmetricKey
in class Cipher
encKey
- The encrypted key.algID
- The algorithm identifier of the wrapped symmetric key.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()
erase
in class Cipher
public final int getBlockSize()
getBlockSize
in class Cipher
public final byte[] getIV()
getIV
in class Cipher
protected void setIV(byte[] iv) throws CipherException
iv
- The new IV to set.CipherException
public final Padding.ID getPaddingID()
getPaddingID
in class Cipher
Padding.ID
|
Oracle Fusion Middleware Crypto FIPS Java API Reference for Oracle Security Developer Tools 11g Release 1 (11.1.1) E10696-03 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |