@protontech/openpgp 5.7.0 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lightweight/argon2id.min.mjs +3 -0
- package/dist/lightweight/argon2id.min.mjs.map +1 -0
- package/dist/lightweight/{index.mjs → argon2id.mjs} +6 -7
- package/dist/lightweight/bn.interface.min.mjs +1 -1
- package/dist/lightweight/bn.interface.mjs +1 -1
- package/dist/lightweight/bn.min.mjs +1 -1
- package/dist/lightweight/bn.mjs +1 -1
- package/dist/lightweight/elliptic.min.mjs +1 -1
- package/dist/lightweight/elliptic.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +2 -2
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +428 -205
- package/dist/lightweight/ponyfill.es6.min.mjs +1 -1
- package/dist/lightweight/ponyfill.es6.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.min.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.mjs +1 -1
- package/dist/node/openpgp.js +1149 -213
- package/dist/node/openpgp.min.js +3 -3
- package/dist/node/openpgp.min.js.map +1 -1
- package/dist/node/openpgp.min.mjs +3 -3
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +1149 -214
- package/dist/openpgp.js +1134 -204
- package/dist/openpgp.min.js +3 -3
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +3 -3
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +1134 -205
- package/openpgp.d.ts +31 -8
- package/package.json +3 -1
- package/dist/lightweight/index.min.mjs +0 -3
- package/dist/lightweight/index.min.mjs.map +0 -1
package/dist/node/openpgp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
1
|
+
/*! OpenPGP.js v5.9.0 - 2023-05-15 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -1927,7 +1927,7 @@ const util = {
|
|
|
1927
1927
|
if (!util.isString(data)) {
|
|
1928
1928
|
return false;
|
|
1929
1929
|
}
|
|
1930
|
-
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}
|
|
1930
|
+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}[0-9]*|xn--[a-zA-Z\-0-9]+)))$/;
|
|
1931
1931
|
return re.test(data);
|
|
1932
1932
|
},
|
|
1933
1933
|
|
|
@@ -2124,14 +2124,14 @@ const util = {
|
|
|
2124
2124
|
* provided with the application or distribution.
|
|
2125
2125
|
*/
|
|
2126
2126
|
|
|
2127
|
-
const Buffer = util.getNodeBuffer();
|
|
2127
|
+
const Buffer$1 = util.getNodeBuffer();
|
|
2128
2128
|
|
|
2129
2129
|
let encodeChunk;
|
|
2130
2130
|
let decodeChunk;
|
|
2131
|
-
if (Buffer) {
|
|
2132
|
-
encodeChunk = buf => Buffer.from(buf).toString('base64');
|
|
2131
|
+
if (Buffer$1) {
|
|
2132
|
+
encodeChunk = buf => Buffer$1.from(buf).toString('base64');
|
|
2133
2133
|
decodeChunk = str => {
|
|
2134
|
-
const b = Buffer.from(str, 'base64');
|
|
2134
|
+
const b = Buffer$1.from(str, 'base64');
|
|
2135
2135
|
return new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
|
|
2136
2136
|
};
|
|
2137
2137
|
} else {
|
|
@@ -2323,6 +2323,7 @@ var enums = {
|
|
|
2323
2323
|
simple: 0,
|
|
2324
2324
|
salted: 1,
|
|
2325
2325
|
iterated: 3,
|
|
2326
|
+
argon2: 4,
|
|
2326
2327
|
gnu: 101
|
|
2327
2328
|
},
|
|
2328
2329
|
|
|
@@ -2637,6 +2638,8 @@ var enums = {
|
|
|
2637
2638
|
splitPrivateKey: 16,
|
|
2638
2639
|
/** 0x20 - This key may be used for authentication. */
|
|
2639
2640
|
authentication: 32,
|
|
2641
|
+
/** This key may be used for forwarded communications */
|
|
2642
|
+
forwardedCommunication: 64,
|
|
2640
2643
|
/** 0x80 - The private component of this key may be in the
|
|
2641
2644
|
* possession of more than one person. */
|
|
2642
2645
|
sharedPrivateKey: 128
|
|
@@ -2787,12 +2790,41 @@ var config = {
|
|
|
2787
2790
|
*/
|
|
2788
2791
|
v5Keys: false,
|
|
2789
2792
|
/**
|
|
2790
|
-
*
|
|
2791
|
-
*
|
|
2793
|
+
* S2K (String to Key) type, used for key derivation in the context of secret key encryption
|
|
2794
|
+
* and password-encrypted data. Weaker s2k options are not allowed.
|
|
2795
|
+
* Note: Argon2 is the strongest option but not all OpenPGP implementations are compatible with it
|
|
2796
|
+
* (pending standardisation).
|
|
2797
|
+
* @memberof module:config
|
|
2798
|
+
* @property {enums.s2k.argon2|enums.s2k.iterated} s2kType {@link module:enums.s2k}
|
|
2799
|
+
*/
|
|
2800
|
+
s2kType: enums.s2k.iterated,
|
|
2801
|
+
/**
|
|
2802
|
+
* {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3| RFC4880 3.7.1.3}:
|
|
2803
|
+
* Iteration Count Byte for Iterated and Salted S2K (String to Key).
|
|
2804
|
+
* Only relevant if `config.s2kType` is set to `enums.s2k.iterated`.
|
|
2805
|
+
* Note: this is the exponent value, not the final number of iterations (refer to specs for more details).
|
|
2792
2806
|
* @memberof module:config
|
|
2793
2807
|
* @property {Integer} s2kIterationCountByte
|
|
2794
2808
|
*/
|
|
2795
2809
|
s2kIterationCountByte: 224,
|
|
2810
|
+
/**
|
|
2811
|
+
* {@link https://tools.ietf.org/html/draft-ietf-openpgp-crypto-refresh-07.html#section-3.7.1.4| draft-crypto-refresh 3.7.1.4}:
|
|
2812
|
+
* Argon2 parameters for S2K (String to Key).
|
|
2813
|
+
* Only relevant if `config.s2kType` is set to `enums.s2k.argon2`.
|
|
2814
|
+
* Default settings correspond to the second recommendation from RFC9106 ("uniformly safe option"),
|
|
2815
|
+
* to ensure compatibility with memory-constrained environments.
|
|
2816
|
+
* For more details on the choice of parameters, see https://tools.ietf.org/html/rfc9106#section-4.
|
|
2817
|
+
* @memberof module:config
|
|
2818
|
+
* @property {Object} params
|
|
2819
|
+
* @property {Integer} params.passes - number of iterations t
|
|
2820
|
+
* @property {Integer} params.parallelism - degree of parallelism p
|
|
2821
|
+
* @property {Integer} params.memoryExponent - one-octet exponent indicating the memory size, which will be: 2**memoryExponent kibibytes.
|
|
2822
|
+
*/
|
|
2823
|
+
s2kArgon2Params: {
|
|
2824
|
+
passes: 3,
|
|
2825
|
+
parallelism: 4, // lanes
|
|
2826
|
+
memoryExponent: 16 // 64 MiB of RAM
|
|
2827
|
+
},
|
|
2796
2828
|
/**
|
|
2797
2829
|
* Allow decryption of messages without integrity protection.
|
|
2798
2830
|
* This is an **insecure** setting:
|
|
@@ -2812,6 +2844,13 @@ var config = {
|
|
|
2812
2844
|
* @property {Boolean} allowUnauthenticatedStream
|
|
2813
2845
|
*/
|
|
2814
2846
|
allowUnauthenticatedStream: false,
|
|
2847
|
+
/**
|
|
2848
|
+
* Allow decrypting forwarded messages, using keys with 0x40 ('forwarded communication') flag.
|
|
2849
|
+
* Note: this is related to a **non-standard feature**.
|
|
2850
|
+
* @memberof module:config
|
|
2851
|
+
* @property {Boolean} allowForwardedMessages
|
|
2852
|
+
*/
|
|
2853
|
+
allowForwardedMessages: false,
|
|
2815
2854
|
/**
|
|
2816
2855
|
* @memberof module:config
|
|
2817
2856
|
* @property {Boolean} checksumRequired Do not throw error when armor is missing a checksum
|
|
@@ -2888,6 +2927,14 @@ var config = {
|
|
|
2888
2927
|
* @property {Boolean} ignoreMalformedPackets Ignore malformed packets on parsing instead of throwing an error
|
|
2889
2928
|
*/
|
|
2890
2929
|
ignoreMalformedPackets: false,
|
|
2930
|
+
/**
|
|
2931
|
+
* Parsing of packets is normally restricted to a predefined set of packets. For example a Sym. Encrypted Integrity Protected Data Packet can only
|
|
2932
|
+
* contain a certain set of packets including LiteralDataPacket. With this setting we can allow additional packets, which is probably not advisable
|
|
2933
|
+
* as a global config setting, but can be used for specific function calls (e.g. decrypt method of Message).
|
|
2934
|
+
* @memberof module:config
|
|
2935
|
+
* @property {Array} additionalAllowedPackets Allow additional packets on parsing. Defined as array of packet classes, e.g. [PublicKeyPacket]
|
|
2936
|
+
*/
|
|
2937
|
+
additionalAllowedPackets: [],
|
|
2891
2938
|
/**
|
|
2892
2939
|
* @memberof module:config
|
|
2893
2940
|
* @property {Boolean} showVersion Whether to include {@link module:config/config.versionString} in armored messages
|
|
@@ -2902,7 +2949,7 @@ var config = {
|
|
|
2902
2949
|
* @memberof module:config
|
|
2903
2950
|
* @property {String} versionString A version string to be included in armored messages
|
|
2904
2951
|
*/
|
|
2905
|
-
versionString: 'OpenPGP.js 5.
|
|
2952
|
+
versionString: 'OpenPGP.js 5.9.0',
|
|
2906
2953
|
/**
|
|
2907
2954
|
* @memberof module:config
|
|
2908
2955
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -10250,7 +10297,7 @@ async function CBC(key) {
|
|
|
10250
10297
|
|
|
10251
10298
|
const webCrypto$3 = util.getWebCrypto();
|
|
10252
10299
|
const nodeCrypto$3 = util.getNodeCrypto();
|
|
10253
|
-
const Buffer$
|
|
10300
|
+
const Buffer$2 = util.getNodeBuffer();
|
|
10254
10301
|
|
|
10255
10302
|
|
|
10256
10303
|
const blockLength$1 = 16;
|
|
@@ -10282,7 +10329,7 @@ async function CTR(key) {
|
|
|
10282
10329
|
if (util.getNodeCrypto()) { // Node crypto library
|
|
10283
10330
|
return async function(pt, iv) {
|
|
10284
10331
|
const en = new nodeCrypto$3.createCipheriv('aes-' + (key.length * 8) + '-ctr', key, iv);
|
|
10285
|
-
const ct = Buffer$
|
|
10332
|
+
const ct = Buffer$2.concat([en.update(pt), en.final()]);
|
|
10286
10333
|
return new Uint8Array(ct);
|
|
10287
10334
|
};
|
|
10288
10335
|
}
|
|
@@ -10919,7 +10966,7 @@ class AES_GCM {
|
|
|
10919
10966
|
|
|
10920
10967
|
const webCrypto$4 = util.getWebCrypto();
|
|
10921
10968
|
const nodeCrypto$4 = util.getNodeCrypto();
|
|
10922
|
-
const Buffer$
|
|
10969
|
+
const Buffer$3 = util.getNodeBuffer();
|
|
10923
10970
|
|
|
10924
10971
|
const blockLength$3 = 16;
|
|
10925
10972
|
const ivLength$2 = 12; // size of the IV in bytes
|
|
@@ -10965,7 +11012,7 @@ async function GCM(cipher, key) {
|
|
|
10965
11012
|
encrypt: async function(pt, iv, adata = new Uint8Array()) {
|
|
10966
11013
|
const en = new nodeCrypto$4.createCipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10967
11014
|
en.setAAD(adata);
|
|
10968
|
-
const ct = Buffer$
|
|
11015
|
+
const ct = Buffer$3.concat([en.update(pt), en.final(), en.getAuthTag()]); // append auth tag to ciphertext
|
|
10969
11016
|
return new Uint8Array(ct);
|
|
10970
11017
|
},
|
|
10971
11018
|
|
|
@@ -10973,7 +11020,7 @@ async function GCM(cipher, key) {
|
|
|
10973
11020
|
const de = new nodeCrypto$4.createDecipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10974
11021
|
de.setAAD(adata);
|
|
10975
11022
|
de.setAuthTag(ct.slice(ct.length - tagLength$2, ct.length)); // read auth tag at end of ciphertext
|
|
10976
|
-
const pt = Buffer$
|
|
11023
|
+
const pt = Buffer$3.concat([de.update(ct.slice(0, ct.length - tagLength$2)), de.final()]);
|
|
10977
11024
|
return new Uint8Array(pt);
|
|
10978
11025
|
}
|
|
10979
11026
|
};
|
|
@@ -14398,7 +14445,7 @@ function buildEcdhParam(public_algo, oid, kdfParams, fingerprint) {
|
|
|
14398
14445
|
return util.concatUint8Array([
|
|
14399
14446
|
oid.write(),
|
|
14400
14447
|
new Uint8Array([public_algo]),
|
|
14401
|
-
kdfParams.
|
|
14448
|
+
kdfParams.write(true),
|
|
14402
14449
|
util.stringToUint8Array('Anonymous Sender '),
|
|
14403
14450
|
kdfParams.replacementFingerprint || fingerprint.subarray(0, 20)
|
|
14404
14451
|
]);
|
|
@@ -15240,32 +15287,28 @@ class ECDHSymmetricKey {
|
|
|
15240
15287
|
|
|
15241
15288
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15242
15289
|
|
|
15290
|
+
const VERSION_FORWARDING = 0xFF;
|
|
15291
|
+
|
|
15243
15292
|
class KDFParams {
|
|
15244
15293
|
/**
|
|
15245
15294
|
* @param {Integer} version Version, defaults to 1
|
|
15246
15295
|
* @param {enums.hash} hash Hash algorithm
|
|
15247
15296
|
* @param {enums.symmetric} cipher Symmetric algorithm
|
|
15248
|
-
* @param {
|
|
15249
|
-
* @param {Uint8Array} replacementFingerprint (v2 only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15250
|
-
* @param {Uint8Array} replacementKDFParams (v2 only) serialized KDF params to use in KDF digest computation
|
|
15297
|
+
* @param {Uint8Array} replacementFingerprint (forwarding only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15251
15298
|
*/
|
|
15252
15299
|
constructor(data) {
|
|
15253
15300
|
if (data) {
|
|
15254
|
-
const { version, hash, cipher,
|
|
15301
|
+
const { version, hash, cipher, replacementFingerprint } = data;
|
|
15255
15302
|
this.version = version || 1;
|
|
15256
15303
|
this.hash = hash;
|
|
15257
15304
|
this.cipher = cipher;
|
|
15258
15305
|
|
|
15259
|
-
this.flags = flags;
|
|
15260
15306
|
this.replacementFingerprint = replacementFingerprint;
|
|
15261
|
-
this.replacementKDFParams = replacementKDFParams;
|
|
15262
15307
|
} else {
|
|
15263
15308
|
this.version = null;
|
|
15264
15309
|
this.hash = null;
|
|
15265
15310
|
this.cipher = null;
|
|
15266
|
-
this.flags = null;
|
|
15267
15311
|
this.replacementFingerprint = null;
|
|
15268
|
-
this.replacementKDFParams = null;
|
|
15269
15312
|
}
|
|
15270
15313
|
}
|
|
15271
15314
|
|
|
@@ -15275,44 +15318,41 @@ class KDFParams {
|
|
|
15275
15318
|
* @returns {Number} Number of read bytes.
|
|
15276
15319
|
*/
|
|
15277
15320
|
read(input) {
|
|
15321
|
+
const totalBytes = input[0];
|
|
15278
15322
|
this.version = input[1];
|
|
15279
15323
|
this.hash = input[2];
|
|
15280
15324
|
this.cipher = input[3];
|
|
15281
15325
|
let readBytes = 4;
|
|
15282
15326
|
|
|
15283
|
-
if (this.version ===
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
readBytes += 20;
|
|
15288
|
-
}
|
|
15289
|
-
if (this.flags & enums.kdfFlags.replace_kdf_params) {
|
|
15290
|
-
const fieldLength = input[readBytes] + 1; // account for length
|
|
15291
|
-
this.replacementKDFParams = input.slice(readBytes, readBytes + fieldLength);
|
|
15292
|
-
readBytes += fieldLength;
|
|
15293
|
-
}
|
|
15327
|
+
if (this.version === VERSION_FORWARDING) {
|
|
15328
|
+
const fingerprintLength = totalBytes - readBytes + 1; // acount for length byte
|
|
15329
|
+
this.replacementFingerprint = input.slice(readBytes, readBytes + fingerprintLength);
|
|
15330
|
+
readBytes += fingerprintLength;
|
|
15294
15331
|
}
|
|
15295
15332
|
return readBytes;
|
|
15296
15333
|
}
|
|
15297
15334
|
|
|
15298
15335
|
/**
|
|
15299
15336
|
* Write KDFParams to an Uint8Array
|
|
15337
|
+
* @param {Boolean} [forReplacementParams] - forwarding only: whether to serialize data to use for replacement params
|
|
15300
15338
|
* @returns {Uint8Array} Array with the KDFParams value
|
|
15301
15339
|
*/
|
|
15302
|
-
write() {
|
|
15303
|
-
if (!this.version || this.version === 1) {
|
|
15340
|
+
write(forReplacementParams) {
|
|
15341
|
+
if (!this.version || this.version === 1 || forReplacementParams) {
|
|
15304
15342
|
return new Uint8Array([3, 1, this.hash, this.cipher]);
|
|
15305
15343
|
}
|
|
15306
15344
|
|
|
15307
|
-
const
|
|
15308
|
-
new Uint8Array([
|
|
15309
|
-
|
|
15310
|
-
|
|
15345
|
+
const forwardingFields = util.concatUint8Array([
|
|
15346
|
+
new Uint8Array([
|
|
15347
|
+
3 + this.replacementFingerprint.length,
|
|
15348
|
+
this.version,
|
|
15349
|
+
this.hash,
|
|
15350
|
+
this.cipher
|
|
15351
|
+
]),
|
|
15352
|
+
this.replacementFingerprint
|
|
15311
15353
|
]);
|
|
15312
15354
|
|
|
15313
|
-
|
|
15314
|
-
v2Fields[0] = v2Fields.length - 1;
|
|
15315
|
-
return new Uint8Array(v2Fields);
|
|
15355
|
+
return forwardingFields;
|
|
15316
15356
|
}
|
|
15317
15357
|
}
|
|
15318
15358
|
|
|
@@ -15895,6 +15935,339 @@ const mod = {
|
|
|
15895
15935
|
|
|
15896
15936
|
Object.assign(mod, crypto$1);
|
|
15897
15937
|
|
|
15938
|
+
const ARGON2_TYPE = 0x02; // id
|
|
15939
|
+
const ARGON2_VERSION = 0x13;
|
|
15940
|
+
const ARGON2_SALT_SIZE = 16;
|
|
15941
|
+
|
|
15942
|
+
class Argon2OutOfMemoryError extends Error {
|
|
15943
|
+
constructor(...params) {
|
|
15944
|
+
super(...params);
|
|
15945
|
+
|
|
15946
|
+
if (Error.captureStackTrace) {
|
|
15947
|
+
Error.captureStackTrace(this, Argon2OutOfMemoryError);
|
|
15948
|
+
}
|
|
15949
|
+
|
|
15950
|
+
this.name = 'Argon2OutOfMemoryError';
|
|
15951
|
+
}
|
|
15952
|
+
}
|
|
15953
|
+
|
|
15954
|
+
// cache argon wasm module
|
|
15955
|
+
let loadArgonWasmModule;
|
|
15956
|
+
let argon2Promise;
|
|
15957
|
+
// reload wasm module above this treshold, to deallocated used memory
|
|
15958
|
+
const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
|
|
15959
|
+
|
|
15960
|
+
class Argon2S2K {
|
|
15961
|
+
/**
|
|
15962
|
+
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
15963
|
+
*/
|
|
15964
|
+
constructor(config$1 = config) {
|
|
15965
|
+
const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
|
|
15966
|
+
|
|
15967
|
+
this.type = 'argon2';
|
|
15968
|
+
/** @type {Uint8Array} 16 bytes of salt */
|
|
15969
|
+
this.salt = null;
|
|
15970
|
+
/** @type {Integer} number of passes */
|
|
15971
|
+
this.t = passes;
|
|
15972
|
+
/** @type {Integer} degree of parallelism (lanes) */
|
|
15973
|
+
this.p = parallelism;
|
|
15974
|
+
/** @type {Integer} exponent indicating memory size */
|
|
15975
|
+
this.encodedM = memoryExponent;
|
|
15976
|
+
}
|
|
15977
|
+
|
|
15978
|
+
generateSalt() {
|
|
15979
|
+
this.salt = mod.random.getRandomBytes(ARGON2_SALT_SIZE);
|
|
15980
|
+
}
|
|
15981
|
+
|
|
15982
|
+
/**
|
|
15983
|
+
* Parsing function for argon2 string-to-key specifier.
|
|
15984
|
+
* @param {Uint8Array} bytes - Payload of argon2 string-to-key specifier
|
|
15985
|
+
* @returns {Integer} Actual length of the object.
|
|
15986
|
+
*/
|
|
15987
|
+
read(bytes) {
|
|
15988
|
+
let i = 0;
|
|
15989
|
+
|
|
15990
|
+
this.salt = bytes.subarray(i, i + 16);
|
|
15991
|
+
i += 16;
|
|
15992
|
+
|
|
15993
|
+
this.t = bytes[i++];
|
|
15994
|
+
this.p = bytes[i++];
|
|
15995
|
+
this.encodedM = bytes[i++]; // memory size exponent, one-octect
|
|
15996
|
+
|
|
15997
|
+
return i;
|
|
15998
|
+
}
|
|
15999
|
+
|
|
16000
|
+
/**
|
|
16001
|
+
* Serializes s2k information
|
|
16002
|
+
* @returns {Uint8Array} Binary representation of s2k.
|
|
16003
|
+
*/
|
|
16004
|
+
write() {
|
|
16005
|
+
const arr = [
|
|
16006
|
+
new Uint8Array([enums.write(enums.s2k, this.type)]),
|
|
16007
|
+
this.salt,
|
|
16008
|
+
new Uint8Array([this.t, this.p, this.encodedM])
|
|
16009
|
+
];
|
|
16010
|
+
|
|
16011
|
+
return util.concatUint8Array(arr);
|
|
16012
|
+
}
|
|
16013
|
+
|
|
16014
|
+
/**
|
|
16015
|
+
* Produces a key using the specified passphrase and the defined
|
|
16016
|
+
* hashAlgorithm
|
|
16017
|
+
* @param {String} passphrase - Passphrase containing user input
|
|
16018
|
+
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to `keySize`
|
|
16019
|
+
* @throws {Argon2OutOfMemoryError|Errors}
|
|
16020
|
+
* @async
|
|
16021
|
+
*/
|
|
16022
|
+
async produceKey(passphrase, keySize) {
|
|
16023
|
+
const decodedM = 2 << (this.encodedM - 1);
|
|
16024
|
+
|
|
16025
|
+
try {
|
|
16026
|
+
if (!argon2Promise) { // first load
|
|
16027
|
+
loadArgonWasmModule = loadArgonWasmModule || (await Promise.resolve().then(function () { return index; })).default;
|
|
16028
|
+
argon2Promise = loadArgonWasmModule();
|
|
16029
|
+
}
|
|
16030
|
+
// important to keep local ref to argon2 in case the module is reloaded by another instance
|
|
16031
|
+
const argon2 = await argon2Promise;
|
|
16032
|
+
|
|
16033
|
+
const passwordBytes = util.encodeUTF8(passphrase);
|
|
16034
|
+
const hash = argon2({
|
|
16035
|
+
version: ARGON2_VERSION,
|
|
16036
|
+
type: ARGON2_TYPE,
|
|
16037
|
+
password: passwordBytes,
|
|
16038
|
+
salt: this.salt,
|
|
16039
|
+
tagLength: keySize,
|
|
16040
|
+
memorySize: decodedM,
|
|
16041
|
+
parallelism: this.p,
|
|
16042
|
+
passes: this.t
|
|
16043
|
+
});
|
|
16044
|
+
|
|
16045
|
+
// a lot of memory was used, reload to deallocate
|
|
16046
|
+
if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
|
|
16047
|
+
// it will be awaited if needed at the next `produceKey` invocation
|
|
16048
|
+
argon2Promise = loadArgonWasmModule();
|
|
16049
|
+
}
|
|
16050
|
+
return hash;
|
|
16051
|
+
} catch (e) {
|
|
16052
|
+
if (e.message && (
|
|
16053
|
+
e.message.includes('Unable to grow instance memory') || // Chrome
|
|
16054
|
+
e.message.includes('failed to grow memory') || // Firefox
|
|
16055
|
+
e.message.includes('WebAssembly.Memory.grow') || // Safari
|
|
16056
|
+
e.message.includes('Out of memory') // Safari iOS
|
|
16057
|
+
)) {
|
|
16058
|
+
throw new Argon2OutOfMemoryError('Could not allocate required memory for Argon2');
|
|
16059
|
+
} else {
|
|
16060
|
+
throw e;
|
|
16061
|
+
}
|
|
16062
|
+
}
|
|
16063
|
+
}
|
|
16064
|
+
}
|
|
16065
|
+
|
|
16066
|
+
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
16067
|
+
|
|
16068
|
+
class GenericS2K {
|
|
16069
|
+
/**
|
|
16070
|
+
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
16071
|
+
*/
|
|
16072
|
+
constructor(s2kType, config$1 = config) {
|
|
16073
|
+
/**
|
|
16074
|
+
* Hash function identifier, or 0 for gnu-dummy keys
|
|
16075
|
+
* @type {module:enums.hash | 0}
|
|
16076
|
+
*/
|
|
16077
|
+
this.algorithm = enums.hash.sha256;
|
|
16078
|
+
/**
|
|
16079
|
+
* enums.s2k identifier or 'gnu-dummy'
|
|
16080
|
+
* @type {String}
|
|
16081
|
+
*/
|
|
16082
|
+
this.type = enums.read(enums.s2k, s2kType);
|
|
16083
|
+
/** @type {Integer} */
|
|
16084
|
+
this.c = config$1.s2kIterationCountByte;
|
|
16085
|
+
/** Eight bytes of salt in a binary string.
|
|
16086
|
+
* @type {Uint8Array}
|
|
16087
|
+
*/
|
|
16088
|
+
this.salt = null;
|
|
16089
|
+
}
|
|
16090
|
+
|
|
16091
|
+
generateSalt() {
|
|
16092
|
+
switch (this.type) {
|
|
16093
|
+
case 'salted':
|
|
16094
|
+
case 'iterated':
|
|
16095
|
+
this.salt = mod.random.getRandomBytes(8);
|
|
16096
|
+
}
|
|
16097
|
+
}
|
|
16098
|
+
|
|
16099
|
+
getCount() {
|
|
16100
|
+
// Exponent bias, defined in RFC4880
|
|
16101
|
+
const expbias = 6;
|
|
16102
|
+
|
|
16103
|
+
return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
|
|
16104
|
+
}
|
|
16105
|
+
|
|
16106
|
+
/**
|
|
16107
|
+
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
|
16108
|
+
* @param {Uint8Array} bytes - Payload of string-to-key specifier
|
|
16109
|
+
* @returns {Integer} Actual length of the object.
|
|
16110
|
+
*/
|
|
16111
|
+
read(bytes) {
|
|
16112
|
+
let i = 0;
|
|
16113
|
+
this.algorithm = bytes[i++];
|
|
16114
|
+
|
|
16115
|
+
switch (this.type) {
|
|
16116
|
+
case 'simple':
|
|
16117
|
+
break;
|
|
16118
|
+
|
|
16119
|
+
case 'salted':
|
|
16120
|
+
this.salt = bytes.subarray(i, i + 8);
|
|
16121
|
+
i += 8;
|
|
16122
|
+
break;
|
|
16123
|
+
|
|
16124
|
+
case 'iterated':
|
|
16125
|
+
this.salt = bytes.subarray(i, i + 8);
|
|
16126
|
+
i += 8;
|
|
16127
|
+
|
|
16128
|
+
// Octet 10: count, a one-octet, coded value
|
|
16129
|
+
this.c = bytes[i++];
|
|
16130
|
+
break;
|
|
16131
|
+
case 'gnu':
|
|
16132
|
+
if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
|
|
16133
|
+
i += 3; // GNU
|
|
16134
|
+
const gnuExtType = 1000 + bytes[i++];
|
|
16135
|
+
if (gnuExtType === 1001) {
|
|
16136
|
+
this.type = 'gnu-dummy';
|
|
16137
|
+
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
16138
|
+
} else {
|
|
16139
|
+
throw new Error('Unknown s2k gnu protection mode.');
|
|
16140
|
+
}
|
|
16141
|
+
} else {
|
|
16142
|
+
throw new Error('Unknown s2k type.');
|
|
16143
|
+
}
|
|
16144
|
+
break;
|
|
16145
|
+
|
|
16146
|
+
default:
|
|
16147
|
+
throw new Error('Unknown s2k type.');
|
|
16148
|
+
}
|
|
16149
|
+
|
|
16150
|
+
return i;
|
|
16151
|
+
}
|
|
16152
|
+
|
|
16153
|
+
/**
|
|
16154
|
+
* Serializes s2k information
|
|
16155
|
+
* @returns {Uint8Array} Binary representation of s2k.
|
|
16156
|
+
*/
|
|
16157
|
+
write() {
|
|
16158
|
+
if (this.type === 'gnu-dummy') {
|
|
16159
|
+
return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
|
|
16160
|
+
}
|
|
16161
|
+
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
|
|
16162
|
+
|
|
16163
|
+
switch (this.type) {
|
|
16164
|
+
case 'simple':
|
|
16165
|
+
break;
|
|
16166
|
+
case 'salted':
|
|
16167
|
+
arr.push(this.salt);
|
|
16168
|
+
break;
|
|
16169
|
+
case 'iterated':
|
|
16170
|
+
arr.push(this.salt);
|
|
16171
|
+
arr.push(new Uint8Array([this.c]));
|
|
16172
|
+
break;
|
|
16173
|
+
case 'gnu':
|
|
16174
|
+
throw new Error('GNU s2k type not supported.');
|
|
16175
|
+
default:
|
|
16176
|
+
throw new Error('Unknown s2k type.');
|
|
16177
|
+
}
|
|
16178
|
+
|
|
16179
|
+
return util.concatUint8Array(arr);
|
|
16180
|
+
}
|
|
16181
|
+
|
|
16182
|
+
/**
|
|
16183
|
+
* Produces a key using the specified passphrase and the defined
|
|
16184
|
+
* hashAlgorithm
|
|
16185
|
+
* @param {String} passphrase - Passphrase containing user input
|
|
16186
|
+
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
|
|
16187
|
+
* hashAlgorithm hash length
|
|
16188
|
+
* @async
|
|
16189
|
+
*/
|
|
16190
|
+
async produceKey(passphrase, numBytes) {
|
|
16191
|
+
passphrase = util.encodeUTF8(passphrase);
|
|
16192
|
+
|
|
16193
|
+
const arr = [];
|
|
16194
|
+
let rlength = 0;
|
|
16195
|
+
|
|
16196
|
+
let prefixlen = 0;
|
|
16197
|
+
while (rlength < numBytes) {
|
|
16198
|
+
let toHash;
|
|
16199
|
+
switch (this.type) {
|
|
16200
|
+
case 'simple':
|
|
16201
|
+
toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
|
|
16202
|
+
break;
|
|
16203
|
+
case 'salted':
|
|
16204
|
+
toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
|
|
16205
|
+
break;
|
|
16206
|
+
case 'iterated': {
|
|
16207
|
+
const data = util.concatUint8Array([this.salt, passphrase]);
|
|
16208
|
+
let datalen = data.length;
|
|
16209
|
+
const count = Math.max(this.getCount(), datalen);
|
|
16210
|
+
toHash = new Uint8Array(prefixlen + count);
|
|
16211
|
+
toHash.set(data, prefixlen);
|
|
16212
|
+
for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
|
|
16213
|
+
toHash.copyWithin(pos, prefixlen, pos);
|
|
16214
|
+
}
|
|
16215
|
+
break;
|
|
16216
|
+
}
|
|
16217
|
+
case 'gnu':
|
|
16218
|
+
throw new Error('GNU s2k type not supported.');
|
|
16219
|
+
default:
|
|
16220
|
+
throw new Error('Unknown s2k type.');
|
|
16221
|
+
}
|
|
16222
|
+
const result = await mod.hash.digest(this.algorithm, toHash);
|
|
16223
|
+
arr.push(result);
|
|
16224
|
+
rlength += result.length;
|
|
16225
|
+
prefixlen++;
|
|
16226
|
+
}
|
|
16227
|
+
|
|
16228
|
+
return util.concatUint8Array(arr).subarray(0, numBytes);
|
|
16229
|
+
}
|
|
16230
|
+
}
|
|
16231
|
+
|
|
16232
|
+
const allowedS2KTypesForEncryption = new Set([enums.s2k.argon2, enums.s2k.iterated]);
|
|
16233
|
+
|
|
16234
|
+
/**
|
|
16235
|
+
* Instantiate a new S2K instance of the given type
|
|
16236
|
+
* @param {module:enums.s2k} type
|
|
16237
|
+
* @oaram {Object} [config]
|
|
16238
|
+
* @returns {Object} New s2k object
|
|
16239
|
+
* @throws {Error} for unknown or unsupported types
|
|
16240
|
+
*/
|
|
16241
|
+
function newS2KFromType(type, config$1 = config) {
|
|
16242
|
+
switch (type) {
|
|
16243
|
+
case enums.s2k.argon2:
|
|
16244
|
+
return new Argon2S2K(config$1);
|
|
16245
|
+
case enums.s2k.iterated:
|
|
16246
|
+
case enums.s2k.gnu:
|
|
16247
|
+
case enums.s2k.salted:
|
|
16248
|
+
case enums.s2k.simple:
|
|
16249
|
+
return new GenericS2K(type, config$1);
|
|
16250
|
+
default:
|
|
16251
|
+
throw new Error(`Unsupported S2K type ${type}`);
|
|
16252
|
+
}
|
|
16253
|
+
}
|
|
16254
|
+
|
|
16255
|
+
/**
|
|
16256
|
+
* Instantiate a new S2K instance based on the config settings
|
|
16257
|
+
* @oaram {Object} config
|
|
16258
|
+
* @returns {Object} New s2k object
|
|
16259
|
+
* @throws {Error} for unknown or unsupported types
|
|
16260
|
+
*/
|
|
16261
|
+
function newS2KFromConfig(config) {
|
|
16262
|
+
const { s2kType } = config;
|
|
16263
|
+
|
|
16264
|
+
if (!allowedS2KTypesForEncryption.has(s2kType)) {
|
|
16265
|
+
throw new Error('The provided `config.s2kType` value is not allowed');
|
|
16266
|
+
}
|
|
16267
|
+
|
|
16268
|
+
return newS2KFromType(s2kType, config);
|
|
16269
|
+
}
|
|
16270
|
+
|
|
15898
16271
|
var TYPED_OK = typeof Uint8Array !== "undefined" &&
|
|
15899
16272
|
typeof Uint16Array !== "undefined" &&
|
|
15900
16273
|
typeof Int32Array !== "undefined";
|
|
@@ -23949,6 +24322,9 @@ class PacketList extends Array {
|
|
|
23949
24322
|
* @async
|
|
23950
24323
|
*/
|
|
23951
24324
|
async read(bytes, allowedPackets, config$1 = config) {
|
|
24325
|
+
if (config$1.additionalAllowedPackets.length) {
|
|
24326
|
+
allowedPackets = { ...allowedPackets, ...util.constructAllowedPackets(config$1.additionalAllowedPackets) };
|
|
24327
|
+
}
|
|
23952
24328
|
this.stream = transformPair(bytes, async (readable, writable) => {
|
|
23953
24329
|
const writer = getWriter(writable);
|
|
23954
24330
|
try {
|
|
@@ -24716,166 +25092,6 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
24716
25092
|
|
|
24717
25093
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
24718
25094
|
|
|
24719
|
-
class S2K {
|
|
24720
|
-
/**
|
|
24721
|
-
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
24722
|
-
*/
|
|
24723
|
-
constructor(config$1 = config) {
|
|
24724
|
-
/**
|
|
24725
|
-
* Hash function identifier, or 0 for gnu-dummy keys
|
|
24726
|
-
* @type {module:enums.hash | 0}
|
|
24727
|
-
*/
|
|
24728
|
-
this.algorithm = enums.hash.sha256;
|
|
24729
|
-
/**
|
|
24730
|
-
* enums.s2k identifier or 'gnu-dummy'
|
|
24731
|
-
* @type {String}
|
|
24732
|
-
*/
|
|
24733
|
-
this.type = 'iterated';
|
|
24734
|
-
/** @type {Integer} */
|
|
24735
|
-
this.c = config$1.s2kIterationCountByte;
|
|
24736
|
-
/** Eight bytes of salt in a binary string.
|
|
24737
|
-
* @type {Uint8Array}
|
|
24738
|
-
*/
|
|
24739
|
-
this.salt = null;
|
|
24740
|
-
}
|
|
24741
|
-
|
|
24742
|
-
getCount() {
|
|
24743
|
-
// Exponent bias, defined in RFC4880
|
|
24744
|
-
const expbias = 6;
|
|
24745
|
-
|
|
24746
|
-
return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
|
|
24747
|
-
}
|
|
24748
|
-
|
|
24749
|
-
/**
|
|
24750
|
-
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
|
24751
|
-
* @param {Uint8Array} bytes - Payload of string-to-key specifier
|
|
24752
|
-
* @returns {Integer} Actual length of the object.
|
|
24753
|
-
*/
|
|
24754
|
-
read(bytes) {
|
|
24755
|
-
let i = 0;
|
|
24756
|
-
this.type = enums.read(enums.s2k, bytes[i++]);
|
|
24757
|
-
this.algorithm = bytes[i++];
|
|
24758
|
-
|
|
24759
|
-
switch (this.type) {
|
|
24760
|
-
case 'simple':
|
|
24761
|
-
break;
|
|
24762
|
-
|
|
24763
|
-
case 'salted':
|
|
24764
|
-
this.salt = bytes.subarray(i, i + 8);
|
|
24765
|
-
i += 8;
|
|
24766
|
-
break;
|
|
24767
|
-
|
|
24768
|
-
case 'iterated':
|
|
24769
|
-
this.salt = bytes.subarray(i, i + 8);
|
|
24770
|
-
i += 8;
|
|
24771
|
-
|
|
24772
|
-
// Octet 10: count, a one-octet, coded value
|
|
24773
|
-
this.c = bytes[i++];
|
|
24774
|
-
break;
|
|
24775
|
-
|
|
24776
|
-
case 'gnu':
|
|
24777
|
-
if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
|
|
24778
|
-
i += 3; // GNU
|
|
24779
|
-
const gnuExtType = 1000 + bytes[i++];
|
|
24780
|
-
if (gnuExtType === 1001) {
|
|
24781
|
-
this.type = 'gnu-dummy';
|
|
24782
|
-
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
24783
|
-
} else {
|
|
24784
|
-
throw new Error('Unknown s2k gnu protection mode.');
|
|
24785
|
-
}
|
|
24786
|
-
} else {
|
|
24787
|
-
throw new Error('Unknown s2k type.');
|
|
24788
|
-
}
|
|
24789
|
-
break;
|
|
24790
|
-
|
|
24791
|
-
default:
|
|
24792
|
-
throw new Error('Unknown s2k type.');
|
|
24793
|
-
}
|
|
24794
|
-
|
|
24795
|
-
return i;
|
|
24796
|
-
}
|
|
24797
|
-
|
|
24798
|
-
/**
|
|
24799
|
-
* Serializes s2k information
|
|
24800
|
-
* @returns {Uint8Array} Binary representation of s2k.
|
|
24801
|
-
*/
|
|
24802
|
-
write() {
|
|
24803
|
-
if (this.type === 'gnu-dummy') {
|
|
24804
|
-
return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
|
|
24805
|
-
}
|
|
24806
|
-
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
|
|
24807
|
-
|
|
24808
|
-
switch (this.type) {
|
|
24809
|
-
case 'simple':
|
|
24810
|
-
break;
|
|
24811
|
-
case 'salted':
|
|
24812
|
-
arr.push(this.salt);
|
|
24813
|
-
break;
|
|
24814
|
-
case 'iterated':
|
|
24815
|
-
arr.push(this.salt);
|
|
24816
|
-
arr.push(new Uint8Array([this.c]));
|
|
24817
|
-
break;
|
|
24818
|
-
case 'gnu':
|
|
24819
|
-
throw new Error('GNU s2k type not supported.');
|
|
24820
|
-
default:
|
|
24821
|
-
throw new Error('Unknown s2k type.');
|
|
24822
|
-
}
|
|
24823
|
-
|
|
24824
|
-
return util.concatUint8Array(arr);
|
|
24825
|
-
}
|
|
24826
|
-
|
|
24827
|
-
/**
|
|
24828
|
-
* Produces a key using the specified passphrase and the defined
|
|
24829
|
-
* hashAlgorithm
|
|
24830
|
-
* @param {String} passphrase - Passphrase containing user input
|
|
24831
|
-
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
|
|
24832
|
-
* hashAlgorithm hash length
|
|
24833
|
-
* @async
|
|
24834
|
-
*/
|
|
24835
|
-
async produceKey(passphrase, numBytes) {
|
|
24836
|
-
passphrase = util.encodeUTF8(passphrase);
|
|
24837
|
-
|
|
24838
|
-
const arr = [];
|
|
24839
|
-
let rlength = 0;
|
|
24840
|
-
|
|
24841
|
-
let prefixlen = 0;
|
|
24842
|
-
while (rlength < numBytes) {
|
|
24843
|
-
let toHash;
|
|
24844
|
-
switch (this.type) {
|
|
24845
|
-
case 'simple':
|
|
24846
|
-
toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
|
|
24847
|
-
break;
|
|
24848
|
-
case 'salted':
|
|
24849
|
-
toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
|
|
24850
|
-
break;
|
|
24851
|
-
case 'iterated': {
|
|
24852
|
-
const data = util.concatUint8Array([this.salt, passphrase]);
|
|
24853
|
-
let datalen = data.length;
|
|
24854
|
-
const count = Math.max(this.getCount(), datalen);
|
|
24855
|
-
toHash = new Uint8Array(prefixlen + count);
|
|
24856
|
-
toHash.set(data, prefixlen);
|
|
24857
|
-
for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
|
|
24858
|
-
toHash.copyWithin(pos, prefixlen, pos);
|
|
24859
|
-
}
|
|
24860
|
-
break;
|
|
24861
|
-
}
|
|
24862
|
-
case 'gnu':
|
|
24863
|
-
throw new Error('GNU s2k type not supported.');
|
|
24864
|
-
default:
|
|
24865
|
-
throw new Error('Unknown s2k type.');
|
|
24866
|
-
}
|
|
24867
|
-
const result = await mod.hash.digest(this.algorithm, toHash);
|
|
24868
|
-
arr.push(result);
|
|
24869
|
-
rlength += result.length;
|
|
24870
|
-
prefixlen++;
|
|
24871
|
-
}
|
|
24872
|
-
|
|
24873
|
-
return util.concatUint8Array(arr).subarray(0, numBytes);
|
|
24874
|
-
}
|
|
24875
|
-
}
|
|
24876
|
-
|
|
24877
|
-
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
24878
|
-
|
|
24879
25095
|
/**
|
|
24880
25096
|
* Symmetric-Key Encrypted Session Key Packets (Tag 3)
|
|
24881
25097
|
*
|
|
@@ -24943,7 +25159,8 @@ class SymEncryptedSessionKeyPacket {
|
|
|
24943
25159
|
}
|
|
24944
25160
|
|
|
24945
25161
|
// A string-to-key (S2K) specifier, length as defined above.
|
|
24946
|
-
|
|
25162
|
+
const s2kType = bytes[offset++];
|
|
25163
|
+
this.s2k = newS2KFromType(s2kType);
|
|
24947
25164
|
offset += this.s2k.read(bytes.subarray(offset, bytes.length));
|
|
24948
25165
|
|
|
24949
25166
|
if (this.version === 5) {
|
|
@@ -25032,8 +25249,8 @@ class SymEncryptedSessionKeyPacket {
|
|
|
25032
25249
|
|
|
25033
25250
|
this.sessionKeyEncryptionAlgorithm = algo;
|
|
25034
25251
|
|
|
25035
|
-
this.s2k =
|
|
25036
|
-
this.s2k.
|
|
25252
|
+
this.s2k = newS2KFromConfig(config$1);
|
|
25253
|
+
this.s2k.generateSalt();
|
|
25037
25254
|
|
|
25038
25255
|
const { blockSize, keySize } = mod.getCipher(algo);
|
|
25039
25256
|
const encryptionKey = await this.s2k.produceKey(passphrase, keySize);
|
|
@@ -25659,7 +25876,8 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25659
25876
|
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
25660
25877
|
// string-to-key specifier. The length of the string-to-key
|
|
25661
25878
|
// specifier is implied by its type, as described above.
|
|
25662
|
-
|
|
25879
|
+
const s2kType = bytes[i++];
|
|
25880
|
+
this.s2k = newS2KFromType(s2kType);
|
|
25663
25881
|
i += this.s2k.read(bytes.subarray(i, bytes.length));
|
|
25664
25882
|
|
|
25665
25883
|
if (this.s2k.type === 'gnu-dummy') {
|
|
@@ -25797,7 +26015,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25797
26015
|
}
|
|
25798
26016
|
this.isEncrypted = null;
|
|
25799
26017
|
this.keyMaterial = null;
|
|
25800
|
-
this.s2k =
|
|
26018
|
+
this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
|
|
25801
26019
|
this.s2k.algorithm = 0;
|
|
25802
26020
|
this.s2k.c = 0;
|
|
25803
26021
|
this.s2k.type = 'gnu-dummy';
|
|
@@ -25828,8 +26046,8 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25828
26046
|
throw new Error('A non-empty passphrase is required for key encryption.');
|
|
25829
26047
|
}
|
|
25830
26048
|
|
|
25831
|
-
this.s2k =
|
|
25832
|
-
this.s2k.
|
|
26049
|
+
this.s2k = newS2KFromConfig(config$1);
|
|
26050
|
+
this.s2k.generateSalt();
|
|
25833
26051
|
const cleartext = mod.serializeParams(this.algorithm, this.privateParams);
|
|
25834
26052
|
this.symmetric = enums.symmetric.aes256;
|
|
25835
26053
|
const key = await produceEncryptionKey(this.s2k, passphrase, this.symmetric);
|
|
@@ -27660,7 +27878,8 @@ function isValidDecryptionKeyPacket(signature, config) {
|
|
|
27660
27878
|
|
|
27661
27879
|
return !signature.keyFlags ||
|
|
27662
27880
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27663
|
-
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0
|
|
27881
|
+
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0 ||
|
|
27882
|
+
(config.allowForwardedMessages && (signature.keyFlags[0] & enums.keyFlags.forwardedCommunication) !== 0);
|
|
27664
27883
|
}
|
|
27665
27884
|
|
|
27666
27885
|
/**
|
|
@@ -28608,7 +28827,7 @@ class Key {
|
|
|
28608
28827
|
throw exception || new Error('Could not find primary user');
|
|
28609
28828
|
}
|
|
28610
28829
|
await Promise.all(users.map(async function (a) {
|
|
28611
|
-
return a.
|
|
28830
|
+
return a.selfCertification.revoked || a.user.isRevoked(a.selfCertification, null, date, config$1);
|
|
28612
28831
|
}));
|
|
28613
28832
|
// sort by primary user flag and signature creation time
|
|
28614
28833
|
const primaryUser = users.sort(function(a, b) {
|
|
@@ -28831,7 +29050,8 @@ class Key {
|
|
|
28831
29050
|
|
|
28832
29051
|
results.push(...signatures.map(
|
|
28833
29052
|
signature => ({
|
|
28834
|
-
userID: user.userID.userID,
|
|
29053
|
+
userID: user.userID ? user.userID.userID : null,
|
|
29054
|
+
userAttribute: user.userAttribute,
|
|
28835
29055
|
keyID: signature.keyID,
|
|
28836
29056
|
valid: signature.valid
|
|
28837
29057
|
}))
|
|
@@ -29707,6 +29927,9 @@ class Message {
|
|
|
29707
29927
|
decryptedSessionKeyPackets.push(skeskPacket);
|
|
29708
29928
|
} catch (err) {
|
|
29709
29929
|
util.printDebugError(err);
|
|
29930
|
+
if (err instanceof Argon2OutOfMemoryError) {
|
|
29931
|
+
exception = err;
|
|
29932
|
+
}
|
|
29710
29933
|
}
|
|
29711
29934
|
}));
|
|
29712
29935
|
}));
|
|
@@ -43854,9 +44077,722 @@ var elliptic$1 = /*#__PURE__*/Object.freeze({
|
|
|
43854
44077
|
__moduleExports: elliptic_1
|
|
43855
44078
|
});
|
|
43856
44079
|
|
|
44080
|
+
// Adapted from the reference implementation in RFC7693
|
|
44081
|
+
// Initial port to Javascript by https://github.com/dcposch and https://github.com/emilbayes
|
|
44082
|
+
|
|
44083
|
+
// Uint64 values are represented using two Uint32s, stored as little endian
|
|
44084
|
+
// NB: Uint32Arrays endianness depends on the underlying system, so for interoperability, conversions between Uint8Array and Uint32Arrays
|
|
44085
|
+
// need to be manually handled
|
|
44086
|
+
|
|
44087
|
+
// 64-bit unsigned addition (little endian, in place)
|
|
44088
|
+
// Sets a[i,i+1] += b[j,j+1]
|
|
44089
|
+
// `a` and `b` must be Uint32Array(2)
|
|
44090
|
+
function ADD64 (a, i, b, j) {
|
|
44091
|
+
a[i] += b[j];
|
|
44092
|
+
a[i+1] += b[j+1] + (a[i] < b[j]); // add carry
|
|
44093
|
+
}
|
|
44094
|
+
|
|
44095
|
+
// Increment 64-bit little-endian unsigned value by `c` (in place)
|
|
44096
|
+
// `a` must be Uint32Array(2)
|
|
44097
|
+
function INC64 (a, c) {
|
|
44098
|
+
a[0] += c;
|
|
44099
|
+
a[1] += (a[0] < c);
|
|
44100
|
+
}
|
|
44101
|
+
|
|
44102
|
+
// G Mixing function
|
|
44103
|
+
// The ROTRs are inlined for speed
|
|
44104
|
+
function G (v, m, a, b, c, d, ix, iy) {
|
|
44105
|
+
ADD64(v, a, v, b); // v[a,a+1] += v[b,b+1]
|
|
44106
|
+
ADD64(v, a, m, ix); // v[a, a+1] += x ... x0
|
|
44107
|
+
|
|
44108
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
44109
|
+
let xor0 = v[d] ^ v[a];
|
|
44110
|
+
let xor1 = v[d + 1] ^ v[a + 1];
|
|
44111
|
+
v[d] = xor1;
|
|
44112
|
+
v[d + 1] = xor0;
|
|
44113
|
+
|
|
44114
|
+
ADD64(v, c, v, d);
|
|
44115
|
+
|
|
44116
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
44117
|
+
xor0 = v[b] ^ v[c];
|
|
44118
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
44119
|
+
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
44120
|
+
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
44121
|
+
|
|
44122
|
+
ADD64(v, a, v, b);
|
|
44123
|
+
ADD64(v, a, m, iy);
|
|
44124
|
+
|
|
44125
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
44126
|
+
xor0 = v[d] ^ v[a];
|
|
44127
|
+
xor1 = v[d + 1] ^ v[a + 1];
|
|
44128
|
+
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
44129
|
+
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
44130
|
+
|
|
44131
|
+
ADD64(v, c, v, d);
|
|
44132
|
+
|
|
44133
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
44134
|
+
xor0 = v[b] ^ v[c];
|
|
44135
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
44136
|
+
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
44137
|
+
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
44138
|
+
}
|
|
44139
|
+
|
|
44140
|
+
// Initialization Vector
|
|
44141
|
+
const BLAKE2B_IV32 = new Uint32Array([
|
|
44142
|
+
0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85,
|
|
44143
|
+
0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A,
|
|
44144
|
+
0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C,
|
|
44145
|
+
0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19
|
|
44146
|
+
]);
|
|
44147
|
+
|
|
44148
|
+
// These are offsets into a Uint64 buffer.
|
|
44149
|
+
// Multiply them all by 2 to make them offsets into a Uint32 buffer
|
|
44150
|
+
const SIGMA = new Uint8Array([
|
|
44151
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
44152
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
|
|
44153
|
+
11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
|
|
44154
|
+
7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
|
|
44155
|
+
9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
|
|
44156
|
+
2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
|
|
44157
|
+
12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,
|
|
44158
|
+
13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,
|
|
44159
|
+
6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,
|
|
44160
|
+
10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,
|
|
44161
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
44162
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3
|
|
44163
|
+
].map(x => x * 2));
|
|
44164
|
+
|
|
44165
|
+
// Compression function. 'last' flag indicates last block.
|
|
44166
|
+
// Note: we're representing 16 uint64s as 32 uint32s
|
|
44167
|
+
function compress(S, last) {
|
|
44168
|
+
const v = new Uint32Array(32);
|
|
44169
|
+
const m = new Uint32Array(S.b.buffer, S.b.byteOffset, 32);
|
|
44170
|
+
|
|
44171
|
+
// init work variables
|
|
44172
|
+
for (let i = 0; i < 16; i++) {
|
|
44173
|
+
v[i] = S.h[i];
|
|
44174
|
+
v[i + 16] = BLAKE2B_IV32[i];
|
|
44175
|
+
}
|
|
44176
|
+
|
|
44177
|
+
// low 64 bits of offset
|
|
44178
|
+
v[24] ^= S.t0[0];
|
|
44179
|
+
v[25] ^= S.t0[1];
|
|
44180
|
+
// high 64 bits not supported (`t1`), offset may not be higher than 2**53-1
|
|
44181
|
+
|
|
44182
|
+
// if last block
|
|
44183
|
+
const f0 = last ? 0xFFFFFFFF : 0;
|
|
44184
|
+
v[28] ^= f0;
|
|
44185
|
+
v[29] ^= f0;
|
|
44186
|
+
|
|
44187
|
+
// twelve rounds of mixing
|
|
44188
|
+
for (let i = 0; i < 12; i++) {
|
|
44189
|
+
// ROUND(r)
|
|
44190
|
+
const i16 = i << 4;
|
|
44191
|
+
G(v, m, 0, 8, 16, 24, SIGMA[i16 + 0], SIGMA[i16 + 1]);
|
|
44192
|
+
G(v, m, 2, 10, 18, 26, SIGMA[i16 + 2], SIGMA[i16 + 3]);
|
|
44193
|
+
G(v, m, 4, 12, 20, 28, SIGMA[i16 + 4], SIGMA[i16 + 5]);
|
|
44194
|
+
G(v, m, 6, 14, 22, 30, SIGMA[i16 + 6], SIGMA[i16 + 7]);
|
|
44195
|
+
G(v, m, 0, 10, 20, 30, SIGMA[i16 + 8], SIGMA[i16 + 9]);
|
|
44196
|
+
G(v, m, 2, 12, 22, 24, SIGMA[i16 + 10], SIGMA[i16 + 11]);
|
|
44197
|
+
G(v, m, 4, 14, 16, 26, SIGMA[i16 + 12], SIGMA[i16 + 13]);
|
|
44198
|
+
G(v, m, 6, 8, 18, 28, SIGMA[i16 + 14], SIGMA[i16 + 15]);
|
|
44199
|
+
}
|
|
44200
|
+
|
|
44201
|
+
for (let i = 0; i < 16; i++) {
|
|
44202
|
+
S.h[i] ^= v[i] ^ v[i + 16];
|
|
44203
|
+
}
|
|
44204
|
+
}
|
|
44205
|
+
|
|
44206
|
+
// Creates a BLAKE2b hashing context
|
|
44207
|
+
// Requires an output length between 1 and 64 bytes
|
|
44208
|
+
// Takes an optional Uint8Array key
|
|
44209
|
+
class Blake2b {
|
|
44210
|
+
constructor(outlen, key, salt, personal) {
|
|
44211
|
+
const params = new Uint8Array(64);
|
|
44212
|
+
// 0: outlen, keylen, fanout, depth
|
|
44213
|
+
// 4: leaf length, sequential mode
|
|
44214
|
+
// 8: node offset
|
|
44215
|
+
// 12: node offset
|
|
44216
|
+
// 16: node depth, inner length, rfu
|
|
44217
|
+
// 20: rfu
|
|
44218
|
+
// 24: rfu
|
|
44219
|
+
// 28: rfu
|
|
44220
|
+
// 32: salt
|
|
44221
|
+
// 36: salt
|
|
44222
|
+
// 40: salt
|
|
44223
|
+
// 44: salt
|
|
44224
|
+
// 48: personal
|
|
44225
|
+
// 52: personal
|
|
44226
|
+
// 56: personal
|
|
44227
|
+
// 60: personal
|
|
44228
|
+
|
|
44229
|
+
// init internal state
|
|
44230
|
+
this.S = {
|
|
44231
|
+
b: new Uint8Array(BLOCKBYTES),
|
|
44232
|
+
h: new Uint32Array(OUTBYTES_MAX / 4),
|
|
44233
|
+
t0: new Uint32Array(2), // input counter `t`, lower 64-bits only
|
|
44234
|
+
c: 0, // `fill`, pointer within buffer, up to `BLOCKBYTES`
|
|
44235
|
+
outlen // output length in bytes
|
|
44236
|
+
};
|
|
44237
|
+
|
|
44238
|
+
// init parameter block
|
|
44239
|
+
params[0] = outlen;
|
|
44240
|
+
if (key) params[1] = key.length;
|
|
44241
|
+
params[2] = 1; // fanout
|
|
44242
|
+
params[3] = 1; // depth
|
|
44243
|
+
if (salt) params.set(salt, 32);
|
|
44244
|
+
if (personal) params.set(personal, 48);
|
|
44245
|
+
const params32 = new Uint32Array(params.buffer, params.byteOffset, params.length / Uint32Array.BYTES_PER_ELEMENT);
|
|
44246
|
+
|
|
44247
|
+
// initialize hash state
|
|
44248
|
+
for (let i = 0; i < 16; i++) {
|
|
44249
|
+
this.S.h[i] = BLAKE2B_IV32[i] ^ params32[i];
|
|
44250
|
+
}
|
|
44251
|
+
|
|
44252
|
+
// key the hash, if applicable
|
|
44253
|
+
if (key) {
|
|
44254
|
+
const block = new Uint8Array(BLOCKBYTES);
|
|
44255
|
+
block.set(key);
|
|
44256
|
+
this.update(block);
|
|
44257
|
+
}
|
|
44258
|
+
}
|
|
44259
|
+
|
|
44260
|
+
// Updates a BLAKE2b streaming hash
|
|
44261
|
+
// Requires Uint8Array (byte array)
|
|
44262
|
+
update(input) {
|
|
44263
|
+
if (!(input instanceof Uint8Array)) throw new Error('Input must be Uint8Array or Buffer')
|
|
44264
|
+
// for (let i = 0; i < input.length; i++) {
|
|
44265
|
+
// if (this.S.c === BLOCKBYTES) { // buffer full
|
|
44266
|
+
// INC64(this.S.t0, this.S.c) // add counters
|
|
44267
|
+
// compress(this.S, false)
|
|
44268
|
+
// this.S.c = 0 // empty buffer
|
|
44269
|
+
// }
|
|
44270
|
+
// this.S.b[this.S.c++] = input[i]
|
|
44271
|
+
// }
|
|
44272
|
+
let i = 0;
|
|
44273
|
+
while(i < input.length) {
|
|
44274
|
+
if (this.S.c === BLOCKBYTES) { // buffer full
|
|
44275
|
+
INC64(this.S.t0, this.S.c); // add counters
|
|
44276
|
+
compress(this.S, false);
|
|
44277
|
+
this.S.c = 0; // empty buffer
|
|
44278
|
+
}
|
|
44279
|
+
let left = BLOCKBYTES - this.S.c;
|
|
44280
|
+
this.S.b.set(input.subarray(i, i + left), this.S.c); // end index can be out of bounds
|
|
44281
|
+
const fill = Math.min(left, input.length - i);
|
|
44282
|
+
this.S.c += fill;
|
|
44283
|
+
i += fill;
|
|
44284
|
+
}
|
|
44285
|
+
return this
|
|
44286
|
+
}
|
|
44287
|
+
|
|
44288
|
+
/**
|
|
44289
|
+
* Return a BLAKE2b hash, either filling the given Uint8Array or allocating a new one
|
|
44290
|
+
* @param {Uint8Array} [prealloc] - optional preallocated buffer
|
|
44291
|
+
* @returns {ArrayBuffer} message digest
|
|
44292
|
+
*/
|
|
44293
|
+
digest(prealloc) {
|
|
44294
|
+
INC64(this.S.t0, this.S.c); // mark last block offset
|
|
44295
|
+
|
|
44296
|
+
// final block, padded
|
|
44297
|
+
this.S.b.fill(0, this.S.c);
|
|
44298
|
+
this.S.c = BLOCKBYTES;
|
|
44299
|
+
compress(this.S, true);
|
|
44300
|
+
|
|
44301
|
+
const out = prealloc || new Uint8Array(this.S.outlen);
|
|
44302
|
+
for (let i = 0; i < this.S.outlen; i++) {
|
|
44303
|
+
// must be loaded individually since default Uint32 endianness is platform dependant
|
|
44304
|
+
out[i] = this.S.h[i >> 2] >> (8 * (i & 3));
|
|
44305
|
+
}
|
|
44306
|
+
this.S.h = null; // prevent calling `update` after `digest`
|
|
44307
|
+
return out.buffer;
|
|
44308
|
+
}
|
|
44309
|
+
}
|
|
44310
|
+
|
|
44311
|
+
|
|
44312
|
+
function createHash(outlen, key, salt, personal) {
|
|
44313
|
+
if (outlen > OUTBYTES_MAX) throw new Error(`outlen must be at most ${OUTBYTES_MAX} (given: ${outlen})`)
|
|
44314
|
+
if (key) {
|
|
44315
|
+
if (!(key instanceof Uint8Array)) throw new Error('key must be Uint8Array or Buffer')
|
|
44316
|
+
if (key.length > KEYBYTES_MAX) throw new Error(`key size must be at most ${KEYBYTES_MAX} (given: ${key.length})`)
|
|
44317
|
+
}
|
|
44318
|
+
if (salt) {
|
|
44319
|
+
if (!(salt instanceof Uint8Array)) throw new Error('salt must be Uint8Array or Buffer')
|
|
44320
|
+
if (salt.length !== SALTBYTES) throw new Error(`salt must be exactly ${SALTBYTES} (given: ${salt.length}`)
|
|
44321
|
+
}
|
|
44322
|
+
if (personal) {
|
|
44323
|
+
if (!(personal instanceof Uint8Array)) throw new Error('personal must be Uint8Array or Buffer')
|
|
44324
|
+
if (personal.length !== PERSONALBYTES) throw new Error(`salt must be exactly ${PERSONALBYTES} (given: ${personal.length}`)
|
|
44325
|
+
}
|
|
44326
|
+
|
|
44327
|
+
return new Blake2b(outlen, key, salt, personal)
|
|
44328
|
+
}
|
|
44329
|
+
|
|
44330
|
+
const OUTBYTES_MAX = 64;
|
|
44331
|
+
const KEYBYTES_MAX = 64;
|
|
44332
|
+
const SALTBYTES = 16;
|
|
44333
|
+
const PERSONALBYTES = 16;
|
|
44334
|
+
const BLOCKBYTES = 128;
|
|
44335
|
+
|
|
44336
|
+
const TYPE$2 = 2; // Argon2id
|
|
44337
|
+
const VERSION$4 = 0x13;
|
|
44338
|
+
const TAGBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
|
|
44339
|
+
const TAGBYTES_MIN = 4; // Math.pow(2, 32) - 1;
|
|
44340
|
+
const SALTBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
|
|
44341
|
+
const SALTBYTES_MIN = 8;
|
|
44342
|
+
const passwordBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
|
|
44343
|
+
const passwordBYTES_MIN = 8;
|
|
44344
|
+
const MEMBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
|
|
44345
|
+
const ADBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1; // associated data (optional)
|
|
44346
|
+
const SECRETBYTES_MAX = 32; // key (optional)
|
|
44347
|
+
|
|
44348
|
+
const ARGON2_BLOCK_SIZE = 1024;
|
|
44349
|
+
const ARGON2_PREHASH_DIGEST_LENGTH = 64;
|
|
44350
|
+
|
|
44351
|
+
const isLittleEndian$1 = new Uint8Array(new Uint16Array([0xabcd]).buffer)[0] === 0xcd;
|
|
44352
|
+
|
|
44353
|
+
// store n as a little-endian 32-bit Uint8Array inside buf (at buf[i:i+3])
|
|
44354
|
+
function LE32(buf, n, i) {
|
|
44355
|
+
buf[i+0] = n;
|
|
44356
|
+
buf[i+1] = n >> 8;
|
|
44357
|
+
buf[i+2] = n >> 16;
|
|
44358
|
+
buf[i+3] = n >> 24;
|
|
44359
|
+
return buf;
|
|
44360
|
+
}
|
|
44361
|
+
|
|
44362
|
+
/**
|
|
44363
|
+
* Store n as a 64-bit LE number in the given buffer (from buf[i] to buf[i+7])
|
|
44364
|
+
* @param {Uint8Array} buf
|
|
44365
|
+
* @param {Number} n
|
|
44366
|
+
* @param {Number} i
|
|
44367
|
+
*/
|
|
44368
|
+
function LE64(buf, n, i) {
|
|
44369
|
+
if (n > Number.MAX_SAFE_INTEGER) throw new Error("LE64: large numbers unsupported");
|
|
44370
|
+
// ECMAScript standard has engines convert numbers to 32-bit integers for bitwise operations
|
|
44371
|
+
// shifting by 32 or more bits is not supported (https://stackoverflow.com/questions/6729122/javascript-bit-shift-number-wraps)
|
|
44372
|
+
// so we manually extract each byte
|
|
44373
|
+
let remainder = n;
|
|
44374
|
+
for (let offset = i; offset < i+7; offset++) { // last byte can be ignored as it would overflow MAX_SAFE_INTEGER
|
|
44375
|
+
buf[offset] = remainder; // implicit & 0xff
|
|
44376
|
+
remainder = (remainder - buf[offset]) / 256;
|
|
44377
|
+
}
|
|
44378
|
+
return buf;
|
|
44379
|
+
}
|
|
44380
|
+
|
|
44381
|
+
/**
|
|
44382
|
+
* Variable-Length Hash Function H'
|
|
44383
|
+
* @param {Number} outlen - T
|
|
44384
|
+
* @param {Uint8Array} X - value to hash
|
|
44385
|
+
* @param {Uint8Array} res - output buffer, of length `outlength` or larger
|
|
44386
|
+
*/
|
|
44387
|
+
function H_(outlen, X, res) {
|
|
44388
|
+
const V = new Uint8Array(64); // no need to keep around all V_i
|
|
44389
|
+
|
|
44390
|
+
const V1_in = new Uint8Array(4 + X.length);
|
|
44391
|
+
LE32(V1_in, outlen, 0);
|
|
44392
|
+
V1_in.set(X, 4);
|
|
44393
|
+
if (outlen <= 64) {
|
|
44394
|
+
// H'^T(A) = H^T(LE32(T)||A)
|
|
44395
|
+
createHash(outlen).update(V1_in).digest(res);
|
|
44396
|
+
return res
|
|
44397
|
+
}
|
|
44398
|
+
|
|
44399
|
+
const r = Math.ceil(outlen / 32) - 2;
|
|
44400
|
+
|
|
44401
|
+
// Let V_i be a 64-byte block and W_i be its first 32 bytes.
|
|
44402
|
+
// V_1 = H^(64)(LE32(T)||A)
|
|
44403
|
+
// V_2 = H^(64)(V_1)
|
|
44404
|
+
// ...
|
|
44405
|
+
// V_r = H^(64)(V_{r-1})
|
|
44406
|
+
// V_{r+1} = H^(T-32*r)(V_{r})
|
|
44407
|
+
// H'^T(X) = W_1 || W_2 || ... || W_r || V_{r+1}
|
|
44408
|
+
for (let i = 0; i < r; i++) {
|
|
44409
|
+
createHash(64).update(i === 0 ? V1_in : V).digest(V);
|
|
44410
|
+
// store W_i in result buffer already
|
|
44411
|
+
res.set(V.subarray(0, 32), i*32);
|
|
44412
|
+
}
|
|
44413
|
+
// V_{r+1}
|
|
44414
|
+
const V_r1 = new Uint8Array(createHash(outlen - 32*r).update(V).digest());
|
|
44415
|
+
res.set(V_r1, r*32);
|
|
44416
|
+
|
|
44417
|
+
return res;
|
|
44418
|
+
}
|
|
44419
|
+
|
|
44420
|
+
// compute buf = xs ^ ys
|
|
44421
|
+
function XOR(wasmContext, buf, xs, ys) {
|
|
44422
|
+
wasmContext.fn.XOR(
|
|
44423
|
+
buf.byteOffset,
|
|
44424
|
+
xs.byteOffset,
|
|
44425
|
+
ys.byteOffset,
|
|
44426
|
+
);
|
|
44427
|
+
return buf
|
|
44428
|
+
}
|
|
44429
|
+
|
|
44430
|
+
/**
|
|
44431
|
+
* @param {Uint8Array} X (read-only)
|
|
44432
|
+
* @param {Uint8Array} Y (read-only)
|
|
44433
|
+
* @param {Uint8Array} R - output buffer
|
|
44434
|
+
* @returns
|
|
44435
|
+
*/
|
|
44436
|
+
function G$1(wasmContext, X, Y, R) {
|
|
44437
|
+
wasmContext.fn.G(
|
|
44438
|
+
X.byteOffset,
|
|
44439
|
+
Y.byteOffset,
|
|
44440
|
+
R.byteOffset,
|
|
44441
|
+
wasmContext.refs.gZ.byteOffset
|
|
44442
|
+
);
|
|
44443
|
+
return R;
|
|
44444
|
+
}
|
|
44445
|
+
|
|
44446
|
+
function G2(wasmContext, X, Y, R) {
|
|
44447
|
+
wasmContext.fn.G2(
|
|
44448
|
+
X.byteOffset,
|
|
44449
|
+
Y.byteOffset,
|
|
44450
|
+
R.byteOffset,
|
|
44451
|
+
wasmContext.refs.gZ.byteOffset
|
|
44452
|
+
);
|
|
44453
|
+
return R;
|
|
44454
|
+
}
|
|
44455
|
+
|
|
44456
|
+
// Generator for data-independent J1, J2. Each `next()` invocation returns a new pair of values.
|
|
44457
|
+
function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLength, segmentOffset) {
|
|
44458
|
+
// For each segment, we do the following. First, we compute the value Z as:
|
|
44459
|
+
// Z= ( LE64(r) || LE64(l) || LE64(sl) || LE64(m') || LE64(t) || LE64(y) )
|
|
44460
|
+
wasmContext.refs.prngTmp.fill(0);
|
|
44461
|
+
const Z = wasmContext.refs.prngTmp.subarray(0, 6 * 8);
|
|
44462
|
+
LE64(Z, pass, 0);
|
|
44463
|
+
LE64(Z, lane, 8);
|
|
44464
|
+
LE64(Z, slice, 16);
|
|
44465
|
+
LE64(Z, m_, 24);
|
|
44466
|
+
LE64(Z, totalPasses, 32);
|
|
44467
|
+
LE64(Z, TYPE$2, 40);
|
|
44468
|
+
|
|
44469
|
+
// Then we compute q/(128*SL) 1024-byte values
|
|
44470
|
+
// G( ZERO(1024),
|
|
44471
|
+
// G( ZERO(1024), Z || LE64(1) || ZERO(968) ) ),
|
|
44472
|
+
// ...,
|
|
44473
|
+
// G( ZERO(1024),
|
|
44474
|
+
// G( ZERO(1024), Z || LE64(q/(128*SL)) || ZERO(968) )),
|
|
44475
|
+
for(let i = 1; i <= segmentLength; i++) {
|
|
44476
|
+
// tmp.set(Z); // no need to re-copy
|
|
44477
|
+
LE64(wasmContext.refs.prngTmp, i, Z.length); // tmp.set(ZER0968) not necessary, memory already zeroed
|
|
44478
|
+
const g2 = G2(wasmContext, wasmContext.refs.ZERO1024, wasmContext.refs.prngTmp, wasmContext.refs.prngR );
|
|
44479
|
+
|
|
44480
|
+
// each invocation of G^2 outputs 1024 bytes that are to be partitioned into 8-bytes values, take as X1 || X2
|
|
44481
|
+
// NB: the first generated pair must be used for the first block of the segment, and so on.
|
|
44482
|
+
// Hence, if some blocks are skipped (e.g. during the first pass), the corresponding J1J2 are discarded based on the given segmentOffset.
|
|
44483
|
+
for(let k = i === 1 ? segmentOffset*8 : 0; k < g2.length; k += 8) {
|
|
44484
|
+
yield g2.subarray(k, k+8);
|
|
44485
|
+
}
|
|
44486
|
+
}
|
|
44487
|
+
return [];
|
|
44488
|
+
}
|
|
44489
|
+
|
|
44490
|
+
function validateParams$7({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
|
|
44491
|
+
const assertLength = (name, value, min, max) => {
|
|
44492
|
+
if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
|
|
44493
|
+
};
|
|
44494
|
+
|
|
44495
|
+
if (type !== TYPE$2 || version !== VERSION$4) throw new Error('Unsupported type or version');
|
|
44496
|
+
assertLength('password', password, passwordBYTES_MIN, passwordBYTES_MAX);
|
|
44497
|
+
assertLength('salt', salt, SALTBYTES_MIN, SALTBYTES_MAX);
|
|
44498
|
+
assertLength('tag', tagLength, TAGBYTES_MIN, TAGBYTES_MAX);
|
|
44499
|
+
assertLength('memory', memorySize, 8*parallelism, MEMBYTES_MAX);
|
|
44500
|
+
// optional fields
|
|
44501
|
+
ad && assertLength('associated data', ad, 0, ADBYTES_MAX);
|
|
44502
|
+
secret && assertLength('secret', secret, 0, SECRETBYTES_MAX);
|
|
44503
|
+
|
|
44504
|
+
return { type, version, tagLength, password, salt, ad, secret, lanes: parallelism, memorySize, passes };
|
|
44505
|
+
}
|
|
44506
|
+
|
|
44507
|
+
const KB = 1024;
|
|
44508
|
+
const WASM_PAGE_SIZE = 64 * KB;
|
|
44509
|
+
|
|
44510
|
+
function argon2id(params, { memory, instance: wasmInstance }) {
|
|
44511
|
+
if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
|
|
44512
|
+
|
|
44513
|
+
const ctx = validateParams$7({ type: TYPE$2, version: VERSION$4, ...params });
|
|
44514
|
+
|
|
44515
|
+
const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
|
|
44516
|
+
const wasmRefs = {};
|
|
44517
|
+
const wasmFn = {};
|
|
44518
|
+
wasmFn.G = wasmG;
|
|
44519
|
+
wasmFn.G2 = wasmG2;
|
|
44520
|
+
wasmFn.XOR = wasmXOR;
|
|
44521
|
+
|
|
44522
|
+
// The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p.
|
|
44523
|
+
const m_ = 4 * ctx.lanes * Math.floor(ctx.memorySize / (4 * ctx.lanes));
|
|
44524
|
+
const requiredMemory = m_ * ARGON2_BLOCK_SIZE + 10 * KB; // Additional KBs for utility references
|
|
44525
|
+
if (memory.buffer.byteLength < requiredMemory) {
|
|
44526
|
+
const missing = Math.ceil((requiredMemory - memory.buffer.byteLength) / WASM_PAGE_SIZE);
|
|
44527
|
+
// If enough memory is available, the `memory.buffer` is internally detached and the reference updated.
|
|
44528
|
+
// Otherwise, the operation fails, and the original memory can still be used.
|
|
44529
|
+
memory.grow(missing);
|
|
44530
|
+
}
|
|
44531
|
+
|
|
44532
|
+
let offset = 0;
|
|
44533
|
+
// Init wasm memory needed in other functions
|
|
44534
|
+
wasmRefs.gZ = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+= wasmRefs.gZ.length;
|
|
44535
|
+
wasmRefs.prngR = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngR.length;
|
|
44536
|
+
wasmRefs.prngTmp = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngTmp.length;
|
|
44537
|
+
wasmRefs.ZERO1024 = new Uint8Array(memory.buffer, offset, 1024); offset+=wasmRefs.ZERO1024.length;
|
|
44538
|
+
// Init wasm memory needed locally
|
|
44539
|
+
const lz = new Uint32Array(memory.buffer, offset, 2); offset+=lz.length * Uint32Array.BYTES_PER_ELEMENT;
|
|
44540
|
+
const wasmContext = { fn: wasmFn, refs: wasmRefs };
|
|
44541
|
+
const newBlock = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=newBlock.length;
|
|
44542
|
+
const blockMemory = new Uint8Array(memory.buffer, offset, ctx.memorySize * ARGON2_BLOCK_SIZE);
|
|
44543
|
+
const allocatedMemory = new Uint8Array(memory.buffer, 0, offset);
|
|
44544
|
+
|
|
44545
|
+
// 1. Establish H_0
|
|
44546
|
+
const H0 = getH0(ctx);
|
|
44547
|
+
|
|
44548
|
+
// 2. Allocate the memory as m' 1024-byte blocks
|
|
44549
|
+
// For p lanes, the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m' / p columns.
|
|
44550
|
+
const q = m_ / ctx.lanes;
|
|
44551
|
+
const B = new Array(ctx.lanes).fill(null).map(() => new Array(q));
|
|
44552
|
+
const initBlock = (i, j) => {
|
|
44553
|
+
B[i][j] = blockMemory.subarray(i*q*1024 + j*1024, (i*q*1024 + j*1024) + ARGON2_BLOCK_SIZE);
|
|
44554
|
+
return B[i][j];
|
|
44555
|
+
};
|
|
44556
|
+
|
|
44557
|
+
for (let i = 0; i < ctx.lanes; i++) {
|
|
44558
|
+
// const LEi = LE0; // since p = 1 for us
|
|
44559
|
+
const tmp = new Uint8Array(H0.length + 8);
|
|
44560
|
+
// 3. Compute B[i][0] for all i ranging from (and including) 0 to (not including) p
|
|
44561
|
+
// B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))
|
|
44562
|
+
tmp.set(H0); LE32(tmp, 0, H0.length); LE32(tmp, i, H0.length + 4);
|
|
44563
|
+
H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 0));
|
|
44564
|
+
// 4. Compute B[i][1] for all i ranging from (and including) 0 to (not including) p
|
|
44565
|
+
// B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))
|
|
44566
|
+
LE32(tmp, 1, H0.length);
|
|
44567
|
+
H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 1));
|
|
44568
|
+
}
|
|
44569
|
+
|
|
44570
|
+
// 5. Compute B[i][j] for all i ranging from (and including) 0 to (not including) p and for all j ranging from (and including) 2
|
|
44571
|
+
// to (not including) q. The computation MUST proceed slicewise (Section 3.4) : first, blocks from slice 0 are computed for all lanes
|
|
44572
|
+
// (in an arbitrary order of lanes), then blocks from slice 1 are computed, etc.
|
|
44573
|
+
const SL = 4; // vertical slices
|
|
44574
|
+
const segmentLength = q / SL;
|
|
44575
|
+
for (let pass = 0; pass < ctx.passes; pass++) {
|
|
44576
|
+
// The intersection of a slice and a lane is called a segment, which has a length of q/SL. Segments of the same slice can be computed in parallel
|
|
44577
|
+
for (let sl = 0; sl < SL; sl++) {
|
|
44578
|
+
const isDataIndependent = pass === 0 && sl <= 1;
|
|
44579
|
+
for (let i = 0; i < ctx.lanes; i++) { // lane
|
|
44580
|
+
// On the first slice of the first pass, blocks 0 and 1 are already filled
|
|
44581
|
+
let segmentOffset = sl === 0 && pass === 0 ? 2 : 0;
|
|
44582
|
+
// no need to generate all J1J2s, use iterator/generator that creates the value on the fly (to save memory)
|
|
44583
|
+
const PRNG = isDataIndependent ? makePRNG(wasmContext, pass, i, sl, m_, ctx.passes, segmentLength, segmentOffset) : null;
|
|
44584
|
+
for (segmentOffset; segmentOffset < segmentLength; segmentOffset++) {
|
|
44585
|
+
const j = sl * segmentLength + segmentOffset;
|
|
44586
|
+
const prevBlock = j > 0 ? B[i][j-1] : B[i][q-1]; // B[i][(j-1) mod q]
|
|
44587
|
+
|
|
44588
|
+
// we can assume the PRNG is never done
|
|
44589
|
+
const J1J2 = isDataIndependent ? PRNG.next().value : prevBlock; // .subarray(0, 8) not required since we only pass the byteOffset to wasm
|
|
44590
|
+
// The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
|
|
44591
|
+
wasmLZ(lz.byteOffset, J1J2.byteOffset, i, ctx.lanes, pass, sl, segmentOffset, SL, segmentLength);
|
|
44592
|
+
const l = lz[0]; const z = lz[1];
|
|
44593
|
+
// for (let i = 0; i < p; i++ )
|
|
44594
|
+
// B[i][j] = G(B[i][j-1], B[l][z])
|
|
44595
|
+
// The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
|
|
44596
|
+
if (pass === 0) initBlock(i, j);
|
|
44597
|
+
G$1(wasmContext, prevBlock, B[l][z], pass > 0 ? newBlock : B[i][j]);
|
|
44598
|
+
|
|
44599
|
+
// 6. If the number of passes t is larger than 1, we repeat step 5. However, blocks are computed differently as the old value is XORed with the new one
|
|
44600
|
+
if (pass > 0) XOR(wasmContext, B[i][j], newBlock, B[i][j]);
|
|
44601
|
+
}
|
|
44602
|
+
}
|
|
44603
|
+
}
|
|
44604
|
+
}
|
|
44605
|
+
|
|
44606
|
+
// 7. After t steps have been iterated, the final block C is computed as the XOR of the last column:
|
|
44607
|
+
// C = B[0][q-1] XOR B[1][q-1] XOR ... XOR B[p-1][q-1]
|
|
44608
|
+
const C = B[0][q-1];
|
|
44609
|
+
for(let i = 1; i < ctx.lanes; i++) {
|
|
44610
|
+
XOR(wasmContext, C, C, B[i][q-1]);
|
|
44611
|
+
}
|
|
44612
|
+
|
|
44613
|
+
const tag = H_(ctx.tagLength, C, new Uint8Array(ctx.tagLength));
|
|
44614
|
+
// clear memory since the module might be cached
|
|
44615
|
+
allocatedMemory.fill(0); // clear sensitive contents
|
|
44616
|
+
memory.grow(0); // allow deallocation
|
|
44617
|
+
// 8. The output tag is computed as H'^T(C).
|
|
44618
|
+
return tag;
|
|
44619
|
+
|
|
44620
|
+
}
|
|
44621
|
+
|
|
44622
|
+
function getH0(ctx) {
|
|
44623
|
+
const H = createHash(ARGON2_PREHASH_DIGEST_LENGTH);
|
|
44624
|
+
const ZERO32 = new Uint8Array(4);
|
|
44625
|
+
const params = new Uint8Array(24);
|
|
44626
|
+
LE32(params, ctx.lanes, 0);
|
|
44627
|
+
LE32(params, ctx.tagLength, 4);
|
|
44628
|
+
LE32(params, ctx.memorySize, 8);
|
|
44629
|
+
LE32(params, ctx.passes, 12);
|
|
44630
|
+
LE32(params, ctx.version, 16);
|
|
44631
|
+
LE32(params, ctx.type, 20);
|
|
44632
|
+
|
|
44633
|
+
const toHash = [params];
|
|
44634
|
+
if (ctx.password) {
|
|
44635
|
+
toHash.push(LE32(new Uint8Array(4), ctx.password.length, 0));
|
|
44636
|
+
toHash.push(ctx.password);
|
|
44637
|
+
} else {
|
|
44638
|
+
toHash.push(ZERO32); // context.password.length
|
|
44639
|
+
}
|
|
44640
|
+
|
|
44641
|
+
if (ctx.salt) {
|
|
44642
|
+
toHash.push(LE32(new Uint8Array(4), ctx.salt.length, 0));
|
|
44643
|
+
toHash.push(ctx.salt);
|
|
44644
|
+
} else {
|
|
44645
|
+
toHash.push(ZERO32); // context.salt.length
|
|
44646
|
+
}
|
|
44647
|
+
|
|
44648
|
+
if (ctx.secret) {
|
|
44649
|
+
toHash.push(LE32(new Uint8Array(4), ctx.secret.length, 0));
|
|
44650
|
+
toHash.push(ctx.secret);
|
|
44651
|
+
// todo clear secret?
|
|
44652
|
+
} else {
|
|
44653
|
+
toHash.push(ZERO32); // context.secret.length
|
|
44654
|
+
}
|
|
44655
|
+
|
|
44656
|
+
if (ctx.ad) {
|
|
44657
|
+
toHash.push(LE32(new Uint8Array(4), ctx.ad.length, 0));
|
|
44658
|
+
toHash.push(ctx.ad);
|
|
44659
|
+
} else {
|
|
44660
|
+
toHash.push(ZERO32); // context.ad.length
|
|
44661
|
+
}
|
|
44662
|
+
H.update(concatArrays(toHash));
|
|
44663
|
+
|
|
44664
|
+
const outputBuffer = H.digest();
|
|
44665
|
+
return new Uint8Array(outputBuffer);
|
|
44666
|
+
}
|
|
44667
|
+
|
|
44668
|
+
function concatArrays(arrays) {
|
|
44669
|
+
if (arrays.length === 1) return arrays[0];
|
|
44670
|
+
|
|
44671
|
+
let totalLength = 0;
|
|
44672
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
44673
|
+
if (!(arrays[i] instanceof Uint8Array)) {
|
|
44674
|
+
throw new Error('concatArrays: Data must be in the form of a Uint8Array');
|
|
44675
|
+
}
|
|
44676
|
+
|
|
44677
|
+
totalLength += arrays[i].length;
|
|
44678
|
+
}
|
|
44679
|
+
|
|
44680
|
+
const result = new Uint8Array(totalLength);
|
|
44681
|
+
let pos = 0;
|
|
44682
|
+
arrays.forEach((element) => {
|
|
44683
|
+
result.set(element, pos);
|
|
44684
|
+
pos += element.length;
|
|
44685
|
+
});
|
|
44686
|
+
|
|
44687
|
+
return result;
|
|
44688
|
+
}
|
|
44689
|
+
|
|
44690
|
+
let isSIMDSupported;
|
|
44691
|
+
async function wasmLoader(memory, getSIMD, getNonSIMD) {
|
|
44692
|
+
const importObject = { env: { memory } };
|
|
44693
|
+
if (isSIMDSupported === undefined) {
|
|
44694
|
+
try {
|
|
44695
|
+
isSIMDSupported = true; // will be overwritten in the catch
|
|
44696
|
+
return await getSIMD(importObject);
|
|
44697
|
+
} catch(e) {
|
|
44698
|
+
isSIMDSupported = false;
|
|
44699
|
+
}
|
|
44700
|
+
}
|
|
44701
|
+
|
|
44702
|
+
const loader = isSIMDSupported ? getSIMD : getNonSIMD;
|
|
44703
|
+
return loader(importObject);
|
|
44704
|
+
}
|
|
44705
|
+
|
|
44706
|
+
async function setupWasm(getSIMD, getNonSIMD) {
|
|
44707
|
+
const memory = new WebAssembly.Memory({
|
|
44708
|
+
// in pages of 64KiB each
|
|
44709
|
+
// these values need to be compatible with those declared when building in `build-wasm`
|
|
44710
|
+
initial: 1040, // 65MB
|
|
44711
|
+
maximum: 65536, // 4GB
|
|
44712
|
+
});
|
|
44713
|
+
const wasmModule = await wasmLoader(memory, getSIMD, getNonSIMD);
|
|
44714
|
+
|
|
44715
|
+
/**
|
|
44716
|
+
* Argon2id hash function
|
|
44717
|
+
* @callback computeHash
|
|
44718
|
+
* @param {Object} params
|
|
44719
|
+
* @param {Uint8Array} params.password - password
|
|
44720
|
+
* @param {Uint8Array} params.salt - salt
|
|
44721
|
+
* @param {Integer} params.parallelism
|
|
44722
|
+
* @param {Integer} params.passes
|
|
44723
|
+
* @param {Integer} params.memorySize - in kibibytes
|
|
44724
|
+
* @param {Integer} params.tagLength - output tag length
|
|
44725
|
+
* @param {Uint8Array} [params.ad] - associated data (optional)
|
|
44726
|
+
* @param {Uint8Array} [params.secret] - secret data (optional)
|
|
44727
|
+
* @return {Uint8Array} argon2id hash
|
|
44728
|
+
*/
|
|
44729
|
+
const computeHash = (params) => argon2id(params, { instance: wasmModule.instance, memory });
|
|
44730
|
+
|
|
44731
|
+
return computeHash;
|
|
44732
|
+
}
|
|
44733
|
+
|
|
44734
|
+
function _loadWasmModule (sync, filepath, src, imports) {
|
|
44735
|
+
function _instantiateOrCompile(source, imports, stream) {
|
|
44736
|
+
var instantiateFunc = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;
|
|
44737
|
+
var compileFunc = stream ? WebAssembly.compileStreaming : WebAssembly.compile;
|
|
44738
|
+
|
|
44739
|
+
if (imports) {
|
|
44740
|
+
return instantiateFunc(source, imports)
|
|
44741
|
+
} else {
|
|
44742
|
+
return compileFunc(source)
|
|
44743
|
+
}
|
|
44744
|
+
}
|
|
44745
|
+
|
|
44746
|
+
|
|
44747
|
+
var buf = null;
|
|
44748
|
+
if (filepath) {
|
|
44749
|
+
|
|
44750
|
+
var fs = require("fs");
|
|
44751
|
+
var path = require("path");
|
|
44752
|
+
|
|
44753
|
+
return new Promise((resolve, reject) => {
|
|
44754
|
+
fs.readFile(path.resolve(__dirname, filepath), (error, buffer) => {
|
|
44755
|
+
if (error != null) {
|
|
44756
|
+
reject(error);
|
|
44757
|
+
} else {
|
|
44758
|
+
resolve(_instantiateOrCompile(buffer, imports, false));
|
|
44759
|
+
}
|
|
44760
|
+
});
|
|
44761
|
+
});
|
|
44762
|
+
|
|
44763
|
+
}
|
|
44764
|
+
|
|
44765
|
+
|
|
44766
|
+
buf = Buffer.from(src, 'base64');
|
|
44767
|
+
|
|
44768
|
+
|
|
44769
|
+
|
|
44770
|
+
if(sync) {
|
|
44771
|
+
var mod = new WebAssembly.Module(buf);
|
|
44772
|
+
return imports ? new WebAssembly.Instance(mod, imports) : mod
|
|
44773
|
+
} else {
|
|
44774
|
+
return _instantiateOrCompile(buf, imports, false)
|
|
44775
|
+
}
|
|
44776
|
+
}
|
|
44777
|
+
|
|
44778
|
+
function wasmSIMD(imports){return _loadWasmModule(0, null, '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', imports)}
|
|
44779
|
+
|
|
44780
|
+
function wasmNonSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABPwhgBH9/f38AYAABf2AAAGADf39/AGARf39/f39/f39/f39/f39/f38AYAl/f39/f39/f38Bf2ABfwBgAX8BfwITAQNlbnYGbWVtb3J5AgGQCICABAMLCgIDBAAABQEGBwEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwADAkcyAAQFZ2V0TFoABRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAkJc3RhY2tTYXZlAAYMc3RhY2tSZXN0b3JlAAcKc3RhY2tBbGxvYwAICQcBAEEBCwEACssaCgMAAQtQAQJ/A0AgACAEQQN0IgNqIAIgA2opAwAgASADaikDAIU3AwAgACADQQhyIgNqIAIgA2opAwAgASADaikDAIU3AwAgBEECaiIEQYABRw0ACwveDwICfgF/IAAgAUEDdGoiEyATKQMAIhEgACAFQQN0aiIBKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA1BA3RqIgUgESAFKQMAhUIgiSIRNwMAIAAgCUEDdGoiCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIoiSIRNwMAIBMgESATKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAFIBEgBSkDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgASARIAEpAwCFQgGJNwMAIAAgAkEDdGoiDSANKQMAIhEgACAGQQN0aiICKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA5BA3RqIgYgESAGKQMAhUIgiSIRNwMAIAAgCkEDdGoiCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIoiSIRNwMAIA0gESANKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAKIBEgCikDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAiARIAIpAwCFQgGJNwMAIAAgA0EDdGoiDiAOKQMAIhEgACAHQQN0aiIDKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA9BA3RqIgcgESAHKQMAhUIgiSIRNwMAIAAgC0EDdGoiCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAMgESADKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAHIBEgBykDAIVCMIkiETcDACALIBEgCykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQgGJNwMAIAAgBEEDdGoiDyAPKQMAIhEgACAIQQN0aiIEKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIBBBA3RqIgggESAIKQMAhUIgiSIRNwMAIAAgDEEDdGoiACARIAApAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA8gESAPKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAIIBEgCCkDAIVCMIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIBMgEykDACIRIAIpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAggESAIKQMAhUIgiSIRNwMAIAsgESALKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACACIBEgAikDAIVCKIkiETcDACATIBEgEykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgCCARIAgpAwCFQjCJIhE3AwAgCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIBiTcDACANIA0pAwAiESADKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAFIBEgBSkDAIVCIIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQiiJIhE3AwAgDSARIA0pAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAUgESAFKQMAhUIwiSIRNwMAIAAgESAAKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACADIBEgAykDAIVCAYk3AwAgDiAOKQMAIhEgBCkDACISfCARQgGGQv7///8fgyASQv////8Pg358IhE3AwAgBiARIAYpAwCFQiCJIhE3AwAgCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIA8gDykDACIRIAEpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAcgESAHKQMAhUIgiSIRNwMAIAogESAKKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACABIBEgASkDAIVCKIkiETcDACAPIBEgDykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgByARIAcpAwCFQjCJIhE3AwAgCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIBiTcDAAvdCAEPfwNAIAIgBUEDdCIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAIgBkEIciIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAVBAmoiBUGAAUcNAAsDQCADIARBA3QiAGogACACaikDADcDACADIARBAXIiAEEDdCIBaiABIAJqKQMANwMAIAMgBEECciIBQQN0IgVqIAIgBWopAwA3AwAgAyAEQQNyIgVBA3QiBmogAiAGaikDADcDACADIARBBHIiBkEDdCIHaiACIAdqKQMANwMAIAMgBEEFciIHQQN0IghqIAIgCGopAwA3AwAgAyAEQQZyIghBA3QiCWogAiAJaikDADcDACADIARBB3IiCUEDdCIKaiACIApqKQMANwMAIAMgBEEIciIKQQN0IgtqIAIgC2opAwA3AwAgAyAEQQlyIgtBA3QiDGogAiAMaikDADcDACADIARBCnIiDEEDdCINaiACIA1qKQMANwMAIAMgBEELciINQQN0Ig5qIAIgDmopAwA3AwAgAyAEQQxyIg5BA3QiD2ogAiAPaikDADcDACADIARBDXIiD0EDdCIQaiACIBBqKQMANwMAIAMgBEEOciIQQQN0IhFqIAIgEWopAwA3AwAgAyAEQQ9yIhFBA3QiEmogAiASaikDADcDACADIARB//8DcSAAQf//A3EgAUH//wNxIAVB//8DcSAGQf//A3EgB0H//wNxIAhB//8DcSAJQf//A3EgCkH//wNxIAtB//8DcSAMQf//A3EgDUH//wNxIA5B//8DcSAPQf//A3EgEEH//wNxIBFB//8DcRACIARB8ABJIQAgBEEQaiEEIAANAAtBACEBIANBAEEBQRBBEUEgQSFBMEExQcAAQcEAQdAAQdEAQeAAQeEAQfAAQfEAEAIgA0ECQQNBEkETQSJBI0EyQTNBwgBBwwBB0gBB0wBB4gBB4wBB8gBB8wAQAiADQQRBBUEUQRVBJEElQTRBNUHEAEHFAEHUAEHVAEHkAEHlAEH0AEH1ABACIANBBkEHQRZBF0EmQSdBNkE3QcYAQccAQdYAQdcAQeYAQecAQfYAQfcAEAIgA0EIQQlBGEEZQShBKUE4QTlByABByQBB2ABB2QBB6ABB6QBB+ABB+QAQAiADQQpBC0EaQRtBKkErQTpBO0HKAEHLAEHaAEHbAEHqAEHrAEH6AEH7ABACIANBDEENQRxBHUEsQS1BPEE9QcwAQc0AQdwAQd0AQewAQe0AQfwAQf0AEAIgA0EOQQ9BHkEfQS5BL0E+QT9BzgBBzwBB3gBB3wBB7gBB7wBB/gBB/wAQAgNAIAIgAUEDdCIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAiAAQQhyIgRqIgUgAyAEaikDACAFKQMAhTcDACACIABBEHIiBGoiBSADIARqKQMAIAUpAwCFNwMAIAIgAEEYciIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAUEEaiIBQYABRw0ACwsWACAAIAEgAiADEAMgACACIAIgAxADC3sCAX8BfiACIQkgATUCACEKIAQgBXIEQCABKAIEIANwIQkLIAAgCTYCACAAIAdBAWsgBSAEGyAIbCAGQQFrQQBBfyAGGyACIAlGG2oiASAFQQFqIAhsQQAgBBtqIAGtIAogCn5CIIh+QiCIp0F/c2ogByAIbHA2AgQgAAsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwUAQYAICw==', imports)}
|
|
44781
|
+
|
|
44782
|
+
const loadWasm = async () => setupWasm(
|
|
44783
|
+
(instanceObject) => wasmSIMD(instanceObject),
|
|
44784
|
+
(instanceObject) => wasmNonSIMD(instanceObject),
|
|
44785
|
+
);
|
|
44786
|
+
|
|
44787
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
44788
|
+
__proto__: null,
|
|
44789
|
+
'default': loadWasm
|
|
44790
|
+
});
|
|
44791
|
+
|
|
43857
44792
|
exports.AEADEncryptedDataPacket = AEADEncryptedDataPacket;
|
|
43858
44793
|
exports.CleartextMessage = CleartextMessage;
|
|
43859
44794
|
exports.CompressedDataPacket = CompressedDataPacket;
|
|
44795
|
+
exports.KDFParams = KDFParams;
|
|
43860
44796
|
exports.LiteralDataPacket = LiteralDataPacket;
|
|
43861
44797
|
exports.MarkerPacket = MarkerPacket;
|
|
43862
44798
|
exports.Message = Message;
|