This creates an object that can perform the Advanced Encryption
Standard (AES) block cipher.
Usage
AES(key, mode=c("ECB", "CBC", "CTR"), IV=NULL)
Arguments
key
The key as a 16, 24 or 32 byte raw vector for AES-128, AES-192 or
AES-256 respectively.
mode
The encryption mode to use. Currently only “electronic
codebook” (ECB), “cipher-block chaining” (CBC) and
“counter” (CTR) modes are supported.
IV
The initial vector for CBC mode or initial counter for CTR mode.
Details
The standard NIST definition of CTR mode doesn't define how the counter
is updated, it just requires that it be updated with each block
and not repeat itself for a long time. This implementation treats it as a
128 bit integer and adds 1 with each successive block.
Value
An object of class "AES". This is a list containing the
following component functions:
encrypt(text)
A function to encrypt a text vector. The text
may be a single element character vector or a raw vector. It returns
the ciphertext as a raw vector.
decrypt(ciphertext, raw = FALSE)
A function to decrypt the
ciphertext. In ECB mode, the same AES
object can be used for both encryption and decryption, but in
CBC and CTR modes a new object needs to be
created, using the same initial key and IV values.
IV()
Report on the current state of the initialization vector.
As blocks are encrypted or decrypted in CBC or CTR mode, the initialization
vector is updated, so both operations can be performed sequentially on
subsets of the text or ciphertext.
block_size(), key_size(), mode()
Report on these aspects of
the AES object.
Author(s)
The R interface was written by Duncan Murdoch. The design is loosely
based on the Python Crypto implementation. The underlying AES
implementation is by Christophe Devine.
References
United States National Institute of Standards and Technology (2001).
"Announcing the ADVANCED ENCRYPTION STANDARD (AES)".
Federal Information Processing Standards Publication 197.
http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf.