Expand description
Code related to PBKDF2
Functions
sourcederiveBits
deriveBits
source(algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">, baseKey: Pbkdf2KeyMaterial, length: number): Promise<ArrayBuffer>
(algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">, baseKey: Pbkdf2KeyMaterial, length: number): Promise<ArrayBuffer>
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
algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">
baseKey: Pbkdf2KeyMaterial
length: number
Returns Promise<ArrayBuffer>
sourcederiveKey
deriveKey
source(algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">, baseKey: Pbkdf2KeyMaterial, derivedKeyType: EnforcedHmacKeyGenParams | EnforcedAesKeyGenParams, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<HmacCryptoKey | AesCryptoKeys>
(algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">, baseKey: Pbkdf2KeyMaterial, derivedKeyType: EnforcedHmacKeyGenParams | EnforcedAesKeyGenParams, extractable?: boolean, keyUsages?: KeyUsage[]): Promise<HmacCryptoKey | AesCryptoKeys>
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
algorithm: Omit<EnforcedPbkdf2Params, "iterations" | "name">
baseKey: Pbkdf2KeyMaterial
derivedKeyType: EnforcedHmacKeyGenParams | EnforcedAesKeyGenParams
Optional extractable: boolean
Optional keyUsages: KeyUsage[]
Returns Promise<HmacCryptoKey | AesCryptoKeys>
sourcegenerateKeyMaterial
generateKeyMaterial
source(format: KeyFormat, key: BufferSource, extractable?: boolean): Promise<Pbkdf2ProxiedKeyMaterial>
(format: KeyFormat, key: BufferSource, extractable?: boolean): Promise<Pbkdf2ProxiedKeyMaterial>
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