The IBlockCipher Interface
Figure 1: Ciphers class diagram
All ciphers in GNU Crypto implement the IBlockCipher
interface,
and support all the methods listed in this section.
java.lang.String CIPHER_BLOCK_SIZE
|
Variable |
A property name in the attributes map that is passed to the init
method, representing the cipher's desired block size. The mapped value
should be a java.lang.Integer of the cipher's block size, in
bytes. If this attribute is omitted, the cipher's default block size is used.
|
java.lang.String KEY_MATERIAL
|
Variable |
A property name in the attributes map that is passed to the init
method, representing the bytes that are to compose the cipher's key. The
mapped value must be a byte array, and its length must be one of the
cipher's supported key sizes.
|
void init (java.util.Map attributes) throws java.security.InvalidKeyException, java.lang.IllegalStateException
|
Function |
Initializes the cipher for transforming data. The attributes
parameter must be a java.util.Map that has, at least, a mapping
between the KEY_MATERIAL property name to a byte array containing
the key. Ciphers may define other property names. If the supplied
byte array is not an acceptable key, this method throws a
java.security.InvalidKeyException . If this instance has already
been initialized, this method throws a
java.lang.IllegalStateException .
|
java.lang.String name ( )
|
Function |
Returns the cipher's canonical name.
|
int defaultBlockSize ( )
|
Function |
Returns the default block size, in bytes.
|
int defaultKeySize ( )
|
Function |
Returns the default key size, in bytes.
|
java.util.Iterator blockSizes ( )
|
Function |
Returns a java.util.Iterator of the cipher's supported block
sizes. Each element of the iterator is a java.lang.Integer .
|
java.util.Iterator keySizes ( )
|
Function |
Returns a java.util.Iterator of the cipher's supported key sizes.
Each element of the iterator is a java.lang.Integer .
|
java.lang.Object clone ( )
|
Function |
Returns a clone of this cipher. The cloned instance must be initialized,
as this method will not clone the cipher's internal key.
|
int currentBlockSize ( ) throws java.lang.IllegalStateException
|
Function |
Returns the cipher's current block size, in bytes, or will throw a
java.lang.IllegalStateException if this instance has not been
initialized.
|
Resets this instance, which may then be re-initialized.
|
void encryptBlock (byte[] plaintext, int inOffset, byte[] ciphertext, int outOffset) throws java.lang.IllegalStateException
|
Function |
Encrypts a block of bytes from plaintext starting at
inOffset, storing the encrypted bytes in ciphertext,
starting at outOffset. It is up to the programmer to ensure that
there is at least one full block in plaintext from inOffset
and space for one full block in ciphertext from outOffset. A
java.lang.IllegalStateException will be thrown if the cipher has
not been initialized.
|
void decryptBlock (byte[] ciphertext, int inOffset, byte[] plaintext, int outOffset) throws java.lang.IllegalStateException
|
Function |
Decrypts a block of bytes from ciphertext starting at
inOffset, storing the encrypted bytes in plaintext,
starting at outOffset. It is up to the programmer to ensure that
there is at least one full block in ciphertext from inOffset
and space for one full block in plaintext from outOffset. A
java.lang.IllegalStateException will be thrown if the cipher has
not been initialized.
|
boolean selfTest ( )
|
Function |
Performs a simple test of conformance, to ensure that there are no
implementation or system errors. This method returns true if the
test succeeds; false otherwise.
|