APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv abstract Class FeedbackCipher

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.crypto.provider.OutputFeedback, com.sun.crypto.provider.PCBC, com.sun.crypto.provider.AESKeyWrap, com.sun.crypto.provider.AESKeyWrapPadded, com.sun.crypto.provider.CipherBlockChaining, com.sun.crypto.provider.CipherFeedback, com.sun.crypto.provider.CounterMode, com.sun.crypto.provider.ElectronicCodeBook
Imports
java.security.InvalidKeyException, .InvalidAlgorithmParameterException, javax.crypto.*

This class represents a block cipher in one of its modes. It wraps a SymmetricCipher maintaining the mode state and providing the capability to encrypt amounts of data larger than a single block.
Author
Jan Luehe
See Also
ElectronicCodeBook, CipherBlockChaining, CipherFeedback, OutputFeedback, PCBC

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final SymmetricCipher
pack-priv byte[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract int

Returns:

the number of bytes placed into plain
decrypt
(byte[]
the input buffer with the data to be decrypted
cipher
,
int
the offset in cipher
cipherOffset
,
int
the length of the input data
cipherLen
,
byte[]
the buffer for the decryption result
plain
,
int
the offset in plain
plainOffset
)

Performs decryption operation.

pack-priv int

Returns:

the number of bytes placed into plain
decryptFinal
(byte[]
the input buffer with the data to be decrypted
cipher
,
int
the offset in cipher
cipherOffset
,
int
the length of the input data
cipherLen
,
byte[]
the buffer for the decryption result
plain
,
int
the offset in plain
plainOffset
)

Performs decryption operation for the last time.

pack-priv abstract int

Returns:

the number of bytes placed into cipher
encrypt
(byte[]
the input buffer with the data to be encrypted
plain
,
int
the offset in plain
plainOffset
,
int
the length of the input data
plainLen
,
byte[]
the buffer for the encryption result
cipher
,
int
the offset in cipher
cipherOffset
)

Performs encryption operation.

pack-priv int

Returns:

the number of bytes placed into cipher
encryptFinal
(byte[]
the input buffer with the data to be encrypted
plain
,
int
the offset in plain
plainOffset
,
int
the length of the input data
plainLen
,
byte[]
the buffer for the encryption result
cipher
,
int
the offset in cipher
cipherOffset
)

Performs encryption operation for the last time.

pack-priv final int

Returns:

the block size of the embedded cipher
getBlockSize
()

Gets the block size of the embedded cipher.

pack-priv final SymmetricCipher
pack-priv abstract String

Returns:

the name of the feedback mechanism
getFeedback
()

Gets the name of the feedback mechanism

pack-priv final byte[]

Returns:

the initialization vector
getIV
()

Gets the initialization vector.

pack-priv abstract void
init(boolean
flag indicating encryption or decryption mode
decrypting
,
String
the algorithm name (never null)
algorithm
,
byte[]
the key (never null)
key
,
byte[]
the iv (either null or blockSize bytes long)
iv
)

Initializes the cipher in the specified mode with the given key and iv.

pack-priv abstract void
reset()

Resets the iv to its original value.

pack-priv abstract void
restore()

Restores the content of this cipher to the previous saved one.

pack-priv abstract void
save()

Save the current content of this cipher.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockSizeback to summary
pack-priv final int blockSize
embeddedCipherback to summary
pack-priv final SymmetricCipher embeddedCipher
ivback to summary
pack-priv byte[] iv

Constructor Detail

FeedbackCipherback to summary
pack-priv FeedbackCipher(SymmetricCipher embeddedCipher)

Method Detail

decryptback to summary
pack-priv abstract int decrypt(byte[] cipher, int cipherOffset, int cipherLen, byte[] plain, int plainOffset)

Performs decryption operation.

The input cipher, starting at cipherOffset and ending at (cipherOffset+cipherLen-1), is decrypted. The result is stored in plain, starting at plainOffset.

The subclass that implements Cipher should ensure that init has been called before this method is called.

Parameters
cipher:byte[]

the input buffer with the data to be decrypted

cipherOffset:int

the offset in cipher

cipherLen:int

the length of the input data

plain:byte[]

the buffer for the decryption result

plainOffset:int

the offset in plain

Returns:int

the number of bytes placed into plain

decryptFinalback to summary
pack-priv int decryptFinal(byte[] cipher, int cipherOffset, int cipherLen, byte[] plain, int plainOffset) throws IllegalBlockSizeException

Performs decryption operation for the last time.

Note

For cipher feedback modes which does not perform special handling for the last few blocks, this is essentially the same as encrypt(...). Given most modes do not do special handling, the default impl for this method is to simply call decrypt(...).

Parameters
cipher:byte[]

the input buffer with the data to be decrypted

cipherOffset:int

the offset in cipher

cipherLen:int

the length of the input data

plain:byte[]

the buffer for the decryption result

plainOffset:int

the offset in plain

Returns:int

the number of bytes placed into plain

encryptback to summary
pack-priv abstract int encrypt(byte[] plain, int plainOffset, int plainLen, byte[] cipher, int cipherOffset)

Performs encryption operation.

The input plain, starting at plainOffset and ending at (plainOffset+plainLen-1), is encrypted. The result is stored in cipher, starting at cipherOffset.

The subclass that implements Cipher should ensure that init has been called before this method is called.

Parameters
plain:byte[]

the input buffer with the data to be encrypted

plainOffset:int

the offset in plain

plainLen:int

the length of the input data

cipher:byte[]

the buffer for the encryption result

cipherOffset:int

the offset in cipher

Returns:int

the number of bytes placed into cipher

encryptFinalback to summary
pack-priv int encryptFinal(byte[] plain, int plainOffset, int plainLen, byte[] cipher, int cipherOffset) throws IllegalBlockSizeException

Performs encryption operation for the last time.

Note

For cipher feedback modes which does not perform special handling for the last few blocks, this is essentially the same as encrypt(...). Given most modes do not do special handling, the default impl for this method is to simply call encrypt(...).

Parameters
plain:byte[]

the input buffer with the data to be encrypted

plainOffset:int

the offset in plain

plainLen:int

the length of the input data

cipher:byte[]

the buffer for the encryption result

cipherOffset:int

the offset in cipher

Returns:int

the number of bytes placed into cipher

getBlockSizeback to summary
pack-priv final int getBlockSize()

Gets the block size of the embedded cipher.

Returns:int

the block size of the embedded cipher

getEmbeddedCipherback to summary
pack-priv final SymmetricCipher getEmbeddedCipher()
getFeedbackback to summary
pack-priv abstract String getFeedback()

Gets the name of the feedback mechanism

Returns:String

the name of the feedback mechanism

getIVback to summary
pack-priv final byte[] getIV()

Gets the initialization vector.

Returns:byte[]

the initialization vector

initback to summary
pack-priv abstract void init(boolean decrypting, String algorithm, byte[] key, byte[] iv) throws InvalidKeyException, InvalidAlgorithmParameterException

Initializes the cipher in the specified mode with the given key and iv.

Parameters
decrypting:boolean

flag indicating encryption or decryption mode

algorithm:String

the algorithm name (never null)

key:byte[]

the key (never null)

iv:byte[]

the iv (either null or blockSize bytes long)

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
resetback to summary
pack-priv abstract void reset()

Resets the iv to its original value. This is used when doFinal is called in the Cipher class, so that the cipher can be reused (with its original iv).

restoreback to summary
pack-priv abstract void restore()

Restores the content of this cipher to the previous saved one.

saveback to summary
pack-priv abstract void save()

Save the current content of this cipher.