AES block cipher.

WARNING: This implementation uses lookup tables, so it's susceptible to cache-timing side-channel attacks. (A constant-time version we tried was super slow: a few kilobytes per second)

Key size: 16, 24 or 32 bytes, block size: 16 bytes.

Implements

Constructors

  • Constructs AES with the given 16, 24 or 32-byte key for AES-128, AES-192, or AES-256.

    If noDecryption is true, decryption key will not expanded, saving time and memory for cipher modes when decryption is not used (such as AES-CTR).

    Parameters

    • key: Uint8Array
    • noDecryption: boolean = false

    Returns AES

Properties

blockSize: 16 = 16

Byte length of cipher block.

Methods

  • Decrypt 16-byte block src into 16-byte block dst.

    Source and destination may point to the same byte array.

    This function should not be used to encrypt data without any cipher mode! It should only be used to implement a cipher mode.

    Parameters

    • src: Uint8Array
    • dst: Uint8Array

    Returns this

  • Encrypt 16-byte block src into 16-byte block dst.

    Source and destination may point to the same byte array.

    This function should not be used to encrypt data without any cipher mode! It should only be used to implement a cipher mode.

    Parameters

    • src: Uint8Array
    • dst: Uint8Array

    Returns this

  • Re-initializes this instance with a new key.

    This is helpful to avoid allocations.

    Parameters

    • key: Uint8Array
    • noDecryption: boolean = false

    Returns this