for
Original: April 6, 1998
The NIST intention is to allow both international and U.S. domestic submitters to present AES candidate algorithms under a single, stable API specification. The API set described herein permits all AES submitters to present a working implementation of their algorithm in the Java programming language that (a) can be tested with the freely supplied NIST KAT and MCT Java command line tools, (b) supports the NIST requirement for Electronic Codebook (ECB), Cipher Block Chaining (CBC), and 1-bit Cipher Feedback (1-CFB) modes, and (c) can be compared to other algorithm implementations running on the same Java Virtual Machine (JVM) and/or same implementation running on different JVMs.
To further help submitters with their Java implementation, the NIST and the Cryptix Development Team have co-developed a Kit that includes:
The toolkit is now available from Cryptix. This toolkit is also available at http://cryptix.moremagic.com/aes/, http://193.192.247.149/mirror/cryptix/aes/, and http://www.bssl.co.uk/mirrors/cryptix/aes/.
The Minimum Acceptability Requirements (section 3) of the Request for Candidate Algorithm states:
To be considered as a “proper” candidate algorithm submission (and continue further in the AES Development Process), candidate algorithms must meet the following minimum acceptability requirements:
- The algorithm must implement symmetric (secret) key cryptography.
- The algorithm must be a block cipher.
- The candidate algorithm shall be capable of supporting key-block combinations with sizes of 128-128, 192-128, and 256-128 bits. A submitted algorithm may support other key-block sizes and combinations, and such features will be taken into consideration during analysis and evaluation.
The NIST General Requirements (section 2.C.2) also state that the mathematically optimized implementations (both Java and ANSI C) will support the ECB, CBC, and 1-CFB modes of operation.
To fulfil these minimum requirements, the Basic API shall implement the block cipher algorithm primitive operations to (a) generate its internal key from the user supplied key material and (b) to operate the block cipher in encryption/decryption in Electronic Code Book mode. The Extended API shall allow users to instantiate and operate a candidate algorithm in all three required feedback modes of operation.
Shall consist of the following four public methods to be available in a public class called XXX_Algorithm in the package XXX, where the token XXX is replaced with the actual name of the candidate algorithm.
public static synchronized Object makeKey (byte[] key)
throws InvalidKeyException
Signature
makeKey (byte[] key)
Description
Expand a user-supplied key material into a session key.
Parameters
- key
- The 128/192/256-bit user-key material to use, encoded in a Java byte array.
Exceptions
- InvalidKeyException
- If the user-supplied key material is invalid.
Returns
An object of class Object that contains the session key (also known as the round keys) for both encryption and decryption operations. The semantics of the contents of this object are implementation dependant.
public static byte[] blockEncrypt (byte[] in, int inOffset,
Object sessionKey)
Signature
blockEncrypt (byte[] in, int inOffset, Object sessionKey)
Description
Encrypt exactly one block of plaintext in Electronic Code Book mode, returning the resulting ciphertext.
Parameters
- in
- A buffer (Java byte array) containing the plaintext.
- inOffset
- Offset in in buffer where plaintext starts.
- sessionKey
- The session key object returned by a previous invocation to the makeKey() method.
Exceptions
None
Returns
A Java byte array containing the resulting ciphertext block.
public static byte[] blockDecrypt (byte[] in, int inOffset,
Object sessionKey)
Signature
blockDecrypt (byte[] in, int inOffset, Object sessionKey)
Description
Decrypt exactly one block of ciphertext in Electronic Code Book mode, returning the resulting plaintext.
Parameters
- in
- A buffer (Java byte array) containing the ciphertext.
- inOffset
- Offset in in buffer where ciphertext starts.
- sessionKey
- The session key object returned by a previous invocation to the makeKey() method.
Exceptions
None
Returns
A Java byte array containing the resulting plaintext block.
public static boolean self_test()
Signature
self_test()
Description
Basic simple self test(s).
Parameters
None
Exceptions
None
Returns
True iff all tests pass; false otherwise.
The Extended API is defined in the NIST.NIST_CipherSpi interface (included in the Kit). It consists of the following methods.
public abstract void init (int state, byte[] key) throws
InvalidKeyExceptiony
;
Signature
init (int state, byte[] key)
Description
Initialize this cipher for encryption/decryption, using designated key material.
Parameters
- state
- Desired operation state of this instance. Valid values are ENCRYPT_STATE or DECRYPT_STATE.
- key
- User key material to use for the session.
Exceptions
- InvalidKeyException
- If the user-supplied key material is invalid.
Returns
Void.
See also
In NIST.NIST_Cipher
- ENCRYPT_STATE
- DECRYPT_STATE
public abstract void setIV (byte[] iv) throws
InvalidParameterException;
Signature
setIV (byte[] iv)
Description
Set the starting value of the IV.
Parameters
- iv
- The user-supplied IV value.
Exceptions
- InvalidParameterException
- If the supplied IV value is of the wrong length.
Returns
Void.
public abstract byte[] update (byte[] in, int inOff, int
inLen);
Signature
update (byte[] in, int inOff, int inLen)
Description
Continue a multi-part encryption/decryption operation.
Parameters
- in
- Input buffer containing the plaintext/ciphertext (depending on the current cipher's operational state).
- inOff
- Offset into in specifying where data starts. Caller must ensure it's a positive value that will not cause an ArrayIndexOutOfBoundsException when accessing in.
- inLen
- Length of the subarray. Caller must ensure inLen is a non-zero positive value.
Exceptions
- NullPointerException
- If the IV has not been set.
- IllegalStateException
- If the cipher's operational state is not properly set.
Returns
The encrypted/decrypted input text.
public abstract byte[] doFinal (byte[] in, int inOff, int
inLen);
Signature
doFinal (byte[] in, int inOff, int inLen)
Description
Encrypt/decrypt data in a single-part operation or finish a multi-part operation.
Parameters
- in
- Input buffer containing the plaintext/ciphertext (depending on the current cipher's operational state).
- inOff
- Offset into in specifying where data starts. Caller must ensure it's a positive value that will not cause an ArrayIndexOutOfBoundsException when accessing in.
- inLen
- Length of the subarray. Caller must ensure inLen is zero or a positive value.
Exceptions
- NullPointerException
- If the IV has not been set.
- IllegalStateException
- If the cipher's operational state is not properly set.
- InvalidParameterException
- If the operation when carried out, will cause an illegal block size exception; eg. the total length of data to encrypt is not a multiple of the cipher's block size.
Returns
The encrypted/decrypted input text including any other data that may have been buffered in one or more earlier invocations to update.
public abstract boolean self_test();
Signature
self_test()
Description
Basic simple self test(s).
Parameters
None
Exceptions
None
Returns
True iff all tests pass; false otherwise.
For submitters who choose to implement their own Extended API, the following notes should be considered:
NIST.NIST_Cipher
(for example):NIST_Cipher cipher = new NIST_Cipher("Foo", ECB_MODE);
NIST.NIST_Cipher
class will try to instantiate an object that
implements an AES candidate algorithm operating in one of the NIST
required modes.NIST.NIST_CipherSpi
Extended API interface and is supposed to be called
aes_suffix
, located in package
aes
.
suffix
will be ECB, CBC or CFB depending on the value of
the mode
argument according to the following table:
Mode |
Suffix |
Full class name |
---|---|---|
|
ECB |
|
|
CBC |
|
|
CFB |
|
If the above fails, this class then tries
to use NIST's own implementations of the feedback modes which assume
a class named
aes_Algorithm
in package
aes
implementing the Basic API.
If that also fails, this class then throws the appropriate
Exception.
Algorithm
where the word Algorithm is
substituted by the actual candidate algorithm; eg. for a candidate
algorithm named Foo, the implementation classes will belong
to the package Foo
.Algorithm.jar
where the word
Algorithm is substituted by the actual candidate algorithm name;
eg. for a candidate algorithm named "Foo", the implementation
classes will be packaged in the file Foo.jar
.
Computer Security Division
National Institute of Standards and Technology