Home  Contents

AES Cipher Block Chaining

Cipher Core4 Lua Commands

SYNOPSIS

  1. ciphertext = aes:cbcEncrypt(plaintext)
  2. plaintext = aes:cbcDecrypt(ciphertext)

DESCRIPTION

Encryption or decryption of multiple blocks of 16 bytes. The blocks are processed using the cipher block chaining mode of operation. The CBC mode makes sure that multiple blocks with the same plaintext data are encrypted to different ciphertexts. This avoids giving clues to an attacker.

As these functions work on full blocks, the passed data must be a string that is a multiple of 16 bytes in length. To process arbitrary data, see aes:padEncrypt() and aes:padDecrypt().

aes must be an AES state handle as returned by cipher.aes(). The handle must have its key initialized using aes:setupEncrypt() or aes:setupDecrypt(), and it must have its initialization vector initialized using aes:setIV or aes:clearIV.

RETURN VALUE

A string of the same length as the passed data.

ERRORS

Raises an error if aes is not an AES state handle as returned by cipher.aes().

SEE ALSO