Convert hkdf.js to ts

This commit is contained in:
RMidhunSuresh 2021-11-17 14:04:43 +05:30
parent afecac3e3c
commit 6c2aa1bf61
2 changed files with 4 additions and 2 deletions

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import aesjs from "../../../lib/aes-js/index.js"; import aesjs from "../../../lib/aes-js/index.js";
import {hkdf} from "../../utils/crypto/hkdf.js"; import {hkdf} from "../../utils/crypto/hkdf";
import {Platform as ModernPlatform} from "./Platform.js"; import {Platform as ModernPlatform} from "./Platform.js";
export function Platform(container, paths) { export function Platform(container, paths) {

View file

@ -6,8 +6,10 @@
* Based on https://github.com/junkurihara/jscu/blob/develop/packages/js-crypto-hkdf/src/hkdf.ts * Based on https://github.com/junkurihara/jscu/blob/develop/packages/js-crypto-hkdf/src/hkdf.ts
*/ */
import type {Crypto} from "../../platform/web/dom/Crypto.js";
// forked this code to make it use the cryptoDriver for HMAC that is more backwards-compatible // forked this code to make it use the cryptoDriver for HMAC that is more backwards-compatible
export async function hkdf(cryptoDriver, key, salt, info, hash, length) { export async function hkdf(cryptoDriver: Crypto, key: Uint8Array, salt: Uint8Array, info: Uint8Array, hash: string, length: number): Promise<Uint8Array> {
length = length / 8; length = length / 8;
const len = cryptoDriver.digestSize(hash); const len = cryptoDriver.digestSize(hash);