_md.d.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Internal Merkle-Damgard hash utils.
  3. * @module
  4. */
  5. import { type Input, Hash } from './utils.ts';
  6. /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
  7. export declare function setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void;
  8. /** Choice: a ? b : c */
  9. export declare function Chi(a: number, b: number, c: number): number;
  10. /** Majority function, true if any two inputs is true. */
  11. export declare function Maj(a: number, b: number, c: number): number;
  12. /**
  13. * Merkle-Damgard hash construction base class.
  14. * Could be used to create MD5, RIPEMD, SHA1, SHA2.
  15. */
  16. export declare abstract class HashMD<T extends HashMD<T>> extends Hash<T> {
  17. protected abstract process(buf: DataView, offset: number): void;
  18. protected abstract get(): number[];
  19. protected abstract set(...args: number[]): void;
  20. abstract destroy(): void;
  21. protected abstract roundClean(): void;
  22. readonly blockLen: number;
  23. readonly outputLen: number;
  24. readonly padOffset: number;
  25. readonly isLE: boolean;
  26. protected buffer: Uint8Array;
  27. protected view: DataView;
  28. protected finished: boolean;
  29. protected length: number;
  30. protected pos: number;
  31. protected destroyed: boolean;
  32. constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean);
  33. update(data: Input): this;
  34. digestInto(out: Uint8Array): void;
  35. digest(): Uint8Array;
  36. _cloneInto(to?: T): T;
  37. clone(): T;
  38. }
  39. /**
  40. * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
  41. * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
  42. */
  43. /** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
  44. export declare const SHA256_IV: Uint32Array;
  45. /** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */
  46. export declare const SHA224_IV: Uint32Array;
  47. /** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */
  48. export declare const SHA384_IV: Uint32Array;
  49. /** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
  50. export declare const SHA512_IV: Uint32Array;
  51. //# sourceMappingURL=_md.d.ts.map