修改后台权限
This commit is contained in:
9
node_modules/@ecies/ciphers/dist/_node/compat.d.ts
generated
vendored
Normal file
9
node_modules/@ecies/ciphers/dist/_node/compat.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { type Cipher } from "@noble/ciphers/utils";
|
||||
/**
|
||||
* make `node:crypto`'s ciphers compatible with `@noble/ciphers`.
|
||||
*
|
||||
* `Cipher`'s interface is the same for both `aes-256-gcm` and `chacha20-poly1305`,
|
||||
* albeit the latter is one of `CipherCCMTypes`.
|
||||
* Interestingly, whether to set `plaintextLength` or not, or which value to set, has no actual effect.
|
||||
*/
|
||||
export declare const _compat: (algorithm: "aes-256-gcm" | "aes-256-cbc" | "chacha20-poly1305", key: Uint8Array, nonce: Uint8Array, AAD?: Uint8Array) => Cipher;
|
||||
55
node_modules/@ecies/ciphers/dist/_node/compat.js
generated
vendored
Normal file
55
node_modules/@ecies/ciphers/dist/_node/compat.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports._compat = void 0;
|
||||
// biome-ignore-all lint/suspicious/noExplicitAny: hide type error
|
||||
var node_crypto_1 = require("node:crypto");
|
||||
var utils_1 = require("@noble/ciphers/utils");
|
||||
var AEAD_TAG_LENGTH = 16;
|
||||
// @ts-expect-error: only necessary for deno
|
||||
var IS_DENO = globalThis.Deno !== undefined;
|
||||
/**
|
||||
* make `node:crypto`'s ciphers compatible with `@noble/ciphers`.
|
||||
*
|
||||
* `Cipher`'s interface is the same for both `aes-256-gcm` and `chacha20-poly1305`,
|
||||
* albeit the latter is one of `CipherCCMTypes`.
|
||||
* Interestingly, whether to set `plaintextLength` or not, or which value to set, has no actual effect.
|
||||
*/
|
||||
var _compat = function (algorithm, key, nonce, AAD) {
|
||||
var isAEAD = algorithm === "aes-256-gcm" || algorithm === "chacha20-poly1305";
|
||||
var authTagLength = isAEAD ? AEAD_TAG_LENGTH : 0;
|
||||
// authTagLength is necessary for `chacha20-poly1305` before Node v16.17
|
||||
var options = isAEAD ? { authTagLength: authTagLength } : undefined;
|
||||
var encrypt = function (plainText) {
|
||||
var cipher = (0, node_crypto_1.createCipheriv)(algorithm, key, nonce, options);
|
||||
if (isAEAD && AAD !== undefined) {
|
||||
cipher.setAAD(AAD);
|
||||
}
|
||||
var updated = cipher.update(plainText);
|
||||
var finalized = cipher.final();
|
||||
var tag = isAEAD ? cipher.getAuthTag() : new Uint8Array(0);
|
||||
return (0, utils_1.concatBytes)(updated, finalized, tag);
|
||||
};
|
||||
var decrypt = function (cipherText) {
|
||||
var rawCipherText = cipherText.subarray(0, cipherText.length - authTagLength);
|
||||
var tag = cipherText.subarray(cipherText.length - authTagLength);
|
||||
var decipher = (0, node_crypto_1.createDecipheriv)(algorithm, key, nonce, options);
|
||||
if (isAEAD) {
|
||||
if (AAD !== undefined) {
|
||||
decipher.setAAD(AAD);
|
||||
}
|
||||
decipher.setAuthTag(tag);
|
||||
}
|
||||
/* v8 ignore if -- @preserve */
|
||||
if (!isAEAD && IS_DENO) {
|
||||
decipher.setAutoPadding(false); // See: https://github.com/denoland/deno/issues/28381
|
||||
}
|
||||
var updated = decipher.update(rawCipherText);
|
||||
var finalized = decipher.final();
|
||||
return (0, utils_1.concatBytes)(updated, finalized);
|
||||
};
|
||||
return {
|
||||
encrypt: encrypt,
|
||||
decrypt: decrypt,
|
||||
};
|
||||
};
|
||||
exports._compat = _compat;
|
||||
4
node_modules/@ecies/ciphers/dist/_node/hchacha.d.ts
generated
vendored
Normal file
4
node_modules/@ecies/ciphers/dist/_node/hchacha.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Copied from `@noble/ciphers/chacha`
|
||||
*/
|
||||
export declare const _hchacha20: (s: Uint32Array, k: Uint32Array, i: Uint32Array, o32: Uint32Array) => void;
|
||||
90
node_modules/@ecies/ciphers/dist/_node/hchacha.js
generated
vendored
Normal file
90
node_modules/@ecies/ciphers/dist/_node/hchacha.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
// biome-ignore-all format lint: copied code
|
||||
// prettier-ignore
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports._hchacha20 = void 0;
|
||||
/**
|
||||
* Copied from `@noble/ciphers/chacha`
|
||||
*/
|
||||
var _hchacha20 = function (s, k, i, o32) {
|
||||
var x00 = s[0], x01 = s[1], x02 = s[2], x03 = s[3], x04 = k[0], x05 = k[1], x06 = k[2], x07 = k[3], x08 = k[4], x09 = k[5], x10 = k[6], x11 = k[7], x12 = i[0], x13 = i[1], x14 = i[2], x15 = i[3];
|
||||
for (var r = 0; r < 20; r += 2) {
|
||||
x00 = (x00 + x04) | 0;
|
||||
x12 = rotl(x12 ^ x00, 16);
|
||||
x08 = (x08 + x12) | 0;
|
||||
x04 = rotl(x04 ^ x08, 12);
|
||||
x00 = (x00 + x04) | 0;
|
||||
x12 = rotl(x12 ^ x00, 8);
|
||||
x08 = (x08 + x12) | 0;
|
||||
x04 = rotl(x04 ^ x08, 7);
|
||||
x01 = (x01 + x05) | 0;
|
||||
x13 = rotl(x13 ^ x01, 16);
|
||||
x09 = (x09 + x13) | 0;
|
||||
x05 = rotl(x05 ^ x09, 12);
|
||||
x01 = (x01 + x05) | 0;
|
||||
x13 = rotl(x13 ^ x01, 8);
|
||||
x09 = (x09 + x13) | 0;
|
||||
x05 = rotl(x05 ^ x09, 7);
|
||||
x02 = (x02 + x06) | 0;
|
||||
x14 = rotl(x14 ^ x02, 16);
|
||||
x10 = (x10 + x14) | 0;
|
||||
x06 = rotl(x06 ^ x10, 12);
|
||||
x02 = (x02 + x06) | 0;
|
||||
x14 = rotl(x14 ^ x02, 8);
|
||||
x10 = (x10 + x14) | 0;
|
||||
x06 = rotl(x06 ^ x10, 7);
|
||||
x03 = (x03 + x07) | 0;
|
||||
x15 = rotl(x15 ^ x03, 16);
|
||||
x11 = (x11 + x15) | 0;
|
||||
x07 = rotl(x07 ^ x11, 12);
|
||||
x03 = (x03 + x07) | 0;
|
||||
x15 = rotl(x15 ^ x03, 8);
|
||||
x11 = (x11 + x15) | 0;
|
||||
x07 = rotl(x07 ^ x11, 7);
|
||||
x00 = (x00 + x05) | 0;
|
||||
x15 = rotl(x15 ^ x00, 16);
|
||||
x10 = (x10 + x15) | 0;
|
||||
x05 = rotl(x05 ^ x10, 12);
|
||||
x00 = (x00 + x05) | 0;
|
||||
x15 = rotl(x15 ^ x00, 8);
|
||||
x10 = (x10 + x15) | 0;
|
||||
x05 = rotl(x05 ^ x10, 7);
|
||||
x01 = (x01 + x06) | 0;
|
||||
x12 = rotl(x12 ^ x01, 16);
|
||||
x11 = (x11 + x12) | 0;
|
||||
x06 = rotl(x06 ^ x11, 12);
|
||||
x01 = (x01 + x06) | 0;
|
||||
x12 = rotl(x12 ^ x01, 8);
|
||||
x11 = (x11 + x12) | 0;
|
||||
x06 = rotl(x06 ^ x11, 7);
|
||||
x02 = (x02 + x07) | 0;
|
||||
x13 = rotl(x13 ^ x02, 16);
|
||||
x08 = (x08 + x13) | 0;
|
||||
x07 = rotl(x07 ^ x08, 12);
|
||||
x02 = (x02 + x07) | 0;
|
||||
x13 = rotl(x13 ^ x02, 8);
|
||||
x08 = (x08 + x13) | 0;
|
||||
x07 = rotl(x07 ^ x08, 7);
|
||||
x03 = (x03 + x04) | 0;
|
||||
x14 = rotl(x14 ^ x03, 16);
|
||||
x09 = (x09 + x14) | 0;
|
||||
x04 = rotl(x04 ^ x09, 12);
|
||||
x03 = (x03 + x04) | 0;
|
||||
x14 = rotl(x14 ^ x03, 8);
|
||||
x09 = (x09 + x14) | 0;
|
||||
x04 = rotl(x04 ^ x09, 7);
|
||||
}
|
||||
var oi = 0;
|
||||
o32[oi++] = x00;
|
||||
o32[oi++] = x01;
|
||||
o32[oi++] = x02;
|
||||
o32[oi++] = x03;
|
||||
o32[oi++] = x12;
|
||||
o32[oi++] = x13;
|
||||
o32[oi++] = x14;
|
||||
o32[oi++] = x15;
|
||||
};
|
||||
exports._hchacha20 = _hchacha20;
|
||||
var rotl = function (a, b) {
|
||||
return (a << b) | (a >>> (32 - b));
|
||||
};
|
||||
Reference in New Issue
Block a user