@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/openpgp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v5.7.0 - 2023-03-06 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
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
  const doneWritingPromise = Symbol('doneWritingPromise');
@@ -1907,7 +1907,7 @@ const util = {
1907
1907
  if (!util.isString(data)) {
1908
1908
  return false;
1909
1909
  }
1910
- 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,}|xn--[a-zA-Z\-0-9]+)))$/;
1910
+ 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]+)))$/;
1911
1911
  return re.test(data);
1912
1912
  },
1913
1913
 
@@ -2303,6 +2303,7 @@ var enums = {
2303
2303
  simple: 0,
2304
2304
  salted: 1,
2305
2305
  iterated: 3,
2306
+ argon2: 4,
2306
2307
  gnu: 101
2307
2308
  },
2308
2309
 
@@ -2617,6 +2618,8 @@ var enums = {
2617
2618
  splitPrivateKey: 16,
2618
2619
  /** 0x20 - This key may be used for authentication. */
2619
2620
  authentication: 32,
2621
+ /** This key may be used for forwarded communications */
2622
+ forwardedCommunication: 64,
2620
2623
  /** 0x80 - The private component of this key may be in the
2621
2624
  * possession of more than one person. */
2622
2625
  sharedPrivateKey: 128
@@ -2767,12 +2770,41 @@ var config = {
2767
2770
  */
2768
2771
  v5Keys: false,
2769
2772
  /**
2770
- * {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3|RFC4880 3.7.1.3}:
2771
- * Iteration Count Byte for S2K (String to Key)
2773
+ * S2K (String to Key) type, used for key derivation in the context of secret key encryption
2774
+ * and password-encrypted data. Weaker s2k options are not allowed.
2775
+ * Note: Argon2 is the strongest option but not all OpenPGP implementations are compatible with it
2776
+ * (pending standardisation).
2777
+ * @memberof module:config
2778
+ * @property {enums.s2k.argon2|enums.s2k.iterated} s2kType {@link module:enums.s2k}
2779
+ */
2780
+ s2kType: enums.s2k.iterated,
2781
+ /**
2782
+ * {@link https://tools.ietf.org/html/rfc4880#section-3.7.1.3| RFC4880 3.7.1.3}:
2783
+ * Iteration Count Byte for Iterated and Salted S2K (String to Key).
2784
+ * Only relevant if `config.s2kType` is set to `enums.s2k.iterated`.
2785
+ * Note: this is the exponent value, not the final number of iterations (refer to specs for more details).
2772
2786
  * @memberof module:config
2773
2787
  * @property {Integer} s2kIterationCountByte
2774
2788
  */
2775
2789
  s2kIterationCountByte: 224,
2790
+ /**
2791
+ * {@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}:
2792
+ * Argon2 parameters for S2K (String to Key).
2793
+ * Only relevant if `config.s2kType` is set to `enums.s2k.argon2`.
2794
+ * Default settings correspond to the second recommendation from RFC9106 ("uniformly safe option"),
2795
+ * to ensure compatibility with memory-constrained environments.
2796
+ * For more details on the choice of parameters, see https://tools.ietf.org/html/rfc9106#section-4.
2797
+ * @memberof module:config
2798
+ * @property {Object} params
2799
+ * @property {Integer} params.passes - number of iterations t
2800
+ * @property {Integer} params.parallelism - degree of parallelism p
2801
+ * @property {Integer} params.memoryExponent - one-octet exponent indicating the memory size, which will be: 2**memoryExponent kibibytes.
2802
+ */
2803
+ s2kArgon2Params: {
2804
+ passes: 3,
2805
+ parallelism: 4, // lanes
2806
+ memoryExponent: 16 // 64 MiB of RAM
2807
+ },
2776
2808
  /**
2777
2809
  * Allow decryption of messages without integrity protection.
2778
2810
  * This is an **insecure** setting:
@@ -2792,6 +2824,13 @@ var config = {
2792
2824
  * @property {Boolean} allowUnauthenticatedStream
2793
2825
  */
2794
2826
  allowUnauthenticatedStream: false,
2827
+ /**
2828
+ * Allow decrypting forwarded messages, using keys with 0x40 ('forwarded communication') flag.
2829
+ * Note: this is related to a **non-standard feature**.
2830
+ * @memberof module:config
2831
+ * @property {Boolean} allowForwardedMessages
2832
+ */
2833
+ allowForwardedMessages: false,
2795
2834
  /**
2796
2835
  * @memberof module:config
2797
2836
  * @property {Boolean} checksumRequired Do not throw error when armor is missing a checksum
@@ -2868,6 +2907,14 @@ var config = {
2868
2907
  * @property {Boolean} ignoreMalformedPackets Ignore malformed packets on parsing instead of throwing an error
2869
2908
  */
2870
2909
  ignoreMalformedPackets: false,
2910
+ /**
2911
+ * Parsing of packets is normally restricted to a predefined set of packets. For example a Sym. Encrypted Integrity Protected Data Packet can only
2912
+ * contain a certain set of packets including LiteralDataPacket. With this setting we can allow additional packets, which is probably not advisable
2913
+ * as a global config setting, but can be used for specific function calls (e.g. decrypt method of Message).
2914
+ * @memberof module:config
2915
+ * @property {Array} additionalAllowedPackets Allow additional packets on parsing. Defined as array of packet classes, e.g. [PublicKeyPacket]
2916
+ */
2917
+ additionalAllowedPackets: [],
2871
2918
  /**
2872
2919
  * @memberof module:config
2873
2920
  * @property {Boolean} showVersion Whether to include {@link module:config/config.versionString} in armored messages
@@ -2882,7 +2929,7 @@ var config = {
2882
2929
  * @memberof module:config
2883
2930
  * @property {String} versionString A version string to be included in armored messages
2884
2931
  */
2885
- versionString: 'OpenPGP.js 5.7.0',
2932
+ versionString: 'OpenPGP.js 5.9.0',
2886
2933
  /**
2887
2934
  * @memberof module:config
2888
2935
  * @property {String} commentString A comment string to be included in armored messages
@@ -14372,7 +14419,7 @@ function buildEcdhParam(public_algo, oid, kdfParams, fingerprint) {
14372
14419
  return util.concatUint8Array([
14373
14420
  oid.write(),
14374
14421
  new Uint8Array([public_algo]),
14375
- kdfParams.replacementKDFParams || kdfParams.write(),
14422
+ kdfParams.write(true),
14376
14423
  util.stringToUint8Array('Anonymous Sender '),
14377
14424
  kdfParams.replacementFingerprint || fingerprint.subarray(0, 20)
14378
14425
  ]);
@@ -15214,32 +15261,28 @@ class ECDHSymmetricKey {
15214
15261
 
15215
15262
  // OpenPGP.js - An OpenPGP implementation in javascript
15216
15263
 
15264
+ const VERSION_FORWARDING = 0xFF;
15265
+
15217
15266
  class KDFParams {
15218
15267
  /**
15219
15268
  * @param {Integer} version Version, defaults to 1
15220
15269
  * @param {enums.hash} hash Hash algorithm
15221
15270
  * @param {enums.symmetric} cipher Symmetric algorithm
15222
- * @param {enums.kdfFlags} flags (v2 only) flags
15223
- * @param {Uint8Array} replacementFingerprint (v2 only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
15224
- * @param {Uint8Array} replacementKDFParams (v2 only) serialized KDF params to use in KDF digest computation
15271
+ * @param {Uint8Array} replacementFingerprint (forwarding only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
15225
15272
  */
15226
15273
  constructor(data) {
15227
15274
  if (data) {
15228
- const { version, hash, cipher, flags, replacementFingerprint, replacementKDFParams } = data;
15275
+ const { version, hash, cipher, replacementFingerprint } = data;
15229
15276
  this.version = version || 1;
15230
15277
  this.hash = hash;
15231
15278
  this.cipher = cipher;
15232
15279
 
15233
- this.flags = flags;
15234
15280
  this.replacementFingerprint = replacementFingerprint;
15235
- this.replacementKDFParams = replacementKDFParams;
15236
15281
  } else {
15237
15282
  this.version = null;
15238
15283
  this.hash = null;
15239
15284
  this.cipher = null;
15240
- this.flags = null;
15241
15285
  this.replacementFingerprint = null;
15242
- this.replacementKDFParams = null;
15243
15286
  }
15244
15287
  }
15245
15288
 
@@ -15249,44 +15292,41 @@ class KDFParams {
15249
15292
  * @returns {Number} Number of read bytes.
15250
15293
  */
15251
15294
  read(input) {
15295
+ const totalBytes = input[0];
15252
15296
  this.version = input[1];
15253
15297
  this.hash = input[2];
15254
15298
  this.cipher = input[3];
15255
15299
  let readBytes = 4;
15256
15300
 
15257
- if (this.version === 2) {
15258
- this.flags = input[readBytes++];
15259
- if (this.flags & enums.kdfFlags.replace_fingerprint) {
15260
- this.replacementFingerprint = input.slice(readBytes, readBytes + 20);
15261
- readBytes += 20;
15262
- }
15263
- if (this.flags & enums.kdfFlags.replace_kdf_params) {
15264
- const fieldLength = input[readBytes] + 1; // account for length
15265
- this.replacementKDFParams = input.slice(readBytes, readBytes + fieldLength);
15266
- readBytes += fieldLength;
15267
- }
15301
+ if (this.version === VERSION_FORWARDING) {
15302
+ const fingerprintLength = totalBytes - readBytes + 1; // acount for length byte
15303
+ this.replacementFingerprint = input.slice(readBytes, readBytes + fingerprintLength);
15304
+ readBytes += fingerprintLength;
15268
15305
  }
15269
15306
  return readBytes;
15270
15307
  }
15271
15308
 
15272
15309
  /**
15273
15310
  * Write KDFParams to an Uint8Array
15311
+ * @param {Boolean} [forReplacementParams] - forwarding only: whether to serialize data to use for replacement params
15274
15312
  * @returns {Uint8Array} Array with the KDFParams value
15275
15313
  */
15276
- write() {
15277
- if (!this.version || this.version === 1) {
15314
+ write(forReplacementParams) {
15315
+ if (!this.version || this.version === 1 || forReplacementParams) {
15278
15316
  return new Uint8Array([3, 1, this.hash, this.cipher]);
15279
15317
  }
15280
15318
 
15281
- const v2Fields = util.concatUint8Array([
15282
- new Uint8Array([4, 2, this.hash, this.cipher, this.flags]),
15283
- this.replacementFingerprint || new Uint8Array(),
15284
- this.replacementKDFParams || new Uint8Array()
15319
+ const forwardingFields = util.concatUint8Array([
15320
+ new Uint8Array([
15321
+ 3 + this.replacementFingerprint.length,
15322
+ this.version,
15323
+ this.hash,
15324
+ this.cipher
15325
+ ]),
15326
+ this.replacementFingerprint
15285
15327
  ]);
15286
15328
 
15287
- // update length field
15288
- v2Fields[0] = v2Fields.length - 1;
15289
- return new Uint8Array(v2Fields);
15329
+ return forwardingFields;
15290
15330
  }
15291
15331
  }
15292
15332
 
@@ -15869,6 +15909,339 @@ const mod = {
15869
15909
 
15870
15910
  Object.assign(mod, crypto$1);
15871
15911
 
15912
+ const ARGON2_TYPE = 0x02; // id
15913
+ const ARGON2_VERSION = 0x13;
15914
+ const ARGON2_SALT_SIZE = 16;
15915
+
15916
+ class Argon2OutOfMemoryError extends Error {
15917
+ constructor(...params) {
15918
+ super(...params);
15919
+
15920
+ if (Error.captureStackTrace) {
15921
+ Error.captureStackTrace(this, Argon2OutOfMemoryError);
15922
+ }
15923
+
15924
+ this.name = 'Argon2OutOfMemoryError';
15925
+ }
15926
+ }
15927
+
15928
+ // cache argon wasm module
15929
+ let loadArgonWasmModule;
15930
+ let argon2Promise;
15931
+ // reload wasm module above this treshold, to deallocated used memory
15932
+ const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
15933
+
15934
+ class Argon2S2K {
15935
+ /**
15936
+ * @param {Object} [config] - Full configuration, defaults to openpgp.config
15937
+ */
15938
+ constructor(config$1 = config) {
15939
+ const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
15940
+
15941
+ this.type = 'argon2';
15942
+ /** @type {Uint8Array} 16 bytes of salt */
15943
+ this.salt = null;
15944
+ /** @type {Integer} number of passes */
15945
+ this.t = passes;
15946
+ /** @type {Integer} degree of parallelism (lanes) */
15947
+ this.p = parallelism;
15948
+ /** @type {Integer} exponent indicating memory size */
15949
+ this.encodedM = memoryExponent;
15950
+ }
15951
+
15952
+ generateSalt() {
15953
+ this.salt = mod.random.getRandomBytes(ARGON2_SALT_SIZE);
15954
+ }
15955
+
15956
+ /**
15957
+ * Parsing function for argon2 string-to-key specifier.
15958
+ * @param {Uint8Array} bytes - Payload of argon2 string-to-key specifier
15959
+ * @returns {Integer} Actual length of the object.
15960
+ */
15961
+ read(bytes) {
15962
+ let i = 0;
15963
+
15964
+ this.salt = bytes.subarray(i, i + 16);
15965
+ i += 16;
15966
+
15967
+ this.t = bytes[i++];
15968
+ this.p = bytes[i++];
15969
+ this.encodedM = bytes[i++]; // memory size exponent, one-octect
15970
+
15971
+ return i;
15972
+ }
15973
+
15974
+ /**
15975
+ * Serializes s2k information
15976
+ * @returns {Uint8Array} Binary representation of s2k.
15977
+ */
15978
+ write() {
15979
+ const arr = [
15980
+ new Uint8Array([enums.write(enums.s2k, this.type)]),
15981
+ this.salt,
15982
+ new Uint8Array([this.t, this.p, this.encodedM])
15983
+ ];
15984
+
15985
+ return util.concatUint8Array(arr);
15986
+ }
15987
+
15988
+ /**
15989
+ * Produces a key using the specified passphrase and the defined
15990
+ * hashAlgorithm
15991
+ * @param {String} passphrase - Passphrase containing user input
15992
+ * @returns {Promise<Uint8Array>} Produced key with a length corresponding to `keySize`
15993
+ * @throws {Argon2OutOfMemoryError|Errors}
15994
+ * @async
15995
+ */
15996
+ async produceKey(passphrase, keySize) {
15997
+ const decodedM = 2 << (this.encodedM - 1);
15998
+
15999
+ try {
16000
+ if (!argon2Promise) { // first load
16001
+ loadArgonWasmModule = loadArgonWasmModule || (await Promise.resolve().then(function () { return index; })).default;
16002
+ argon2Promise = loadArgonWasmModule();
16003
+ }
16004
+ // important to keep local ref to argon2 in case the module is reloaded by another instance
16005
+ const argon2 = await argon2Promise;
16006
+
16007
+ const passwordBytes = util.encodeUTF8(passphrase);
16008
+ const hash = argon2({
16009
+ version: ARGON2_VERSION,
16010
+ type: ARGON2_TYPE,
16011
+ password: passwordBytes,
16012
+ salt: this.salt,
16013
+ tagLength: keySize,
16014
+ memorySize: decodedM,
16015
+ parallelism: this.p,
16016
+ passes: this.t
16017
+ });
16018
+
16019
+ // a lot of memory was used, reload to deallocate
16020
+ if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
16021
+ // it will be awaited if needed at the next `produceKey` invocation
16022
+ argon2Promise = loadArgonWasmModule();
16023
+ }
16024
+ return hash;
16025
+ } catch (e) {
16026
+ if (e.message && (
16027
+ e.message.includes('Unable to grow instance memory') || // Chrome
16028
+ e.message.includes('failed to grow memory') || // Firefox
16029
+ e.message.includes('WebAssembly.Memory.grow') || // Safari
16030
+ e.message.includes('Out of memory') // Safari iOS
16031
+ )) {
16032
+ throw new Argon2OutOfMemoryError('Could not allocate required memory for Argon2');
16033
+ } else {
16034
+ throw e;
16035
+ }
16036
+ }
16037
+ }
16038
+ }
16039
+
16040
+ // GPG4Browsers - An OpenPGP implementation in javascript
16041
+
16042
+ class GenericS2K {
16043
+ /**
16044
+ * @param {Object} [config] - Full configuration, defaults to openpgp.config
16045
+ */
16046
+ constructor(s2kType, config$1 = config) {
16047
+ /**
16048
+ * Hash function identifier, or 0 for gnu-dummy keys
16049
+ * @type {module:enums.hash | 0}
16050
+ */
16051
+ this.algorithm = enums.hash.sha256;
16052
+ /**
16053
+ * enums.s2k identifier or 'gnu-dummy'
16054
+ * @type {String}
16055
+ */
16056
+ this.type = enums.read(enums.s2k, s2kType);
16057
+ /** @type {Integer} */
16058
+ this.c = config$1.s2kIterationCountByte;
16059
+ /** Eight bytes of salt in a binary string.
16060
+ * @type {Uint8Array}
16061
+ */
16062
+ this.salt = null;
16063
+ }
16064
+
16065
+ generateSalt() {
16066
+ switch (this.type) {
16067
+ case 'salted':
16068
+ case 'iterated':
16069
+ this.salt = mod.random.getRandomBytes(8);
16070
+ }
16071
+ }
16072
+
16073
+ getCount() {
16074
+ // Exponent bias, defined in RFC4880
16075
+ const expbias = 6;
16076
+
16077
+ return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
16078
+ }
16079
+
16080
+ /**
16081
+ * Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
16082
+ * @param {Uint8Array} bytes - Payload of string-to-key specifier
16083
+ * @returns {Integer} Actual length of the object.
16084
+ */
16085
+ read(bytes) {
16086
+ let i = 0;
16087
+ this.algorithm = bytes[i++];
16088
+
16089
+ switch (this.type) {
16090
+ case 'simple':
16091
+ break;
16092
+
16093
+ case 'salted':
16094
+ this.salt = bytes.subarray(i, i + 8);
16095
+ i += 8;
16096
+ break;
16097
+
16098
+ case 'iterated':
16099
+ this.salt = bytes.subarray(i, i + 8);
16100
+ i += 8;
16101
+
16102
+ // Octet 10: count, a one-octet, coded value
16103
+ this.c = bytes[i++];
16104
+ break;
16105
+ case 'gnu':
16106
+ if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
16107
+ i += 3; // GNU
16108
+ const gnuExtType = 1000 + bytes[i++];
16109
+ if (gnuExtType === 1001) {
16110
+ this.type = 'gnu-dummy';
16111
+ // GnuPG extension mode 1001 -- don't write secret key at all
16112
+ } else {
16113
+ throw new Error('Unknown s2k gnu protection mode.');
16114
+ }
16115
+ } else {
16116
+ throw new Error('Unknown s2k type.');
16117
+ }
16118
+ break;
16119
+
16120
+ default:
16121
+ throw new Error('Unknown s2k type.');
16122
+ }
16123
+
16124
+ return i;
16125
+ }
16126
+
16127
+ /**
16128
+ * Serializes s2k information
16129
+ * @returns {Uint8Array} Binary representation of s2k.
16130
+ */
16131
+ write() {
16132
+ if (this.type === 'gnu-dummy') {
16133
+ return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
16134
+ }
16135
+ const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
16136
+
16137
+ switch (this.type) {
16138
+ case 'simple':
16139
+ break;
16140
+ case 'salted':
16141
+ arr.push(this.salt);
16142
+ break;
16143
+ case 'iterated':
16144
+ arr.push(this.salt);
16145
+ arr.push(new Uint8Array([this.c]));
16146
+ break;
16147
+ case 'gnu':
16148
+ throw new Error('GNU s2k type not supported.');
16149
+ default:
16150
+ throw new Error('Unknown s2k type.');
16151
+ }
16152
+
16153
+ return util.concatUint8Array(arr);
16154
+ }
16155
+
16156
+ /**
16157
+ * Produces a key using the specified passphrase and the defined
16158
+ * hashAlgorithm
16159
+ * @param {String} passphrase - Passphrase containing user input
16160
+ * @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
16161
+ * hashAlgorithm hash length
16162
+ * @async
16163
+ */
16164
+ async produceKey(passphrase, numBytes) {
16165
+ passphrase = util.encodeUTF8(passphrase);
16166
+
16167
+ const arr = [];
16168
+ let rlength = 0;
16169
+
16170
+ let prefixlen = 0;
16171
+ while (rlength < numBytes) {
16172
+ let toHash;
16173
+ switch (this.type) {
16174
+ case 'simple':
16175
+ toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
16176
+ break;
16177
+ case 'salted':
16178
+ toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
16179
+ break;
16180
+ case 'iterated': {
16181
+ const data = util.concatUint8Array([this.salt, passphrase]);
16182
+ let datalen = data.length;
16183
+ const count = Math.max(this.getCount(), datalen);
16184
+ toHash = new Uint8Array(prefixlen + count);
16185
+ toHash.set(data, prefixlen);
16186
+ for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
16187
+ toHash.copyWithin(pos, prefixlen, pos);
16188
+ }
16189
+ break;
16190
+ }
16191
+ case 'gnu':
16192
+ throw new Error('GNU s2k type not supported.');
16193
+ default:
16194
+ throw new Error('Unknown s2k type.');
16195
+ }
16196
+ const result = await mod.hash.digest(this.algorithm, toHash);
16197
+ arr.push(result);
16198
+ rlength += result.length;
16199
+ prefixlen++;
16200
+ }
16201
+
16202
+ return util.concatUint8Array(arr).subarray(0, numBytes);
16203
+ }
16204
+ }
16205
+
16206
+ const allowedS2KTypesForEncryption = new Set([enums.s2k.argon2, enums.s2k.iterated]);
16207
+
16208
+ /**
16209
+ * Instantiate a new S2K instance of the given type
16210
+ * @param {module:enums.s2k} type
16211
+ * @oaram {Object} [config]
16212
+ * @returns {Object} New s2k object
16213
+ * @throws {Error} for unknown or unsupported types
16214
+ */
16215
+ function newS2KFromType(type, config$1 = config) {
16216
+ switch (type) {
16217
+ case enums.s2k.argon2:
16218
+ return new Argon2S2K(config$1);
16219
+ case enums.s2k.iterated:
16220
+ case enums.s2k.gnu:
16221
+ case enums.s2k.salted:
16222
+ case enums.s2k.simple:
16223
+ return new GenericS2K(type, config$1);
16224
+ default:
16225
+ throw new Error(`Unsupported S2K type ${type}`);
16226
+ }
16227
+ }
16228
+
16229
+ /**
16230
+ * Instantiate a new S2K instance based on the config settings
16231
+ * @oaram {Object} config
16232
+ * @returns {Object} New s2k object
16233
+ * @throws {Error} for unknown or unsupported types
16234
+ */
16235
+ function newS2KFromConfig(config) {
16236
+ const { s2kType } = config;
16237
+
16238
+ if (!allowedS2KTypesForEncryption.has(s2kType)) {
16239
+ throw new Error('The provided `config.s2kType` value is not allowed');
16240
+ }
16241
+
16242
+ return newS2KFromType(s2kType, config);
16243
+ }
16244
+
15872
16245
  var TYPED_OK = typeof Uint8Array !== "undefined" &&
15873
16246
  typeof Uint16Array !== "undefined" &&
15874
16247
  typeof Int32Array !== "undefined";
@@ -23923,6 +24296,9 @@ class PacketList extends Array {
23923
24296
  * @async
23924
24297
  */
23925
24298
  async read(bytes, allowedPackets, config$1 = config) {
24299
+ if (config$1.additionalAllowedPackets.length) {
24300
+ allowedPackets = { ...allowedPackets, ...util.constructAllowedPackets(config$1.additionalAllowedPackets) };
24301
+ }
23926
24302
  this.stream = transformPair(bytes, async (readable, writable) => {
23927
24303
  const writer = getWriter(writable);
23928
24304
  try {
@@ -24690,166 +25066,6 @@ class PublicKeyEncryptedSessionKeyPacket {
24690
25066
 
24691
25067
  // GPG4Browsers - An OpenPGP implementation in javascript
24692
25068
 
24693
- class S2K {
24694
- /**
24695
- * @param {Object} [config] - Full configuration, defaults to openpgp.config
24696
- */
24697
- constructor(config$1 = config) {
24698
- /**
24699
- * Hash function identifier, or 0 for gnu-dummy keys
24700
- * @type {module:enums.hash | 0}
24701
- */
24702
- this.algorithm = enums.hash.sha256;
24703
- /**
24704
- * enums.s2k identifier or 'gnu-dummy'
24705
- * @type {String}
24706
- */
24707
- this.type = 'iterated';
24708
- /** @type {Integer} */
24709
- this.c = config$1.s2kIterationCountByte;
24710
- /** Eight bytes of salt in a binary string.
24711
- * @type {Uint8Array}
24712
- */
24713
- this.salt = null;
24714
- }
24715
-
24716
- getCount() {
24717
- // Exponent bias, defined in RFC4880
24718
- const expbias = 6;
24719
-
24720
- return (16 + (this.c & 15)) << ((this.c >> 4) + expbias);
24721
- }
24722
-
24723
- /**
24724
- * Parsing function for a string-to-key specifier ({@link https://tools.ietf.org/html/rfc4880#section-3.7|RFC 4880 3.7}).
24725
- * @param {Uint8Array} bytes - Payload of string-to-key specifier
24726
- * @returns {Integer} Actual length of the object.
24727
- */
24728
- read(bytes) {
24729
- let i = 0;
24730
- this.type = enums.read(enums.s2k, bytes[i++]);
24731
- this.algorithm = bytes[i++];
24732
-
24733
- switch (this.type) {
24734
- case 'simple':
24735
- break;
24736
-
24737
- case 'salted':
24738
- this.salt = bytes.subarray(i, i + 8);
24739
- i += 8;
24740
- break;
24741
-
24742
- case 'iterated':
24743
- this.salt = bytes.subarray(i, i + 8);
24744
- i += 8;
24745
-
24746
- // Octet 10: count, a one-octet, coded value
24747
- this.c = bytes[i++];
24748
- break;
24749
-
24750
- case 'gnu':
24751
- if (util.uint8ArrayToString(bytes.subarray(i, i + 3)) === 'GNU') {
24752
- i += 3; // GNU
24753
- const gnuExtType = 1000 + bytes[i++];
24754
- if (gnuExtType === 1001) {
24755
- this.type = 'gnu-dummy';
24756
- // GnuPG extension mode 1001 -- don't write secret key at all
24757
- } else {
24758
- throw new Error('Unknown s2k gnu protection mode.');
24759
- }
24760
- } else {
24761
- throw new Error('Unknown s2k type.');
24762
- }
24763
- break;
24764
-
24765
- default:
24766
- throw new Error('Unknown s2k type.');
24767
- }
24768
-
24769
- return i;
24770
- }
24771
-
24772
- /**
24773
- * Serializes s2k information
24774
- * @returns {Uint8Array} Binary representation of s2k.
24775
- */
24776
- write() {
24777
- if (this.type === 'gnu-dummy') {
24778
- return new Uint8Array([101, 0, ...util.stringToUint8Array('GNU'), 1]);
24779
- }
24780
- const arr = [new Uint8Array([enums.write(enums.s2k, this.type), this.algorithm])];
24781
-
24782
- switch (this.type) {
24783
- case 'simple':
24784
- break;
24785
- case 'salted':
24786
- arr.push(this.salt);
24787
- break;
24788
- case 'iterated':
24789
- arr.push(this.salt);
24790
- arr.push(new Uint8Array([this.c]));
24791
- break;
24792
- case 'gnu':
24793
- throw new Error('GNU s2k type not supported.');
24794
- default:
24795
- throw new Error('Unknown s2k type.');
24796
- }
24797
-
24798
- return util.concatUint8Array(arr);
24799
- }
24800
-
24801
- /**
24802
- * Produces a key using the specified passphrase and the defined
24803
- * hashAlgorithm
24804
- * @param {String} passphrase - Passphrase containing user input
24805
- * @returns {Promise<Uint8Array>} Produced key with a length corresponding to.
24806
- * hashAlgorithm hash length
24807
- * @async
24808
- */
24809
- async produceKey(passphrase, numBytes) {
24810
- passphrase = util.encodeUTF8(passphrase);
24811
-
24812
- const arr = [];
24813
- let rlength = 0;
24814
-
24815
- let prefixlen = 0;
24816
- while (rlength < numBytes) {
24817
- let toHash;
24818
- switch (this.type) {
24819
- case 'simple':
24820
- toHash = util.concatUint8Array([new Uint8Array(prefixlen), passphrase]);
24821
- break;
24822
- case 'salted':
24823
- toHash = util.concatUint8Array([new Uint8Array(prefixlen), this.salt, passphrase]);
24824
- break;
24825
- case 'iterated': {
24826
- const data = util.concatUint8Array([this.salt, passphrase]);
24827
- let datalen = data.length;
24828
- const count = Math.max(this.getCount(), datalen);
24829
- toHash = new Uint8Array(prefixlen + count);
24830
- toHash.set(data, prefixlen);
24831
- for (let pos = prefixlen + datalen; pos < count; pos += datalen, datalen *= 2) {
24832
- toHash.copyWithin(pos, prefixlen, pos);
24833
- }
24834
- break;
24835
- }
24836
- case 'gnu':
24837
- throw new Error('GNU s2k type not supported.');
24838
- default:
24839
- throw new Error('Unknown s2k type.');
24840
- }
24841
- const result = await mod.hash.digest(this.algorithm, toHash);
24842
- arr.push(result);
24843
- rlength += result.length;
24844
- prefixlen++;
24845
- }
24846
-
24847
- return util.concatUint8Array(arr).subarray(0, numBytes);
24848
- }
24849
- }
24850
-
24851
- // GPG4Browsers - An OpenPGP implementation in javascript
24852
-
24853
25069
  /**
24854
25070
  * Symmetric-Key Encrypted Session Key Packets (Tag 3)
24855
25071
  *
@@ -24917,7 +25133,8 @@ class SymEncryptedSessionKeyPacket {
24917
25133
  }
24918
25134
 
24919
25135
  // A string-to-key (S2K) specifier, length as defined above.
24920
- this.s2k = new S2K();
25136
+ const s2kType = bytes[offset++];
25137
+ this.s2k = newS2KFromType(s2kType);
24921
25138
  offset += this.s2k.read(bytes.subarray(offset, bytes.length));
24922
25139
 
24923
25140
  if (this.version === 5) {
@@ -25006,8 +25223,8 @@ class SymEncryptedSessionKeyPacket {
25006
25223
 
25007
25224
  this.sessionKeyEncryptionAlgorithm = algo;
25008
25225
 
25009
- this.s2k = new S2K(config$1);
25010
- this.s2k.salt = mod.random.getRandomBytes(8);
25226
+ this.s2k = newS2KFromConfig(config$1);
25227
+ this.s2k.generateSalt();
25011
25228
 
25012
25229
  const { blockSize, keySize } = mod.getCipher(algo);
25013
25230
  const encryptionKey = await this.s2k.produceKey(passphrase, keySize);
@@ -25633,7 +25850,8 @@ class SecretKeyPacket extends PublicKeyPacket {
25633
25850
  // - [Optional] If string-to-key usage octet was 255, 254, or 253, a
25634
25851
  // string-to-key specifier. The length of the string-to-key
25635
25852
  // specifier is implied by its type, as described above.
25636
- this.s2k = new S2K();
25853
+ const s2kType = bytes[i++];
25854
+ this.s2k = newS2KFromType(s2kType);
25637
25855
  i += this.s2k.read(bytes.subarray(i, bytes.length));
25638
25856
 
25639
25857
  if (this.s2k.type === 'gnu-dummy') {
@@ -25771,7 +25989,7 @@ class SecretKeyPacket extends PublicKeyPacket {
25771
25989
  }
25772
25990
  this.isEncrypted = null;
25773
25991
  this.keyMaterial = null;
25774
- this.s2k = new S2K(config$1);
25992
+ this.s2k = newS2KFromType(enums.s2k.gnu, config$1);
25775
25993
  this.s2k.algorithm = 0;
25776
25994
  this.s2k.c = 0;
25777
25995
  this.s2k.type = 'gnu-dummy';
@@ -25802,8 +26020,8 @@ class SecretKeyPacket extends PublicKeyPacket {
25802
26020
  throw new Error('A non-empty passphrase is required for key encryption.');
25803
26021
  }
25804
26022
 
25805
- this.s2k = new S2K(config$1);
25806
- this.s2k.salt = mod.random.getRandomBytes(8);
26023
+ this.s2k = newS2KFromConfig(config$1);
26024
+ this.s2k.generateSalt();
25807
26025
  const cleartext = mod.serializeParams(this.algorithm, this.privateParams);
25808
26026
  this.symmetric = enums.symmetric.aes256;
25809
26027
  const key = await produceEncryptionKey(this.s2k, passphrase, this.symmetric);
@@ -27634,7 +27852,8 @@ function isValidDecryptionKeyPacket(signature, config) {
27634
27852
 
27635
27853
  return !signature.keyFlags ||
27636
27854
  (signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
27637
- (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0;
27855
+ (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0 ||
27856
+ (config.allowForwardedMessages && (signature.keyFlags[0] & enums.keyFlags.forwardedCommunication) !== 0);
27638
27857
  }
27639
27858
 
27640
27859
  /**
@@ -28582,7 +28801,7 @@ class Key {
28582
28801
  throw exception || new Error('Could not find primary user');
28583
28802
  }
28584
28803
  await Promise.all(users.map(async function (a) {
28585
- return a.user.revoked || a.user.isRevoked(a.selfCertification, null, date, config$1);
28804
+ return a.selfCertification.revoked || a.user.isRevoked(a.selfCertification, null, date, config$1);
28586
28805
  }));
28587
28806
  // sort by primary user flag and signature creation time
28588
28807
  const primaryUser = users.sort(function(a, b) {
@@ -28805,7 +29024,8 @@ class Key {
28805
29024
 
28806
29025
  results.push(...signatures.map(
28807
29026
  signature => ({
28808
- userID: user.userID.userID,
29027
+ userID: user.userID ? user.userID.userID : null,
29028
+ userAttribute: user.userAttribute,
28809
29029
  keyID: signature.keyID,
28810
29030
  valid: signature.valid
28811
29031
  }))
@@ -29681,6 +29901,9 @@ class Message {
29681
29901
  decryptedSessionKeyPackets.push(skeskPacket);
29682
29902
  } catch (err) {
29683
29903
  util.printDebugError(err);
29904
+ if (err instanceof Argon2OutOfMemoryError) {
29905
+ exception = err;
29906
+ }
29684
29907
  }
29685
29908
  }));
29686
29909
  }));
@@ -43828,4 +44051,710 @@ var elliptic$1 = /*#__PURE__*/Object.freeze({
43828
44051
  __moduleExports: elliptic_1
43829
44052
  });
43830
44053
 
43831
- export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, 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 };
44054
+ // Adapted from the reference implementation in RFC7693
44055
+ // Initial port to Javascript by https://github.com/dcposch and https://github.com/emilbayes
44056
+
44057
+ // Uint64 values are represented using two Uint32s, stored as little endian
44058
+ // NB: Uint32Arrays endianness depends on the underlying system, so for interoperability, conversions between Uint8Array and Uint32Arrays
44059
+ // need to be manually handled
44060
+
44061
+ // 64-bit unsigned addition (little endian, in place)
44062
+ // Sets a[i,i+1] += b[j,j+1]
44063
+ // `a` and `b` must be Uint32Array(2)
44064
+ function ADD64 (a, i, b, j) {
44065
+ a[i] += b[j];
44066
+ a[i+1] += b[j+1] + (a[i] < b[j]); // add carry
44067
+ }
44068
+
44069
+ // Increment 64-bit little-endian unsigned value by `c` (in place)
44070
+ // `a` must be Uint32Array(2)
44071
+ function INC64 (a, c) {
44072
+ a[0] += c;
44073
+ a[1] += (a[0] < c);
44074
+ }
44075
+
44076
+ // G Mixing function
44077
+ // The ROTRs are inlined for speed
44078
+ function G (v, m, a, b, c, d, ix, iy) {
44079
+ ADD64(v, a, v, b); // v[a,a+1] += v[b,b+1]
44080
+ ADD64(v, a, m, ix); // v[a, a+1] += x ... x0
44081
+
44082
+ // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
44083
+ let xor0 = v[d] ^ v[a];
44084
+ let xor1 = v[d + 1] ^ v[a + 1];
44085
+ v[d] = xor1;
44086
+ v[d + 1] = xor0;
44087
+
44088
+ ADD64(v, c, v, d);
44089
+
44090
+ // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
44091
+ xor0 = v[b] ^ v[c];
44092
+ xor1 = v[b + 1] ^ v[c + 1];
44093
+ v[b] = (xor0 >>> 24) ^ (xor1 << 8);
44094
+ v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
44095
+
44096
+ ADD64(v, a, v, b);
44097
+ ADD64(v, a, m, iy);
44098
+
44099
+ // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
44100
+ xor0 = v[d] ^ v[a];
44101
+ xor1 = v[d + 1] ^ v[a + 1];
44102
+ v[d] = (xor0 >>> 16) ^ (xor1 << 16);
44103
+ v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
44104
+
44105
+ ADD64(v, c, v, d);
44106
+
44107
+ // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
44108
+ xor0 = v[b] ^ v[c];
44109
+ xor1 = v[b + 1] ^ v[c + 1];
44110
+ v[b] = (xor1 >>> 31) ^ (xor0 << 1);
44111
+ v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
44112
+ }
44113
+
44114
+ // Initialization Vector
44115
+ const BLAKE2B_IV32 = new Uint32Array([
44116
+ 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85,
44117
+ 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A,
44118
+ 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C,
44119
+ 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19
44120
+ ]);
44121
+
44122
+ // These are offsets into a Uint64 buffer.
44123
+ // Multiply them all by 2 to make them offsets into a Uint32 buffer
44124
+ const SIGMA = new Uint8Array([
44125
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
44126
+ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
44127
+ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
44128
+ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
44129
+ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
44130
+ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
44131
+ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,
44132
+ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,
44133
+ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,
44134
+ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,
44135
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
44136
+ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3
44137
+ ].map(x => x * 2));
44138
+
44139
+ // Compression function. 'last' flag indicates last block.
44140
+ // Note: we're representing 16 uint64s as 32 uint32s
44141
+ function compress(S, last) {
44142
+ const v = new Uint32Array(32);
44143
+ const m = new Uint32Array(S.b.buffer, S.b.byteOffset, 32);
44144
+
44145
+ // init work variables
44146
+ for (let i = 0; i < 16; i++) {
44147
+ v[i] = S.h[i];
44148
+ v[i + 16] = BLAKE2B_IV32[i];
44149
+ }
44150
+
44151
+ // low 64 bits of offset
44152
+ v[24] ^= S.t0[0];
44153
+ v[25] ^= S.t0[1];
44154
+ // high 64 bits not supported (`t1`), offset may not be higher than 2**53-1
44155
+
44156
+ // if last block
44157
+ const f0 = last ? 0xFFFFFFFF : 0;
44158
+ v[28] ^= f0;
44159
+ v[29] ^= f0;
44160
+
44161
+ // twelve rounds of mixing
44162
+ for (let i = 0; i < 12; i++) {
44163
+ // ROUND(r)
44164
+ const i16 = i << 4;
44165
+ G(v, m, 0, 8, 16, 24, SIGMA[i16 + 0], SIGMA[i16 + 1]);
44166
+ G(v, m, 2, 10, 18, 26, SIGMA[i16 + 2], SIGMA[i16 + 3]);
44167
+ G(v, m, 4, 12, 20, 28, SIGMA[i16 + 4], SIGMA[i16 + 5]);
44168
+ G(v, m, 6, 14, 22, 30, SIGMA[i16 + 6], SIGMA[i16 + 7]);
44169
+ G(v, m, 0, 10, 20, 30, SIGMA[i16 + 8], SIGMA[i16 + 9]);
44170
+ G(v, m, 2, 12, 22, 24, SIGMA[i16 + 10], SIGMA[i16 + 11]);
44171
+ G(v, m, 4, 14, 16, 26, SIGMA[i16 + 12], SIGMA[i16 + 13]);
44172
+ G(v, m, 6, 8, 18, 28, SIGMA[i16 + 14], SIGMA[i16 + 15]);
44173
+ }
44174
+
44175
+ for (let i = 0; i < 16; i++) {
44176
+ S.h[i] ^= v[i] ^ v[i + 16];
44177
+ }
44178
+ }
44179
+
44180
+ // Creates a BLAKE2b hashing context
44181
+ // Requires an output length between 1 and 64 bytes
44182
+ // Takes an optional Uint8Array key
44183
+ class Blake2b {
44184
+ constructor(outlen, key, salt, personal) {
44185
+ const params = new Uint8Array(64);
44186
+ // 0: outlen, keylen, fanout, depth
44187
+ // 4: leaf length, sequential mode
44188
+ // 8: node offset
44189
+ // 12: node offset
44190
+ // 16: node depth, inner length, rfu
44191
+ // 20: rfu
44192
+ // 24: rfu
44193
+ // 28: rfu
44194
+ // 32: salt
44195
+ // 36: salt
44196
+ // 40: salt
44197
+ // 44: salt
44198
+ // 48: personal
44199
+ // 52: personal
44200
+ // 56: personal
44201
+ // 60: personal
44202
+
44203
+ // init internal state
44204
+ this.S = {
44205
+ b: new Uint8Array(BLOCKBYTES),
44206
+ h: new Uint32Array(OUTBYTES_MAX / 4),
44207
+ t0: new Uint32Array(2), // input counter `t`, lower 64-bits only
44208
+ c: 0, // `fill`, pointer within buffer, up to `BLOCKBYTES`
44209
+ outlen // output length in bytes
44210
+ };
44211
+
44212
+ // init parameter block
44213
+ params[0] = outlen;
44214
+ if (key) params[1] = key.length;
44215
+ params[2] = 1; // fanout
44216
+ params[3] = 1; // depth
44217
+ if (salt) params.set(salt, 32);
44218
+ if (personal) params.set(personal, 48);
44219
+ const params32 = new Uint32Array(params.buffer, params.byteOffset, params.length / Uint32Array.BYTES_PER_ELEMENT);
44220
+
44221
+ // initialize hash state
44222
+ for (let i = 0; i < 16; i++) {
44223
+ this.S.h[i] = BLAKE2B_IV32[i] ^ params32[i];
44224
+ }
44225
+
44226
+ // key the hash, if applicable
44227
+ if (key) {
44228
+ const block = new Uint8Array(BLOCKBYTES);
44229
+ block.set(key);
44230
+ this.update(block);
44231
+ }
44232
+ }
44233
+
44234
+ // Updates a BLAKE2b streaming hash
44235
+ // Requires Uint8Array (byte array)
44236
+ update(input) {
44237
+ if (!(input instanceof Uint8Array)) throw new Error('Input must be Uint8Array or Buffer')
44238
+ // for (let i = 0; i < input.length; i++) {
44239
+ // if (this.S.c === BLOCKBYTES) { // buffer full
44240
+ // INC64(this.S.t0, this.S.c) // add counters
44241
+ // compress(this.S, false)
44242
+ // this.S.c = 0 // empty buffer
44243
+ // }
44244
+ // this.S.b[this.S.c++] = input[i]
44245
+ // }
44246
+ let i = 0;
44247
+ while(i < input.length) {
44248
+ if (this.S.c === BLOCKBYTES) { // buffer full
44249
+ INC64(this.S.t0, this.S.c); // add counters
44250
+ compress(this.S, false);
44251
+ this.S.c = 0; // empty buffer
44252
+ }
44253
+ let left = BLOCKBYTES - this.S.c;
44254
+ this.S.b.set(input.subarray(i, i + left), this.S.c); // end index can be out of bounds
44255
+ const fill = Math.min(left, input.length - i);
44256
+ this.S.c += fill;
44257
+ i += fill;
44258
+ }
44259
+ return this
44260
+ }
44261
+
44262
+ /**
44263
+ * Return a BLAKE2b hash, either filling the given Uint8Array or allocating a new one
44264
+ * @param {Uint8Array} [prealloc] - optional preallocated buffer
44265
+ * @returns {ArrayBuffer} message digest
44266
+ */
44267
+ digest(prealloc) {
44268
+ INC64(this.S.t0, this.S.c); // mark last block offset
44269
+
44270
+ // final block, padded
44271
+ this.S.b.fill(0, this.S.c);
44272
+ this.S.c = BLOCKBYTES;
44273
+ compress(this.S, true);
44274
+
44275
+ const out = prealloc || new Uint8Array(this.S.outlen);
44276
+ for (let i = 0; i < this.S.outlen; i++) {
44277
+ // must be loaded individually since default Uint32 endianness is platform dependant
44278
+ out[i] = this.S.h[i >> 2] >> (8 * (i & 3));
44279
+ }
44280
+ this.S.h = null; // prevent calling `update` after `digest`
44281
+ return out.buffer;
44282
+ }
44283
+ }
44284
+
44285
+
44286
+ function createHash(outlen, key, salt, personal) {
44287
+ if (outlen > OUTBYTES_MAX) throw new Error(`outlen must be at most ${OUTBYTES_MAX} (given: ${outlen})`)
44288
+ if (key) {
44289
+ if (!(key instanceof Uint8Array)) throw new Error('key must be Uint8Array or Buffer')
44290
+ if (key.length > KEYBYTES_MAX) throw new Error(`key size must be at most ${KEYBYTES_MAX} (given: ${key.length})`)
44291
+ }
44292
+ if (salt) {
44293
+ if (!(salt instanceof Uint8Array)) throw new Error('salt must be Uint8Array or Buffer')
44294
+ if (salt.length !== SALTBYTES) throw new Error(`salt must be exactly ${SALTBYTES} (given: ${salt.length}`)
44295
+ }
44296
+ if (personal) {
44297
+ if (!(personal instanceof Uint8Array)) throw new Error('personal must be Uint8Array or Buffer')
44298
+ if (personal.length !== PERSONALBYTES) throw new Error(`salt must be exactly ${PERSONALBYTES} (given: ${personal.length}`)
44299
+ }
44300
+
44301
+ return new Blake2b(outlen, key, salt, personal)
44302
+ }
44303
+
44304
+ const OUTBYTES_MAX = 64;
44305
+ const KEYBYTES_MAX = 64;
44306
+ const SALTBYTES = 16;
44307
+ const PERSONALBYTES = 16;
44308
+ const BLOCKBYTES = 128;
44309
+
44310
+ const TYPE$2 = 2; // Argon2id
44311
+ const VERSION$4 = 0x13;
44312
+ const TAGBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
44313
+ const TAGBYTES_MIN = 4; // Math.pow(2, 32) - 1;
44314
+ const SALTBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;
44315
+ const SALTBYTES_MIN = 8;
44316
+ const passwordBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
44317
+ const passwordBYTES_MIN = 8;
44318
+ const MEMBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;
44319
+ const ADBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1; // associated data (optional)
44320
+ const SECRETBYTES_MAX = 32; // key (optional)
44321
+
44322
+ const ARGON2_BLOCK_SIZE = 1024;
44323
+ const ARGON2_PREHASH_DIGEST_LENGTH = 64;
44324
+
44325
+ const isLittleEndian$1 = new Uint8Array(new Uint16Array([0xabcd]).buffer)[0] === 0xcd;
44326
+
44327
+ // store n as a little-endian 32-bit Uint8Array inside buf (at buf[i:i+3])
44328
+ function LE32(buf, n, i) {
44329
+ buf[i+0] = n;
44330
+ buf[i+1] = n >> 8;
44331
+ buf[i+2] = n >> 16;
44332
+ buf[i+3] = n >> 24;
44333
+ return buf;
44334
+ }
44335
+
44336
+ /**
44337
+ * Store n as a 64-bit LE number in the given buffer (from buf[i] to buf[i+7])
44338
+ * @param {Uint8Array} buf
44339
+ * @param {Number} n
44340
+ * @param {Number} i
44341
+ */
44342
+ function LE64(buf, n, i) {
44343
+ if (n > Number.MAX_SAFE_INTEGER) throw new Error("LE64: large numbers unsupported");
44344
+ // ECMAScript standard has engines convert numbers to 32-bit integers for bitwise operations
44345
+ // shifting by 32 or more bits is not supported (https://stackoverflow.com/questions/6729122/javascript-bit-shift-number-wraps)
44346
+ // so we manually extract each byte
44347
+ let remainder = n;
44348
+ for (let offset = i; offset < i+7; offset++) { // last byte can be ignored as it would overflow MAX_SAFE_INTEGER
44349
+ buf[offset] = remainder; // implicit & 0xff
44350
+ remainder = (remainder - buf[offset]) / 256;
44351
+ }
44352
+ return buf;
44353
+ }
44354
+
44355
+ /**
44356
+ * Variable-Length Hash Function H'
44357
+ * @param {Number} outlen - T
44358
+ * @param {Uint8Array} X - value to hash
44359
+ * @param {Uint8Array} res - output buffer, of length `outlength` or larger
44360
+ */
44361
+ function H_(outlen, X, res) {
44362
+ const V = new Uint8Array(64); // no need to keep around all V_i
44363
+
44364
+ const V1_in = new Uint8Array(4 + X.length);
44365
+ LE32(V1_in, outlen, 0);
44366
+ V1_in.set(X, 4);
44367
+ if (outlen <= 64) {
44368
+ // H'^T(A) = H^T(LE32(T)||A)
44369
+ createHash(outlen).update(V1_in).digest(res);
44370
+ return res
44371
+ }
44372
+
44373
+ const r = Math.ceil(outlen / 32) - 2;
44374
+
44375
+ // Let V_i be a 64-byte block and W_i be its first 32 bytes.
44376
+ // V_1 = H^(64)(LE32(T)||A)
44377
+ // V_2 = H^(64)(V_1)
44378
+ // ...
44379
+ // V_r = H^(64)(V_{r-1})
44380
+ // V_{r+1} = H^(T-32*r)(V_{r})
44381
+ // H'^T(X) = W_1 || W_2 || ... || W_r || V_{r+1}
44382
+ for (let i = 0; i < r; i++) {
44383
+ createHash(64).update(i === 0 ? V1_in : V).digest(V);
44384
+ // store W_i in result buffer already
44385
+ res.set(V.subarray(0, 32), i*32);
44386
+ }
44387
+ // V_{r+1}
44388
+ const V_r1 = new Uint8Array(createHash(outlen - 32*r).update(V).digest());
44389
+ res.set(V_r1, r*32);
44390
+
44391
+ return res;
44392
+ }
44393
+
44394
+ // compute buf = xs ^ ys
44395
+ function XOR(wasmContext, buf, xs, ys) {
44396
+ wasmContext.fn.XOR(
44397
+ buf.byteOffset,
44398
+ xs.byteOffset,
44399
+ ys.byteOffset,
44400
+ );
44401
+ return buf
44402
+ }
44403
+
44404
+ /**
44405
+ * @param {Uint8Array} X (read-only)
44406
+ * @param {Uint8Array} Y (read-only)
44407
+ * @param {Uint8Array} R - output buffer
44408
+ * @returns
44409
+ */
44410
+ function G$1(wasmContext, X, Y, R) {
44411
+ wasmContext.fn.G(
44412
+ X.byteOffset,
44413
+ Y.byteOffset,
44414
+ R.byteOffset,
44415
+ wasmContext.refs.gZ.byteOffset
44416
+ );
44417
+ return R;
44418
+ }
44419
+
44420
+ function G2(wasmContext, X, Y, R) {
44421
+ wasmContext.fn.G2(
44422
+ X.byteOffset,
44423
+ Y.byteOffset,
44424
+ R.byteOffset,
44425
+ wasmContext.refs.gZ.byteOffset
44426
+ );
44427
+ return R;
44428
+ }
44429
+
44430
+ // Generator for data-independent J1, J2. Each `next()` invocation returns a new pair of values.
44431
+ function* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLength, segmentOffset) {
44432
+ // For each segment, we do the following. First, we compute the value Z as:
44433
+ // Z= ( LE64(r) || LE64(l) || LE64(sl) || LE64(m') || LE64(t) || LE64(y) )
44434
+ wasmContext.refs.prngTmp.fill(0);
44435
+ const Z = wasmContext.refs.prngTmp.subarray(0, 6 * 8);
44436
+ LE64(Z, pass, 0);
44437
+ LE64(Z, lane, 8);
44438
+ LE64(Z, slice, 16);
44439
+ LE64(Z, m_, 24);
44440
+ LE64(Z, totalPasses, 32);
44441
+ LE64(Z, TYPE$2, 40);
44442
+
44443
+ // Then we compute q/(128*SL) 1024-byte values
44444
+ // G( ZERO(1024),
44445
+ // G( ZERO(1024), Z || LE64(1) || ZERO(968) ) ),
44446
+ // ...,
44447
+ // G( ZERO(1024),
44448
+ // G( ZERO(1024), Z || LE64(q/(128*SL)) || ZERO(968) )),
44449
+ for(let i = 1; i <= segmentLength; i++) {
44450
+ // tmp.set(Z); // no need to re-copy
44451
+ LE64(wasmContext.refs.prngTmp, i, Z.length); // tmp.set(ZER0968) not necessary, memory already zeroed
44452
+ const g2 = G2(wasmContext, wasmContext.refs.ZERO1024, wasmContext.refs.prngTmp, wasmContext.refs.prngR );
44453
+
44454
+ // each invocation of G^2 outputs 1024 bytes that are to be partitioned into 8-bytes values, take as X1 || X2
44455
+ // NB: the first generated pair must be used for the first block of the segment, and so on.
44456
+ // Hence, if some blocks are skipped (e.g. during the first pass), the corresponding J1J2 are discarded based on the given segmentOffset.
44457
+ for(let k = i === 1 ? segmentOffset*8 : 0; k < g2.length; k += 8) {
44458
+ yield g2.subarray(k, k+8);
44459
+ }
44460
+ }
44461
+ return [];
44462
+ }
44463
+
44464
+ function validateParams$7({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {
44465
+ const assertLength = (name, value, min, max) => {
44466
+ if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }
44467
+ };
44468
+
44469
+ if (type !== TYPE$2 || version !== VERSION$4) throw new Error('Unsupported type or version');
44470
+ assertLength('password', password, passwordBYTES_MIN, passwordBYTES_MAX);
44471
+ assertLength('salt', salt, SALTBYTES_MIN, SALTBYTES_MAX);
44472
+ assertLength('tag', tagLength, TAGBYTES_MIN, TAGBYTES_MAX);
44473
+ assertLength('memory', memorySize, 8*parallelism, MEMBYTES_MAX);
44474
+ // optional fields
44475
+ ad && assertLength('associated data', ad, 0, ADBYTES_MAX);
44476
+ secret && assertLength('secret', secret, 0, SECRETBYTES_MAX);
44477
+
44478
+ return { type, version, tagLength, password, salt, ad, secret, lanes: parallelism, memorySize, passes };
44479
+ }
44480
+
44481
+ const KB = 1024;
44482
+ const WASM_PAGE_SIZE = 64 * KB;
44483
+
44484
+ function argon2id(params, { memory, instance: wasmInstance }) {
44485
+ if (!isLittleEndian$1) throw new Error('BigEndian system not supported'); // optmisations assume LE system
44486
+
44487
+ const ctx = validateParams$7({ type: TYPE$2, version: VERSION$4, ...params });
44488
+
44489
+ const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;
44490
+ const wasmRefs = {};
44491
+ const wasmFn = {};
44492
+ wasmFn.G = wasmG;
44493
+ wasmFn.G2 = wasmG2;
44494
+ wasmFn.XOR = wasmXOR;
44495
+
44496
+ // The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p.
44497
+ const m_ = 4 * ctx.lanes * Math.floor(ctx.memorySize / (4 * ctx.lanes));
44498
+ const requiredMemory = m_ * ARGON2_BLOCK_SIZE + 10 * KB; // Additional KBs for utility references
44499
+ if (memory.buffer.byteLength < requiredMemory) {
44500
+ const missing = Math.ceil((requiredMemory - memory.buffer.byteLength) / WASM_PAGE_SIZE);
44501
+ // If enough memory is available, the `memory.buffer` is internally detached and the reference updated.
44502
+ // Otherwise, the operation fails, and the original memory can still be used.
44503
+ memory.grow(missing);
44504
+ }
44505
+
44506
+ let offset = 0;
44507
+ // Init wasm memory needed in other functions
44508
+ wasmRefs.gZ = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+= wasmRefs.gZ.length;
44509
+ wasmRefs.prngR = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngR.length;
44510
+ wasmRefs.prngTmp = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngTmp.length;
44511
+ wasmRefs.ZERO1024 = new Uint8Array(memory.buffer, offset, 1024); offset+=wasmRefs.ZERO1024.length;
44512
+ // Init wasm memory needed locally
44513
+ const lz = new Uint32Array(memory.buffer, offset, 2); offset+=lz.length * Uint32Array.BYTES_PER_ELEMENT;
44514
+ const wasmContext = { fn: wasmFn, refs: wasmRefs };
44515
+ const newBlock = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=newBlock.length;
44516
+ const blockMemory = new Uint8Array(memory.buffer, offset, ctx.memorySize * ARGON2_BLOCK_SIZE);
44517
+ const allocatedMemory = new Uint8Array(memory.buffer, 0, offset);
44518
+
44519
+ // 1. Establish H_0
44520
+ const H0 = getH0(ctx);
44521
+
44522
+ // 2. Allocate the memory as m' 1024-byte blocks
44523
+ // For p lanes, the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m' / p columns.
44524
+ const q = m_ / ctx.lanes;
44525
+ const B = new Array(ctx.lanes).fill(null).map(() => new Array(q));
44526
+ const initBlock = (i, j) => {
44527
+ B[i][j] = blockMemory.subarray(i*q*1024 + j*1024, (i*q*1024 + j*1024) + ARGON2_BLOCK_SIZE);
44528
+ return B[i][j];
44529
+ };
44530
+
44531
+ for (let i = 0; i < ctx.lanes; i++) {
44532
+ // const LEi = LE0; // since p = 1 for us
44533
+ const tmp = new Uint8Array(H0.length + 8);
44534
+ // 3. Compute B[i][0] for all i ranging from (and including) 0 to (not including) p
44535
+ // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))
44536
+ tmp.set(H0); LE32(tmp, 0, H0.length); LE32(tmp, i, H0.length + 4);
44537
+ H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 0));
44538
+ // 4. Compute B[i][1] for all i ranging from (and including) 0 to (not including) p
44539
+ // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))
44540
+ LE32(tmp, 1, H0.length);
44541
+ H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 1));
44542
+ }
44543
+
44544
+ // 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
44545
+ // to (not including) q. The computation MUST proceed slicewise (Section 3.4) : first, blocks from slice 0 are computed for all lanes
44546
+ // (in an arbitrary order of lanes), then blocks from slice 1 are computed, etc.
44547
+ const SL = 4; // vertical slices
44548
+ const segmentLength = q / SL;
44549
+ for (let pass = 0; pass < ctx.passes; pass++) {
44550
+ // 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
44551
+ for (let sl = 0; sl < SL; sl++) {
44552
+ const isDataIndependent = pass === 0 && sl <= 1;
44553
+ for (let i = 0; i < ctx.lanes; i++) { // lane
44554
+ // On the first slice of the first pass, blocks 0 and 1 are already filled
44555
+ let segmentOffset = sl === 0 && pass === 0 ? 2 : 0;
44556
+ // no need to generate all J1J2s, use iterator/generator that creates the value on the fly (to save memory)
44557
+ const PRNG = isDataIndependent ? makePRNG(wasmContext, pass, i, sl, m_, ctx.passes, segmentLength, segmentOffset) : null;
44558
+ for (segmentOffset; segmentOffset < segmentLength; segmentOffset++) {
44559
+ const j = sl * segmentLength + segmentOffset;
44560
+ const prevBlock = j > 0 ? B[i][j-1] : B[i][q-1]; // B[i][(j-1) mod q]
44561
+
44562
+ // we can assume the PRNG is never done
44563
+ const J1J2 = isDataIndependent ? PRNG.next().value : prevBlock; // .subarray(0, 8) not required since we only pass the byteOffset to wasm
44564
+ // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
44565
+ wasmLZ(lz.byteOffset, J1J2.byteOffset, i, ctx.lanes, pass, sl, segmentOffset, SL, segmentLength);
44566
+ const l = lz[0]; const z = lz[1];
44567
+ // for (let i = 0; i < p; i++ )
44568
+ // B[i][j] = G(B[i][j-1], B[l][z])
44569
+ // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.
44570
+ if (pass === 0) initBlock(i, j);
44571
+ G$1(wasmContext, prevBlock, B[l][z], pass > 0 ? newBlock : B[i][j]);
44572
+
44573
+ // 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
44574
+ if (pass > 0) XOR(wasmContext, B[i][j], newBlock, B[i][j]);
44575
+ }
44576
+ }
44577
+ }
44578
+ }
44579
+
44580
+ // 7. After t steps have been iterated, the final block C is computed as the XOR of the last column:
44581
+ // C = B[0][q-1] XOR B[1][q-1] XOR ... XOR B[p-1][q-1]
44582
+ const C = B[0][q-1];
44583
+ for(let i = 1; i < ctx.lanes; i++) {
44584
+ XOR(wasmContext, C, C, B[i][q-1]);
44585
+ }
44586
+
44587
+ const tag = H_(ctx.tagLength, C, new Uint8Array(ctx.tagLength));
44588
+ // clear memory since the module might be cached
44589
+ allocatedMemory.fill(0); // clear sensitive contents
44590
+ memory.grow(0); // allow deallocation
44591
+ // 8. The output tag is computed as H'^T(C).
44592
+ return tag;
44593
+
44594
+ }
44595
+
44596
+ function getH0(ctx) {
44597
+ const H = createHash(ARGON2_PREHASH_DIGEST_LENGTH);
44598
+ const ZERO32 = new Uint8Array(4);
44599
+ const params = new Uint8Array(24);
44600
+ LE32(params, ctx.lanes, 0);
44601
+ LE32(params, ctx.tagLength, 4);
44602
+ LE32(params, ctx.memorySize, 8);
44603
+ LE32(params, ctx.passes, 12);
44604
+ LE32(params, ctx.version, 16);
44605
+ LE32(params, ctx.type, 20);
44606
+
44607
+ const toHash = [params];
44608
+ if (ctx.password) {
44609
+ toHash.push(LE32(new Uint8Array(4), ctx.password.length, 0));
44610
+ toHash.push(ctx.password);
44611
+ } else {
44612
+ toHash.push(ZERO32); // context.password.length
44613
+ }
44614
+
44615
+ if (ctx.salt) {
44616
+ toHash.push(LE32(new Uint8Array(4), ctx.salt.length, 0));
44617
+ toHash.push(ctx.salt);
44618
+ } else {
44619
+ toHash.push(ZERO32); // context.salt.length
44620
+ }
44621
+
44622
+ if (ctx.secret) {
44623
+ toHash.push(LE32(new Uint8Array(4), ctx.secret.length, 0));
44624
+ toHash.push(ctx.secret);
44625
+ // todo clear secret?
44626
+ } else {
44627
+ toHash.push(ZERO32); // context.secret.length
44628
+ }
44629
+
44630
+ if (ctx.ad) {
44631
+ toHash.push(LE32(new Uint8Array(4), ctx.ad.length, 0));
44632
+ toHash.push(ctx.ad);
44633
+ } else {
44634
+ toHash.push(ZERO32); // context.ad.length
44635
+ }
44636
+ H.update(concatArrays(toHash));
44637
+
44638
+ const outputBuffer = H.digest();
44639
+ return new Uint8Array(outputBuffer);
44640
+ }
44641
+
44642
+ function concatArrays(arrays) {
44643
+ if (arrays.length === 1) return arrays[0];
44644
+
44645
+ let totalLength = 0;
44646
+ for (let i = 0; i < arrays.length; i++) {
44647
+ if (!(arrays[i] instanceof Uint8Array)) {
44648
+ throw new Error('concatArrays: Data must be in the form of a Uint8Array');
44649
+ }
44650
+
44651
+ totalLength += arrays[i].length;
44652
+ }
44653
+
44654
+ const result = new Uint8Array(totalLength);
44655
+ let pos = 0;
44656
+ arrays.forEach((element) => {
44657
+ result.set(element, pos);
44658
+ pos += element.length;
44659
+ });
44660
+
44661
+ return result;
44662
+ }
44663
+
44664
+ let isSIMDSupported;
44665
+ async function wasmLoader(memory, getSIMD, getNonSIMD) {
44666
+ const importObject = { env: { memory } };
44667
+ if (isSIMDSupported === undefined) {
44668
+ try {
44669
+ isSIMDSupported = true; // will be overwritten in the catch
44670
+ return await getSIMD(importObject);
44671
+ } catch(e) {
44672
+ isSIMDSupported = false;
44673
+ }
44674
+ }
44675
+
44676
+ const loader = isSIMDSupported ? getSIMD : getNonSIMD;
44677
+ return loader(importObject);
44678
+ }
44679
+
44680
+ async function setupWasm(getSIMD, getNonSIMD) {
44681
+ const memory = new WebAssembly.Memory({
44682
+ // in pages of 64KiB each
44683
+ // these values need to be compatible with those declared when building in `build-wasm`
44684
+ initial: 1040, // 65MB
44685
+ maximum: 65536, // 4GB
44686
+ });
44687
+ const wasmModule = await wasmLoader(memory, getSIMD, getNonSIMD);
44688
+
44689
+ /**
44690
+ * Argon2id hash function
44691
+ * @callback computeHash
44692
+ * @param {Object} params
44693
+ * @param {Uint8Array} params.password - password
44694
+ * @param {Uint8Array} params.salt - salt
44695
+ * @param {Integer} params.parallelism
44696
+ * @param {Integer} params.passes
44697
+ * @param {Integer} params.memorySize - in kibibytes
44698
+ * @param {Integer} params.tagLength - output tag length
44699
+ * @param {Uint8Array} [params.ad] - associated data (optional)
44700
+ * @param {Uint8Array} [params.secret] - secret data (optional)
44701
+ * @return {Uint8Array} argon2id hash
44702
+ */
44703
+ const computeHash = (params) => argon2id(params, { instance: wasmModule.instance, memory });
44704
+
44705
+ return computeHash;
44706
+ }
44707
+
44708
+ function _loadWasmModule (sync, filepath, src, imports) {
44709
+ function _instantiateOrCompile(source, imports, stream) {
44710
+ var instantiateFunc = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;
44711
+ var compileFunc = stream ? WebAssembly.compileStreaming : WebAssembly.compile;
44712
+
44713
+ if (imports) {
44714
+ return instantiateFunc(source, imports)
44715
+ } else {
44716
+ return compileFunc(source)
44717
+ }
44718
+ }
44719
+
44720
+
44721
+ var buf = null;
44722
+ if (filepath) {
44723
+
44724
+ return _instantiateOrCompile(fetch(filepath), imports, true);
44725
+
44726
+ }
44727
+
44728
+
44729
+ var raw = globalThis.atob(src);
44730
+ var rawLength = raw.length;
44731
+ buf = new Uint8Array(new ArrayBuffer(rawLength));
44732
+ for(var i = 0; i < rawLength; i++) {
44733
+ buf[i] = raw.charCodeAt(i);
44734
+ }
44735
+
44736
+
44737
+
44738
+ if(sync) {
44739
+ var mod = new WebAssembly.Module(buf);
44740
+ return imports ? new WebAssembly.Instance(mod, imports) : mod
44741
+ } else {
44742
+ return _instantiateOrCompile(buf, imports, false)
44743
+ }
44744
+ }
44745
+
44746
+ function wasmSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABKwdgBH9/f38AYAABf2AAAGADf39/AGAJf39/f39/f39/AX9gAX8AYAF/AX8CEwEDZW52Bm1lbW9yeQIBkAiAgAQDCgkCAwAABAEFBgEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwACAkcyAAMFZ2V0TFoABBlfX2luZGl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EACAB/QAEAP1R/QsEACAQQQRqIhBBwABHDQALCxYAIAAgASACIAMQAiAAIAIgAiADEAILewIBfwF+IAIhCSABNQIAIQogBCAFcgRAIAEoAgQgA3AhCQsgACAJNgIAIAAgB0EBayAFIAQbIAhsIAZBAWtBAEF/IAYbIAIgCUYbaiIBIAVBAWogCGxBACAEG2ogAa0gCiAKfkIgiH5CIIinQX9zaiAHIAhscDYCBCAACwQAIwALBgAgACQACxAAIwAgAGtBcHEiACQAIAALBQBBgAgL', imports)}
44747
+
44748
+ 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+fCIRNwMAIAEgESABKQMAhUIBiTc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ABB6QBB+ABB+QAQAiADQQpBC0EaQRtBKkErQTpBO0HKAEHLAEHaAEHbAEHqAEHrAEH6AEH7ABACIANBDEENQRxBHUEsQS1BPEE9QcwAQc0AQdwAQd0AQewAQe0AQfwAQf0AEAIgA0EOQQ9BHkEfQS5BL0E+QT9BzgBBzwBB3gBB3wBB7gBB7wBB/gBB/wAQAgNAIAIgAUEDdCIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAiAAQQhyIgRqIgUgAyAEaikDACAFKQMAhTcDACACIABBEHIiBGoiBSADIARqKQMAIAUpAwCFNwMAIAIgAEEYciIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAUEEaiIBQYABRw0ACwsWACAAIAEgAiADEAMgACACIAIgAxADC3sCAX8BfiACIQkgATUCACEKIAQgBXIEQCABKAIEIANwIQkLIAAgCTYCACAAIAdBAWsgBSAEGyAIbCAGQQFrQQBBfyAGGyACIAlGG2oiASAFQQFqIAhsQQAgBBtqIAGtIAogCn5CIIh+QiCIp0F/c2ogByAIbHA2AgQgAAsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwUAQYAICw==', imports)}
44749
+
44750
+ const loadWasm = async () => setupWasm(
44751
+ (instanceObject) => wasmSIMD(instanceObject),
44752
+ (instanceObject) => wasmNonSIMD(instanceObject),
44753
+ );
44754
+
44755
+ var index = /*#__PURE__*/Object.freeze({
44756
+ __proto__: null,
44757
+ 'default': loadWasm
44758
+ });
44759
+
44760
+ 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 };