Class: AES

AES

Implements the AES symmetric encryption algorithm (specified in FIPS 197 [http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf])

new AES(data)

Creates a new AES instance
Parameters:
Name Type Description
data Object Initialization options for the class, passed automatically into AES#initialize
Author:
License:
Source:

Extends

Requires

  • module:convert

Members

debug_mode :Boolean

Controls whether to log debug output to the console.
Type:
  • Boolean
Default Value:
  • false
Source:
See:

Methods

debug_write(arguments)

Writes debug information to the console if BlockCipher#debug_mode is turned on.
Parameters:
Name Type Argument Description
arguments mixed <repeatable>
The variables to write to console
Inherited From:
Source:

decrypt(ciphertext) → {String}

Decrypts a string.
Parameters:
Name Type Description
ciphertext String An ASCII string to decrypt.
Inherited From:
Source:
Returns:
Encrypted data
Type
String

encrypt(plaintext) → {String}

Encrypts a string using the padding and block cipher mode of operation specificed on initialization.
Parameters:
Name Type Description
plaintext String An ASCII string to encrypt. Can be binary or plaintext. For plaintext, be sure to use convert.utf8.encode to encode any UTF characters.
Inherited From:
Source:
Returns:
Decrypted data
Type
String

get_block_size() → {Number}

Getter function for the block size
Source:
Returns:
The block size (in bits)
Type
Number

get_key() → {Array}

Getter function for the key
Source:
Returns:
The byte array for the key
Type
Array

get_key_length() → {Number}

Getter function for the key length
Source:
Returns:
The key length (in bits)
Type
Number

get_salt() → {String}

Gets the salt used for any passphrase-based key derivation.
Inherited From:
Source:
Returns:
Type
String

initialize(data) → {AES}

Called automatically on class instantiation. Invokes BlockCipher#initialize before handling class-specific functionality.
Parameters:
Name Type Description
data Object See BlockCipher#initialize for a list of supported properties.
Source:
Returns:
Type
AES

set_key(key) → {AES}

Set the key, either from a string or an array of byte values
Parameters:
Name Type Description
key string | Array The symmetric key. Must be ASCII-encoded binary string or Array.
Source:
Throws:
Will throw an error if the key is not 128, 192, or 256 bits
Returns:
This AES instance (chainable)
Type
AES

test() → {boolean}

Sanity test for the class. NOTE: You must initialize the instance with data.block_mode set to ECB and data.pad_mode set to ZeroPadding for this to work! See BlockCipher#initialize for more information on initialization properties.
Source:
Returns:
Type
boolean