Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • AES

Implements

  • BlockCipher

Index

Constructors

  • 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
    • noDecryption: boolean = false

    Returns AES

Properties

blockSize: 16 = 16

Methods

  • Erases expanded keys from memory.

    Returns AES

  • decryptBlock(src: Uint8Array, dst: Uint8Array): AES
  • 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 AES

  • encryptBlock(src: Uint8Array, dst: Uint8Array): AES
  • 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 AES

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

    This is helpful to avoid allocations.

    Parameters

    • key: Uint8Array
    • noDecryption: boolean = false

    Returns AES

Generated using TypeDoc