Expand description

Code related to PBKDF2

Functions

Derive a number bits with a given key material

example
const bits = await PBKDF2.deriveBits(
{ hash: "SHA-512" },
keyMaterial,
128
);
example
const bits = await keyMaterial.deriveBits(
{ hash: "SHA-512" },
128
);

Parameters

Returns Promise<ArrayBuffer>

Derive a shared key from PBKDF2 key material

example
const hmacParams: params.EnforcedHmacKeyGenParams = {
name: Authentication.Alg.Code.HMAC,
hash: SHA.Alg.Variant.SHA_512,
length: 512,
};
let key = await PBKDF2.deriveKey(
{ hash: "SHA512" },
keyMaterial,
hmacParams
);
example
const hmacParams: params.EnforcedHmacKeyGenParams = {
name: Authentication.Alg.Code.HMAC,
hash: SHA.Alg.Variant.SHA_512,
length: 512,
};
let key = await keyMaterial.deriveKey(
{ hash: "SHA512" },
hmacParams
);

Parameters

Returns Promise<HmacCryptoKey | AesCryptoKeys>

Generate key material for deriving

example
const keyMaterial = await PBKDF2.generateKeyMaterial("raw", new TextEncoder().encode("could_be_a_little_entropy"));

Parameters

  • format: KeyFormat
  • key: BufferSource
  • Optional extractable: boolean

Returns Promise<Pbkdf2ProxiedKeyMaterial>