@protontech/openpgp 6.0.1 → 6.0.2-patch.1

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.
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.1 - 2024-11-25 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.2-patch.1 - 2024-12-13 - 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 { createRequire } from 'module';
@@ -1706,7 +1706,7 @@ var config = {
1706
1706
  * @memberof module:config
1707
1707
  * @property {String} versionString A version string to be included in armored messages
1708
1708
  */
1709
- versionString: 'OpenPGP.js 6.0.1',
1709
+ versionString: 'OpenPGP.js 6.0.2-patch.1',
1710
1710
  /**
1711
1711
  * @memberof module:config
1712
1712
  * @property {String} commentString A comment string to be included in armored messages
@@ -9291,7 +9291,11 @@ async function generate$a(algo) {
9291
9291
  seed: b64ToUint8Array(privateKey.d, true)
9292
9292
  };
9293
9293
  } catch (err) {
9294
- if (err.name !== 'NotSupportedError' && err.name !== 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
9294
+ if (
9295
+ err.name !== 'NotSupportedError' &&
9296
+ err.name !== 'OperationError' && // Temporary (hopefully) fix for WebKit on Linux
9297
+ err.name !== 'SyntaxError' // Temporary fix for Palemoon throwing 'SyntaxError'
9298
+ ) {
9295
9299
  throw err;
9296
9300
  }
9297
9301
  const seed = getRandomBytes(getPayloadSize$1(algo));
@@ -9343,7 +9347,7 @@ async function sign$9(algo, hashAlgo, message, publicKey, privateKey, hashed) {
9343
9347
 
9344
9348
  return { RS: signature };
9345
9349
  } catch (err) {
9346
- if (err.name !== 'NotSupportedError') {
9350
+ if (err.name !== 'NotSupportedError' && err.name !== 'SyntaxError') { // Temporary fix for Palemoon throwing 'SyntaxError'
9347
9351
  throw err;
9348
9352
  }
9349
9353
  const secretKey = util.concatUint8Array([privateKey, publicKey]);
@@ -9389,7 +9393,7 @@ async function verify$9(algo, hashAlgo, { RS }, m, publicKey, hashed) {
9389
9393
  const verified = await webCrypto.verify('Ed25519', key, RS, hashed);
9390
9394
  return verified;
9391
9395
  } catch (err) {
9392
- if (err.name !== 'NotSupportedError') {
9396
+ if (err.name !== 'NotSupportedError' && err.name !== 'SyntaxError') { // Temporary fix for Palemoon throwing 'SyntaxError'
9393
9397
  throw err;
9394
9398
  }
9395
9399
  return verify$a(RS, hashed, publicKey);
@@ -11336,12 +11340,8 @@ async function generate$6(algo) {
11336
11340
  async function encaps$1(eccAlgo, eccRecipientPublicKey) {
11337
11341
  switch (eccAlgo) {
11338
11342
  case enums.publicKey.pqc_mlkem_x25519: {
11339
- const { ephemeralPublicKey: eccCipherText, sharedSecret: eccSharedSecret } = await generateEphemeralEncryptionMaterial(enums.publicKey.x25519, eccRecipientPublicKey);
11340
- const eccKeyShare = await hash.sha3_256(util.concatUint8Array([
11341
- eccSharedSecret,
11342
- eccCipherText,
11343
- eccRecipientPublicKey
11344
- ]));
11343
+ const { ephemeralPublicKey: eccCipherText, sharedSecret: eccKeyShare } = await generateEphemeralEncryptionMaterial(enums.publicKey.x25519, eccRecipientPublicKey);
11344
+
11345
11345
  return {
11346
11346
  eccCipherText,
11347
11347
  eccKeyShare
@@ -11355,12 +11355,7 @@ async function encaps$1(eccAlgo, eccRecipientPublicKey) {
11355
11355
  async function decaps$1(eccAlgo, eccCipherText, eccSecretKey, eccPublicKey) {
11356
11356
  switch (eccAlgo) {
11357
11357
  case enums.publicKey.pqc_mlkem_x25519: {
11358
- const eccSharedSecret = await recomputeSharedSecret(enums.publicKey.x25519, eccCipherText, eccPublicKey, eccSecretKey);
11359
- const eccKeyShare = await hash.sha3_256(util.concatUint8Array([
11360
- eccSharedSecret,
11361
- eccCipherText,
11362
- eccPublicKey
11363
- ]));
11358
+ const eccKeyShare = await recomputeSharedSecret(enums.publicKey.x25519, eccCipherText, eccPublicKey, eccSecretKey);
11364
11359
  return eccKeyShare;
11365
11360
  }
11366
11361
  default:
@@ -11472,7 +11467,7 @@ async function decrypt$1(algo, eccCipherText, mlkemCipherText, eccSecretKey, ecc
11472
11467
  async function multiKeyCombine(algo, ecdhKeyShare, ecdhCipherText, ecdhPublicKey, mlkemKeyShare, mlkemCipherText, mlkemPublicKey) {
11473
11468
  // LAMPS-aligned and NIST compatible combiner, proposed in: https://mailarchive.ietf.org/arch/msg/openpgp/NMTCy707LICtxIhP3Xt1U5C8MF0/
11474
11469
  // 2a. KDF(mlkemSS || tradSS || tradCT || tradPK || Domain)
11475
- // where Domain is "Domain" for LAMPS, and "mlkemCT || mlkemPK || algId" for OpenPGP
11470
+ // where Domain is "Domain" for LAMPS, and "mlkemCT || mlkemPK || algId || const" for OpenPGP
11476
11471
  const encData = util.concatUint8Array([
11477
11472
  mlkemKeyShare,
11478
11473
  ecdhKeyShare,
@@ -11481,7 +11476,8 @@ async function multiKeyCombine(algo, ecdhKeyShare, ecdhCipherText, ecdhPublicKey
11481
11476
  // domSep
11482
11477
  mlkemCipherText,
11483
11478
  mlkemPublicKey,
11484
- new Uint8Array([algo])
11479
+ new Uint8Array([algo]),
11480
+ util.encodeUTF8('OpenPGPCompositeKDFv1')
11485
11481
  ]);
11486
11482
 
11487
11483
  const kek = await hash.digest(enums.hash.sha3_256, encData);
package/dist/openpgp.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.1 - 2024-11-25 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.2-patch.1 - 2024-12-13 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  var openpgp = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1705,7 +1705,7 @@ var openpgp = (function (exports) {
1705
1705
  * @memberof module:config
1706
1706
  * @property {String} versionString A version string to be included in armored messages
1707
1707
  */
1708
- versionString: 'OpenPGP.js 6.0.1',
1708
+ versionString: 'OpenPGP.js 6.0.2-patch.1',
1709
1709
  /**
1710
1710
  * @memberof module:config
1711
1711
  * @property {String} commentString A comment string to be included in armored messages
@@ -9284,7 +9284,11 @@ var openpgp = (function (exports) {
9284
9284
  seed: b64ToUint8Array(privateKey.d, true)
9285
9285
  };
9286
9286
  } catch (err) {
9287
- if (err.name !== 'NotSupportedError' && err.name !== 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
9287
+ if (
9288
+ err.name !== 'NotSupportedError' &&
9289
+ err.name !== 'OperationError' && // Temporary (hopefully) fix for WebKit on Linux
9290
+ err.name !== 'SyntaxError' // Temporary fix for Palemoon throwing 'SyntaxError'
9291
+ ) {
9288
9292
  throw err;
9289
9293
  }
9290
9294
  const seed = getRandomBytes(getPayloadSize$1(algo));
@@ -9336,7 +9340,7 @@ var openpgp = (function (exports) {
9336
9340
 
9337
9341
  return { RS: signature };
9338
9342
  } catch (err) {
9339
- if (err.name !== 'NotSupportedError') {
9343
+ if (err.name !== 'NotSupportedError' && err.name !== 'SyntaxError') { // Temporary fix for Palemoon throwing 'SyntaxError'
9340
9344
  throw err;
9341
9345
  }
9342
9346
  const secretKey = util.concatUint8Array([privateKey, publicKey]);
@@ -9382,7 +9386,7 @@ var openpgp = (function (exports) {
9382
9386
  const verified = await webCrypto.verify('Ed25519', key, RS, hashed);
9383
9387
  return verified;
9384
9388
  } catch (err) {
9385
- if (err.name !== 'NotSupportedError') {
9389
+ if (err.name !== 'NotSupportedError' && err.name !== 'SyntaxError') { // Temporary fix for Palemoon throwing 'SyntaxError'
9386
9390
  throw err;
9387
9391
  }
9388
9392
  return verify$a(RS, hashed, publicKey);
@@ -11329,12 +11333,8 @@ var openpgp = (function (exports) {
11329
11333
  async function encaps$1(eccAlgo, eccRecipientPublicKey) {
11330
11334
  switch (eccAlgo) {
11331
11335
  case enums.publicKey.pqc_mlkem_x25519: {
11332
- const { ephemeralPublicKey: eccCipherText, sharedSecret: eccSharedSecret } = await generateEphemeralEncryptionMaterial(enums.publicKey.x25519, eccRecipientPublicKey);
11333
- const eccKeyShare = await hash.sha3_256(util.concatUint8Array([
11334
- eccSharedSecret,
11335
- eccCipherText,
11336
- eccRecipientPublicKey
11337
- ]));
11336
+ const { ephemeralPublicKey: eccCipherText, sharedSecret: eccKeyShare } = await generateEphemeralEncryptionMaterial(enums.publicKey.x25519, eccRecipientPublicKey);
11337
+
11338
11338
  return {
11339
11339
  eccCipherText,
11340
11340
  eccKeyShare
@@ -11348,12 +11348,7 @@ var openpgp = (function (exports) {
11348
11348
  async function decaps$1(eccAlgo, eccCipherText, eccSecretKey, eccPublicKey) {
11349
11349
  switch (eccAlgo) {
11350
11350
  case enums.publicKey.pqc_mlkem_x25519: {
11351
- const eccSharedSecret = await recomputeSharedSecret(enums.publicKey.x25519, eccCipherText, eccPublicKey, eccSecretKey);
11352
- const eccKeyShare = await hash.sha3_256(util.concatUint8Array([
11353
- eccSharedSecret,
11354
- eccCipherText,
11355
- eccPublicKey
11356
- ]));
11351
+ const eccKeyShare = await recomputeSharedSecret(enums.publicKey.x25519, eccCipherText, eccPublicKey, eccSecretKey);
11357
11352
  return eccKeyShare;
11358
11353
  }
11359
11354
  default:
@@ -11465,7 +11460,7 @@ var openpgp = (function (exports) {
11465
11460
  async function multiKeyCombine(algo, ecdhKeyShare, ecdhCipherText, ecdhPublicKey, mlkemKeyShare, mlkemCipherText, mlkemPublicKey) {
11466
11461
  // LAMPS-aligned and NIST compatible combiner, proposed in: https://mailarchive.ietf.org/arch/msg/openpgp/NMTCy707LICtxIhP3Xt1U5C8MF0/
11467
11462
  // 2a. KDF(mlkemSS || tradSS || tradCT || tradPK || Domain)
11468
- // where Domain is "Domain" for LAMPS, and "mlkemCT || mlkemPK || algId" for OpenPGP
11463
+ // where Domain is "Domain" for LAMPS, and "mlkemCT || mlkemPK || algId || const" for OpenPGP
11469
11464
  const encData = util.concatUint8Array([
11470
11465
  mlkemKeyShare,
11471
11466
  ecdhKeyShare,
@@ -11474,7 +11469,8 @@ var openpgp = (function (exports) {
11474
11469
  // domSep
11475
11470
  mlkemCipherText,
11476
11471
  mlkemPublicKey,
11477
- new Uint8Array([algo])
11472
+ new Uint8Array([algo]),
11473
+ util.encodeUTF8('OpenPGPCompositeKDFv1')
11478
11474
  ]);
11479
11475
 
11480
11476
  const kek = await hash.digest(enums.hash.sha3_256, encData);