@protontech/openpgp 5.10.2 → 5.11.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/bn.interface.min.mjs +1 -1
- package/dist/lightweight/bn.interface.mjs +1 -1
- package/dist/lightweight/bn.min.mjs +1 -1
- package/dist/lightweight/bn.mjs +1 -1
- package/dist/lightweight/elliptic.min.mjs +1 -1
- package/dist/lightweight/elliptic.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +2 -2
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +162 -106
- package/dist/lightweight/ponyfill.es6.min.mjs +1 -1
- package/dist/lightweight/ponyfill.es6.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.min.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.mjs +1 -1
- package/dist/node/openpgp.js +163 -105
- package/dist/node/openpgp.min.js +3 -3
- package/dist/node/openpgp.min.js.map +1 -1
- package/dist/node/openpgp.min.mjs +3 -3
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +162 -106
- package/dist/openpgp.js +163 -105
- package/dist/openpgp.min.js +3 -3
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +3 -3
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +162 -106
- package/openpgp.d.ts +15 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
1
|
+
/*! OpenPGP.js v5.11.1-0 - 2024-02-14 - 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');
|
|
@@ -241,18 +241,17 @@ if (NodeReadableStream$1) {
|
|
|
241
241
|
this.push(null);
|
|
242
242
|
break;
|
|
243
243
|
}
|
|
244
|
-
if (!this.push(value)
|
|
245
|
-
this._reading = false;
|
|
244
|
+
if (!this.push(value)) {
|
|
246
245
|
break;
|
|
247
246
|
}
|
|
248
247
|
}
|
|
249
|
-
} catch(e) {
|
|
250
|
-
this.
|
|
248
|
+
} catch (e) {
|
|
249
|
+
this.destroy(e);
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
252
|
|
|
254
|
-
_destroy(
|
|
255
|
-
this._reader.cancel(
|
|
253
|
+
async _destroy(error, callback) {
|
|
254
|
+
this._reader.cancel(error).then(callback, callback);
|
|
256
255
|
}
|
|
257
256
|
}
|
|
258
257
|
|
|
@@ -287,7 +286,7 @@ function Reader(input) {
|
|
|
287
286
|
const reader = input.getReader();
|
|
288
287
|
this._read = reader.read.bind(reader);
|
|
289
288
|
this._releaseLock = () => {};
|
|
290
|
-
this._cancel = () => {};
|
|
289
|
+
this._cancel = async () => {};
|
|
291
290
|
return;
|
|
292
291
|
}
|
|
293
292
|
let streamType = isStream(input);
|
|
@@ -1552,17 +1551,21 @@ var enums = {
|
|
|
1552
1551
|
'2b8104000a': 'secp256k1',
|
|
1553
1552
|
'2B8104000A': 'secp256k1',
|
|
1554
1553
|
|
|
1555
|
-
/** Ed25519 */
|
|
1554
|
+
/** Ed25519 - deprecated by crypto-refresh (replaced by standaone Ed25519 algo) */
|
|
1555
|
+
'ed25519Legacy': 'ed25519',
|
|
1556
1556
|
'ED25519': 'ed25519',
|
|
1557
|
+
/** @deprecated use `ed25519Legacy` instead */
|
|
1557
1558
|
'ed25519': 'ed25519',
|
|
1558
1559
|
'Ed25519': 'ed25519',
|
|
1559
1560
|
'1.3.6.1.4.1.11591.15.1': 'ed25519',
|
|
1560
1561
|
'2b06010401da470f01': 'ed25519',
|
|
1561
1562
|
'2B06010401DA470F01': 'ed25519',
|
|
1562
1563
|
|
|
1563
|
-
/** Curve25519 */
|
|
1564
|
+
/** Curve25519 - deprecated by crypto-refresh (replaced by standaone X25519 algo) */
|
|
1565
|
+
'curve25519Legacy': 'curve25519',
|
|
1564
1566
|
'X25519': 'curve25519',
|
|
1565
1567
|
'cv25519': 'curve25519',
|
|
1568
|
+
/** @deprecated use `curve25519Legacy` instead */
|
|
1566
1569
|
'curve25519': 'curve25519',
|
|
1567
1570
|
'Curve25519': 'curve25519',
|
|
1568
1571
|
'1.3.6.1.4.1.3029.1.5.1': 'curve25519',
|
|
@@ -1633,8 +1636,11 @@ var enums = {
|
|
|
1633
1636
|
ecdsa: 19,
|
|
1634
1637
|
/** EdDSA (Sign only) - deprecated by crypto-refresh (replaced by `ed25519` identifier below)
|
|
1635
1638
|
* [{@link https://tools.ietf.org/html/draft-koch-eddsa-for-openpgp-04|Draft RFC}] */
|
|
1636
|
-
|
|
1637
|
-
|
|
1639
|
+
eddsaLegacy: 22, // NB: this is declared before `eddsa` to translate 22 to 'eddsa' for backwards compatibility
|
|
1640
|
+
/** @deprecated use `eddsaLegacy` instead */
|
|
1641
|
+
ed25519Legacy: 22,
|
|
1642
|
+
/** @deprecated use `eddsaLegacy` instead */
|
|
1643
|
+
eddsa: 22,
|
|
1638
1644
|
/** Reserved for AEDH */
|
|
1639
1645
|
aedh: 23,
|
|
1640
1646
|
/** Reserved for AEDSA */
|
|
@@ -2944,7 +2950,7 @@ var config = {
|
|
|
2944
2950
|
* @memberof module:config
|
|
2945
2951
|
* @property {String} versionString A version string to be included in armored messages
|
|
2946
2952
|
*/
|
|
2947
|
-
versionString: 'OpenPGP.js 5.
|
|
2953
|
+
versionString: 'OpenPGP.js 5.11.1-0',
|
|
2948
2954
|
/**
|
|
2949
2955
|
* @memberof module:config
|
|
2950
2956
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -2995,7 +3001,14 @@ var config = {
|
|
|
2995
3001
|
* @memberof module:config
|
|
2996
3002
|
* @property {Set<String>} rejectCurves {@link module:enums.curve}
|
|
2997
3003
|
*/
|
|
2998
|
-
rejectCurves: new Set([enums.curve.secp256k1])
|
|
3004
|
+
rejectCurves: new Set([enums.curve.secp256k1]),
|
|
3005
|
+
/**
|
|
3006
|
+
* Whether to validate generated EdDSA signatures before returning them, to ensure they are not faulty signatures.
|
|
3007
|
+
* This check will make signing 2-3 times slower.
|
|
3008
|
+
* Faulty signatures may be generated (in principle) if random bitflips occur at specific points in the signature
|
|
3009
|
+
* computation, and could be used to recover the signer's secret key given a second signature over the same data.
|
|
3010
|
+
*/
|
|
3011
|
+
checkEdDSAFaultySignatures: true
|
|
2999
3012
|
};
|
|
3000
3013
|
|
|
3001
3014
|
// GPG4Browsers - An OpenPGP implementation in javascript
|
|
@@ -10965,42 +10978,42 @@ async function GCM(cipher, key) {
|
|
|
10965
10978
|
throw new Error('GCM mode supports only AES cipher');
|
|
10966
10979
|
}
|
|
10967
10980
|
|
|
10968
|
-
if (util.
|
|
10969
|
-
const _key = await webCrypto$4.importKey('raw', key, { name: ALGO }, false, ['encrypt', 'decrypt']);
|
|
10970
|
-
|
|
10981
|
+
if (util.getNodeCrypto()) { // Node crypto library
|
|
10971
10982
|
return {
|
|
10972
10983
|
encrypt: async function(pt, iv, adata = new Uint8Array()) {
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
const ct = await webCrypto$4.encrypt({ name: ALGO, iv, additionalData: adata, tagLength: tagLength$2 * 8 }, _key, pt);
|
|
10984
|
+
const en = new nodeCrypto$4.createCipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10985
|
+
en.setAAD(adata);
|
|
10986
|
+
const ct = Buffer$2.concat([en.update(pt), en.final(), en.getAuthTag()]); // append auth tag to ciphertext
|
|
10977
10987
|
return new Uint8Array(ct);
|
|
10978
10988
|
},
|
|
10979
10989
|
|
|
10980
10990
|
decrypt: async function(ct, iv, adata = new Uint8Array()) {
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
const pt =
|
|
10991
|
+
const de = new nodeCrypto$4.createDecipheriv('aes-' + (key.length * 8) + '-gcm', key, iv);
|
|
10992
|
+
de.setAAD(adata);
|
|
10993
|
+
de.setAuthTag(ct.slice(ct.length - tagLength$2, ct.length)); // read auth tag at end of ciphertext
|
|
10994
|
+
const pt = Buffer$2.concat([de.update(ct.slice(0, ct.length - tagLength$2)), de.final()]);
|
|
10985
10995
|
return new Uint8Array(pt);
|
|
10986
10996
|
}
|
|
10987
10997
|
};
|
|
10988
10998
|
}
|
|
10989
10999
|
|
|
10990
|
-
if (util.
|
|
11000
|
+
if (util.getWebCrypto() && key.length !== 24) { // WebCrypto (no 192 bit support) see: https://www.chromium.org/blink/webcrypto#TOC-AES-support
|
|
11001
|
+
const _key = await webCrypto$4.importKey('raw', key, { name: ALGO }, false, ['encrypt', 'decrypt']);
|
|
11002
|
+
|
|
10991
11003
|
return {
|
|
10992
11004
|
encrypt: async function(pt, iv, adata = new Uint8Array()) {
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
11005
|
+
if (!pt.length) { // iOS does not support GCM-en/decrypting empty messages
|
|
11006
|
+
return AES_GCM.encrypt(pt, key, iv, adata);
|
|
11007
|
+
}
|
|
11008
|
+
const ct = await webCrypto$4.encrypt({ name: ALGO, iv, additionalData: adata, tagLength: tagLength$2 * 8 }, _key, pt);
|
|
10996
11009
|
return new Uint8Array(ct);
|
|
10997
11010
|
},
|
|
10998
11011
|
|
|
10999
11012
|
decrypt: async function(ct, iv, adata = new Uint8Array()) {
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
const pt =
|
|
11013
|
+
if (ct.length === tagLength$2) { // iOS does not support GCM-en/decrypting empty messages
|
|
11014
|
+
return AES_GCM.decrypt(ct, key, iv, adata);
|
|
11015
|
+
}
|
|
11016
|
+
const pt = await webCrypto$4.decrypt({ name: ALGO, iv, additionalData: adata, tagLength: tagLength$2 * 8 }, _key, ct);
|
|
11004
11017
|
return new Uint8Array(pt);
|
|
11005
11018
|
}
|
|
11006
11019
|
};
|
|
@@ -12003,11 +12016,11 @@ const nodeCrypto$5 = util.getNodeCrypto();
|
|
|
12003
12016
|
*/
|
|
12004
12017
|
function getRandomBytes(length) {
|
|
12005
12018
|
const buf = new Uint8Array(length);
|
|
12006
|
-
if (
|
|
12007
|
-
crypto.getRandomValues(buf);
|
|
12008
|
-
} else if (nodeCrypto$5) {
|
|
12019
|
+
if (nodeCrypto$5) {
|
|
12009
12020
|
const bytes = nodeCrypto$5.randomBytes(buf.length);
|
|
12010
12021
|
buf.set(bytes);
|
|
12022
|
+
} else if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
12023
|
+
crypto.getRandomValues(buf);
|
|
12011
12024
|
} else {
|
|
12012
12025
|
throw new Error('No secure random number generator available.');
|
|
12013
12026
|
}
|
|
@@ -13569,7 +13582,7 @@ const curves = {
|
|
|
13569
13582
|
},
|
|
13570
13583
|
ed25519: {
|
|
13571
13584
|
oid: [0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xDA, 0x47, 0x0F, 0x01],
|
|
13572
|
-
keyType: enums.publicKey.
|
|
13585
|
+
keyType: enums.publicKey.eddsaLegacy,
|
|
13573
13586
|
hash: enums.hash.sha512,
|
|
13574
13587
|
node: false, // nodeCurves.ed25519 TODO
|
|
13575
13588
|
payloadSize: 32
|
|
@@ -14174,10 +14187,24 @@ naclFastLight.hash = bytes => new Uint8Array(_512().update(bytes).digest());
|
|
|
14174
14187
|
async function sign$2(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
14175
14188
|
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
|
|
14176
14189
|
// see https://tools.ietf.org/id/draft-ietf-openpgp-rfc4880bis-10.html#section-15-7.2
|
|
14177
|
-
throw new Error('Hash algorithm too weak
|
|
14190
|
+
throw new Error('Hash algorithm too weak for EdDSA.');
|
|
14178
14191
|
}
|
|
14179
14192
|
const secretKey = util.concatUint8Array([privateKey, publicKey.subarray(1)]);
|
|
14180
14193
|
const signature = naclFastLight.sign.detached(hashed, secretKey);
|
|
14194
|
+
if (config.checkEdDSAFaultySignatures && !naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1))) {
|
|
14195
|
+
/**
|
|
14196
|
+
* Detect faulty signatures caused by random bitflips during `crypto_sign` which could lead to private key extraction
|
|
14197
|
+
* if two signatures over the same message are obtained.
|
|
14198
|
+
* See https://github.com/jedisct1/libsodium/issues/170.
|
|
14199
|
+
* If the input data is not deterministic, e.g. thanks to the random salt in v6 OpenPGP signatures (not yet implemented),
|
|
14200
|
+
* then the generated signature is always safe, and the verification step is skipped.
|
|
14201
|
+
* Otherwise, we need to verify the generated to ensure that no bitflip occured:
|
|
14202
|
+
* - in M between the computation of `r` and `h`.
|
|
14203
|
+
* - in the public key before computing `h`
|
|
14204
|
+
* The verification step is almost 2-3 times as slow as signing, but it's faster than re-signing + re-deriving the public key for separate checks.
|
|
14205
|
+
*/
|
|
14206
|
+
throw new Error('Transient signing failure');
|
|
14207
|
+
}
|
|
14181
14208
|
// EdDSA signature params are returned in little-endian format
|
|
14182
14209
|
return {
|
|
14183
14210
|
r: signature.subarray(0, 32),
|
|
@@ -14198,6 +14225,9 @@ async function sign$2(oid, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
14198
14225
|
* @async
|
|
14199
14226
|
*/
|
|
14200
14227
|
async function verify$2(oid, hashAlgo, { r, s }, m, publicKey, hashed) {
|
|
14228
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(enums.hash.sha256)) {
|
|
14229
|
+
throw new Error('Hash algorithm too weak for EdDSA.');
|
|
14230
|
+
}
|
|
14201
14231
|
const signature = util.concatUint8Array([r, s]);
|
|
14202
14232
|
return naclFastLight.sign.detached.verify(hashed, signature, publicKey.subarray(1));
|
|
14203
14233
|
}
|
|
@@ -14267,14 +14297,27 @@ async function generate$2(algo) {
|
|
|
14267
14297
|
* @async
|
|
14268
14298
|
*/
|
|
14269
14299
|
async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
14270
|
-
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(
|
|
14271
|
-
|
|
14272
|
-
throw new Error('Hash algorithm too weak: sha256 or stronger is required for EdDSA.');
|
|
14300
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(getPreferredHashAlgo$1(algo))) {
|
|
14301
|
+
throw new Error('Hash algorithm too weak for EdDSA.');
|
|
14273
14302
|
}
|
|
14274
14303
|
switch (algo) {
|
|
14275
14304
|
case enums.publicKey.ed25519: {
|
|
14276
14305
|
const secretKey = util.concatUint8Array([privateKey, publicKey]);
|
|
14277
14306
|
const signature = naclFastLight.sign.detached(hashed, secretKey);
|
|
14307
|
+
if (config.checkEdDSAFaultySignatures && !naclFastLight.sign.detached.verify(hashed, signature, publicKey)) {
|
|
14308
|
+
/**
|
|
14309
|
+
* Detect faulty signatures caused by random bitflips during `crypto_sign` which could lead to private key extraction
|
|
14310
|
+
* if two signatures over the same message are obtained.
|
|
14311
|
+
* See https://github.com/jedisct1/libsodium/issues/170.
|
|
14312
|
+
* If the input data is not deterministic, e.g. thanks to the random salt in v6 OpenPGP signatures (not yet implemented),
|
|
14313
|
+
* then the generated signature is always safe, and the verification step is skipped.
|
|
14314
|
+
* Otherwise, we need to verify the generated to ensure that no bitflip occured:
|
|
14315
|
+
* - in M between the computation of `r` and `h`.
|
|
14316
|
+
* - in the public key before computing `h`
|
|
14317
|
+
* The verification step is almost 2-3 times as slow as signing, but it's faster than re-signing + re-deriving the public key for separate checks.
|
|
14318
|
+
*/
|
|
14319
|
+
throw new Error('Transient signing failure');
|
|
14320
|
+
}
|
|
14278
14321
|
return { RS: signature };
|
|
14279
14322
|
}
|
|
14280
14323
|
case enums.publicKey.ed448:
|
|
@@ -14296,6 +14339,9 @@ async function sign$3(algo, hashAlgo, message, publicKey, privateKey, hashed) {
|
|
|
14296
14339
|
* @async
|
|
14297
14340
|
*/
|
|
14298
14341
|
async function verify$3(algo, hashAlgo, { RS }, m, publicKey, hashed) {
|
|
14342
|
+
if (hash.getHashByteLength(hashAlgo) < hash.getHashByteLength(getPreferredHashAlgo$1(algo))) {
|
|
14343
|
+
throw new Error('Hash algorithm too weak for EdDSA.');
|
|
14344
|
+
}
|
|
14299
14345
|
switch (algo) {
|
|
14300
14346
|
case enums.publicKey.ed25519: {
|
|
14301
14347
|
return naclFastLight.sign.detached.verify(hashed, RS, publicKey);
|
|
@@ -14331,12 +14377,22 @@ async function validateParams$4(algo, A, seed) {
|
|
|
14331
14377
|
}
|
|
14332
14378
|
}
|
|
14333
14379
|
|
|
14380
|
+
function getPreferredHashAlgo$1(algo) {
|
|
14381
|
+
switch (algo) {
|
|
14382
|
+
case enums.publicKey.ed25519:
|
|
14383
|
+
return enums.hash.sha256;
|
|
14384
|
+
default:
|
|
14385
|
+
throw new Error('Unknown EdDSA algo');
|
|
14386
|
+
}
|
|
14387
|
+
}
|
|
14388
|
+
|
|
14334
14389
|
var eddsa = /*#__PURE__*/Object.freeze({
|
|
14335
14390
|
__proto__: null,
|
|
14336
14391
|
generate: generate$2,
|
|
14337
14392
|
sign: sign$3,
|
|
14338
14393
|
verify: verify$3,
|
|
14339
|
-
validateParams: validateParams$4
|
|
14394
|
+
validateParams: validateParams$4,
|
|
14395
|
+
getPreferredHashAlgo: getPreferredHashAlgo$1
|
|
14340
14396
|
});
|
|
14341
14397
|
|
|
14342
14398
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
@@ -14950,8 +15006,6 @@ async function generate$3(algo) {
|
|
|
14950
15006
|
case enums.publicKey.x25519: {
|
|
14951
15007
|
// k stays in little-endian, unlike legacy ECDH over curve25519
|
|
14952
15008
|
const k = getRandomBytes(32);
|
|
14953
|
-
k[0] &= 248;
|
|
14954
|
-
k[31] = (k[31] & 127) | 64;
|
|
14955
15009
|
const { publicKey: A } = naclFastLight.box.keyPair.fromSecretKey(k);
|
|
14956
15010
|
return { A, k };
|
|
14957
15011
|
}
|
|
@@ -15386,8 +15440,7 @@ function parseSignatureParams(algo, signature) {
|
|
|
15386
15440
|
// Algorithm-Specific Fields for legacy EdDSA signatures:
|
|
15387
15441
|
// - MPI of an EC point r.
|
|
15388
15442
|
// - EdDSA value s, in MPI, in the little endian representation
|
|
15389
|
-
case enums.publicKey.
|
|
15390
|
-
case enums.publicKey.ed25519Legacy: {
|
|
15443
|
+
case enums.publicKey.eddsaLegacy: {
|
|
15391
15444
|
// When parsing little-endian MPI data, we always need to left-pad it, as done with big-endian values:
|
|
15392
15445
|
// https://www.ietf.org/archive/id/draft-ietf-openpgp-rfc4880bis-10.html#section-3.2-9
|
|
15393
15446
|
let r = util.readMPI(signature.subarray(read)); read += r.length + 2;
|
|
@@ -15448,8 +15501,7 @@ async function verify$5(algo, hashAlgo, signature, publicParams, privateParams,
|
|
|
15448
15501
|
const s = util.leftPad(signature.s, curveSize);
|
|
15449
15502
|
return publicKey.elliptic.ecdsa.verify(oid, hashAlgo, { r, s }, data, Q, hashed);
|
|
15450
15503
|
}
|
|
15451
|
-
case enums.publicKey.
|
|
15452
|
-
case enums.publicKey.ed25519Legacy: {
|
|
15504
|
+
case enums.publicKey.eddsaLegacy: {
|
|
15453
15505
|
const { oid, Q } = publicParams;
|
|
15454
15506
|
// signature already padded on parsing
|
|
15455
15507
|
return publicKey.elliptic.eddsaLegacy.verify(oid, hashAlgo, signature, data, Q, hashed);
|
|
@@ -15512,8 +15564,7 @@ async function sign$5(algo, hashAlgo, publicKeyParams, privateKeyParams, data, h
|
|
|
15512
15564
|
const { d } = privateKeyParams;
|
|
15513
15565
|
return publicKey.elliptic.ecdsa.sign(oid, hashAlgo, data, Q, d, hashed);
|
|
15514
15566
|
}
|
|
15515
|
-
case enums.publicKey.
|
|
15516
|
-
case enums.publicKey.ed25519Legacy: {
|
|
15567
|
+
case enums.publicKey.eddsaLegacy: {
|
|
15517
15568
|
const { oid, Q } = publicKeyParams;
|
|
15518
15569
|
const { seed } = privateKeyParams;
|
|
15519
15570
|
return publicKey.elliptic.eddsaLegacy.sign(oid, hashAlgo, data, Q, seed, hashed);
|
|
@@ -15904,8 +15955,7 @@ function parsePublicKeyParams(algo, bytes) {
|
|
|
15904
15955
|
const Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
15905
15956
|
return { read: read, publicParams: { oid, Q } };
|
|
15906
15957
|
}
|
|
15907
|
-
case enums.publicKey.
|
|
15908
|
-
case enums.publicKey.ed25519Legacy: {
|
|
15958
|
+
case enums.publicKey.eddsaLegacy: {
|
|
15909
15959
|
const oid = new OID(); read += oid.read(bytes);
|
|
15910
15960
|
checkSupportedCurve(oid);
|
|
15911
15961
|
let Q = util.readMPI(bytes.subarray(read)); read += Q.length + 2;
|
|
@@ -15967,8 +16017,7 @@ function parsePrivateKeyParams(algo, bytes, publicParams) {
|
|
|
15967
16017
|
d = util.leftPad(d, curve.payloadSize);
|
|
15968
16018
|
return { read, privateParams: { d } };
|
|
15969
16019
|
}
|
|
15970
|
-
case enums.publicKey.
|
|
15971
|
-
case enums.publicKey.ed25519Legacy: {
|
|
16020
|
+
case enums.publicKey.eddsaLegacy: {
|
|
15972
16021
|
const curve = new CurveWithOID(publicParams.oid);
|
|
15973
16022
|
let seed = util.readMPI(bytes.subarray(read)); read += seed.length + 2;
|
|
15974
16023
|
seed = util.leftPad(seed, curve.payloadSize);
|
|
@@ -16103,8 +16152,7 @@ function generateParams(algo, bits, oid, symmetric) {
|
|
|
16103
16152
|
privateParams: { d: secret },
|
|
16104
16153
|
publicParams: { oid: new OID(oid), Q }
|
|
16105
16154
|
}));
|
|
16106
|
-
case enums.publicKey.
|
|
16107
|
-
case enums.publicKey.ed25519Legacy:
|
|
16155
|
+
case enums.publicKey.eddsaLegacy:
|
|
16108
16156
|
return publicKey.elliptic.generate(oid).then(({ oid, Q, secret }) => ({
|
|
16109
16157
|
privateParams: { seed: secret },
|
|
16110
16158
|
publicParams: { oid: new OID(oid), Q }
|
|
@@ -16198,8 +16246,7 @@ async function validateParams$8(algo, publicParams, privateParams) {
|
|
|
16198
16246
|
const { d } = privateParams;
|
|
16199
16247
|
return algoModule.validateParams(oid, Q, d);
|
|
16200
16248
|
}
|
|
16201
|
-
case enums.publicKey.
|
|
16202
|
-
case enums.publicKey.ed25519Legacy: {
|
|
16249
|
+
case enums.publicKey.eddsaLegacy: {
|
|
16203
16250
|
const { Q, oid } = publicParams;
|
|
16204
16251
|
const { seed } = privateParams;
|
|
16205
16252
|
return publicKey.elliptic.eddsaLegacy.validateParams(oid, Q, seed);
|
|
@@ -16282,6 +16329,23 @@ function checkSupportedCurve(oid) {
|
|
|
16282
16329
|
}
|
|
16283
16330
|
}
|
|
16284
16331
|
|
|
16332
|
+
/**
|
|
16333
|
+
* Get preferred hash algo for a given elliptic algo
|
|
16334
|
+
* @param {module:enums.publicKey} algo - alrogithm identifier
|
|
16335
|
+
* @param {module:type/oid} [oid] - curve OID if needed by algo
|
|
16336
|
+
*/
|
|
16337
|
+
function getPreferredCurveHashAlgo(algo, oid) {
|
|
16338
|
+
switch (algo) {
|
|
16339
|
+
case enums.publicKey.ecdsa:
|
|
16340
|
+
case enums.publicKey.eddsaLegacy:
|
|
16341
|
+
return publicKey.elliptic.getPreferredHashAlgo(oid);
|
|
16342
|
+
case enums.publicKey.ed25519:
|
|
16343
|
+
return publicKey.elliptic.eddsa.getPreferredHashAlgo(algo);
|
|
16344
|
+
default:
|
|
16345
|
+
throw new Error('Unknown elliptic signing algo');
|
|
16346
|
+
}
|
|
16347
|
+
}
|
|
16348
|
+
|
|
16285
16349
|
var crypto$1 = /*#__PURE__*/Object.freeze({
|
|
16286
16350
|
__proto__: null,
|
|
16287
16351
|
publicKeyEncrypt: publicKeyEncrypt,
|
|
@@ -16295,7 +16359,8 @@ var crypto$1 = /*#__PURE__*/Object.freeze({
|
|
|
16295
16359
|
getPrefixRandom: getPrefixRandom,
|
|
16296
16360
|
generateSessionKey: generateSessionKey,
|
|
16297
16361
|
getAEADMode: getAEADMode,
|
|
16298
|
-
getCipher: getCipher
|
|
16362
|
+
getCipher: getCipher,
|
|
16363
|
+
getPreferredCurveHashAlgo: getPreferredCurveHashAlgo
|
|
16299
16364
|
});
|
|
16300
16365
|
|
|
16301
16366
|
/**
|
|
@@ -28053,25 +28118,22 @@ async function createBindingSignature(subkey, primaryKey, options, config) {
|
|
|
28053
28118
|
const dataToSign = {};
|
|
28054
28119
|
dataToSign.key = primaryKey;
|
|
28055
28120
|
dataToSign.bind = subkey;
|
|
28056
|
-
const
|
|
28057
|
-
subkeySignaturePacket.signatureType = enums.signature.subkeyBinding;
|
|
28058
|
-
subkeySignaturePacket.publicKeyAlgorithm = primaryKey.algorithm;
|
|
28059
|
-
subkeySignaturePacket.hashAlgorithm = await getPreferredHashAlgo$1(null, subkey, undefined, undefined, config);
|
|
28121
|
+
const signatureProperties = { signatureType: enums.signature.subkeyBinding };
|
|
28060
28122
|
if (options.sign) {
|
|
28061
|
-
|
|
28062
|
-
|
|
28123
|
+
signatureProperties.keyFlags = [enums.keyFlags.signData];
|
|
28124
|
+
signatureProperties.embeddedSignature = await createSignaturePacket(dataToSign, null, subkey, {
|
|
28063
28125
|
signatureType: enums.signature.keyBinding
|
|
28064
28126
|
}, options.date, undefined, undefined, undefined, config);
|
|
28065
28127
|
} else {
|
|
28066
|
-
|
|
28128
|
+
signatureProperties.keyFlags = options.forwarding ?
|
|
28067
28129
|
[enums.keyFlags.forwardedCommunication] :
|
|
28068
28130
|
[enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage];
|
|
28069
28131
|
}
|
|
28070
28132
|
if (options.keyExpirationTime > 0) {
|
|
28071
|
-
|
|
28072
|
-
|
|
28133
|
+
signatureProperties.keyExpirationTime = options.keyExpirationTime;
|
|
28134
|
+
signatureProperties.keyNeverExpires = false;
|
|
28073
28135
|
}
|
|
28074
|
-
await
|
|
28136
|
+
const subkeySignaturePacket = await createSignaturePacket(dataToSign, null, primaryKey, signatureProperties, options.date, undefined, undefined, undefined, config);
|
|
28075
28137
|
return subkeySignaturePacket;
|
|
28076
28138
|
}
|
|
28077
28139
|
|
|
@@ -28085,7 +28147,7 @@ async function createBindingSignature(subkey, primaryKey, options, config) {
|
|
|
28085
28147
|
* @returns {Promise<enums.hash>}
|
|
28086
28148
|
* @async
|
|
28087
28149
|
*/
|
|
28088
|
-
async function getPreferredHashAlgo$
|
|
28150
|
+
async function getPreferredHashAlgo$2(key, keyPacket, date = new Date(), userID = {}, config) {
|
|
28089
28151
|
let hashAlgo = config.preferredHashAlgorithm;
|
|
28090
28152
|
let prefAlgo = hashAlgo;
|
|
28091
28153
|
if (key) {
|
|
@@ -28096,17 +28158,11 @@ async function getPreferredHashAlgo$1(key, keyPacket, date = new Date(), userID
|
|
|
28096
28158
|
prefAlgo : hashAlgo;
|
|
28097
28159
|
}
|
|
28098
28160
|
}
|
|
28099
|
-
switch (
|
|
28100
|
-
case
|
|
28101
|
-
case
|
|
28102
|
-
case
|
|
28103
|
-
|
|
28104
|
-
switch (keyPacket.algorithm) {
|
|
28105
|
-
case enums.publicKey.ecdh:
|
|
28106
|
-
case enums.publicKey.ecdsa:
|
|
28107
|
-
case enums.publicKey.eddsa:
|
|
28108
|
-
prefAlgo = mod.publicKey.elliptic.getPreferredHashAlgo(keyPacket.publicParams.oid);
|
|
28109
|
-
}
|
|
28161
|
+
switch (keyPacket.algorithm) {
|
|
28162
|
+
case enums.publicKey.ecdsa:
|
|
28163
|
+
case enums.publicKey.eddsaLegacy:
|
|
28164
|
+
case enums.publicKey.ed25519:
|
|
28165
|
+
prefAlgo = mod.getPreferredCurveHashAlgo(keyPacket.algorithm, keyPacket.publicParams.oid);
|
|
28110
28166
|
}
|
|
28111
28167
|
return mod.hash.getHashByteLength(hashAlgo) <= mod.hash.getHashByteLength(prefAlgo) ?
|
|
28112
28168
|
prefAlgo : hashAlgo;
|
|
@@ -28174,7 +28230,7 @@ async function createSignaturePacket(dataToSign, privateKey, signingKeyPacket, s
|
|
|
28174
28230
|
const signaturePacket = new SignaturePacket();
|
|
28175
28231
|
Object.assign(signaturePacket, signatureProperties);
|
|
28176
28232
|
signaturePacket.publicKeyAlgorithm = signingKeyPacket.algorithm;
|
|
28177
|
-
signaturePacket.hashAlgorithm = await getPreferredHashAlgo$
|
|
28233
|
+
signaturePacket.hashAlgorithm = await getPreferredHashAlgo$2(privateKey, signingKeyPacket, date, userID, config);
|
|
28178
28234
|
signaturePacket.rawNotations = notations;
|
|
28179
28235
|
await signaturePacket.sign(signingKeyPacket, dataToSign, date, detached);
|
|
28180
28236
|
return signaturePacket;
|
|
@@ -28315,11 +28371,11 @@ function sanitizeKeyOptions(options, subkeyDefaults = {}) {
|
|
|
28315
28371
|
} catch (e) {
|
|
28316
28372
|
throw new Error('Unknown curve');
|
|
28317
28373
|
}
|
|
28318
|
-
if (options.curve === enums.curve.
|
|
28319
|
-
options.curve = options.sign ? enums.curve.
|
|
28374
|
+
if (options.curve === enums.curve.ed25519Legacy || options.curve === enums.curve.curve25519Legacy) {
|
|
28375
|
+
options.curve = options.sign ? enums.curve.ed25519Legacy : enums.curve.curve25519Legacy;
|
|
28320
28376
|
}
|
|
28321
28377
|
if (options.sign) {
|
|
28322
|
-
options.algorithm = options.curve === enums.curve.
|
|
28378
|
+
options.algorithm = options.curve === enums.curve.ed25519Legacy ? enums.publicKey.eddsaLegacy : enums.publicKey.ecdsa;
|
|
28323
28379
|
} else {
|
|
28324
28380
|
options.algorithm = enums.publicKey.ecdh;
|
|
28325
28381
|
}
|
|
@@ -28357,7 +28413,7 @@ function isValidEncryptionKeyPacket(keyPacket, signature) {
|
|
|
28357
28413
|
return keyAlgo !== enums.publicKey.dsa &&
|
|
28358
28414
|
keyAlgo !== enums.publicKey.rsaSign &&
|
|
28359
28415
|
keyAlgo !== enums.publicKey.ecdsa &&
|
|
28360
|
-
keyAlgo !== enums.publicKey.
|
|
28416
|
+
keyAlgo !== enums.publicKey.eddsaLegacy &&
|
|
28361
28417
|
keyAlgo !== enums.publicKey.ed25519 &&
|
|
28362
28418
|
(!signature.keyFlags ||
|
|
28363
28419
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
@@ -28403,7 +28459,7 @@ function checkKeyRequirements(keyPacket, config) {
|
|
|
28403
28459
|
}
|
|
28404
28460
|
break;
|
|
28405
28461
|
case enums.publicKey.ecdsa:
|
|
28406
|
-
case enums.publicKey.
|
|
28462
|
+
case enums.publicKey.eddsaLegacy:
|
|
28407
28463
|
case enums.publicKey.ecdh:
|
|
28408
28464
|
if (config.rejectCurves.has(algoInfo.curve)) {
|
|
28409
28465
|
throw new Error(`Support for ${algoInfo.algorithm} keys using curve ${algoInfo.curve} is disabled.`);
|
|
@@ -30030,50 +30086,50 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPackets, options, conf
|
|
|
30030
30086
|
const dataToSign = {};
|
|
30031
30087
|
dataToSign.userID = userIDPacket;
|
|
30032
30088
|
dataToSign.key = secretKeyPacket;
|
|
30033
|
-
|
|
30034
|
-
|
|
30035
|
-
|
|
30036
|
-
|
|
30037
|
-
|
|
30038
|
-
signaturePacket.preferredSymmetricAlgorithms = createPreferredAlgos([
|
|
30089
|
+
|
|
30090
|
+
const signatureProperties = {};
|
|
30091
|
+
signatureProperties.signatureType = enums.signature.certGeneric;
|
|
30092
|
+
signatureProperties.keyFlags = [enums.keyFlags.certifyKeys | enums.keyFlags.signData];
|
|
30093
|
+
signatureProperties.preferredSymmetricAlgorithms = createPreferredAlgos([
|
|
30039
30094
|
// prefer aes256, aes128, then aes192 (no WebCrypto support: https://www.chromium.org/blink/webcrypto#TOC-AES-support)
|
|
30040
30095
|
enums.symmetric.aes256,
|
|
30041
30096
|
enums.symmetric.aes128,
|
|
30042
30097
|
enums.symmetric.aes192
|
|
30043
30098
|
], config.preferredSymmetricAlgorithm);
|
|
30044
30099
|
if (config.aeadProtect) {
|
|
30045
|
-
|
|
30100
|
+
signatureProperties.preferredAEADAlgorithms = createPreferredAlgos([
|
|
30046
30101
|
enums.aead.eax,
|
|
30047
30102
|
enums.aead.ocb
|
|
30048
30103
|
], config.preferredAEADAlgorithm);
|
|
30049
30104
|
}
|
|
30050
|
-
|
|
30105
|
+
signatureProperties.preferredHashAlgorithms = createPreferredAlgos([
|
|
30051
30106
|
// prefer fast asm.js implementations (SHA-256)
|
|
30052
30107
|
enums.hash.sha256,
|
|
30053
30108
|
enums.hash.sha512
|
|
30054
30109
|
], config.preferredHashAlgorithm);
|
|
30055
|
-
|
|
30110
|
+
signatureProperties.preferredCompressionAlgorithms = createPreferredAlgos([
|
|
30056
30111
|
enums.compression.zlib,
|
|
30057
30112
|
enums.compression.zip,
|
|
30058
30113
|
enums.compression.uncompressed
|
|
30059
30114
|
], config.preferredCompressionAlgorithm);
|
|
30060
30115
|
if (index === 0) {
|
|
30061
|
-
|
|
30116
|
+
signatureProperties.isPrimaryUserID = true;
|
|
30062
30117
|
}
|
|
30063
30118
|
// integrity protection always enabled
|
|
30064
|
-
|
|
30065
|
-
|
|
30119
|
+
signatureProperties.features = [0];
|
|
30120
|
+
signatureProperties.features[0] |= enums.features.modificationDetection;
|
|
30066
30121
|
if (config.aeadProtect) {
|
|
30067
|
-
|
|
30122
|
+
signatureProperties.features[0] |= enums.features.aead;
|
|
30068
30123
|
}
|
|
30069
30124
|
if (config.v5Keys) {
|
|
30070
|
-
|
|
30125
|
+
signatureProperties.features[0] |= enums.features.v5Keys;
|
|
30071
30126
|
}
|
|
30072
30127
|
if (options.keyExpirationTime > 0) {
|
|
30073
|
-
|
|
30074
|
-
|
|
30128
|
+
signatureProperties.keyExpirationTime = options.keyExpirationTime;
|
|
30129
|
+
signatureProperties.keyNeverExpires = false;
|
|
30075
30130
|
}
|
|
30076
|
-
|
|
30131
|
+
|
|
30132
|
+
const signaturePacket = await createSignaturePacket(dataToSign, null, secretKeyPacket, signatureProperties, options.date, undefined, undefined, undefined, config);
|
|
30077
30133
|
|
|
30078
30134
|
return { userIDPacket, signaturePacket };
|
|
30079
30135
|
})).then(list => {
|
|
@@ -30775,7 +30831,7 @@ class Message {
|
|
|
30775
30831
|
const signingKey = await primaryKey.getSigningKey(signingKeyID, date, userIDs, config$1);
|
|
30776
30832
|
const onePassSig = new OnePassSignaturePacket();
|
|
30777
30833
|
onePassSig.signatureType = signatureType;
|
|
30778
|
-
onePassSig.hashAlgorithm = await getPreferredHashAlgo$
|
|
30834
|
+
onePassSig.hashAlgorithm = await getPreferredHashAlgo$2(primaryKey, signingKey.keyPacket, date, userIDs, config$1);
|
|
30779
30835
|
onePassSig.publicKeyAlgorithm = signingKey.keyPacket.algorithm;
|
|
30780
30836
|
onePassSig.issuerKeyID = signingKey.getKeyID();
|
|
30781
30837
|
if (i === signingKeys.length - 1) {
|
|
@@ -32093,4 +32149,4 @@ function formatObject(object, format, config) {
|
|
|
32093
32149
|
}
|
|
32094
32150
|
}
|
|
32095
32151
|
|
|
32096
|
-
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, _224 as _, commonjsGlobal as a, armor, common$1 as b, createCommonjsModule as c, config, createCleartextMessage, createMessage, common as d, decrypt$5 as decrypt, decryptKey, decryptSessionKeys, _256 as e, encrypt$5 as encrypt, encryptKey, encryptSessionKey, enums, _384 as f, _512 as g, generateKey, generateSessionKey$1 as generateSessionKey, inherits_browser as i, minimalisticAssert as m, ripemd as r, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$6 as sign, utils as u, unarmor, verify$6 as verify };
|
|
32152
|
+
export { AEADEncryptedDataPacket, Argon2OutOfMemoryError, Argon2S2K, 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, _224 as _, commonjsGlobal as a, armor, common$1 as b, createCommonjsModule as c, config, createCleartextMessage, createMessage, common as d, decrypt$5 as decrypt, decryptKey, decryptSessionKeys, _256 as e, encrypt$5 as encrypt, encryptKey, encryptSessionKey, enums, _384 as f, _512 as g, generateKey, generateSessionKey$1 as generateSessionKey, inherits_browser as i, minimalisticAssert as m, ripemd as r, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$6 as sign, utils as u, unarmor, verify$6 as verify };
|