AES (Rijndael) encryption and decryption is performed using the functions below. Typically, a key is first expanded using the appropriate function (depending on whether one decrypts or encrypts) and then the stream is encoded/decoded using AESEncryptBlock() or AESDecryptBlock(). A convenience function calls both of these for streams that comprise just a single block. The AES interface assumes that all data is word-aligned. Character streams have to be aligned to fit on word boundaries.
Encryption of a single block is performed by calling the funciton AESEncrypt(). If multiple blocks are to be encrypted with an identical key, the funciton AESEncryptKey() should be called once followed by multiple calls to AESEncryptBlock()
Decryption of a single block is performed by calling the funciton AESDecrypt(). If multiple blocks are to be decrypted with an identical key, the funciton AESDecryptKey() should be called once followed by multiple calls to AESDecryptBlock()
This function encrypts a block of plaintext into a block of ciphertext, given an expanded key.
Use AESEncryptExpandKey() to expand a 128-bit key. All are supplied as arrays of integers.
Parameters: |
|
---|
This function expands a 128-bit key into a format suitable for efficient encryption The output array needs to be at least 44 (that is Nb*(Nr+1)) words long.
Parameters: |
|
---|
This function encrypts a block of plaintext into a block of ciphertext, given a key.
All are supplied as arrays of integers. Calling this function is equivalent to first calling AESEncryptExpandKey() and then AESEncryptBlock().
Parameters: |
|
---|
This function encrypts a block of plaintext into a block of ciphertext, given an expanded key.
Use AESEncryptExpandKey() to expand a 128-bit key. All are supplied as arrays of integers.
Parameters: |
|
---|
This function expands a 128-bit key into a format suitable for efficient decryption The output array needs to be at least 44 (that is Nb*(Nr+1)) words long.
Parameters: |
|
---|
This function encrypts a block of plaintext into a block of ciphertext, given a key.
All are supplied as arrays of integers. Calling this function is equivalent to first calling AESDecryptExpandKey() and then AESDecryptBlock().
Parameters: |
|
---|
An example program is shown below:
unsigned int plain[4] = {1,2,3,4};
unsigned int key[4] = {12314241,4367465,1231244,1234569};
unsigned int cipher[4];
main() {
AESEncrypt(input, key, cipher);
AESDecrypt(cipher, key, output);
return 0;
}