@protontech/openpgp 6.0.0-beta.3.patch.0 → 6.0.0-beta.3.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.
package/dist/openpgp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-beta.3.patch.0 - 2024-09-09 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.3.patch.1 - 2024-09-11 - 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');
@@ -1682,7 +1682,7 @@ var config = {
1682
1682
  * @memberof module:config
1683
1683
  * @property {String} versionString A version string to be included in armored messages
1684
1684
  */
1685
- versionString: 'OpenPGP.js 6.0.0-beta.3.patch.0',
1685
+ versionString: 'OpenPGP.js 6.0.0-beta.3.patch.1',
1686
1686
  /**
1687
1687
  * @memberof module:config
1688
1688
  * @property {String} commentString A comment string to be included in armored messages
@@ -9292,7 +9292,7 @@ async function sign$6(algo, hashAlgo, message, publicKey, privateKey, hashed) {
9292
9292
  case enums.publicKey.ed25519:
9293
9293
  try {
9294
9294
  const webCrypto = util.getWebCrypto();
9295
- const jwk = privateKeyToJWK$1(algo, publicKey, privateKey);
9295
+ const jwk = privateKeyToJWK(algo, publicKey, privateKey);
9296
9296
  const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['sign']);
9297
9297
 
9298
9298
  const signature = new Uint8Array(
@@ -9339,7 +9339,7 @@ async function verify$6(algo, hashAlgo, { RS }, m, publicKey, hashed) {
9339
9339
  case enums.publicKey.ed25519:
9340
9340
  try {
9341
9341
  const webCrypto = util.getWebCrypto();
9342
- const jwk = publicKeyToJWK$1(algo, publicKey);
9342
+ const jwk = publicKeyToJWK(algo, publicKey);
9343
9343
  const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['verify']);
9344
9344
  const verified = await webCrypto.verify('Ed25519', key, RS, hashed);
9345
9345
  return verified;
@@ -9414,7 +9414,7 @@ function getPreferredHashAlgo$2(algo) {
9414
9414
  }
9415
9415
  }
9416
9416
 
9417
- const publicKeyToJWK$1 = (algo, publicKey) => {
9417
+ const publicKeyToJWK = (algo, publicKey) => {
9418
9418
  switch (algo) {
9419
9419
  case enums.publicKey.ed25519: {
9420
9420
  const jwk = {
@@ -9430,10 +9430,10 @@ const publicKeyToJWK$1 = (algo, publicKey) => {
9430
9430
  }
9431
9431
  };
9432
9432
 
9433
- const privateKeyToJWK$1 = (algo, publicKey, privateKey) => {
9433
+ const privateKeyToJWK = (algo, publicKey, privateKey) => {
9434
9434
  switch (algo) {
9435
9435
  case enums.publicKey.ed25519: {
9436
- const jwk = publicKeyToJWK$1(algo, publicKey);
9436
+ const jwk = publicKeyToJWK(algo, publicKey);
9437
9437
  jwk.d = uint8ArrayToB64(privateKey);
9438
9438
  return jwk;
9439
9439
  }
@@ -9582,27 +9582,12 @@ const HKDF_INFO = {
9582
9582
  */
9583
9583
  async function generate$3(algo) {
9584
9584
  switch (algo) {
9585
- case enums.publicKey.x25519:
9586
- try {
9587
- const webCrypto = util.getWebCrypto();
9588
- const webCryptoKey = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
9589
-
9590
- const privateKey = await webCrypto.exportKey('jwk', webCryptoKey.privateKey);
9591
- const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey);
9592
-
9593
- return {
9594
- A: new Uint8Array(b64ToUint8Array(publicKey.x)),
9595
- k: b64ToUint8Array(privateKey.d, true)
9596
- };
9597
- } catch (err) {
9598
- if (err.name !== 'NotSupportedError') {
9599
- throw err;
9600
- }
9601
- // k stays in little-endian, unlike legacy ECDH over curve25519
9602
- const k = getRandomBytes(32);
9603
- const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
9604
- return { A, k };
9605
- }
9585
+ case enums.publicKey.x25519: {
9586
+ // k stays in little-endian, unlike legacy ECDH over curve25519
9587
+ const k = getRandomBytes(32);
9588
+ const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
9589
+ return { A, k };
9590
+ }
9606
9591
 
9607
9592
  case enums.publicKey.x448: {
9608
9593
  const x448 = await util.getNobleCurve(enums.publicKey.x448);
@@ -9744,32 +9729,13 @@ function getPayloadSize(algo) {
9744
9729
  */
9745
9730
  async function generateEphemeralEncryptionMaterial(algo, recipientA) {
9746
9731
  switch (algo) {
9747
- case enums.publicKey.x25519:
9748
- try {
9749
- const webCrypto = util.getWebCrypto();
9750
- const jwk = publicKeyToJWK(algo, recipientA);
9751
- const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
9752
- const recipientPublicKey = await webCrypto.importKey('jwk', jwk, 'X25519', false, []);
9753
- const sharedSecretBuffer = await webCrypto.deriveBits(
9754
- { name: 'X25519', public: recipientPublicKey },
9755
- ephemeralKeyPair.privateKey,
9756
- getPayloadSize(algo) * 8 // in bits
9757
- );
9758
- const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey);
9759
- return {
9760
- sharedSecret: new Uint8Array(sharedSecretBuffer),
9761
- ephemeralPublicKey: new Uint8Array(b64ToUint8Array(ephemeralPublicKeyJwt.x))
9762
- };
9763
- } catch (err) {
9764
- if (err.name !== 'NotSupportedError') {
9765
- throw err;
9766
- }
9767
- const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
9768
- const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
9769
- const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
9732
+ case enums.publicKey.x25519: {
9733
+ const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
9734
+ const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
9735
+ const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
9770
9736
 
9771
- return { ephemeralPublicKey, sharedSecret };
9772
- }
9737
+ return { ephemeralPublicKey, sharedSecret };
9738
+ }
9773
9739
  case enums.publicKey.x448: {
9774
9740
  const x448 = await util.getNobleCurve(enums.publicKey.x448);
9775
9741
  const ephemeralSecretKey = x448.utils.randomPrivateKey();
@@ -9785,24 +9751,7 @@ async function generateEphemeralEncryptionMaterial(algo, recipientA) {
9785
9751
  async function recomputeSharedSecret(algo, ephemeralPublicKey, A, k) {
9786
9752
  switch (algo) {
9787
9753
  case enums.publicKey.x25519:
9788
- try {
9789
- const webCrypto = util.getWebCrypto();
9790
- const privateKeyJWK = privateKeyToJWK(algo, A, k);
9791
- const ephemeralPublicKeyJWK = publicKeyToJWK(algo, ephemeralPublicKey);
9792
- const privateKey = await webCrypto.importKey('jwk', privateKeyJWK, 'X25519', false, ['deriveKey', 'deriveBits']);
9793
- const ephemeralPublicKeyReference = await webCrypto.importKey('jwk', ephemeralPublicKeyJWK, 'X25519', false, []);
9794
- const sharedSecretBuffer = await webCrypto.deriveBits(
9795
- { name: 'X25519', public: ephemeralPublicKeyReference },
9796
- privateKey,
9797
- getPayloadSize(algo) * 8 // in bits
9798
- );
9799
- return new Uint8Array(sharedSecretBuffer);
9800
- } catch (err) {
9801
- if (err.name !== 'NotSupportedError') {
9802
- throw err;
9803
- }
9804
- return nacl.scalarMult(k, ephemeralPublicKey);
9805
- }
9754
+ return nacl.scalarMult(k, ephemeralPublicKey);
9806
9755
  case enums.publicKey.x448: {
9807
9756
  const x448 = await util.getNobleCurve(enums.publicKey.x448);
9808
9757
  const sharedSecret = x448.getSharedSecret(k, ephemeralPublicKey);
@@ -9813,35 +9762,6 @@ async function recomputeSharedSecret(algo, ephemeralPublicKey, A, k) {
9813
9762
  }
9814
9763
  }
9815
9764
 
9816
-
9817
- function publicKeyToJWK(algo, publicKey) {
9818
- switch (algo) {
9819
- case enums.publicKey.x25519: {
9820
- const jwk = {
9821
- kty: 'OKP',
9822
- crv: 'X25519',
9823
- x: uint8ArrayToB64(publicKey),
9824
- ext: true
9825
- };
9826
- return jwk;
9827
- }
9828
- default:
9829
- throw new Error('Unsupported ECDH algorithm');
9830
- }
9831
- }
9832
-
9833
- function privateKeyToJWK(algo, publicKey, privateKey) {
9834
- switch (algo) {
9835
- case enums.publicKey.x25519: {
9836
- const jwk = publicKeyToJWK(algo, publicKey);
9837
- jwk.d = uint8ArrayToB64(privateKey);
9838
- return jwk;
9839
- }
9840
- default:
9841
- throw new Error('Unsupported ECDH algorithm');
9842
- }
9843
- }
9844
-
9845
9765
  var ecdh_x = /*#__PURE__*/Object.freeze({
9846
9766
  __proto__: null,
9847
9767
  decrypt: decrypt$2,
@@ -12542,13 +12462,25 @@ class Argon2S2K {
12542
12462
  const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
12543
12463
 
12544
12464
  this.type = 'argon2';
12545
- /** @type {Uint8Array} 16 bytes of salt */
12465
+ /**
12466
+ * 16 bytes of salt
12467
+ * @type {Uint8Array}
12468
+ */
12546
12469
  this.salt = null;
12547
- /** @type {Integer} number of passes */
12470
+ /**
12471
+ * number of passes
12472
+ * @type {Integer}
12473
+ */
12548
12474
  this.t = passes;
12549
- /** @type {Integer} degree of parallelism (lanes) */
12475
+ /**
12476
+ * degree of parallelism (lanes)
12477
+ * @type {Integer}
12478
+ */
12550
12479
  this.p = parallelism;
12551
- /** @type {Integer} exponent indicating memory size */
12480
+ /**
12481
+ * exponent indicating memory size
12482
+ * @type {Integer}
12483
+ */
12552
12484
  this.encodedM = memoryExponent;
12553
12485
  }
12554
12486
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protontech/openpgp",
3
3
  "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
4
- "version": "6.0.0-beta.3.patch.0",
4
+ "version": "6.0.0-beta.3.patch.1",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {
@@ -104,9 +104,9 @@
104
104
  "karma-mocha-reporter": "^2.2.5",
105
105
  "karma-webkit-launcher": "^2.6.0",
106
106
  "mocha": "^10.7.3",
107
- "playwright": "^1.46.1",
107
+ "playwright": "^1.47.0",
108
108
  "rollup": "^4.21.2",
109
- "sinon": "^17.0.1",
109
+ "sinon": "^18.0.1",
110
110
  "ts-node": "^10.9.2",
111
111
  "tslib": "^2.7.0",
112
112
  "tsx": "^4.19.0",