hkdf.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { type CHash, type Input } from './utils.ts';
  2. /**
  3. * HKDF-extract from spec. Less important part. `HKDF-Extract(IKM, salt) -> PRK`
  4. * Arguments position differs from spec (IKM is first one, since it is not optional)
  5. * @param hash - hash function that would be used (e.g. sha256)
  6. * @param ikm - input keying material, the initial key
  7. * @param salt - optional salt value (a non-secret random value)
  8. */
  9. export declare function extract(hash: CHash, ikm: Input, salt?: Input): Uint8Array;
  10. /**
  11. * HKDF-expand from the spec. The most important part. `HKDF-Expand(PRK, info, L) -> OKM`
  12. * @param hash - hash function that would be used (e.g. sha256)
  13. * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step)
  14. * @param info - optional context and application specific information (can be a zero-length string)
  15. * @param length - length of output keying material in bytes
  16. */
  17. export declare function expand(hash: CHash, prk: Input, info?: Input, length?: number): Uint8Array;
  18. /**
  19. * HKDF (RFC 5869): derive keys from an initial input.
  20. * Combines hkdf_extract + hkdf_expand in one step
  21. * @param hash - hash function that would be used (e.g. sha256)
  22. * @param ikm - input keying material, the initial key
  23. * @param salt - optional salt value (a non-secret random value)
  24. * @param info - optional context and application specific information (can be a zero-length string)
  25. * @param length - length of output keying material in bytes
  26. * @example
  27. * import { hkdf } from '@noble/hashes/hkdf';
  28. * import { sha256 } from '@noble/hashes/sha2';
  29. * import { randomBytes } from '@noble/hashes/utils';
  30. * const inputKey = randomBytes(32);
  31. * const salt = randomBytes(32);
  32. * const info = 'application-key';
  33. * const hk1 = hkdf(sha256, inputKey, salt, info, 32);
  34. */
  35. export declare const hkdf: (hash: CHash, ikm: Input, salt: Input | undefined, info: Input | undefined, length: number) => Uint8Array;
  36. //# sourceMappingURL=hkdf.d.ts.map