Swap-Aggregator-Subgraph/node_modules/asmcrypto.js/dist_es8/pbkdf2/pbkdf2-hmac-sha1.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

15 lines
618 B
JavaScript
Executable File

import { HmacSha1 } from '../hmac/hmac-sha1';
export function Pbkdf2HmacSha1(password, salt, count, length) {
const hmac = new HmacSha1(password);
const result = new Uint8Array(length);
const blocks = Math.ceil(length / hmac.HMAC_SIZE);
for (let i = 1; i <= blocks; ++i) {
const j = (i - 1) * hmac.HMAC_SIZE;
const l = (i < blocks ? 0 : length % hmac.HMAC_SIZE) || hmac.HMAC_SIZE;
hmac.reset().process(salt);
hmac.hash.asm.pbkdf2_generate_block(hmac.hash.pos, hmac.hash.len, i, count, 0);
result.set(hmac.hash.heap.subarray(0, l), j);
}
return result;
}