crypt.Aes Extends
Implementation of AES in JavaScript. See http://en.wikipedia.org/wiki/Advanced_Encryption_Standard WARNING: This is ECB mode only. If you are encrypting something longer than 16 bytes, or encrypting more than one value with the same key (so basically, always) you need to use this with a block cipher mode of operation. See goog.crypt.Cbc. See http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation for more information.

Inheritance

Constructor

goog.crypt.Aes(key)

Parameters

key : !Array.<number>
The key as an array of integers in {0, 255}. The key must have lengths of 16, 24, or 32 integers for 128-, 192-, or 256-bit encryption, respectively.

Instance Methods

Public Protected Private
Defined in goog.crypt.Aes
addRoundKey_(round)
AES's AddRoundKey procedure. Add the current round key to the state.
Arguments:
round : number
The current round.
code »
copyInput_(input)
Helper to copy input into the AES state matrix.
Arguments:
input : !Array.<number>
Byte array to copy into the state matrix.
code »
decrypt()
No description.
code »
encrypt()
No description.
code »
generateOutput_() !Array.<number>
Helper to copy the state matrix into an output array.
Returns: !Array.<number>  Output byte array.
code »
invMixColumns_()
AES's InvMixColumns procedure.
code »
invShiftRows_()
AES's InvShiftRows procedure. Shift the values in each row to the right.
code »
keyExpansion_()
AES's KeyExpansion procedure. Create the key schedule from the initial key.
code »
mixColumns_()
AES's MixColumns procedure. Mix the columns of the state using magic.
code »
rotWord_(w) !Array.<number>
AES's RotWord procedure.
Arguments:
w : !Array.<number>
Array of bytes to rotate.
Returns: !Array.<number>  The rotated bytes.
code »
shiftRows_()
AES's ShiftRows procedure. Shift the values in each row to the right. Each row is shifted one more slot than the one above it.
code »
subBytes_(box)
AES's SubBytes procedure. Substitute bytes from the precomputed SBox lookup into the state.
Arguments:
box : !Array.<number>
The SBox or invSBox.
code »
subWord_(w) !Array.<number>
AES's SubWord procedure.
Arguments:
w : !Array.<number>
Bytes to find the SBox substitution for.
Returns: !Array.<number>  The substituted bytes.
code »
testAfterAddRoundKey_(roundNumCurrent)
Tests can populate this with a callback, and that callback will get called each round right after the AddRoundKey step gets executed encrypt().
Arguments:
roundNum : number
Round number.
Current : !Array.<Array.<number>>
state.
code »
testAfterMixColumns_(roundNumCurrent)
Tests can populate this with a callback, and that callback will get called each round right after the MixColumns step gets executed *but only in the decrypt() function*.
Arguments:
roundNum : number
Round number.
Current : !Array.<Array.<number>>
state.
code »
testAfterShiftRows_(roundNumCurrent)
Tests can populate this with a callback, and that callback will get called each round right after the ShiftRows step gets executed *in both functions encrypt() and decrypt()*.
Arguments:
roundNum : number
Round number.
Current : !Array.<Array.<number>>
state.
code »
testAfterSubBytes_(roundNumCurrent)
Tests can populate this with a callback, and that callback will get called each round right after the SubBytes step gets executed *in both functions encrypt() and decrypt()*.
Arguments:
roundNum : number
Round number.
Current : !Array.<Array.<number>>
state.
code »
testKeySchedule_(roundNumComputedindex)
Tests can populate this with a callback, and that callback will get called before each round on the round key. *Gets called in both the encrypt() and decrypt() functions.*
Arguments:
roundNum : number
Round number.
Computed : !Array.<number>
key schedule.
index : number
The index into the key schedule to test. This is not necessarily roundNum because the key schedule is used in reverse in the case of decryption.
code »
testStartRound_(roundNumCurrent)
Tests can populate this with a callback, and that callback will get called at the start of each round *in both functions encrypt() and decrypt()*.
Arguments:
roundNum : number
Round number.
Current : !Array.<Array.<number>>
state.
code »

Instance Properties

Defined in goog.crypt.Aes
keyLength_ :
Key length, in words.
Code »
keySchedule_ :
The key schedule.
Code »
key_ :
The AES key.
Code »
numberOfRounds_ :
Number of rounds. Based on key length per AES spec.
Code »
state_ :
4x4 byte array containing the current state.
Code »
temp_ :
Scratch temporary array for calculation.
Code »

Static Methods

goog.crypt.Aes.assertKeyArray_(arr)
Asserts that the key's array of integers is in the correct format.
Arguments:
arr : !Array.<number>
AES key as array of integers.
code »

Static Properties

goog.crypt.Aes.BLOCK_SIZE_ :
Block size, in words. Fixed at 4 per AES spec.
Code »
goog.crypt.Aes.ENABLE_TEST_MODE :
No description.
Code »
goog.crypt.Aes.INV_SBOX_ :
Precomputed InvSBox lookup.
Code »
goog.crypt.Aes.MULT_2_ :
Precomputed lookup of multiplication by 2 in GF(2^8)
Code »
goog.crypt.Aes.MULT_3_ :
Precomputed lookup of multiplication by 3 in GF(2^8)
Code »
goog.crypt.Aes.MULT_9_ :
Precomputed lookup of multiplication by 9 in GF(2^8)
Code »
goog.crypt.Aes.MULT_B_ :
Precomputed lookup of multiplication by 11 in GF(2^8)
Code »
goog.crypt.Aes.MULT_D_ :
Precomputed lookup of multiplication by 13 in GF(2^8)
Code »
goog.crypt.Aes.MULT_E_ :
Precomputed lookup of multiplication by 14 in GF(2^8)
Code »
goog.crypt.Aes.RCON_ :
Precomputed RCon lookup.
Code »
goog.crypt.Aes.SBOX_ :
Precomputed SBox lookup.
Code »

Package crypt

Package Reference