UNPKG

@hackbg/miscreant-esm

Version:

(ESM port) Misuse resistant symmetric encryption library providing AES-SIV (RFC 5297), AES-PMAC-SIV, and STREAM constructions

46 lines (45 loc) 2.22 kB
/** * The STREAM online authenticated encryption construction. * See <https://eprint.iacr.org/2015/189.pdf> for definition. */ import { IAEADLike, ICryptoProvider } from "./interfaces.dist"; /** Size of a nonce required by STREAM in bytes */ export declare const NONCE_SIZE = 8; /** Byte flag indicating this is the last block in the STREAM (otherwise 0) */ export declare const LAST_BLOCK_FLAG = 1; /** Maximum value of the counter STREAM uses internally to identify messages */ export declare const COUNTER_MAX = 4294967295; /** * A STREAM encryptor with a 32-bit counter, generalized for any AEAD algorithm * * This corresponds to the ℰ stream encryptor object as defined in the paper * Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance */ export declare class StreamEncryptor { /** Create a new StreamEncryptor instance with the given key */ static importKey(keyData: Uint8Array, nonce: Uint8Array, alg: string, provider?: ICryptoProvider): Promise<StreamEncryptor>; private _aead; private _nonce_encoder; constructor(aead: IAEADLike, nonce: Uint8Array); /** Encrypt and authenticate data using the selected AEAD algorithm */ seal(plaintext: Uint8Array, lastBlock?: boolean, associatedData?: Uint8Array): Promise<Uint8Array>; /** Make a best effort to wipe memory used by this instance */ clear(): this; } /** * A STREAM decryptor with a 32-bit counter, generalized for any AEAD algorithm * * This corresponds to the 𝒟 stream decryptor object as defined in the paper * Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance */ export declare class StreamDecryptor { /** Create a new StreamDecryptor instance with the given key */ static importKey(keyData: Uint8Array, nonce: Uint8Array, alg: string, provider?: ICryptoProvider): Promise<StreamDecryptor>; private _aead; private _nonce_encoder; constructor(aead: IAEADLike, nonce: Uint8Array); /** Decrypt and authenticate data using the selected AEAD algorithm */ open(ciphertext: Uint8Array, lastBlock?: boolean, associatedData?: Uint8Array): Promise<Uint8Array>; /** Make a best effort to wipe memory used by this instance */ clear(): this; }