@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.mjs
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
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
4
|
import buffer from 'buffer';
|
|
@@ -1913,7 +1913,7 @@ const util = {
|
|
|
1913
1913
|
if (!util.isString(data)) {
|
|
1914
1914
|
return false;
|
|
1915
1915
|
}
|
|
1916
|
-
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,}
|
|
1916
|
+
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]+)))$/;
|
|
1917
1917
|
return re.test(data);
|
|
1918
1918
|
},
|
|
1919
1919
|
|
|
@@ -2110,14 +2110,14 @@ const util = {
|
|
|
2110
2110
|
* provided with the application or distribution.
|
|
2111
2111
|
*/
|
|
2112
2112
|
|
|
2113
|
-
const Buffer = util.getNodeBuffer();
|
|
2113
|
+
const Buffer$1 = util.getNodeBuffer();
|
|
2114
2114
|
|
|
2115
2115
|
let encodeChunk;
|
|
2116
2116
|
let decodeChunk;
|
|
2117
|
-
if (Buffer) {
|
|
2118
|
-
encodeChunk = buf => Buffer.from(buf).toString('base64');
|
|
2117
|
+
if (Buffer$1) {
|
|
2118
|
+
encodeChunk = buf => Buffer$1.from(buf).toString('base64');
|
|
2119
2119
|
decodeChunk = str => {
|
|
2120
|
-
const b = Buffer.from(str, 'base64');
|
|
2120
|
+
const b = Buffer$1.from(str, 'base64');
|
|
2121
2121
|
return new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
|
|
2122
2122
|
};
|
|
2123
2123
|
} else {
|
|
@@ -2309,6 +2309,7 @@ var enums = {
|
|
|
2309
2309
|
simple: 0,
|
|
2310
2310
|
salted: 1,
|
|
2311
2311
|
iterated: 3,
|
|
2312
|
+
argon2: 4,
|
|
2312
2313
|
gnu: 101
|
|
2313
2314
|
},
|
|
2314
2315
|
|
|
@@ -2623,6 +2624,8 @@ var enums = {
|
|
|
2623
2624
|
splitPrivateKey: 16,
|
|
2624
2625
|
/** 0x20 - This key may be used for authentication. */
|
|
2625
2626
|
authentication: 32,
|
|
2627
|
+
/** This key may be used for forwarded communications */
|
|
2628
|
+
forwardedCommunication: 64,
|
|
2626
2629
|
/** 0x80 - The private component of this key may be in the
|
|
2627
2630
|
* possession of more than one person. */
|
|
2628
2631
|
sharedPrivateKey: 128
|
|
@@ -2773,12 +2776,41 @@ var config = {
|
|
|
2773
2776
|
*/
|
|
2774
2777
|
v5Keys: false,
|
|
2775
2778
|
/**
|
|
2776
|
-
*
|
|
2777
|
-
*
|
|
2779
|
+
* S2K (String to Key) type, used for key derivation in the context of secret key encryption
|
|
2780
|
+
* and password-encrypted data. Weaker s2k options are not allowed.
|
|
2781
|
+
* Note: Argon2 is the strongest option but not all OpenPGP implementations are compatible with it
|
|
2782
|
+
* (pending standardisation).
|
|
2783
|
+
* @memberof module:config
|
|
2784
|
+
* @property {enums.s2k.argon2|enums.s2k.iterated} s2kType {@link module:enums.s2k}
|
|
2785
|
+
*/
|
|
2786
|
+
s2kType: enums.s2k.iterated,
|
|
2787
|
+
/**
|
|
2788
|
+
* {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3| RFC4880 3.7.1.3}:
|
|
2789
|
+
* Iteration Count Byte for Iterated and Salted S2K (String to Key).
|
|
2790
|
+
* Only relevant if `config.s2kType` is set to `enums.s2k.iterated`.
|
|
2791
|
+
* Note: this is the exponent value, not the final number of iterations (refer to specs for more details).
|
|
2778
2792
|
* @memberof module:config
|
|
2779
2793
|
* @property {Integer} s2kIterationCountByte
|
|
2780
2794
|
*/
|
|
2781
2795
|
s2kIterationCountByte: 224,
|
|
2796
|
+
/**
|
|
2797
|
+
* {@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}:
|
|
2798
|
+
* Argon2 parameters for S2K (String to Key).
|
|
2799
|
+
* Only relevant if `config.s2kType` is set to `enums.s2k.argon2`.
|
|
2800
|
+
* Default settings correspond to the second recommendation from RFC9106 ("uniformly safe option"),
|
|
2801
|
+
* to ensure compatibility with memory-constrained environments.
|
|
2802
|
+
* For more details on the choice of parameters, see https://tools.ietf.org/html/rfc9106#section-4.
|
|
2803
|
+
* @memberof module:config
|
|
2804
|
+
* @property {Object} params
|
|
2805
|
+
* @property {Integer} params.passes - number of iterations t
|
|
2806
|
+
* @property {Integer} params.parallelism - degree of parallelism p
|
|
2807
|
+
* @property {Integer} params.memoryExponent - one-octet exponent indicating the memory size, which will be: 2**memoryExponent kibibytes.
|
|
2808
|
+
*/
|
|
2809
|
+
s2kArgon2Params: {
|
|
2810
|
+
passes: 3,
|
|
2811
|
+
parallelism: 4, // lanes
|
|
2812
|
+
memoryExponent: 16 // 64 MiB of RAM
|
|
2813
|
+
},
|
|
2782
2814
|
/**
|
|
2783
2815
|
* Allow decryption of messages without integrity protection.
|
|
2784
2816
|
* This is an **insecure** setting:
|
|
@@ -2798,6 +2830,13 @@ var config = {
|
|
|
2798
2830
|
* @property {Boolean} allowUnauthenticatedStream
|
|
2799
2831
|
*/
|
|
2800
2832
|
allowUnauthenticatedStream: false,
|
|
2833
|
+
/**
|
|
2834
|
+
* Allow decrypting forwarded messages, using keys with 0x40 ('forwarded communication') flag.
|
|
2835
|
+
* Note: this is related to a **non-standard feature**.
|
|
2836
|
+
* @memberof module:config
|
|
2837
|
+
* @property {Boolean} allowForwardedMessages
|
|
2838
|
+
*/
|
|
2839
|
+
allowForwardedMessages: false,
|
|
2801
2840
|
/**
|
|
2802
2841
|
* @memberof module:config
|
|
2803
2842
|
* @property {Boolean} checksumRequired Do not throw error when armor is missing a checksum
|
|
@@ -2874,6 +2913,14 @@ var config = {
|
|
|
2874
2913
|
* @property {Boolean} ignoreMalformedPackets Ignore malformed packets on parsing instead of throwing an error
|
|
2875
2914
|
*/
|
|
2876
2915
|
ignoreMalformedPackets: false,
|
|
2916
|
+
/**
|
|
2917
|
+
* Parsing of packets is normally restricted to a predefined set of packets. For example a Sym. Encrypted Integrity Protected Data Packet can only
|
|
2918
|
+
* contain a certain set of packets including LiteralDataPacket. With this setting we can allow additional packets, which is probably not advisable
|
|
2919
|
+
* as a global config setting, but can be used for specific function calls (e.g. decrypt method of Message).
|
|
2920
|
+
* @memberof module:config
|
|
2921
|
+
* @property {Array} additionalAllowedPackets Allow additional packets on parsing. Defined as array of packet classes, e.g. [PublicKeyPacket]
|
|
2922
|
+
*/
|
|
2923
|
+
additionalAllowedPackets: [],
|
|
2877
2924
|
/**
|
|
2878
2925
|
* @memberof module:config
|
|
2879
2926
|
* @property {Boolean} showVersion Whether to include {@link module:config/config.versionString} in armored messages
|
|
@@ -2888,7 +2935,7 @@ var config = {
|
|
|
2888
2935
|
* @memberof module:config
|
|
2889
2936
|
* @property {String} versionString A version string to be included in armored messages
|
|
2890
2937
|
*/
|
|
2891
|
-
versionString: 'OpenPGP.js 5.
|
|
2938
|
+
versionString: 'OpenPGP.js 5.9.0',
|
|
2892
2939
|
/**
|
|
2893
2940
|
* @memberof module:config
|
|
2894
2941
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -10236,7 +10283,7 @@ async function CBC(key) {
|
|
|
10236
10283
|
|
|
10237
10284
|
const webCrypto$3 = util.getWebCrypto();
|
|
10238
10285
|
const nodeCrypto$3 = util.getNodeCrypto();
|
|
10239
|
-
const Buffer$
|
|
10286
|
+
const Buffer$2 = util.getNodeBuffer();
|
|
10240
10287
|
|
|
10241
10288
|
|
|
10242
10289
|
const blockLength$1 = 16;
|
|
@@ -10268,7 +10315,7 @@ async function CTR(key) {
|
|
|
10268
10315
|
if (util.getNodeCrypto()) { // Node crypto library
|
|
10269
10316
|
return async function(pt, iv) {
|
|
10270
10317
|
const en = new nodeCrypto$3.createCipheriv('aes-' + (key.length * 8) + '-ctr', key, iv);
|
|
10271
|
-
const ct = Buffer$
|
|
10318
|
+
const ct = Buffer$2.concat([en.update(pt), en.final()]);
|
|
10272
10319
|
return new Uint8Array(ct);
|
|
10273
10320
|
};
|
|
10274
10321
|
}
|
|
@@ -10905,7 +10952,7 @@ class AES_GCM {
|
|
|
10905
10952
|
|
|
10906
10953
|
const webCrypto$4 = util.getWebCrypto();
|
|
10907
10954
|
const nodeCrypto$4 = util.getNodeCrypto();
|
|
10908
|
-
const Buffer$
|
|
10955
|
+
const Buffer$3 = util.getNodeBuffer();
|
|
10909
10956
|
|
|
10910
10957
|
const blockLength$3 = 16;
|
|
10911
10958
|
const ivLength$2 = 12; // size of the IV in bytes
|
|
@@ -10951,7 +10998,7 @@ async function GCM(cipher, key) {
|
|
|
10951
10998
|
encrypt: async function(pt, iv, adata = new Uint8Array()) {
|
|
10952
10999
|
const en = new nodeCrypto$4.createCipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10953
11000
|
en.setAAD(adata);
|
|
10954
|
-
const ct = Buffer$
|
|
11001
|
+
const ct = Buffer$3.concat([en.update(pt), en.final(), en.getAuthTag()]); // append auth tag to ciphertext
|
|
10955
11002
|
return new Uint8Array(ct);
|
|
10956
11003
|
},
|
|
10957
11004
|
|
|
@@ -10959,7 +11006,7 @@ async function GCM(cipher, key) {
|
|
|
10959
11006
|
const de = new nodeCrypto$4.createDecipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10960
11007
|
de.setAAD(adata);
|
|
10961
11008
|
de.setAuthTag(ct.slice(ct.length - tagLength$2, ct.length)); // read auth tag at end of ciphertext
|
|
10962
|
-
const pt = Buffer$
|
|
11009
|
+
const pt = Buffer$3.concat([de.update(ct.slice(0, ct.length - tagLength$2)), de.final()]);
|
|
10963
11010
|
return new Uint8Array(pt);
|
|
10964
11011
|
}
|
|
10965
11012
|
};
|
|
@@ -14384,7 +14431,7 @@ function buildEcdhParam(public_algo, oid, kdfParams, fingerprint) {
|
|
|
14384
14431
|
return util.concatUint8Array([
|
|
14385
14432
|
oid.write(),
|
|
14386
14433
|
new Uint8Array([public_algo]),
|
|
14387
|
-
kdfParams.
|
|
14434
|
+
kdfParams.write(true),
|
|
14388
14435
|
util.stringToUint8Array('Anonymous Sender '),
|
|
14389
14436
|
kdfParams.replacementFingerprint || fingerprint.subarray(0, 20)
|
|
14390
14437
|
]);
|
|
@@ -15226,32 +15273,28 @@ class ECDHSymmetricKey {
|
|
|
15226
15273
|
|
|
15227
15274
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15228
15275
|
|
|
15276
|
+
const VERSION_FORWARDING = 0xFF;
|
|
15277
|
+
|
|
15229
15278
|
class KDFParams {
|
|
15230
15279
|
/**
|
|
15231
15280
|
* @param {Integer} version Version, defaults to 1
|
|
15232
15281
|
* @param {enums.hash} hash Hash algorithm
|
|
15233
15282
|
* @param {enums.symmetric} cipher Symmetric algorithm
|
|
15234
|
-
* @param {
|
|
15235
|
-
* @param {Uint8Array} replacementFingerprint (v2 only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15236
|
-
* @param {Uint8Array} replacementKDFParams (v2 only) serialized KDF params to use in KDF digest computation
|
|
15283
|
+
* @param {Uint8Array} replacementFingerprint (forwarding only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15237
15284
|
*/
|
|
15238
15285
|
constructor(data) {
|
|
15239
15286
|
if (data) {
|
|
15240
|
-
const { version, hash, cipher,
|
|
15287
|
+
const { version, hash, cipher, replacementFingerprint } = data;
|
|
15241
15288
|
this.version = version || 1;
|
|
15242
15289
|
this.hash = hash;
|
|
15243
15290
|
this.cipher = cipher;
|
|
15244
15291
|
|
|
15245
|
-
this.flags = flags;
|
|
15246
15292
|
this.replacementFingerprint = replacementFingerprint;
|
|
15247
|
-
this.replacementKDFParams = replacementKDFParams;
|
|
15248
15293
|
} else {
|
|
15249
15294
|
this.version = null;
|
|
15250
15295
|
this.hash = null;
|
|
15251
15296
|
this.cipher = null;
|
|
15252
|
-
this.flags = null;
|
|
15253
15297
|
this.replacementFingerprint = null;
|
|
15254
|
-
this.replacementKDFParams = null;
|
|
15255
15298
|
}
|
|
15256
15299
|
}
|
|
15257
15300
|
|
|
@@ -15261,44 +15304,41 @@ class KDFParams {
|
|
|
15261
15304
|
* @returns {Number} Number of read bytes.
|
|
15262
15305
|
*/
|
|
15263
15306
|
read(input) {
|
|
15307
|
+
const totalBytes = input[0];
|
|
15264
15308
|
this.version = input[1];
|
|
15265
15309
|
this.hash = input[2];
|
|
15266
15310
|
this.cipher = input[3];
|
|
15267
15311
|
let readBytes = 4;
|
|
15268
15312
|
|
|
15269
|
-
if (this.version ===
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
readBytes += 20;
|
|
15274
|
-
}
|
|
15275
|
-
if (this.flags & enums.kdfFlags.replace_kdf_params) {
|
|
15276
|
-
const fieldLength = input[readBytes] + 1; // account for length
|
|
15277
|
-
this.replacementKDFParams = input.slice(readBytes, readBytes + fieldLength);
|
|
15278
|
-
readBytes += fieldLength;
|
|
15279
|
-
}
|
|
15313
|
+
if (this.version === VERSION_FORWARDING) {
|
|
15314
|
+
const fingerprintLength = totalBytes - readBytes + 1; // acount for length byte
|
|
15315
|
+
this.replacementFingerprint = input.slice(readBytes, readBytes + fingerprintLength);
|
|
15316
|
+
readBytes += fingerprintLength;
|
|
15280
15317
|
}
|
|
15281
15318
|
return readBytes;
|
|
15282
15319
|
}
|
|
15283
15320
|
|
|
15284
15321
|
/**
|
|
15285
15322
|
* Write KDFParams to an Uint8Array
|
|
15323
|
+
* @param {Boolean} [forReplacementParams] - forwarding only: whether to serialize data to use for replacement params
|
|
15286
15324
|
* @returns {Uint8Array} Array with the KDFParams value
|
|
15287
15325
|
*/
|
|
15288
|
-
write() {
|
|
15289
|
-
if (!this.version || this.version === 1) {
|
|
15326
|
+
write(forReplacementParams) {
|
|
15327
|
+
if (!this.version || this.version === 1 || forReplacementParams) {
|
|
15290
15328
|
return new Uint8Array([3, 1, this.hash, this.cipher]);
|
|
15291
15329
|
}
|
|
15292
15330
|
|
|
15293
|
-
const
|
|
15294
|
-
new Uint8Array([
|
|
15295
|
-
|
|
15296
|
-
|
|
15331
|
+
const forwardingFields = util.concatUint8Array([
|
|
15332
|
+
new Uint8Array([
|
|
15333
|
+
3 + this.replacementFingerprint.length,
|
|
15334
|
+
this.version,
|
|
15335
|
+
this.hash,
|
|
15336
|
+
this.cipher
|
|
15337
|
+
]),
|
|
15338
|
+
this.replacementFingerprint
|
|
15297
15339
|
]);
|
|
15298
15340
|
|
|
15299
|
-
|
|
15300
|
-
v2Fields[0] = v2Fields.length - 1;
|
|
15301
|
-
return new Uint8Array(v2Fields);
|
|
15341
|
+
return forwardingFields;
|
|
15302
15342
|
}
|
|
15303
15343
|
}
|
|
15304
15344
|
|
|
@@ -15881,6 +15921,339 @@ const mod = {
|
|
|
15881
15921
|
|
|
15882
15922
|
Object.assign(mod, crypto$1);
|
|
15883
15923
|
|
|
15924
|
+
const ARGON2_TYPE = 0x02; // id
|
|
15925
|
+
const ARGON2_VERSION = 0x13;
|
|
15926
|
+
const ARGON2_SALT_SIZE = 16;
|
|
15927
|
+
|
|
15928
|
+
class Argon2OutOfMemoryError extends Error {
|
|
15929
|
+
constructor(...params) {
|
|
15930
|
+
super(...params);
|
|
15931
|
+
|
|
15932
|
+
if (Error.captureStackTrace) {
|
|
15933
|
+
Error.captureStackTrace(this, Argon2OutOfMemoryError);
|
|
15934
|
+
}
|
|
15935
|
+
|
|
15936
|
+
this.name = 'Argon2OutOfMemoryError';
|
|
15937
|
+
}
|
|
15938
|
+
}
|
|
15939
|
+
|
|
15940
|
+
// cache argon wasm module
|
|
15941
|
+
let loadArgonWasmModule;
|
|
15942
|
+
let argon2Promise;
|
|
15943
|
+
// reload wasm module above this treshold, to deallocated used memory
|
|
15944
|
+
const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
|
|
15945
|
+
|
|
15946
|
+
class Argon2S2K {
|
|
15947
|
+
/**
|
|
15948
|
+
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
15949
|
+
*/
|
|
15950
|
+
constructor(config$1 = config) {
|
|
15951
|
+
const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
|
|
15952
|
+
|
|
15953
|
+
this.type = 'argon2';
|
|
15954
|
+
/** @type {Uint8Array} 16 bytes of salt */
|
|
15955
|
+
this.salt = null;
|
|
15956
|
+
/** @type {Integer} number of passes */
|
|
15957
|
+
this.t = passes;
|
|
15958
|
+
/** @type {Integer} degree of parallelism (lanes) */
|
|
15959
|
+
this.p = parallelism;
|
|
15960
|
+
/** @type {Integer} exponent indicating memory size */
|
|
15961
|
+
this.encodedM = memoryExponent;
|
|
15962
|
+
}
|
|
15963
|
+
|
|
15964
|
+
generateSalt() {
|
|
15965
|
+
this.salt = mod.random.getRandomBytes(ARGON2_SALT_SIZE);
|
|
15966
|
+
}
|
|
15967
|
+
|
|
15968
|
+
/**
|
|
15969
|
+
* Parsing function for argon2 string-to-key specifier.
|
|
15970
|
+
* @param {Uint8Array} bytes - Payload of argon2 string-to-key specifier
|
|
15971
|
+
* @returns {Integer} Actual length of the object.
|
|
15972
|
+
*/
|
|
15973
|
+
read(bytes) {
|
|
15974
|
+
let i = 0;
|
|
15975
|
+
|
|
15976
|
+
this.salt = bytes.subarray(i, i + 16);
|
|
15977
|
+
i += 16;
|
|
15978
|
+
|
|
15979
|
+
this.t = bytes[i++];
|
|
15980
|
+
this.p = bytes[i++];
|
|
15981
|
+
this.encodedM = bytes[i++]; // memory size exponent, one-octect
|
|
15982
|
+
|
|
15983
|
+
return i;
|
|
15984
|
+
}
|
|
15985
|
+
|
|
15986
|
+
/**
|
|
15987
|
+
* Serializes s2k information
|
|
15988
|
+
* @returns {Uint8Array} Binary representation of s2k.
|
|
15989
|
+
*/
|
|
15990
|
+
write() {
|
|
15991
|
+
const arr = [
|
|
15992
|
+
new Uint8Array([enums.write(enums.s2k, this.type)]),
|
|
15993
|
+
this.salt,
|
|
15994
|
+
new Uint8Array([this.t, this.p, this.encodedM])
|
|
15995
|
+
];
|
|
15996
|
+
|
|
15997
|
+
return util.concatUint8Array(arr);
|
|
15998
|
+
}
|
|
15999
|
+
|
|
16000
|
+
/**
|
|
16001
|
+
* Produces a key using the specified passphrase and the defined
|
|
16002
|
+
* hashAlgorithm
|
|
16003
|
+
* @param {String} passphrase - Passphrase containing user input
|
|
16004
|
+
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to `keySize`
|
|
16005
|
+
* @throws {Argon2OutOfMemoryError|Errors}
|
|
16006
|
+
* @async
|
|
16007
|
+
*/
|
|
16008
|
+
async produceKey(passphrase, keySize) {
|
|
16009
|
+
const decodedM = 2 << (this.encodedM - 1);
|
|
16010
|
+
|
|
16011
|
+
try {
|
|
16012
|
+
if (!argon2Promise) { // first load
|
|
16013
|
+
loadArgonWasmModule = loadArgonWasmModule || (await Promise.resolve().then(function () { return index; })).default;
|
|
16014
|
+
argon2Promise = loadArgonWasmModule();
|
|
16015
|
+
}
|
|
16016
|
+
// important to keep local ref to argon2 in case the module is reloaded by another instance
|
|
16017
|
+
const argon2 = await argon2Promise;
|
|
16018
|
+
|
|
16019
|
+
const passwordBytes = util.encodeUTF8(passphrase);
|
|
16020
|
+
const hash = argon2({
|
|
16021
|
+
version: ARGON2_VERSION,
|
|
16022
|
+
type: ARGON2_TYPE,
|
|
16023
|
+
password: passwordBytes,
|
|
16024
|
+
salt: this.salt,
|
|
16025
|
+
tagLength: keySize,
|
|
16026
|
+
memorySize: decodedM,
|
|
16027
|
+
parallelism: this.p,
|
|
16028
|
+
passes: this.t
|
|
16029
|
+
});
|
|
16030
|
+
|
|
16031
|
+
// a lot of memory was used, reload to deallocate
|
|
16032
|
+
if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
|
|
16033
|
+
// it will be awaited if needed at the next `produceKey` invocation
|
|
16034
|
+
argon2Promise = loadArgonWasmModule();
|
|
16035
|
+
}
|
|
16036
|
+
return hash;
|
|
16037
|
+
} catch (e) {
|
|
16038
|
+
if (e.message && (
|
|
16039
|
+
e.message.includes('Unable to grow instance memory') || // Chrome
|
|
16040
|
+
e.message.includes('failed to grow memory') || // Firefox
|
|
16041
|
+
e.message.includes('WebAssembly.Memory.grow') || // Safari
|
|
16042
|
+
e.message.includes('Out of memory') // Safari iOS
|
|
16043
|
+
)) {
|
|
16044
|
+
throw new Argon2OutOfMemoryError('Could not allocate required memory for Argon2');
|
|
16045
|
+
} else {
|
|
16046
|
+
throw e;
|
|
16047
|
+
}
|
|
16048
|
+
}
|
|
16049
|
+
}
|
|
16050
|
+
}
|
|
16051
|
+
|
|
16052
|
+
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
16053
|
+
|
|
16054
|
+
class GenericS2K {
|
|
16055
|
+
/**
|
|
16056
|
+
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
16057
|
+
*/
|
|
16058
|
+
constructor(s2kType, config$1 = config) {
|
|
16059
|
+
/**
|
|
16060
|
+
* Hash function identifier, or 0 for gnu-dummy keys
|
|
16061
|
+
* @type {module:enums.hash | 0}
|
|
16062
|
+
*/
|
|
16063
|
+
this.algorithm = enums.hash.sha256;
|
|
16064
|
+
/**
|
|
16065
|
+
* enums.s2k identifier or 'gnu-dummy'
|
|
16066
|
+
* @type {String}
|
|
16067
|
+
*/
|
|
16068
|
+
this.type = enums.read(enums.s2k, s2kType);
|
|
16069
|
+
/** @type {Integer} */
|
|
16070
|
+
this.c = config$1.s2kIterationCountByte;
|
|
16071
|
+
/** Eight bytes of salt in a binary string.
|
|
16072
|
+
* @type {Uint8Array}
|
|
16073
|
+
*/
|
|
16074
|
+
this.salt = null;
|
|
16075
|
+
}
|
|
16076
|
+
|
|
16077
|
+
generateSalt() {
|
|
16078
|
+
switch (this.type) {
|
|
16079
|
+
case 'salted':
|
|
16080
|
+
case 'iterated':
|
|
16081
|
+
this.salt = mod.random.getRandomBytes(8);
|
|
16082
|
+
}
|
|
16083
|
+
}
|
|
16084
|
+
|
|
16085
|
+
getCount() {
|
|
16086
|
+
// Exponent bias, defined in RFC4880
|
|
16087
|
+
const expbias = 6;
|
|
16088
|
+
|
|
16089
|
+
return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
|
|
16090
|
+
}
|
|
16091
|
+
|
|
16092
|
+
/**
|
|
16093
|
+
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
|
16094
|
+
* @param {Uint8Array} bytes - Payload of string-to-key specifier
|
|
16095
|
+
* @returns {Integer} Actual length of the object.
|
|
16096
|
+
*/
|
|
16097
|
+
read(bytes) {
|
|
16098
|
+
let i = 0;
|
|
16099
|
+
this.algorithm = bytes[i++];
|
|
16100
|
+
|
|
16101
|
+
switch (this.type) {
|
|
16102
|
+
case 'simple':
|
|
16103
|
+
break;
|
|
16104
|
+
|
|
16105
|
+
case 'salted':
|
|
16106
|
+
this.salt = bytes.subarray(i, i + 8);
|
|
16107
|
+
i += 8;
|
|
16108
|
+
break;
|
|
16109
|
+
|
|
16110
|
+
case 'iterated':
|
|
16111
|
+
this.salt = bytes.subarray(i, i + 8);
|
|
16112
|
+
i += 8;
|
|
16113
|
+
|
|
16114
|
+
// Octet 10: count, a one-octet, coded value
|
|
16115
|
+
this.c = bytes[i++];
|
|
16116
|
+
break;
|
|
16117
|
+
case 'gnu':
|
|
16118
|
+
if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
|
|
16119
|
+
i += 3; // GNU
|
|
16120
|
+
const gnuExtType = 1000 + bytes[i++];
|
|
16121
|
+
if (gnuExtType === 1001) {
|
|
16122
|
+
this.type = 'gnu-dummy';
|
|
16123
|
+
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
16124
|
+
} else {
|
|
16125
|
+
throw new Error('Unknown s2k gnu protection mode.');
|
|
16126
|
+
}
|
|
16127
|
+
} else {
|
|
16128
|
+
throw new Error('Unknown s2k type.');
|
|
16129
|
+
}
|
|
16130
|
+
break;
|
|
16131
|
+
|
|
16132
|
+
default:
|
|
16133
|
+
throw new Error('Unknown s2k type.');
|
|
16134
|
+
}
|
|
16135
|
+
|
|
16136
|
+
return i;
|
|
16137
|
+
}
|
|
16138
|
+
|
|
16139
|
+
/**
|
|
16140
|
+
* Serializes s2k information
|
|
16141
|
+
* @returns {Uint8Array} Binary representation of s2k.
|
|
16142
|
+
*/
|
|
16143
|
+
write() {
|
|
16144
|
+
if (this.type === 'gnu-dummy') {
|
|
16145
|
+
return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
|
|
16146
|
+
}
|
|
16147
|
+
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
|
|
16148
|
+
|
|
16149
|
+
switch (this.type) {
|
|
16150
|
+
case 'simple':
|
|
16151
|
+
break;
|
|
16152
|
+
case 'salted':
|
|
16153
|
+
arr.push(this.salt);
|
|
16154
|
+
break;
|
|
16155
|
+
case 'iterated':
|
|
16156
|
+
arr.push(this.salt);
|
|
16157
|
+
arr.push(new Uint8Array([this.c]));
|
|
16158
|
+
break;
|
|
16159
|
+
case 'gnu':
|
|
16160
|
+
throw new Error('GNU s2k type not supported.');
|
|
16161
|
+
default:
|
|
16162
|
+
throw new Error('Unknown s2k type.');
|
|
16163
|
+
}
|
|
16164
|
+
|
|
16165
|
+
return util.concatUint8Array(arr);
|
|
16166
|
+
}
|
|
16167
|
+
|
|
16168
|
+
/**
|
|
16169
|
+
* Produces a key using the specified passphrase and the defined
|
|
16170
|
+
* hashAlgorithm
|
|
16171
|
+
* @param {String} passphrase - Passphrase containing user input
|
|
16172
|
+
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
|
|
16173
|
+
* hashAlgorithm hash length
|
|
16174
|
+
* @async
|
|
16175
|
+
*/
|
|
16176
|
+
async produceKey(passphrase, numBytes) {
|
|
16177
|
+
passphrase = util.encodeUTF8(passphrase);
|
|
16178
|
+
|
|
16179
|
+
const arr = [];
|
|
16180
|
+
let rlength = 0;
|
|
16181
|
+
|
|
16182
|
+
let prefixlen = 0;
|
|
16183
|
+
while (rlength < numBytes) {
|
|
16184
|
+
let toHash;
|
|
16185
|
+
switch (this.type) {
|
|
16186
|
+
case 'simple':
|
|
16187
|
+
toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
|
|
16188
|
+
break;
|
|
16189
|
+
case 'salted':
|
|
16190
|
+
toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
|
|
16191
|
+
break;
|
|
16192
|
+
case 'iterated': {
|
|
16193
|
+
const data = util.concatUint8Array([this.salt, passphrase]);
|
|
16194
|
+
let datalen = data.length;
|
|
16195
|
+
const count = Math.max(this.getCount(), datalen);
|
|
16196
|
+
toHash = new Uint8Array(prefixlen + count);
|
|
16197
|
+
toHash.set(data, prefixlen);
|
|
16198
|
+
for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
|
|
16199
|
+
toHash.copyWithin(pos, prefixlen, pos);
|
|
16200
|
+
}
|
|
16201
|
+
break;
|
|
16202
|
+
}
|
|
16203
|
+
case 'gnu':
|
|
16204
|
+
throw new Error('GNU s2k type not supported.');
|
|
16205
|
+
default:
|
|
16206
|
+
throw new Error('Unknown s2k type.');
|
|
16207
|
+
}
|
|
16208
|
+
const result = await mod.hash.digest(this.algorithm, toHash);
|
|
16209
|
+
arr.push(result);
|
|
16210
|
+
rlength += result.length;
|
|
16211
|
+
prefixlen++;
|
|
16212
|
+
}
|
|
16213
|
+
|
|
16214
|
+
return util.concatUint8Array(arr).subarray(0, numBytes);
|
|
16215
|
+
}
|
|
16216
|
+
}
|
|
16217
|
+
|
|
16218
|
+
const allowedS2KTypesForEncryption = new Set([enums.s2k.argon2, enums.s2k.iterated]);
|
|
16219
|
+
|
|
16220
|
+
/**
|
|
16221
|
+
* Instantiate a new S2K instance of the given type
|
|
16222
|
+
* @param {module:enums.s2k} type
|
|
16223
|
+
* @oaram {Object} [config]
|
|
16224
|
+
* @returns {Object} New s2k object
|
|
16225
|
+
* @throws {Error} for unknown or unsupported types
|
|
16226
|
+
*/
|
|
16227
|
+
function newS2KFromType(type, config$1 = config) {
|
|
16228
|
+
switch (type) {
|
|
16229
|
+
case enums.s2k.argon2:
|
|
16230
|
+
return new Argon2S2K(config$1);
|
|
16231
|
+
case enums.s2k.iterated:
|
|
16232
|
+
case enums.s2k.gnu:
|
|
16233
|
+
case enums.s2k.salted:
|
|
16234
|
+
case enums.s2k.simple:
|
|
16235
|
+
return new GenericS2K(type, config$1);
|
|
16236
|
+
default:
|
|
16237
|
+
throw new Error(`Unsupported S2K type ${type}`);
|
|
16238
|
+
}
|
|
16239
|
+
}
|
|
16240
|
+
|
|
16241
|
+
/**
|
|
16242
|
+
* Instantiate a new S2K instance based on the config settings
|
|
16243
|
+
* @oaram {Object} config
|
|
16244
|
+
* @returns {Object} New s2k object
|
|
16245
|
+
* @throws {Error} for unknown or unsupported types
|
|
16246
|
+
*/
|
|
16247
|
+
function newS2KFromConfig(config) {
|
|
16248
|
+
const { s2kType } = config;
|
|
16249
|
+
|
|
16250
|
+
if (!allowedS2KTypesForEncryption.has(s2kType)) {
|
|
16251
|
+
throw new Error('The provided `config.s2kType` value is not allowed');
|
|
16252
|
+
}
|
|
16253
|
+
|
|
16254
|
+
return newS2KFromType(s2kType, config);
|
|
16255
|
+
}
|
|
16256
|
+
|
|
15884
16257
|
var TYPED_OK = typeof Uint8Array !== "undefined" &&
|
|
15885
16258
|
typeof Uint16Array !== "undefined" &&
|
|
15886
16259
|
typeof Int32Array !== "undefined";
|
|
@@ -23935,6 +24308,9 @@ class PacketList extends Array {
|
|
|
23935
24308
|
* @async
|
|
23936
24309
|
*/
|
|
23937
24310
|
async read(bytes, allowedPackets, config$1 = config) {
|
|
24311
|
+
if (config$1.additionalAllowedPackets.length) {
|
|
24312
|
+
allowedPackets = { ...allowedPackets, ...util.constructAllowedPackets(config$1.additionalAllowedPackets) };
|
|
24313
|
+
}
|
|
23938
24314
|
this.stream = transformPair(bytes, async (readable, writable) => {
|
|
23939
24315
|
const writer = getWriter(writable);
|
|
23940
24316
|
try {
|
|
@@ -24702,166 +25078,6 @@ class PublicKeyEncryptedSessionKeyPacket {
|
|
|
24702
25078
|
|
|
24703
25079
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
24704
25080
|
|
|
24705
|
-
class S2K {
|
|
24706
|
-
/**
|
|
24707
|
-
* @param {Object} [config] - Full configuration, defaults to openpgp.config
|
|
24708
|
-
*/
|
|
24709
|
-
constructor(config$1 = config) {
|
|
24710
|
-
/**
|
|
24711
|
-
* Hash function identifier, or 0 for gnu-dummy keys
|
|
24712
|
-
* @type {module:enums.hash | 0}
|
|
24713
|
-
*/
|
|
24714
|
-
this.algorithm = enums.hash.sha256;
|
|
24715
|
-
/**
|
|
24716
|
-
* enums.s2k identifier or 'gnu-dummy'
|
|
24717
|
-
* @type {String}
|
|
24718
|
-
*/
|
|
24719
|
-
this.type = 'iterated';
|
|
24720
|
-
/** @type {Integer} */
|
|
24721
|
-
this.c = config$1.s2kIterationCountByte;
|
|
24722
|
-
/** Eight bytes of salt in a binary string.
|
|
24723
|
-
* @type {Uint8Array}
|
|
24724
|
-
*/
|
|
24725
|
-
this.salt = null;
|
|
24726
|
-
}
|
|
24727
|
-
|
|
24728
|
-
getCount() {
|
|
24729
|
-
// Exponent bias, defined in RFC4880
|
|
24730
|
-
const expbias = 6;
|
|
24731
|
-
|
|
24732
|
-
return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
|
|
24733
|
-
}
|
|
24734
|
-
|
|
24735
|
-
/**
|
|
24736
|
-
* Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
|
|
24737
|
-
* @param {Uint8Array} bytes - Payload of string-to-key specifier
|
|
24738
|
-
* @returns {Integer} Actual length of the object.
|
|
24739
|
-
*/
|
|
24740
|
-
read(bytes) {
|
|
24741
|
-
let i = 0;
|
|
24742
|
-
this.type = enums.read(enums.s2k, bytes[i++]);
|
|
24743
|
-
this.algorithm = bytes[i++];
|
|
24744
|
-
|
|
24745
|
-
switch (this.type) {
|
|
24746
|
-
case 'simple':
|
|
24747
|
-
break;
|
|
24748
|
-
|
|
24749
|
-
case 'salted':
|
|
24750
|
-
this.salt = bytes.subarray(i, i + 8);
|
|
24751
|
-
i += 8;
|
|
24752
|
-
break;
|
|
24753
|
-
|
|
24754
|
-
case 'iterated':
|
|
24755
|
-
this.salt = bytes.subarray(i, i + 8);
|
|
24756
|
-
i += 8;
|
|
24757
|
-
|
|
24758
|
-
// Octet 10: count, a one-octet, coded value
|
|
24759
|
-
this.c = bytes[i++];
|
|
24760
|
-
break;
|
|
24761
|
-
|
|
24762
|
-
case 'gnu':
|
|
24763
|
-
if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
|
|
24764
|
-
i += 3; // GNU
|
|
24765
|
-
const gnuExtType = 1000 + bytes[i++];
|
|
24766
|
-
if (gnuExtType === 1001) {
|
|
24767
|
-
this.type = 'gnu-dummy';
|
|
24768
|
-
// GnuPG extension mode 1001 -- don't write secret key at all
|
|
24769
|
-
} else {
|
|
24770
|
-
throw new Error('Unknown s2k gnu protection mode.');
|
|
24771
|
-
}
|
|
24772
|
-
} else {
|
|
24773
|
-
throw new Error('Unknown s2k type.');
|
|
24774
|
-
}
|
|
24775
|
-
break;
|
|
24776
|
-
|
|
24777
|
-
default:
|
|
24778
|
-
throw new Error('Unknown s2k type.');
|
|
24779
|
-
}
|
|
24780
|
-
|
|
24781
|
-
return i;
|
|
24782
|
-
}
|
|
24783
|
-
|
|
24784
|
-
/**
|
|
24785
|
-
* Serializes s2k information
|
|
24786
|
-
* @returns {Uint8Array} Binary representation of s2k.
|
|
24787
|
-
*/
|
|
24788
|
-
write() {
|
|
24789
|
-
if (this.type === 'gnu-dummy') {
|
|
24790
|
-
return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
|
|
24791
|
-
}
|
|
24792
|
-
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
|
|
24793
|
-
|
|
24794
|
-
switch (this.type) {
|
|
24795
|
-
case 'simple':
|
|
24796
|
-
break;
|
|
24797
|
-
case 'salted':
|
|
24798
|
-
arr.push(this.salt);
|
|
24799
|
-
break;
|
|
24800
|
-
case 'iterated':
|
|
24801
|
-
arr.push(this.salt);
|
|
24802
|
-
arr.push(new Uint8Array([this.c]));
|
|
24803
|
-
break;
|
|
24804
|
-
case 'gnu':
|
|
24805
|
-
throw new Error('GNU s2k type not supported.');
|
|
24806
|
-
default:
|
|
24807
|
-
throw new Error('Unknown s2k type.');
|
|
24808
|
-
}
|
|
24809
|
-
|
|
24810
|
-
return util.concatUint8Array(arr);
|
|
24811
|
-
}
|
|
24812
|
-
|
|
24813
|
-
/**
|
|
24814
|
-
* Produces a key using the specified passphrase and the defined
|
|
24815
|
-
* hashAlgorithm
|
|
24816
|
-
* @param {String} passphrase - Passphrase containing user input
|
|
24817
|
-
* @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
|
|
24818
|
-
* hashAlgorithm hash length
|
|
24819
|
-
* @async
|
|
24820
|
-
*/
|
|
24821
|
-
async produceKey(passphrase, numBytes) {
|
|
24822
|
-
passphrase = util.encodeUTF8(passphrase);
|
|
24823
|
-
|
|
24824
|
-
const arr = [];
|
|
24825
|
-
let rlength = 0;
|
|
24826
|
-
|
|
24827
|
-
let prefixlen = 0;
|
|
24828
|
-
while (rlength < numBytes) {
|
|
24829
|
-
let toHash;
|
|
24830
|
-
switch (this.type) {
|
|
24831
|
-
case 'simple':
|
|
24832
|
-
toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
|
|
24833
|
-
break;
|
|
24834
|
-
case 'salted':
|
|
24835
|
-
toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
|
|
24836
|
-
break;
|
|
24837
|
-
case 'iterated': {
|
|
24838
|
-
const data = util.concatUint8Array([this.salt, passphrase]);
|
|
24839
|
-
let datalen = data.length;
|
|
24840
|
-
const count = Math.max(this.getCount(), datalen);
|
|
24841
|
-
toHash = new Uint8Array(prefixlen + count);
|
|
24842
|
-
toHash.set(data, prefixlen);
|
|
24843
|
-
for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
|
|
24844
|
-
toHash.copyWithin(pos, prefixlen, pos);
|
|
24845
|
-
}
|
|
24846
|
-
break;
|
|
24847
|
-
}
|
|
24848
|
-
case 'gnu':
|
|
24849
|
-
throw new Error('GNU s2k type not supported.');
|
|
24850
|
-
default:
|
|
24851
|
-
throw new Error('Unknown s2k type.');
|
|
24852
|
-
}
|
|
24853
|
-
const result = await mod.hash.digest(this.algorithm, toHash);
|
|
24854
|
-
arr.push(result);
|
|
24855
|
-
rlength += result.length;
|
|
24856
|
-
prefixlen++;
|
|
24857
|
-
}
|
|
24858
|
-
|
|
24859
|
-
return util.concatUint8Array(arr).subarray(0, numBytes);
|
|
24860
|
-
}
|
|
24861
|
-
}
|
|
24862
|
-
|
|
24863
|
-
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
24864
|
-
|
|
24865
25081
|
/**
|
|
24866
25082
|
* Symmetric-Key Encrypted Session Key Packets (Tag 3)
|
|
24867
25083
|
*
|
|
@@ -24929,7 +25145,8 @@ class SymEncryptedSessionKeyPacket {
|
|
|
24929
25145
|
}
|
|
24930
25146
|
|
|
24931
25147
|
// A string-to-key (S2K) specifier, length as defined above.
|
|
24932
|
-
|
|
25148
|
+
const s2kType = bytes[offset++];
|
|
25149
|
+
this.s2k = newS2KFromType(s2kType);
|
|
24933
25150
|
offset += this.s2k.read(bytes.subarray(offset, bytes.length));
|
|
24934
25151
|
|
|
24935
25152
|
if (this.version === 5) {
|
|
@@ -25018,8 +25235,8 @@ class SymEncryptedSessionKeyPacket {
|
|
|
25018
25235
|
|
|
25019
25236
|
this.sessionKeyEncryptionAlgorithm = algo;
|
|
25020
25237
|
|
|
25021
|
-
this.s2k =
|
|
25022
|
-
this.s2k.
|
|
25238
|
+
this.s2k = newS2KFromConfig(config$1);
|
|
25239
|
+
this.s2k.generateSalt();
|
|
25023
25240
|
|
|
25024
25241
|
const { blockSize, keySize } = mod.getCipher(algo);
|
|
25025
25242
|
const encryptionKey = await this.s2k.produceKey(passphrase, keySize);
|
|
@@ -25645,7 +25862,8 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25645
25862
|
// - [Optional] If string-to-key usage octet was 255, 254, or 253, a
|
|
25646
25863
|
// string-to-key specifier. The length of the string-to-key
|
|
25647
25864
|
// specifier is implied by its type, as described above.
|
|
25648
|
-
|
|
25865
|
+
const s2kType = bytes[i++];
|
|
25866
|
+
this.s2k = newS2KFromType(s2kType);
|
|
25649
25867
|
i += this.s2k.read(bytes.subarray(i, bytes.length));
|
|
25650
25868
|
|
|
25651
25869
|
if (this.s2k.type === 'gnu-dummy') {
|
|
@@ -25783,7 +26001,7 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25783
26001
|
}
|
|
25784
26002
|
this.isEncrypted = null;
|
|
25785
26003
|
this.keyMaterial = null;
|
|
25786
|
-
this.s2k =
|
|
26004
|
+
this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
|
|
25787
26005
|
this.s2k.algorithm = 0;
|
|
25788
26006
|
this.s2k.c = 0;
|
|
25789
26007
|
this.s2k.type = 'gnu-dummy';
|
|
@@ -25814,8 +26032,8 @@ class SecretKeyPacket extends PublicKeyPacket {
|
|
|
25814
26032
|
throw new Error('A non-empty passphrase is required for key encryption.');
|
|
25815
26033
|
}
|
|
25816
26034
|
|
|
25817
|
-
this.s2k =
|
|
25818
|
-
this.s2k.
|
|
26035
|
+
this.s2k = newS2KFromConfig(config$1);
|
|
26036
|
+
this.s2k.generateSalt();
|
|
25819
26037
|
const cleartext = mod.serializeParams(this.algorithm, this.privateParams);
|
|
25820
26038
|
this.symmetric = enums.symmetric.aes256;
|
|
25821
26039
|
const key = await produceEncryptionKey(this.s2k, passphrase, this.symmetric);
|
|
@@ -27646,7 +27864,8 @@ function isValidDecryptionKeyPacket(signature, config) {
|
|
|
27646
27864
|
|
|
27647
27865
|
return !signature.keyFlags ||
|
|
27648
27866
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27649
|
-
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0
|
|
27867
|
+
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0 ||
|
|
27868
|
+
(config.allowForwardedMessages && (signature.keyFlags[0] & enums.keyFlags.forwardedCommunication) !== 0);
|
|
27650
27869
|
}
|
|
27651
27870
|
|
|
27652
27871
|
/**
|
|
@@ -28594,7 +28813,7 @@ class Key {
|
|
|
28594
28813
|
throw exception || new Error('Could not find primary user');
|
|
28595
28814
|
}
|
|
28596
28815
|
await Promise.all(users.map(async function (a) {
|
|
28597
|
-
return a.
|
|
28816
|
+
return a.selfCertification.revoked || a.user.isRevoked(a.selfCertification, null, date, config$1);
|
|
28598
28817
|
}));
|
|
28599
28818
|
// sort by primary user flag and signature creation time
|
|
28600
28819
|
const primaryUser = users.sort(function(a, b) {
|
|
@@ -28817,7 +29036,8 @@ class Key {
|
|
|
28817
29036
|
|
|
28818
29037
|
results.push(...signatures.map(
|
|
28819
29038
|
signature => ({
|
|
28820
|
-
userID: user.userID.userID,
|
|
29039
|
+
userID: user.userID ? user.userID.userID : null,
|
|
29040
|
+
userAttribute: user.userAttribute,
|
|
28821
29041
|
keyID: signature.keyID,
|
|
28822
29042
|
valid: signature.valid
|
|
28823
29043
|
}))
|
|
@@ -29693,6 +29913,9 @@ class Message {
|
|
|
29693
29913
|
decryptedSessionKeyPackets.push(skeskPacket);
|
|
29694
29914
|
} catch (err) {
|
|
29695
29915
|
util.printDebugError(err);
|
|
29916
|
+
if (err instanceof Argon2OutOfMemoryError) {
|
|
29917
|
+
exception = err;
|
|
29918
|
+
}
|
|
29696
29919
|
}
|
|
29697
29920
|
}));
|
|
29698
29921
|
}));
|
|
@@ -43840,4 +44063,716 @@ var elliptic$1 = /*#__PURE__*/Object.freeze({
|
|
|
43840
44063
|
__moduleExports: elliptic_1
|
|
43841
44064
|
});
|
|
43842
44065
|
|
|
43843
|
-
|
|
44066
|
+
// Adapted from the reference implementation in RFC7693
|
|
44067
|
+
// Initial port to Javascript by https://github.com/dcposch and https://github.com/emilbayes
|
|
44068
|
+
|
|
44069
|
+
// Uint64 values are represented using two Uint32s, stored as little endian
|
|
44070
|
+
// NB: Uint32Arrays endianness depends on the underlying system, so for interoperability, conversions between Uint8Array and Uint32Arrays
|
|
44071
|
+
// need to be manually handled
|
|
44072
|
+
|
|
44073
|
+
// 64-bit unsigned addition (little endian, in place)
|
|
44074
|
+
// Sets a[i,i+1] += b[j,j+1]
|
|
44075
|
+
// `a` and `b` must be Uint32Array(2)
|
|
44076
|
+
function ADD64 (a, i, b, j) {
|
|
44077
|
+
a[i] += b[j];
|
|
44078
|
+
a[i+1] += b[j+1] + (a[i] < b[j]); // add carry
|
|
44079
|
+
}
|
|
44080
|
+
|
|
44081
|
+
// Increment 64-bit little-endian unsigned value by `c` (in place)
|
|
44082
|
+
// `a` must be Uint32Array(2)
|
|
44083
|
+
function INC64 (a, c) {
|
|
44084
|
+
a[0] += c;
|
|
44085
|
+
a[1] += (a[0] < c);
|
|
44086
|
+
}
|
|
44087
|
+
|
|
44088
|
+
// G Mixing function
|
|
44089
|
+
// The ROTRs are inlined for speed
|
|
44090
|
+
function G (v, m, a, b, c, d, ix, iy) {
|
|
44091
|
+
ADD64(v, a, v, b); // v[a,a+1] += v[b,b+1]
|
|
44092
|
+
ADD64(v, a, m, ix); // v[a, a+1] += x ... x0
|
|
44093
|
+
|
|
44094
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
|
|
44095
|
+
let xor0 = v[d] ^ v[a];
|
|
44096
|
+
let xor1 = v[d + 1] ^ v[a + 1];
|
|
44097
|
+
v[d] = xor1;
|
|
44098
|
+
v[d + 1] = xor0;
|
|
44099
|
+
|
|
44100
|
+
ADD64(v, c, v, d);
|
|
44101
|
+
|
|
44102
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
|
|
44103
|
+
xor0 = v[b] ^ v[c];
|
|
44104
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
44105
|
+
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
|
|
44106
|
+
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
|
|
44107
|
+
|
|
44108
|
+
ADD64(v, a, v, b);
|
|
44109
|
+
ADD64(v, a, m, iy);
|
|
44110
|
+
|
|
44111
|
+
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
|
|
44112
|
+
xor0 = v[d] ^ v[a];
|
|
44113
|
+
xor1 = v[d + 1] ^ v[a + 1];
|
|
44114
|
+
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
|
|
44115
|
+
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
|
|
44116
|
+
|
|
44117
|
+
ADD64(v, c, v, d);
|
|
44118
|
+
|
|
44119
|
+
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
|
|
44120
|
+
xor0 = v[b] ^ v[c];
|
|
44121
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
44122
|
+
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
|
|
44123
|
+
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
|
|
44124
|
+
}
|
|
44125
|
+
|
|
44126
|
+
// Initialization Vector
|
|
44127
|
+
const BLAKE2B_IV32 = new Uint32Array([
|
|
44128
|
+
0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85,
|
|
44129
|
+
0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A,
|
|
44130
|
+
0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C,
|
|
44131
|
+
0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19
|
|
44132
|
+
]);
|
|
44133
|
+
|
|
44134
|
+
// These are offsets into a Uint64 buffer.
|
|
44135
|
+
// Multiply them all by 2 to make them offsets into a Uint32 buffer
|
|
44136
|
+
const SIGMA = new Uint8Array([
|
|
44137
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
44138
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
|
|
44139
|
+
11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
|
|
44140
|
+
7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
|
|
44141
|
+
9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
|
|
44142
|
+
2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
|
|
44143
|
+
12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,
|
|
44144
|
+
13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,
|
|
44145
|
+
6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,
|
|
44146
|
+
10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,
|
|
44147
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
44148
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3
|
|
44149
|
+
].map(x => x * 2));
|
|
44150
|
+
|
|
44151
|
+
// Compression function. 'last' flag indicates last block.
|
|
44152
|
+
// Note: we're representing 16 uint64s as 32 uint32s
|
|
44153
|
+
function compress(S, last) {
|
|
44154
|
+
const v = new Uint32Array(32);
|
|
44155
|
+
const m = new Uint32Array(S.b.buffer, S.b.byteOffset, 32);
|
|
44156
|
+
|
|
44157
|
+
// init work variables
|
|
44158
|
+
for (let i = 0; i < 16; i++) {
|
|
44159
|
+
v[i] = S.h[i];
|
|
44160
|
+
v[i + 16] = BLAKE2B_IV32[i];
|
|
44161
|
+
}
|
|
44162
|
+
|
|
44163
|
+
// low 64 bits of offset
|
|
44164
|
+
v[24] ^= S.t0[0];
|
|
44165
|
+
v[25] ^= S.t0[1];
|
|
44166
|
+
// high 64 bits not supported (`t1`), offset may not be higher than 2**53-1
|
|
44167
|
+
|
|
44168
|
+
// if last block
|
|
44169
|
+
const f0 = last ? 0xFFFFFFFF : 0;
|
|
44170
|
+
v[28] ^= f0;
|
|
44171
|
+
v[29] ^= f0;
|
|
44172
|
+
|
|
44173
|
+
// twelve rounds of mixing
|
|
44174
|
+
for (let i = 0; i < 12; i++) {
|
|
44175
|
+
// ROUND(r)
|
|
44176
|
+
const i16 = i << 4;
|
|
44177
|
+
G(v, m, 0, 8, 16, 24, SIGMA[i16 + 0], SIGMA[i16 + 1]);
|
|
44178
|
+
G(v, m, 2, 10, 18, 26, SIGMA[i16 + 2], SIGMA[i16 + 3]);
|
|
44179
|
+
G(v, m, 4, 12, 20, 28, SIGMA[i16 + 4], SIGMA[i16 + 5]);
|
|
44180
|
+
G(v, m, 6, 14, 22, 30, SIGMA[i16 + 6], SIGMA[i16 + 7]);
|
|
44181
|
+
G(v, m, 0, 10, 20, 30, SIGMA[i16 + 8], SIGMA[i16 + 9]);
|
|
44182
|
+
G(v, m, 2, 12, 22, 24, SIGMA[i16 + 10], SIGMA[i16 + 11]);
|
|
44183
|
+
G(v, m, 4, 14, 16, 26, SIGMA[i16 + 12], SIGMA[i16 + 13]);
|
|
44184
|
+
G(v, m, 6, 8, 18, 28, SIGMA[i16 + 14], SIGMA[i16 + 15]);
|
|
44185
|
+
}
|
|
44186
|
+
|
|
44187
|
+
for (let i = 0; i < 16; i++) {
|
|
44188
|
+
S.h[i] ^= v[i] ^ v[i + 16];
|
|
44189
|
+
}
|
|
44190
|
+
}
|
|
44191
|
+
|
|
44192
|
+
// Creates a BLAKE2b hashing context
|
|
44193
|
+
// Requires an output length between 1 and 64 bytes
|
|
44194
|
+
// Takes an optional Uint8Array key
|
|
44195
|
+
class Blake2b {
|
|
44196
|
+
constructor(outlen, key, salt, personal) {
|
|
44197
|
+
const params = new Uint8Array(64);
|
|
44198
|
+
// 0: outlen, keylen, fanout, depth
|
|
44199
|
+
// 4: leaf length, sequential mode
|
|
44200
|
+
// 8: node offset
|
|
44201
|
+
// 12: node offset
|
|
44202
|
+
// 16: node depth, inner length, rfu
|
|
44203
|
+
// 20: rfu
|
|
44204
|
+
// 24: rfu
|
|
44205
|
+
// 28: rfu
|
|
44206
|
+
// 32: salt
|
|
44207
|
+
// 36: salt
|
|
44208
|
+
// 40: salt
|
|
44209
|
+
// 44: salt
|
|
44210
|
+
// 48: personal
|
|
44211
|
+
// 52: personal
|
|
44212
|
+
// 56: personal
|
|
44213
|
+
// 60: personal
|
|
44214
|
+
|
|
44215
|
+
// init internal state
|
|
44216
|
+
this.S = {
|
|
44217
|
+
b: new Uint8Array(BLOCKBYTES),
|
|
44218
|
+
h: new Uint32Array(OUTBYTES_MAX / 4),
|
|
44219
|
+
t0: new Uint32Array(2), // input counter `t`, lower 64-bits only
|
|
44220
|
+
c: 0, // `fill`, pointer within buffer, up to `BLOCKBYTES`
|
|
44221
|
+
outlen // output length in bytes
|
|
44222
|
+
};
|
|
44223
|
+
|
|
44224
|
+
// init parameter block
|
|
44225
|
+
params[0] = outlen;
|
|
44226
|
+
if (key) params[1] = key.length;
|
|
44227
|
+
params[2] = 1; // fanout
|
|
44228
|
+
params[3] = 1; // depth
|
|
44229
|
+
if (salt) params.set(salt, 32);
|
|
44230
|
+
if (personal) params.set(personal, 48);
|
|
44231
|
+
const params32 = new Uint32Array(params.buffer, params.byteOffset, params.length / Uint32Array.BYTES_PER_ELEMENT);
|
|
44232
|
+
|
|
44233
|
+
// initialize hash state
|
|
44234
|
+
for (let i = 0; i < 16; i++) {
|
|
44235
|
+
this.S.h[i] = BLAKE2B_IV32[i] ^ params32[i];
|
|
44236
|
+
}
|
|
44237
|
+
|
|
44238
|
+
// key the hash, if applicable
|
|
44239
|
+
if (key) {
|
|
44240
|
+
const block = new Uint8Array(BLOCKBYTES);
|
|
44241
|
+
block.set(key);
|
|
44242
|
+
this.update(block);
|
|
44243
|
+
}
|
|
44244
|
+
}
|
|
44245
|
+
|
|
44246
|
+
// Updates a BLAKE2b streaming hash
|
|
44247
|
+
// Requires Uint8Array (byte array)
|
|
44248
|
+
update(input) {
|
|
44249
|
+
if (!(input instanceof Uint8Array)) throw new Error('Input must be Uint8Array or Buffer')
|
|
44250
|
+
// for (let i = 0; i < input.length; i++) {
|
|
44251
|
+
// if (this.S.c === BLOCKBYTES) { // buffer full
|
|
44252
|
+
// INC64(this.S.t0, this.S.c) // add counters
|
|
44253
|
+
// compress(this.S, false)
|
|
44254
|
+
// this.S.c = 0 // empty buffer
|
|
44255
|
+
// }
|
|
44256
|
+
// this.S.b[this.S.c++] = input[i]
|
|
44257
|
+
// }
|
|
44258
|
+
let i = 0;
|
|
44259
|
+
while(i < input.length) {
|
|
44260
|
+
if (this.S.c === BLOCKBYTES) { // buffer full
|
|
44261
|
+
INC64(this.S.t0, this.S.c); // add counters
|
|
44262
|
+
compress(this.S, false);
|
|
44263
|
+
this.S.c = 0; // empty buffer
|
|
44264
|
+
}
|
|
44265
|
+
let left = BLOCKBYTES - this.S.c;
|
|
44266
|
+
this.S.b.set(input.subarray(i, i + left), this.S.c); // end index can be out of bounds
|
|
44267
|
+
const fill = Math.min(left, input.length - i);
|
|
44268
|
+
this.S.c += fill;
|
|
44269
|
+
i += fill;
|
|
44270
|
+
}
|
|
44271
|
+
return this
|
|
44272
|
+
}
|
|
44273
|
+
|
|
44274
|
+
/**
|
|
44275
|
+
* Return a BLAKE2b hash, either filling the given Uint8Array or allocating a new one
|
|
44276
|
+
* @param {Uint8Array} [prealloc] - optional preallocated buffer
|
|
44277
|
+
* @returns {ArrayBuffer} message digest
|
|
44278
|
+
*/
|
|
44279
|
+
digest(prealloc) {
|
|
44280
|
+
INC64(this.S.t0, this.S.c); // mark last block offset
|
|
44281
|
+
|
|
44282
|
+
// final block, padded
|
|
44283
|
+
this.S.b.fill(0, this.S.c);
|
|
44284
|
+
this.S.c = BLOCKBYTES;
|
|
44285
|
+
compress(this.S, true);
|
|
44286
|
+
|
|
44287
|
+
const out = prealloc || new Uint8Array(this.S.outlen);
|
|
44288
|
+
for (let i = 0; i < this.S.outlen; i++) {
|
|
44289
|
+
// must be loaded individually since default Uint32 endianness is platform dependant
|
|
44290
|
+
out[i] = this.S.h[i >> 2] >> (8 * (i & 3));
|
|
44291
|
+
}
|
|
44292
|
+
this.S.h = null; // prevent calling `update` after `digest`
|
|
44293
|
+
return out.buffer;
|
|
44294
|
+
}
|
|
44295
|
+
}
|
|
44296
|
+
|
|
44297
|
+
|
|
44298
|
+
function createHash(outlen, key, salt, personal) {
|
|
44299
|
+
if (outlen > OUTBYTES_MAX) throw new Error(`outlen must be at most ${OUTBYTES_MAX} (given: ${outlen})`)
|
|
44300
|
+
if (key) {
|
|
44301
|
+
if (!(key instanceof Uint8Array)) throw new Error('key must be Uint8Array or Buffer')
|
|
44302
|
+
if (key.length > KEYBYTES_MAX) throw new Error(`key size must be at most ${KEYBYTES_MAX} (given: ${key.length})`)
|
|
44303
|
+
}
|
|
44304
|
+
if (salt) {
|
|
44305
|
+
if (!(salt instanceof Uint8Array)) throw new Error('salt must be Uint8Array or Buffer')
|
|
44306
|
+
if (salt.length !== SALTBYTES) throw new Error(`salt must be exactly ${SALTBYTES} (given: ${salt.length}`)
|
|
44307
|
+
}
|
|
44308
|
+
if (personal) {
|
|
44309
|
+
if (!(personal instanceof Uint8Array)) throw new Error('personal must be Uint8Array or Buffer')
|
|
44310
|
+
if (personal.length !== PERSONALBYTES) throw new Error(`salt must be exactly ${PERSONALBYTES} (given: ${personal.length}`)
|
|
44311
|
+
}
|
|
44312
|
+
|
|
44313
|
+
return new Blake2b(outlen, key, salt, personal)
|
|
44314
|
+
}
|
|
44315
|
+
|
|
44316
|
+
const OUTBYTES_MAX = 64;
|
|
44317
|
+
const KEYBYTES_MAX = 64;
|
|
44318
|
+
const SALTBYTES = 16;
|
|
44319
|
+
const PERSONALBYTES = 16;
|
|
44320
|
+
const BLOCKBYTES = 128;
|
|
44321
|
+
|
|
44322
|
+
const TYPE$2 = 2; // Argon2id
|
|
44323
|
+
const VERSION$4 = 0x13;
|
|
44324
|
+
const TAGBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
|
|
44325
|
+
const TAGBYTES_MIN = 4; // Math.pow(2, 32) - 1;
|
|
44326
|
+
const SALTBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
|
|
44327
|
+
const SALTBYTES_MIN = 8;
|
|
44328
|
+
const passwordBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
|
|
44329
|
+
const passwordBYTES_MIN = 8;
|
|
44330
|
+
const MEMBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
|
|
44331
|
+
const ADBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1; // associated data (optional)
|
|
44332
|
+
const SECRETBYTES_MAX = 32; // key (optional)
|
|
44333
|
+
|
|
44334
|
+
const ARGON2_BLOCK_SIZE = 1024;
|
|
44335
|
+
const ARGON2_PREHASH_DIGEST_LENGTH = 64;
|
|
44336
|
+
|
|
44337
|
+
const isLittleEndian$1 = new Uint8Array(new Uint16Array([0xabcd]).buffer)[0] === 0xcd;
|
|
44338
|
+
|
|
44339
|
+
// store n as a little-endian 32-bit Uint8Array inside buf (at buf[i:i+3])
|
|
44340
|
+
function LE32(buf, n, i) {
|
|
44341
|
+
buf[i+0] = n;
|
|
44342
|
+
buf[i+1] = n >> 8;
|
|
44343
|
+
buf[i+2] = n >> 16;
|
|
44344
|
+
buf[i+3] = n >> 24;
|
|
44345
|
+
return buf;
|
|
44346
|
+
}
|
|
44347
|
+
|
|
44348
|
+
/**
|
|
44349
|
+
* Store n as a 64-bit LE number in the given buffer (from buf[i] to buf[i+7])
|
|
44350
|
+
* @param {Uint8Array} buf
|
|
44351
|
+
* @param {Number} n
|
|
44352
|
+
* @param {Number} i
|
|
44353
|
+
*/
|
|
44354
|
+
function LE64(buf, n, i) {
|
|
44355
|
+
if (n > Number.MAX_SAFE_INTEGER) throw new Error("LE64: large numbers unsupported");
|
|
44356
|
+
// ECMAScript standard has engines convert numbers to 32-bit integers for bitwise operations
|
|
44357
|
+
// shifting by 32 or more bits is not supported (https://stackoverflow.com/questions/6729122/javascript-bit-shift-number-wraps)
|
|
44358
|
+
// so we manually extract each byte
|
|
44359
|
+
let remainder = n;
|
|
44360
|
+
for (let offset = i; offset < i+7; offset++) { // last byte can be ignored as it would overflow MAX_SAFE_INTEGER
|
|
44361
|
+
buf[offset] = remainder; // implicit & 0xff
|
|
44362
|
+
remainder = (remainder - buf[offset]) / 256;
|
|
44363
|
+
}
|
|
44364
|
+
return buf;
|
|
44365
|
+
}
|
|
44366
|
+
|
|
44367
|
+
/**
|
|
44368
|
+
* Variable-Length Hash Function H'
|
|
44369
|
+
* @param {Number} outlen - T
|
|
44370
|
+
* @param {Uint8Array} X - value to hash
|
|
44371
|
+
* @param {Uint8Array} res - output buffer, of length `outlength` or larger
|
|
44372
|
+
*/
|
|
44373
|
+
function H_(outlen, X, res) {
|
|
44374
|
+
const V = new Uint8Array(64); // no need to keep around all V_i
|
|
44375
|
+
|
|
44376
|
+
const V1_in = new Uint8Array(4 + X.length);
|
|
44377
|
+
LE32(V1_in, outlen, 0);
|
|
44378
|
+
V1_in.set(X, 4);
|
|
44379
|
+
if (outlen <= 64) {
|
|
44380
|
+
// H'^T(A) = H^T(LE32(T)||A)
|
|
44381
|
+
createHash(outlen).update(V1_in).digest(res);
|
|
44382
|
+
return res
|
|
44383
|
+
}
|
|
44384
|
+
|
|
44385
|
+
const r = Math.ceil(outlen / 32) - 2;
|
|
44386
|
+
|
|
44387
|
+
// Let V_i be a 64-byte block and W_i be its first 32 bytes.
|
|
44388
|
+
// V_1 = H^(64)(LE32(T)||A)
|
|
44389
|
+
// V_2 = H^(64)(V_1)
|
|
44390
|
+
// ...
|
|
44391
|
+
// V_r = H^(64)(V_{r-1})
|
|
44392
|
+
// V_{r+1} = H^(T-32*r)(V_{r})
|
|
44393
|
+
// H'^T(X) = W_1 || W_2 || ... || W_r || V_{r+1}
|
|
44394
|
+
for (let i = 0; i < r; i++) {
|
|
44395
|
+
createHash(64).update(i === 0 ? V1_in : V).digest(V);
|
|
44396
|
+
// store W_i in result buffer already
|
|
44397
|
+
res.set(V.subarray(0, 32), i*32);
|
|
44398
|
+
}
|
|
44399
|
+
// V_{r+1}
|
|
44400
|
+
const V_r1 = new Uint8Array(createHash(outlen - 32*r).update(V).digest());
|
|
44401
|
+
res.set(V_r1, r*32);
|
|
44402
|
+
|
|
44403
|
+
return res;
|
|
44404
|
+
}
|
|
44405
|
+
|
|
44406
|
+
// compute buf = xs ^ ys
|
|
44407
|
+
function XOR(wasmContext, buf, xs, ys) {
|
|
44408
|
+
wasmContext.fn.XOR(
|
|
44409
|
+
buf.byteOffset,
|
|
44410
|
+
xs.byteOffset,
|
|
44411
|
+
ys.byteOffset,
|
|
44412
|
+
);
|
|
44413
|
+
return buf
|
|
44414
|
+
}
|
|
44415
|
+
|
|
44416
|
+
/**
|
|
44417
|
+
* @param {Uint8Array} X (read-only)
|
|
44418
|
+
* @param {Uint8Array} Y (read-only)
|
|
44419
|
+
* @param {Uint8Array} R - output buffer
|
|
44420
|
+
* @returns
|
|
44421
|
+
*/
|
|
44422
|
+
function G$1(wasmContext, X, Y, R) {
|
|
44423
|
+
wasmContext.fn.G(
|
|
44424
|
+
X.byteOffset,
|
|
44425
|
+
Y.byteOffset,
|
|
44426
|
+
R.byteOffset,
|
|
44427
|
+
wasmContext.refs.gZ.byteOffset
|
|
44428
|
+
);
|
|
44429
|
+
return R;
|
|
44430
|
+
}
|
|
44431
|
+
|
|
44432
|
+
function G2(wasmContext, X, Y, R) {
|
|
44433
|
+
wasmContext.fn.G2(
|
|
44434
|
+
X.byteOffset,
|
|
44435
|
+
Y.byteOffset,
|
|
44436
|
+
R.byteOffset,
|
|
44437
|
+
wasmContext.refs.gZ.byteOffset
|
|
44438
|
+
);
|
|
44439
|
+
return R;
|
|
44440
|
+
}
|
|
44441
|
+
|
|
44442
|
+
// Generator for data-independent J1, J2. Each `next()` invocation returns a new pair of values.
|
|
44443
|
+
function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLength, segmentOffset) {
|
|
44444
|
+
// For each segment, we do the following. First, we compute the value Z as:
|
|
44445
|
+
// Z= ( LE64(r) || LE64(l) || LE64(sl) || LE64(m') || LE64(t) || LE64(y) )
|
|
44446
|
+
wasmContext.refs.prngTmp.fill(0);
|
|
44447
|
+
const Z = wasmContext.refs.prngTmp.subarray(0, 6 * 8);
|
|
44448
|
+
LE64(Z, pass, 0);
|
|
44449
|
+
LE64(Z, lane, 8);
|
|
44450
|
+
LE64(Z, slice, 16);
|
|
44451
|
+
LE64(Z, m_, 24);
|
|
44452
|
+
LE64(Z, totalPasses, 32);
|
|
44453
|
+
LE64(Z, TYPE$2, 40);
|
|
44454
|
+
|
|
44455
|
+
// Then we compute q/(128*SL) 1024-byte values
|
|
44456
|
+
// G( ZERO(1024),
|
|
44457
|
+
// G( ZERO(1024), Z || LE64(1) || ZERO(968) ) ),
|
|
44458
|
+
// ...,
|
|
44459
|
+
// G( ZERO(1024),
|
|
44460
|
+
// G( ZERO(1024), Z || LE64(q/(128*SL)) || ZERO(968) )),
|
|
44461
|
+
for(let i = 1; i <= segmentLength; i++) {
|
|
44462
|
+
// tmp.set(Z); // no need to re-copy
|
|
44463
|
+
LE64(wasmContext.refs.prngTmp, i, Z.length); // tmp.set(ZER0968) not necessary, memory already zeroed
|
|
44464
|
+
const g2 = G2(wasmContext, wasmContext.refs.ZERO1024, wasmContext.refs.prngTmp, wasmContext.refs.prngR );
|
|
44465
|
+
|
|
44466
|
+
// each invocation of G^2 outputs 1024 bytes that are to be partitioned into 8-bytes values, take as X1 || X2
|
|
44467
|
+
// NB: the first generated pair must be used for the first block of the segment, and so on.
|
|
44468
|
+
// Hence, if some blocks are skipped (e.g. during the first pass), the corresponding J1J2 are discarded based on the given segmentOffset.
|
|
44469
|
+
for(let k = i === 1 ? segmentOffset*8 : 0; k < g2.length; k += 8) {
|
|
44470
|
+
yield g2.subarray(k, k+8);
|
|
44471
|
+
}
|
|
44472
|
+
}
|
|
44473
|
+
return [];
|
|
44474
|
+
}
|
|
44475
|
+
|
|
44476
|
+
function validateParams$7({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
|
|
44477
|
+
const assertLength = (name, value, min, max) => {
|
|
44478
|
+
if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
|
|
44479
|
+
};
|
|
44480
|
+
|
|
44481
|
+
if (type !== TYPE$2 || version !== VERSION$4) throw new Error('Unsupported type or version');
|
|
44482
|
+
assertLength('password', password, passwordBYTES_MIN, passwordBYTES_MAX);
|
|
44483
|
+
assertLength('salt', salt, SALTBYTES_MIN, SALTBYTES_MAX);
|
|
44484
|
+
assertLength('tag', tagLength, TAGBYTES_MIN, TAGBYTES_MAX);
|
|
44485
|
+
assertLength('memory', memorySize, 8*parallelism, MEMBYTES_MAX);
|
|
44486
|
+
// optional fields
|
|
44487
|
+
ad && assertLength('associated data', ad, 0, ADBYTES_MAX);
|
|
44488
|
+
secret && assertLength('secret', secret, 0, SECRETBYTES_MAX);
|
|
44489
|
+
|
|
44490
|
+
return { type, version, tagLength, password, salt, ad, secret, lanes: parallelism, memorySize, passes };
|
|
44491
|
+
}
|
|
44492
|
+
|
|
44493
|
+
const KB = 1024;
|
|
44494
|
+
const WASM_PAGE_SIZE = 64 * KB;
|
|
44495
|
+
|
|
44496
|
+
function argon2id(params, { memory, instance: wasmInstance }) {
|
|
44497
|
+
if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
|
|
44498
|
+
|
|
44499
|
+
const ctx = validateParams$7({ type: TYPE$2, version: VERSION$4, ...params });
|
|
44500
|
+
|
|
44501
|
+
const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
|
|
44502
|
+
const wasmRefs = {};
|
|
44503
|
+
const wasmFn = {};
|
|
44504
|
+
wasmFn.G = wasmG;
|
|
44505
|
+
wasmFn.G2 = wasmG2;
|
|
44506
|
+
wasmFn.XOR = wasmXOR;
|
|
44507
|
+
|
|
44508
|
+
// The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p.
|
|
44509
|
+
const m_ = 4 * ctx.lanes * Math.floor(ctx.memorySize / (4 * ctx.lanes));
|
|
44510
|
+
const requiredMemory = m_ * ARGON2_BLOCK_SIZE + 10 * KB; // Additional KBs for utility references
|
|
44511
|
+
if (memory.buffer.byteLength < requiredMemory) {
|
|
44512
|
+
const missing = Math.ceil((requiredMemory - memory.buffer.byteLength) / WASM_PAGE_SIZE);
|
|
44513
|
+
// If enough memory is available, the `memory.buffer` is internally detached and the reference updated.
|
|
44514
|
+
// Otherwise, the operation fails, and the original memory can still be used.
|
|
44515
|
+
memory.grow(missing);
|
|
44516
|
+
}
|
|
44517
|
+
|
|
44518
|
+
let offset = 0;
|
|
44519
|
+
// Init wasm memory needed in other functions
|
|
44520
|
+
wasmRefs.gZ = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+= wasmRefs.gZ.length;
|
|
44521
|
+
wasmRefs.prngR = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngR.length;
|
|
44522
|
+
wasmRefs.prngTmp = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngTmp.length;
|
|
44523
|
+
wasmRefs.ZERO1024 = new Uint8Array(memory.buffer, offset, 1024); offset+=wasmRefs.ZERO1024.length;
|
|
44524
|
+
// Init wasm memory needed locally
|
|
44525
|
+
const lz = new Uint32Array(memory.buffer, offset, 2); offset+=lz.length * Uint32Array.BYTES_PER_ELEMENT;
|
|
44526
|
+
const wasmContext = { fn: wasmFn, refs: wasmRefs };
|
|
44527
|
+
const newBlock = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=newBlock.length;
|
|
44528
|
+
const blockMemory = new Uint8Array(memory.buffer, offset, ctx.memorySize * ARGON2_BLOCK_SIZE);
|
|
44529
|
+
const allocatedMemory = new Uint8Array(memory.buffer, 0, offset);
|
|
44530
|
+
|
|
44531
|
+
// 1. Establish H_0
|
|
44532
|
+
const H0 = getH0(ctx);
|
|
44533
|
+
|
|
44534
|
+
// 2. Allocate the memory as m' 1024-byte blocks
|
|
44535
|
+
// For p lanes, the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m' / p columns.
|
|
44536
|
+
const q = m_ / ctx.lanes;
|
|
44537
|
+
const B = new Array(ctx.lanes).fill(null).map(() => new Array(q));
|
|
44538
|
+
const initBlock = (i, j) => {
|
|
44539
|
+
B[i][j] = blockMemory.subarray(i*q*1024 + j*1024, (i*q*1024 + j*1024) + ARGON2_BLOCK_SIZE);
|
|
44540
|
+
return B[i][j];
|
|
44541
|
+
};
|
|
44542
|
+
|
|
44543
|
+
for (let i = 0; i < ctx.lanes; i++) {
|
|
44544
|
+
// const LEi = LE0; // since p = 1 for us
|
|
44545
|
+
const tmp = new Uint8Array(H0.length + 8);
|
|
44546
|
+
// 3. Compute B[i][0] for all i ranging from (and including) 0 to (not including) p
|
|
44547
|
+
// B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))
|
|
44548
|
+
tmp.set(H0); LE32(tmp, 0, H0.length); LE32(tmp, i, H0.length + 4);
|
|
44549
|
+
H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 0));
|
|
44550
|
+
// 4. Compute B[i][1] for all i ranging from (and including) 0 to (not including) p
|
|
44551
|
+
// B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))
|
|
44552
|
+
LE32(tmp, 1, H0.length);
|
|
44553
|
+
H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 1));
|
|
44554
|
+
}
|
|
44555
|
+
|
|
44556
|
+
// 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
|
|
44557
|
+
// to (not including) q. The computation MUST proceed slicewise (Section 3.4) : first, blocks from slice 0 are computed for all lanes
|
|
44558
|
+
// (in an arbitrary order of lanes), then blocks from slice 1 are computed, etc.
|
|
44559
|
+
const SL = 4; // vertical slices
|
|
44560
|
+
const segmentLength = q / SL;
|
|
44561
|
+
for (let pass = 0; pass < ctx.passes; pass++) {
|
|
44562
|
+
// 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
|
|
44563
|
+
for (let sl = 0; sl < SL; sl++) {
|
|
44564
|
+
const isDataIndependent = pass === 0 && sl <= 1;
|
|
44565
|
+
for (let i = 0; i < ctx.lanes; i++) { // lane
|
|
44566
|
+
// On the first slice of the first pass, blocks 0 and 1 are already filled
|
|
44567
|
+
let segmentOffset = sl === 0 && pass === 0 ? 2 : 0;
|
|
44568
|
+
// no need to generate all J1J2s, use iterator/generator that creates the value on the fly (to save memory)
|
|
44569
|
+
const PRNG = isDataIndependent ? makePRNG(wasmContext, pass, i, sl, m_, ctx.passes, segmentLength, segmentOffset) : null;
|
|
44570
|
+
for (segmentOffset; segmentOffset < segmentLength; segmentOffset++) {
|
|
44571
|
+
const j = sl * segmentLength + segmentOffset;
|
|
44572
|
+
const prevBlock = j > 0 ? B[i][j-1] : B[i][q-1]; // B[i][(j-1) mod q]
|
|
44573
|
+
|
|
44574
|
+
// we can assume the PRNG is never done
|
|
44575
|
+
const J1J2 = isDataIndependent ? PRNG.next().value : prevBlock; // .subarray(0, 8) not required since we only pass the byteOffset to wasm
|
|
44576
|
+
// The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
|
|
44577
|
+
wasmLZ(lz.byteOffset, J1J2.byteOffset, i, ctx.lanes, pass, sl, segmentOffset, SL, segmentLength);
|
|
44578
|
+
const l = lz[0]; const z = lz[1];
|
|
44579
|
+
// for (let i = 0; i < p; i++ )
|
|
44580
|
+
// B[i][j] = G(B[i][j-1], B[l][z])
|
|
44581
|
+
// The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
|
|
44582
|
+
if (pass === 0) initBlock(i, j);
|
|
44583
|
+
G$1(wasmContext, prevBlock, B[l][z], pass > 0 ? newBlock : B[i][j]);
|
|
44584
|
+
|
|
44585
|
+
// 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
|
|
44586
|
+
if (pass > 0) XOR(wasmContext, B[i][j], newBlock, B[i][j]);
|
|
44587
|
+
}
|
|
44588
|
+
}
|
|
44589
|
+
}
|
|
44590
|
+
}
|
|
44591
|
+
|
|
44592
|
+
// 7. After t steps have been iterated, the final block C is computed as the XOR of the last column:
|
|
44593
|
+
// C = B[0][q-1] XOR B[1][q-1] XOR ... XOR B[p-1][q-1]
|
|
44594
|
+
const C = B[0][q-1];
|
|
44595
|
+
for(let i = 1; i < ctx.lanes; i++) {
|
|
44596
|
+
XOR(wasmContext, C, C, B[i][q-1]);
|
|
44597
|
+
}
|
|
44598
|
+
|
|
44599
|
+
const tag = H_(ctx.tagLength, C, new Uint8Array(ctx.tagLength));
|
|
44600
|
+
// clear memory since the module might be cached
|
|
44601
|
+
allocatedMemory.fill(0); // clear sensitive contents
|
|
44602
|
+
memory.grow(0); // allow deallocation
|
|
44603
|
+
// 8. The output tag is computed as H'^T(C).
|
|
44604
|
+
return tag;
|
|
44605
|
+
|
|
44606
|
+
}
|
|
44607
|
+
|
|
44608
|
+
function getH0(ctx) {
|
|
44609
|
+
const H = createHash(ARGON2_PREHASH_DIGEST_LENGTH);
|
|
44610
|
+
const ZERO32 = new Uint8Array(4);
|
|
44611
|
+
const params = new Uint8Array(24);
|
|
44612
|
+
LE32(params, ctx.lanes, 0);
|
|
44613
|
+
LE32(params, ctx.tagLength, 4);
|
|
44614
|
+
LE32(params, ctx.memorySize, 8);
|
|
44615
|
+
LE32(params, ctx.passes, 12);
|
|
44616
|
+
LE32(params, ctx.version, 16);
|
|
44617
|
+
LE32(params, ctx.type, 20);
|
|
44618
|
+
|
|
44619
|
+
const toHash = [params];
|
|
44620
|
+
if (ctx.password) {
|
|
44621
|
+
toHash.push(LE32(new Uint8Array(4), ctx.password.length, 0));
|
|
44622
|
+
toHash.push(ctx.password);
|
|
44623
|
+
} else {
|
|
44624
|
+
toHash.push(ZERO32); // context.password.length
|
|
44625
|
+
}
|
|
44626
|
+
|
|
44627
|
+
if (ctx.salt) {
|
|
44628
|
+
toHash.push(LE32(new Uint8Array(4), ctx.salt.length, 0));
|
|
44629
|
+
toHash.push(ctx.salt);
|
|
44630
|
+
} else {
|
|
44631
|
+
toHash.push(ZERO32); // context.salt.length
|
|
44632
|
+
}
|
|
44633
|
+
|
|
44634
|
+
if (ctx.secret) {
|
|
44635
|
+
toHash.push(LE32(new Uint8Array(4), ctx.secret.length, 0));
|
|
44636
|
+
toHash.push(ctx.secret);
|
|
44637
|
+
// todo clear secret?
|
|
44638
|
+
} else {
|
|
44639
|
+
toHash.push(ZERO32); // context.secret.length
|
|
44640
|
+
}
|
|
44641
|
+
|
|
44642
|
+
if (ctx.ad) {
|
|
44643
|
+
toHash.push(LE32(new Uint8Array(4), ctx.ad.length, 0));
|
|
44644
|
+
toHash.push(ctx.ad);
|
|
44645
|
+
} else {
|
|
44646
|
+
toHash.push(ZERO32); // context.ad.length
|
|
44647
|
+
}
|
|
44648
|
+
H.update(concatArrays(toHash));
|
|
44649
|
+
|
|
44650
|
+
const outputBuffer = H.digest();
|
|
44651
|
+
return new Uint8Array(outputBuffer);
|
|
44652
|
+
}
|
|
44653
|
+
|
|
44654
|
+
function concatArrays(arrays) {
|
|
44655
|
+
if (arrays.length === 1) return arrays[0];
|
|
44656
|
+
|
|
44657
|
+
let totalLength = 0;
|
|
44658
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
44659
|
+
if (!(arrays[i] instanceof Uint8Array)) {
|
|
44660
|
+
throw new Error('concatArrays: Data must be in the form of a Uint8Array');
|
|
44661
|
+
}
|
|
44662
|
+
|
|
44663
|
+
totalLength += arrays[i].length;
|
|
44664
|
+
}
|
|
44665
|
+
|
|
44666
|
+
const result = new Uint8Array(totalLength);
|
|
44667
|
+
let pos = 0;
|
|
44668
|
+
arrays.forEach((element) => {
|
|
44669
|
+
result.set(element, pos);
|
|
44670
|
+
pos += element.length;
|
|
44671
|
+
});
|
|
44672
|
+
|
|
44673
|
+
return result;
|
|
44674
|
+
}
|
|
44675
|
+
|
|
44676
|
+
let isSIMDSupported;
|
|
44677
|
+
async function wasmLoader(memory, getSIMD, getNonSIMD) {
|
|
44678
|
+
const importObject = { env: { memory } };
|
|
44679
|
+
if (isSIMDSupported === undefined) {
|
|
44680
|
+
try {
|
|
44681
|
+
isSIMDSupported = true; // will be overwritten in the catch
|
|
44682
|
+
return await getSIMD(importObject);
|
|
44683
|
+
} catch(e) {
|
|
44684
|
+
isSIMDSupported = false;
|
|
44685
|
+
}
|
|
44686
|
+
}
|
|
44687
|
+
|
|
44688
|
+
const loader = isSIMDSupported ? getSIMD : getNonSIMD;
|
|
44689
|
+
return loader(importObject);
|
|
44690
|
+
}
|
|
44691
|
+
|
|
44692
|
+
async function setupWasm(getSIMD, getNonSIMD) {
|
|
44693
|
+
const memory = new WebAssembly.Memory({
|
|
44694
|
+
// in pages of 64KiB each
|
|
44695
|
+
// these values need to be compatible with those declared when building in `build-wasm`
|
|
44696
|
+
initial: 1040, // 65MB
|
|
44697
|
+
maximum: 65536, // 4GB
|
|
44698
|
+
});
|
|
44699
|
+
const wasmModule = await wasmLoader(memory, getSIMD, getNonSIMD);
|
|
44700
|
+
|
|
44701
|
+
/**
|
|
44702
|
+
* Argon2id hash function
|
|
44703
|
+
* @callback computeHash
|
|
44704
|
+
* @param {Object} params
|
|
44705
|
+
* @param {Uint8Array} params.password - password
|
|
44706
|
+
* @param {Uint8Array} params.salt - salt
|
|
44707
|
+
* @param {Integer} params.parallelism
|
|
44708
|
+
* @param {Integer} params.passes
|
|
44709
|
+
* @param {Integer} params.memorySize - in kibibytes
|
|
44710
|
+
* @param {Integer} params.tagLength - output tag length
|
|
44711
|
+
* @param {Uint8Array} [params.ad] - associated data (optional)
|
|
44712
|
+
* @param {Uint8Array} [params.secret] - secret data (optional)
|
|
44713
|
+
* @return {Uint8Array} argon2id hash
|
|
44714
|
+
*/
|
|
44715
|
+
const computeHash = (params) => argon2id(params, { instance: wasmModule.instance, memory });
|
|
44716
|
+
|
|
44717
|
+
return computeHash;
|
|
44718
|
+
}
|
|
44719
|
+
|
|
44720
|
+
function _loadWasmModule (sync, filepath, src, imports) {
|
|
44721
|
+
function _instantiateOrCompile(source, imports, stream) {
|
|
44722
|
+
var instantiateFunc = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;
|
|
44723
|
+
var compileFunc = stream ? WebAssembly.compileStreaming : WebAssembly.compile;
|
|
44724
|
+
|
|
44725
|
+
if (imports) {
|
|
44726
|
+
return instantiateFunc(source, imports)
|
|
44727
|
+
} else {
|
|
44728
|
+
return compileFunc(source)
|
|
44729
|
+
}
|
|
44730
|
+
}
|
|
44731
|
+
|
|
44732
|
+
|
|
44733
|
+
var buf = null;
|
|
44734
|
+
if (filepath) {
|
|
44735
|
+
|
|
44736
|
+
var fs = require("fs");
|
|
44737
|
+
var path = require("path");
|
|
44738
|
+
|
|
44739
|
+
return new Promise((resolve, reject) => {
|
|
44740
|
+
fs.readFile(path.resolve(__dirname, filepath), (error, buffer) => {
|
|
44741
|
+
if (error != null) {
|
|
44742
|
+
reject(error);
|
|
44743
|
+
} else {
|
|
44744
|
+
resolve(_instantiateOrCompile(buffer, imports, false));
|
|
44745
|
+
}
|
|
44746
|
+
});
|
|
44747
|
+
});
|
|
44748
|
+
|
|
44749
|
+
}
|
|
44750
|
+
|
|
44751
|
+
|
|
44752
|
+
buf = Buffer.from(src, 'base64');
|
|
44753
|
+
|
|
44754
|
+
|
|
44755
|
+
|
|
44756
|
+
if(sync) {
|
|
44757
|
+
var mod = new WebAssembly.Module(buf);
|
|
44758
|
+
return imports ? new WebAssembly.Instance(mod, imports) : mod
|
|
44759
|
+
} else {
|
|
44760
|
+
return _instantiateOrCompile(buf, imports, false)
|
|
44761
|
+
}
|
|
44762
|
+
}
|
|
44763
|
+
|
|
44764
|
+
function wasmSIMD(imports){return _loadWasmModule(0, null, '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', imports)}
|
|
44765
|
+
|
|
44766
|
+
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)}
|
|
44767
|
+
|
|
44768
|
+
const loadWasm = async () => setupWasm(
|
|
44769
|
+
(instanceObject) => wasmSIMD(instanceObject),
|
|
44770
|
+
(instanceObject) => wasmNonSIMD(instanceObject),
|
|
44771
|
+
);
|
|
44772
|
+
|
|
44773
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
44774
|
+
__proto__: null,
|
|
44775
|
+
'default': loadWasm
|
|
44776
|
+
});
|
|
44777
|
+
|
|
44778
|
+
export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, KDFParams, LiteralDataPacket, MarkerPacket, Message, OnePassSignaturePacket, PacketList, PrivateKey, PublicKey, PublicKeyEncryptedSessionKeyPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, Signature, SignaturePacket, Subkey, SymEncryptedIntegrityProtectedDataPacket, SymEncryptedSessionKeyPacket, SymmetricallyEncryptedDataPacket, TrustPacket, UnparseablePacket, UserAttributePacket, UserIDPacket, armor, config, createCleartextMessage, createMessage, decrypt$4 as decrypt, decryptKey, decryptSessionKeys, encrypt$4 as encrypt, encryptKey, encryptSessionKey, enums, generateKey, generateSessionKey$1 as generateSessionKey, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$5 as sign, unarmor, verify$5 as verify };
|