UNPKG

@li0ard/streebog

Version:

Streebog hash function in pure TypeScript

64 lines (63 loc) 2.13 kB
import { type Hash, type TArg, type TRet } from "@noble/hashes/utils.js"; /** * Streebog core class */ declare abstract class Streebog<T extends Streebog<T>> implements Hash<Streebog<T>> { private is512; buffer: Uint8Array; readonly blockLen = 64; outputLen: number; readonly canXOF = false; abstract _cloneInto(to?: T): T; abstract clone(): T; /** * Streebog core constructor * @param is512 Use 512 bits version of algorithm */ constructor(is512: boolean); /** Reset hash state */ destroy(): void; /** Update hash buffer */ update(data: Uint8Array): this; /** Finalize hash computation and return result as Uint8Array */ digest(): TRet<Uint8Array>; /** * Finalize hash computation and write result into Uint8Array * @param buf - Output Uint8Array */ digestInto(buf: TArg<Uint8Array>): void; } /** Streebog 256 aka `GOST R 34.11-2012 256 bits` */ export declare class Streebog256 extends Streebog<Streebog256> { /** Streebog 256 aka `GOST R 34.11-2012 256 bits` */ constructor(); /** Create hash instance */ static create(): Streebog256; /** Clone hash instance */ clone(): Streebog256; _cloneInto(to?: Streebog256): Streebog256; } /** Streebog 512 bit aka `GOST R 34.11-2012 512 bits` */ export declare class Streebog512 extends Streebog<Streebog512> { /** Streebog 512 bit aka `GOST R 34.11-2012 512 bits` */ constructor(); /** Create hash instance */ static create(): Streebog512; /** Clone hash instance */ clone(): Streebog512; _cloneInto(to?: Streebog512): Streebog512; } /** * Compute hash with `Streebog 256 bit` (aka `GOST R 34.11-2012 256 bits`) * @param input Input bytes */ export declare const streebog256: (input: TArg<Uint8Array>) => TRet<Uint8Array>; /** * Compute hash with `Streebog 512 bit` (aka `GOST R 34.11-2012 512 bits`) * @param input Input bytes * @returns {Uint8Array} */ export declare const streebog512: (input: TArg<Uint8Array>) => TRet<Uint8Array>; export * from "./hmac.js"; export * from "./kdf.js"; export * from "./pbkdf2.js";