@hackbg/miscreant-esm
Version:
(ESM port) Misuse resistant symmetric encryption library providing AES-SIV (RFC 5297), AES-PMAC-SIV, and STREAM constructions
33 lines (32 loc) • 1.09 kB
TypeScript
import { IBlockCipher } from "../../interfaces.dist";
import Block from "../../internals/block.dist";
/**
* 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 or 32 bytes, block size: 16 bytes.
*/
export default class SoftAes implements IBlockCipher {
private _encKey;
private _emptyPromise;
/**
* Constructs AES with the given 16 or 32-byte key
* for AES-128 or AES-256.
*/
constructor(keyData: Uint8Array);
/**
* Cleans expanded keys from memory, setting them to zeros.
*/
clear(): this;
/**
* Encrypt 16-byte block in-place, replacing its contents with ciphertext.
*
* This function should not be used to encrypt data without any
* cipher mode! It should only be used to implement a cipher mode.
* This library uses it to implement AES-SIV.
*/
encryptBlock(block: Block): Promise<this>;
}