Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AES

AES block cipher.

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), so we'll have to live with it.

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

Hierarchy

  • AES

Implements

  • BlockCipher

Index

Constructors

Properties

Methods

Constructors

constructor

  • new AES(key: Uint8Array, noDecryption?: boolean): AES
  • 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
    • Default value noDecryption: boolean = false

    Returns AES

Properties

blockSize

blockSize: 16 = 16

Methods

clean

  • clean(): this
  • Cleans expanded keys from memory, setting them to zeros.

    Returns this

decryptBlock

  • decryptBlock(src: Uint8Array, dst: Uint8Array): this
  • Decrypt 16-byte block src into 16-byte block dst.

    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

encryptBlock

  • encryptBlock(src: Uint8Array, dst: Uint8Array): this
  • Encrypt 16-byte block src into 16-byte block dst.

    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

setKey

  • setKey(key: Uint8Array, noDecryption?: boolean): this
  • Re-initializes this instance with the new key.

    This is helpful to avoid allocations.

    Parameters

    • key: Uint8Array
    • Default value noDecryption: boolean = false

    Returns this

Generated using TypeDoc