@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/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.min.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.mjs +1 -1
- package/dist/lightweight/noble_curves.min.mjs +1 -1
- package/dist/lightweight/noble_curves.mjs +1 -1
- package/dist/lightweight/noble_hashes.min.mjs +1 -1
- package/dist/lightweight/noble_hashes.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +4 -4
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +36 -104
- package/dist/lightweight/sha3.min.mjs +1 -1
- package/dist/lightweight/sha3.mjs +1 -1
- package/dist/node/openpgp.cjs +36 -104
- package/dist/node/openpgp.min.cjs +14 -14
- package/dist/node/openpgp.min.cjs.map +1 -1
- package/dist/node/openpgp.min.mjs +14 -14
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +36 -104
- package/dist/openpgp.js +36 -104
- package/dist/openpgp.min.js +14 -14
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +14 -14
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +36 -104
- package/package.json +3 -3
package/dist/node/openpgp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.0.0-beta.3.patch.
|
|
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
|
import { createRequire } from 'module';
|
|
@@ -1686,7 +1686,7 @@ var config = {
|
|
|
1686
1686
|
* @memberof module:config
|
|
1687
1687
|
* @property {String} versionString A version string to be included in armored messages
|
|
1688
1688
|
*/
|
|
1689
|
-
versionString: 'OpenPGP.js 6.0.0-beta.3.patch.
|
|
1689
|
+
versionString: 'OpenPGP.js 6.0.0-beta.3.patch.1',
|
|
1690
1690
|
/**
|
|
1691
1691
|
* @memberof module:config
|
|
1692
1692
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -9302,7 +9302,7 @@ async function sign$6(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
9302
9302
|
case enums.publicKey.ed25519:
|
|
9303
9303
|
try {
|
|
9304
9304
|
const webCrypto = util.getWebCrypto();
|
|
9305
|
-
const jwk = privateKeyToJWK
|
|
9305
|
+
const jwk = privateKeyToJWK(algo, publicKey, privateKey);
|
|
9306
9306
|
const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['sign']);
|
|
9307
9307
|
|
|
9308
9308
|
const signature = new Uint8Array(
|
|
@@ -9349,7 +9349,7 @@ async function verify$6(algo, hashAlgo, { RS }, m, publicKey, hashed) {
|
|
|
9349
9349
|
case enums.publicKey.ed25519:
|
|
9350
9350
|
try {
|
|
9351
9351
|
const webCrypto = util.getWebCrypto();
|
|
9352
|
-
const jwk = publicKeyToJWK
|
|
9352
|
+
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9353
9353
|
const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['verify']);
|
|
9354
9354
|
const verified = await webCrypto.verify('Ed25519', key, RS, hashed);
|
|
9355
9355
|
return verified;
|
|
@@ -9424,7 +9424,7 @@ function getPreferredHashAlgo$2(algo) {
|
|
|
9424
9424
|
}
|
|
9425
9425
|
}
|
|
9426
9426
|
|
|
9427
|
-
const publicKeyToJWK
|
|
9427
|
+
const publicKeyToJWK = (algo, publicKey) => {
|
|
9428
9428
|
switch (algo) {
|
|
9429
9429
|
case enums.publicKey.ed25519: {
|
|
9430
9430
|
const jwk = {
|
|
@@ -9440,10 +9440,10 @@ const publicKeyToJWK$1 = (algo, publicKey) => {
|
|
|
9440
9440
|
}
|
|
9441
9441
|
};
|
|
9442
9442
|
|
|
9443
|
-
const privateKeyToJWK
|
|
9443
|
+
const privateKeyToJWK = (algo, publicKey, privateKey) => {
|
|
9444
9444
|
switch (algo) {
|
|
9445
9445
|
case enums.publicKey.ed25519: {
|
|
9446
|
-
const jwk = publicKeyToJWK
|
|
9446
|
+
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9447
9447
|
jwk.d = uint8ArrayToB64(privateKey);
|
|
9448
9448
|
return jwk;
|
|
9449
9449
|
}
|
|
@@ -9592,27 +9592,12 @@ const HKDF_INFO = {
|
|
|
9592
9592
|
*/
|
|
9593
9593
|
async function generate$3(algo) {
|
|
9594
9594
|
switch (algo) {
|
|
9595
|
-
case enums.publicKey.x25519:
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey);
|
|
9602
|
-
|
|
9603
|
-
return {
|
|
9604
|
-
A: new Uint8Array(b64ToUint8Array(publicKey.x)),
|
|
9605
|
-
k: b64ToUint8Array(privateKey.d, true)
|
|
9606
|
-
};
|
|
9607
|
-
} catch (err) {
|
|
9608
|
-
if (err.name !== 'NotSupportedError') {
|
|
9609
|
-
throw err;
|
|
9610
|
-
}
|
|
9611
|
-
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
9612
|
-
const k = getRandomBytes(32);
|
|
9613
|
-
const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
|
|
9614
|
-
return { A, k };
|
|
9615
|
-
}
|
|
9595
|
+
case enums.publicKey.x25519: {
|
|
9596
|
+
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
9597
|
+
const k = getRandomBytes(32);
|
|
9598
|
+
const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
|
|
9599
|
+
return { A, k };
|
|
9600
|
+
}
|
|
9616
9601
|
|
|
9617
9602
|
case enums.publicKey.x448: {
|
|
9618
9603
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
@@ -9754,32 +9739,13 @@ function getPayloadSize(algo) {
|
|
|
9754
9739
|
*/
|
|
9755
9740
|
async function generateEphemeralEncryptionMaterial(algo, recipientA) {
|
|
9756
9741
|
switch (algo) {
|
|
9757
|
-
case enums.publicKey.x25519:
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
|
|
9762
|
-
const recipientPublicKey = await webCrypto.importKey('jwk', jwk, 'X25519', false, []);
|
|
9763
|
-
const sharedSecretBuffer = await webCrypto.deriveBits(
|
|
9764
|
-
{ name: 'X25519', public: recipientPublicKey },
|
|
9765
|
-
ephemeralKeyPair.privateKey,
|
|
9766
|
-
getPayloadSize(algo) * 8 // in bits
|
|
9767
|
-
);
|
|
9768
|
-
const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey);
|
|
9769
|
-
return {
|
|
9770
|
-
sharedSecret: new Uint8Array(sharedSecretBuffer),
|
|
9771
|
-
ephemeralPublicKey: new Uint8Array(b64ToUint8Array(ephemeralPublicKeyJwt.x))
|
|
9772
|
-
};
|
|
9773
|
-
} catch (err) {
|
|
9774
|
-
if (err.name !== 'NotSupportedError') {
|
|
9775
|
-
throw err;
|
|
9776
|
-
}
|
|
9777
|
-
const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
|
|
9778
|
-
const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
|
|
9779
|
-
const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
9742
|
+
case enums.publicKey.x25519: {
|
|
9743
|
+
const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
|
|
9744
|
+
const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
|
|
9745
|
+
const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
9780
9746
|
|
|
9781
|
-
|
|
9782
|
-
|
|
9747
|
+
return { ephemeralPublicKey, sharedSecret };
|
|
9748
|
+
}
|
|
9783
9749
|
case enums.publicKey.x448: {
|
|
9784
9750
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
9785
9751
|
const ephemeralSecretKey = x448.utils.randomPrivateKey();
|
|
@@ -9795,24 +9761,7 @@ async function generateEphemeralEncryptionMaterial(algo, recipientA) {
|
|
|
9795
9761
|
async function recomputeSharedSecret(algo, ephemeralPublicKey, A, k) {
|
|
9796
9762
|
switch (algo) {
|
|
9797
9763
|
case enums.publicKey.x25519:
|
|
9798
|
-
|
|
9799
|
-
const webCrypto = util.getWebCrypto();
|
|
9800
|
-
const privateKeyJWK = privateKeyToJWK(algo, A, k);
|
|
9801
|
-
const ephemeralPublicKeyJWK = publicKeyToJWK(algo, ephemeralPublicKey);
|
|
9802
|
-
const privateKey = await webCrypto.importKey('jwk', privateKeyJWK, 'X25519', false, ['deriveKey', 'deriveBits']);
|
|
9803
|
-
const ephemeralPublicKeyReference = await webCrypto.importKey('jwk', ephemeralPublicKeyJWK, 'X25519', false, []);
|
|
9804
|
-
const sharedSecretBuffer = await webCrypto.deriveBits(
|
|
9805
|
-
{ name: 'X25519', public: ephemeralPublicKeyReference },
|
|
9806
|
-
privateKey,
|
|
9807
|
-
getPayloadSize(algo) * 8 // in bits
|
|
9808
|
-
);
|
|
9809
|
-
return new Uint8Array(sharedSecretBuffer);
|
|
9810
|
-
} catch (err) {
|
|
9811
|
-
if (err.name !== 'NotSupportedError') {
|
|
9812
|
-
throw err;
|
|
9813
|
-
}
|
|
9814
|
-
return nacl.scalarMult(k, ephemeralPublicKey);
|
|
9815
|
-
}
|
|
9764
|
+
return nacl.scalarMult(k, ephemeralPublicKey);
|
|
9816
9765
|
case enums.publicKey.x448: {
|
|
9817
9766
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
9818
9767
|
const sharedSecret = x448.getSharedSecret(k, ephemeralPublicKey);
|
|
@@ -9823,35 +9772,6 @@ async function recomputeSharedSecret(algo, ephemeralPublicKey, A, k) {
|
|
|
9823
9772
|
}
|
|
9824
9773
|
}
|
|
9825
9774
|
|
|
9826
|
-
|
|
9827
|
-
function publicKeyToJWK(algo, publicKey) {
|
|
9828
|
-
switch (algo) {
|
|
9829
|
-
case enums.publicKey.x25519: {
|
|
9830
|
-
const jwk = {
|
|
9831
|
-
kty: 'OKP',
|
|
9832
|
-
crv: 'X25519',
|
|
9833
|
-
x: uint8ArrayToB64(publicKey),
|
|
9834
|
-
ext: true
|
|
9835
|
-
};
|
|
9836
|
-
return jwk;
|
|
9837
|
-
}
|
|
9838
|
-
default:
|
|
9839
|
-
throw new Error('Unsupported ECDH algorithm');
|
|
9840
|
-
}
|
|
9841
|
-
}
|
|
9842
|
-
|
|
9843
|
-
function privateKeyToJWK(algo, publicKey, privateKey) {
|
|
9844
|
-
switch (algo) {
|
|
9845
|
-
case enums.publicKey.x25519: {
|
|
9846
|
-
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9847
|
-
jwk.d = uint8ArrayToB64(privateKey);
|
|
9848
|
-
return jwk;
|
|
9849
|
-
}
|
|
9850
|
-
default:
|
|
9851
|
-
throw new Error('Unsupported ECDH algorithm');
|
|
9852
|
-
}
|
|
9853
|
-
}
|
|
9854
|
-
|
|
9855
9775
|
var ecdh_x = /*#__PURE__*/Object.freeze({
|
|
9856
9776
|
__proto__: null,
|
|
9857
9777
|
decrypt: decrypt$2,
|
|
@@ -12552,13 +12472,25 @@ class Argon2S2K {
|
|
|
12552
12472
|
const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
|
|
12553
12473
|
|
|
12554
12474
|
this.type = 'argon2';
|
|
12555
|
-
/**
|
|
12475
|
+
/**
|
|
12476
|
+
* 16 bytes of salt
|
|
12477
|
+
* @type {Uint8Array}
|
|
12478
|
+
*/
|
|
12556
12479
|
this.salt = null;
|
|
12557
|
-
/**
|
|
12480
|
+
/**
|
|
12481
|
+
* number of passes
|
|
12482
|
+
* @type {Integer}
|
|
12483
|
+
*/
|
|
12558
12484
|
this.t = passes;
|
|
12559
|
-
/**
|
|
12485
|
+
/**
|
|
12486
|
+
* degree of parallelism (lanes)
|
|
12487
|
+
* @type {Integer}
|
|
12488
|
+
*/
|
|
12560
12489
|
this.p = parallelism;
|
|
12561
|
-
/**
|
|
12490
|
+
/**
|
|
12491
|
+
* exponent indicating memory size
|
|
12492
|
+
* @type {Integer}
|
|
12493
|
+
*/
|
|
12562
12494
|
this.encodedM = memoryExponent;
|
|
12563
12495
|
}
|
|
12564
12496
|
|
package/dist/openpgp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.0.0-beta.3.patch.
|
|
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
|
var openpgp = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -1685,7 +1685,7 @@ var openpgp = (function (exports) {
|
|
|
1685
1685
|
* @memberof module:config
|
|
1686
1686
|
* @property {String} versionString A version string to be included in armored messages
|
|
1687
1687
|
*/
|
|
1688
|
-
versionString: 'OpenPGP.js 6.0.0-beta.3.patch.
|
|
1688
|
+
versionString: 'OpenPGP.js 6.0.0-beta.3.patch.1',
|
|
1689
1689
|
/**
|
|
1690
1690
|
* @memberof module:config
|
|
1691
1691
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -9295,7 +9295,7 @@ var openpgp = (function (exports) {
|
|
|
9295
9295
|
case enums.publicKey.ed25519:
|
|
9296
9296
|
try {
|
|
9297
9297
|
const webCrypto = util.getWebCrypto();
|
|
9298
|
-
const jwk = privateKeyToJWK
|
|
9298
|
+
const jwk = privateKeyToJWK(algo, publicKey, privateKey);
|
|
9299
9299
|
const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['sign']);
|
|
9300
9300
|
|
|
9301
9301
|
const signature = new Uint8Array(
|
|
@@ -9342,7 +9342,7 @@ var openpgp = (function (exports) {
|
|
|
9342
9342
|
case enums.publicKey.ed25519:
|
|
9343
9343
|
try {
|
|
9344
9344
|
const webCrypto = util.getWebCrypto();
|
|
9345
|
-
const jwk = publicKeyToJWK
|
|
9345
|
+
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9346
9346
|
const key = await webCrypto.importKey('jwk', jwk, 'Ed25519', false, ['verify']);
|
|
9347
9347
|
const verified = await webCrypto.verify('Ed25519', key, RS, hashed);
|
|
9348
9348
|
return verified;
|
|
@@ -9417,7 +9417,7 @@ var openpgp = (function (exports) {
|
|
|
9417
9417
|
}
|
|
9418
9418
|
}
|
|
9419
9419
|
|
|
9420
|
-
const publicKeyToJWK
|
|
9420
|
+
const publicKeyToJWK = (algo, publicKey) => {
|
|
9421
9421
|
switch (algo) {
|
|
9422
9422
|
case enums.publicKey.ed25519: {
|
|
9423
9423
|
const jwk = {
|
|
@@ -9433,10 +9433,10 @@ var openpgp = (function (exports) {
|
|
|
9433
9433
|
}
|
|
9434
9434
|
};
|
|
9435
9435
|
|
|
9436
|
-
const privateKeyToJWK
|
|
9436
|
+
const privateKeyToJWK = (algo, publicKey, privateKey) => {
|
|
9437
9437
|
switch (algo) {
|
|
9438
9438
|
case enums.publicKey.ed25519: {
|
|
9439
|
-
const jwk = publicKeyToJWK
|
|
9439
|
+
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9440
9440
|
jwk.d = uint8ArrayToB64(privateKey);
|
|
9441
9441
|
return jwk;
|
|
9442
9442
|
}
|
|
@@ -9585,27 +9585,12 @@ var openpgp = (function (exports) {
|
|
|
9585
9585
|
*/
|
|
9586
9586
|
async function generate$3(algo) {
|
|
9587
9587
|
switch (algo) {
|
|
9588
|
-
case enums.publicKey.x25519:
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey);
|
|
9595
|
-
|
|
9596
|
-
return {
|
|
9597
|
-
A: new Uint8Array(b64ToUint8Array(publicKey.x)),
|
|
9598
|
-
k: b64ToUint8Array(privateKey.d, true)
|
|
9599
|
-
};
|
|
9600
|
-
} catch (err) {
|
|
9601
|
-
if (err.name !== 'NotSupportedError') {
|
|
9602
|
-
throw err;
|
|
9603
|
-
}
|
|
9604
|
-
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
9605
|
-
const k = getRandomBytes(32);
|
|
9606
|
-
const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
|
|
9607
|
-
return { A, k };
|
|
9608
|
-
}
|
|
9588
|
+
case enums.publicKey.x25519: {
|
|
9589
|
+
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
9590
|
+
const k = getRandomBytes(32);
|
|
9591
|
+
const { publicKey: A } = nacl.box.keyPair.fromSecretKey(k);
|
|
9592
|
+
return { A, k };
|
|
9593
|
+
}
|
|
9609
9594
|
|
|
9610
9595
|
case enums.publicKey.x448: {
|
|
9611
9596
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
@@ -9747,32 +9732,13 @@ var openpgp = (function (exports) {
|
|
|
9747
9732
|
*/
|
|
9748
9733
|
async function generateEphemeralEncryptionMaterial(algo, recipientA) {
|
|
9749
9734
|
switch (algo) {
|
|
9750
|
-
case enums.publicKey.x25519:
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
|
|
9755
|
-
const recipientPublicKey = await webCrypto.importKey('jwk', jwk, 'X25519', false, []);
|
|
9756
|
-
const sharedSecretBuffer = await webCrypto.deriveBits(
|
|
9757
|
-
{ name: 'X25519', public: recipientPublicKey },
|
|
9758
|
-
ephemeralKeyPair.privateKey,
|
|
9759
|
-
getPayloadSize(algo) * 8 // in bits
|
|
9760
|
-
);
|
|
9761
|
-
const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey);
|
|
9762
|
-
return {
|
|
9763
|
-
sharedSecret: new Uint8Array(sharedSecretBuffer),
|
|
9764
|
-
ephemeralPublicKey: new Uint8Array(b64ToUint8Array(ephemeralPublicKeyJwt.x))
|
|
9765
|
-
};
|
|
9766
|
-
} catch (err) {
|
|
9767
|
-
if (err.name !== 'NotSupportedError') {
|
|
9768
|
-
throw err;
|
|
9769
|
-
}
|
|
9770
|
-
const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
|
|
9771
|
-
const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
|
|
9772
|
-
const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
9735
|
+
case enums.publicKey.x25519: {
|
|
9736
|
+
const ephemeralSecretKey = getRandomBytes(getPayloadSize(algo));
|
|
9737
|
+
const sharedSecret = nacl.scalarMult(ephemeralSecretKey, recipientA);
|
|
9738
|
+
const { publicKey: ephemeralPublicKey } = nacl.box.keyPair.fromSecretKey(ephemeralSecretKey);
|
|
9773
9739
|
|
|
9774
|
-
|
|
9775
|
-
|
|
9740
|
+
return { ephemeralPublicKey, sharedSecret };
|
|
9741
|
+
}
|
|
9776
9742
|
case enums.publicKey.x448: {
|
|
9777
9743
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
9778
9744
|
const ephemeralSecretKey = x448.utils.randomPrivateKey();
|
|
@@ -9788,24 +9754,7 @@ var openpgp = (function (exports) {
|
|
|
9788
9754
|
async function recomputeSharedSecret(algo, ephemeralPublicKey, A, k) {
|
|
9789
9755
|
switch (algo) {
|
|
9790
9756
|
case enums.publicKey.x25519:
|
|
9791
|
-
|
|
9792
|
-
const webCrypto = util.getWebCrypto();
|
|
9793
|
-
const privateKeyJWK = privateKeyToJWK(algo, A, k);
|
|
9794
|
-
const ephemeralPublicKeyJWK = publicKeyToJWK(algo, ephemeralPublicKey);
|
|
9795
|
-
const privateKey = await webCrypto.importKey('jwk', privateKeyJWK, 'X25519', false, ['deriveKey', 'deriveBits']);
|
|
9796
|
-
const ephemeralPublicKeyReference = await webCrypto.importKey('jwk', ephemeralPublicKeyJWK, 'X25519', false, []);
|
|
9797
|
-
const sharedSecretBuffer = await webCrypto.deriveBits(
|
|
9798
|
-
{ name: 'X25519', public: ephemeralPublicKeyReference },
|
|
9799
|
-
privateKey,
|
|
9800
|
-
getPayloadSize(algo) * 8 // in bits
|
|
9801
|
-
);
|
|
9802
|
-
return new Uint8Array(sharedSecretBuffer);
|
|
9803
|
-
} catch (err) {
|
|
9804
|
-
if (err.name !== 'NotSupportedError') {
|
|
9805
|
-
throw err;
|
|
9806
|
-
}
|
|
9807
|
-
return nacl.scalarMult(k, ephemeralPublicKey);
|
|
9808
|
-
}
|
|
9757
|
+
return nacl.scalarMult(k, ephemeralPublicKey);
|
|
9809
9758
|
case enums.publicKey.x448: {
|
|
9810
9759
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
|
9811
9760
|
const sharedSecret = x448.getSharedSecret(k, ephemeralPublicKey);
|
|
@@ -9816,35 +9765,6 @@ var openpgp = (function (exports) {
|
|
|
9816
9765
|
}
|
|
9817
9766
|
}
|
|
9818
9767
|
|
|
9819
|
-
|
|
9820
|
-
function publicKeyToJWK(algo, publicKey) {
|
|
9821
|
-
switch (algo) {
|
|
9822
|
-
case enums.publicKey.x25519: {
|
|
9823
|
-
const jwk = {
|
|
9824
|
-
kty: 'OKP',
|
|
9825
|
-
crv: 'X25519',
|
|
9826
|
-
x: uint8ArrayToB64(publicKey),
|
|
9827
|
-
ext: true
|
|
9828
|
-
};
|
|
9829
|
-
return jwk;
|
|
9830
|
-
}
|
|
9831
|
-
default:
|
|
9832
|
-
throw new Error('Unsupported ECDH algorithm');
|
|
9833
|
-
}
|
|
9834
|
-
}
|
|
9835
|
-
|
|
9836
|
-
function privateKeyToJWK(algo, publicKey, privateKey) {
|
|
9837
|
-
switch (algo) {
|
|
9838
|
-
case enums.publicKey.x25519: {
|
|
9839
|
-
const jwk = publicKeyToJWK(algo, publicKey);
|
|
9840
|
-
jwk.d = uint8ArrayToB64(privateKey);
|
|
9841
|
-
return jwk;
|
|
9842
|
-
}
|
|
9843
|
-
default:
|
|
9844
|
-
throw new Error('Unsupported ECDH algorithm');
|
|
9845
|
-
}
|
|
9846
|
-
}
|
|
9847
|
-
|
|
9848
9768
|
var ecdh_x = /*#__PURE__*/Object.freeze({
|
|
9849
9769
|
__proto__: null,
|
|
9850
9770
|
decrypt: decrypt$2,
|
|
@@ -12545,13 +12465,25 @@ var openpgp = (function (exports) {
|
|
|
12545
12465
|
const { passes, parallelism, memoryExponent } = config$1.s2kArgon2Params;
|
|
12546
12466
|
|
|
12547
12467
|
this.type = 'argon2';
|
|
12548
|
-
/**
|
|
12468
|
+
/**
|
|
12469
|
+
* 16 bytes of salt
|
|
12470
|
+
* @type {Uint8Array}
|
|
12471
|
+
*/
|
|
12549
12472
|
this.salt = null;
|
|
12550
|
-
/**
|
|
12473
|
+
/**
|
|
12474
|
+
* number of passes
|
|
12475
|
+
* @type {Integer}
|
|
12476
|
+
*/
|
|
12551
12477
|
this.t = passes;
|
|
12552
|
-
/**
|
|
12478
|
+
/**
|
|
12479
|
+
* degree of parallelism (lanes)
|
|
12480
|
+
* @type {Integer}
|
|
12481
|
+
*/
|
|
12553
12482
|
this.p = parallelism;
|
|
12554
|
-
/**
|
|
12483
|
+
/**
|
|
12484
|
+
* exponent indicating memory size
|
|
12485
|
+
* @type {Integer}
|
|
12486
|
+
*/
|
|
12555
12487
|
this.encodedM = memoryExponent;
|
|
12556
12488
|
}
|
|
12557
12489
|
|