deploy: v0.12 fix 存档key名

This commit is contained in:
2026-06-24 03:09:02 +00:00
parent 7a08d49fe3
commit e0a5281119
58743 changed files with 7297269 additions and 39505 deletions
+21
View File
@@ -0,0 +1,21 @@
import { createHmac } from 'crypto';
export default (digest, ikm, salt, info, keylen) => {
const hashlen = parseInt(digest.substr(3), 10) >> 3 || 20;
const prk = createHmac(digest, salt.byteLength ? salt : new Uint8Array(hashlen))
.update(ikm)
.digest();
const N = Math.ceil(keylen / hashlen);
const T = new Uint8Array(hashlen * N + info.byteLength + 1);
let prev = 0;
let start = 0;
for (let c = 1; c <= N; c++) {
T.set(info, start);
T[start + info.byteLength] = c;
T.set(createHmac(digest, prk)
.update(T.subarray(prev, start + info.byteLength + 1))
.digest(), start);
prev = start;
start += hashlen;
}
return T.slice(0, keylen);
};
+14
View File
@@ -0,0 +1,14 @@
import * as crypto from 'crypto';
import fallback from './fallback.js';
let hkdf;
if (typeof crypto.hkdf === 'function' && !process.versions.electron) {
hkdf = async (...args) => new Promise((resolve, reject) => {
crypto.hkdf(...args, (err, arrayBuffer) => {
if (err)
reject(err);
else
resolve(new Uint8Array(arrayBuffer));
});
});
}
export default async (digest, ikm, salt, info, keylen) => (hkdf || fallback)(digest, ikm, salt, info, keylen);