@protontech/openpgp 5.3.1 → 5.5.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/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 +53 -42
- 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 +53 -42
- 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 +53 -42
- package/dist/openpgp.js +53 -42
- 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 +53 -42
- package/openpgp.d.ts +1 -0
- package/package.json +1 -1
package/dist/node/openpgp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
1
|
+
/*! OpenPGP.js v5.5.0 - 2022-10-31 - 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 buffer from 'buffer';
|
|
@@ -1776,7 +1776,7 @@ const util = {
|
|
|
1776
1776
|
*/
|
|
1777
1777
|
printDebug: function (str) {
|
|
1778
1778
|
if (debugMode) {
|
|
1779
|
-
console.log(str);
|
|
1779
|
+
console.log('[OpenPGP.js debug]', str);
|
|
1780
1780
|
}
|
|
1781
1781
|
},
|
|
1782
1782
|
|
|
@@ -1787,7 +1787,7 @@ const util = {
|
|
|
1787
1787
|
*/
|
|
1788
1788
|
printDebugError: function (error) {
|
|
1789
1789
|
if (debugMode) {
|
|
1790
|
-
console.error(error);
|
|
1790
|
+
console.error('[OpenPGP.js debug]', error);
|
|
1791
1791
|
}
|
|
1792
1792
|
},
|
|
1793
1793
|
|
|
@@ -2007,12 +2007,12 @@ const util = {
|
|
|
2007
2007
|
},
|
|
2008
2008
|
|
|
2009
2009
|
/**
|
|
2010
|
-
* Remove trailing spaces and tabs from each line
|
|
2010
|
+
* Remove trailing spaces, carriage returns and tabs from each line
|
|
2011
2011
|
*/
|
|
2012
2012
|
removeTrailingSpaces: function(text) {
|
|
2013
2013
|
return text.split('\n').map(line => {
|
|
2014
2014
|
let i = line.length - 1;
|
|
2015
|
-
for (; i >= 0 && (line[i] === ' ' || line[i] === '\t'); i--);
|
|
2015
|
+
for (; i >= 0 && (line[i] === ' ' || line[i] === '\t' || line[i] === '\r'); i--);
|
|
2016
2016
|
return line.substr(0, i + 1);
|
|
2017
2017
|
}).join('\n');
|
|
2018
2018
|
},
|
|
@@ -2890,7 +2890,7 @@ var defaultConfig = {
|
|
|
2890
2890
|
* @memberof module:config
|
|
2891
2891
|
* @property {String} versionString A version string to be included in armored messages
|
|
2892
2892
|
*/
|
|
2893
|
-
versionString: 'OpenPGP.js 5.
|
|
2893
|
+
versionString: 'OpenPGP.js 5.5.0',
|
|
2894
2894
|
/**
|
|
2895
2895
|
* @memberof module:config
|
|
2896
2896
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -3107,15 +3107,17 @@ function createcrc24(input) {
|
|
|
3107
3107
|
}
|
|
3108
3108
|
|
|
3109
3109
|
/**
|
|
3110
|
-
* Verify armored headers.
|
|
3111
|
-
*
|
|
3110
|
+
* Verify armored headers. crypto-refresh-06, section 6.2:
|
|
3111
|
+
* "An OpenPGP implementation may consider improperly formatted Armor
|
|
3112
|
+
* Headers to be corruption of the ASCII Armor, but SHOULD make an
|
|
3113
|
+
* effort to recover."
|
|
3112
3114
|
* @private
|
|
3113
3115
|
* @param {Array<String>} headers - Armor headers
|
|
3114
3116
|
*/
|
|
3115
3117
|
function verifyHeaders(headers) {
|
|
3116
3118
|
for (let i = 0; i < headers.length; i++) {
|
|
3117
3119
|
if (!/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(headers[i])) {
|
|
3118
|
-
|
|
3120
|
+
util.printDebugError(new Error('Improperly formatted armor header: ' + headers[i]));
|
|
3119
3121
|
}
|
|
3120
3122
|
if (!/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(headers[i])) {
|
|
3121
3123
|
util.printDebugError(new Error('Unknown header: ' + headers[i]));
|
|
@@ -3309,7 +3311,7 @@ function armor(messageType, body, partIndex, partTotal, customComment, config =
|
|
|
3309
3311
|
result.push('-----END PGP MESSAGE, PART ' + partIndex + '-----\n');
|
|
3310
3312
|
break;
|
|
3311
3313
|
case enums.armor.signed:
|
|
3312
|
-
result.push('
|
|
3314
|
+
result.push('-----BEGIN PGP SIGNED MESSAGE-----\n');
|
|
3313
3315
|
result.push('Hash: ' + hash + '\n\n');
|
|
3314
3316
|
result.push(text.replace(/^-/mg, '- -'));
|
|
3315
3317
|
result.push('\n-----BEGIN PGP SIGNATURE-----\n');
|
|
@@ -14300,16 +14302,17 @@ function parsePrivateKeyParams(algo, bytes, publicParams) {
|
|
|
14300
14302
|
}
|
|
14301
14303
|
case enums.publicKey.hmac: {
|
|
14302
14304
|
const { cipher: algo } = publicParams;
|
|
14303
|
-
const keySize = hash.getHashByteLength(algo);
|
|
14305
|
+
const keySize = hash.getHashByteLength(algo.getValue());
|
|
14304
14306
|
const hashSeed = bytes.subarray(read, read + 32); read += 32;
|
|
14305
|
-
const
|
|
14306
|
-
return { read, privateParams: {
|
|
14307
|
+
const keyMaterial = bytes.subarray(read, read + keySize); read += keySize;
|
|
14308
|
+
return { read, privateParams: { hashSeed, keyMaterial } };
|
|
14307
14309
|
}
|
|
14308
14310
|
case enums.publicKey.aead: {
|
|
14309
14311
|
const { cipher: algo } = publicParams;
|
|
14312
|
+
const hashSeed = bytes.subarray(read, read + 32); read += 32;
|
|
14310
14313
|
const { keySize } = getCipher(algo.getValue());
|
|
14311
14314
|
const keyMaterial = bytes.subarray(read, read + keySize); read += keySize;
|
|
14312
|
-
return { read, privateParams: { keyMaterial } };
|
|
14315
|
+
return { read, privateParams: { hashSeed, keyMaterial } };
|
|
14313
14316
|
}
|
|
14314
14317
|
default:
|
|
14315
14318
|
throw new UnsupportedError('Unknown public key encryption algorithm.');
|
|
@@ -14355,13 +14358,12 @@ function parseEncSessionKeyParams(algo, bytes) {
|
|
|
14355
14358
|
// - An authentication tag generated by the AEAD mode.
|
|
14356
14359
|
case enums.publicKey.aead: {
|
|
14357
14360
|
const aeadMode = new AEADEnum(); read += aeadMode.read(bytes.subarray(read));
|
|
14358
|
-
const {
|
|
14361
|
+
const { ivLength } = getAEADMode(aeadMode.getValue());
|
|
14359
14362
|
|
|
14360
14363
|
const iv = bytes.subarray(read, read + ivLength); read += ivLength;
|
|
14361
14364
|
const c = new ShortByteString(); read += c.read(bytes.subarray(read));
|
|
14362
|
-
const t = bytes.subarray(read, read + tagLength);
|
|
14363
14365
|
|
|
14364
|
-
return { aeadMode, iv, c
|
|
14366
|
+
return { aeadMode, iv, c };
|
|
14365
14367
|
}
|
|
14366
14368
|
default:
|
|
14367
14369
|
throw new UnsupportedError('Unknown public key encryption algorithm.');
|
|
@@ -14455,8 +14457,8 @@ async function createSymmetricParams(key, algo) {
|
|
|
14455
14457
|
const bindingHash = await hash.sha256(seed);
|
|
14456
14458
|
return {
|
|
14457
14459
|
privateParams: {
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
+
hashSeed: seed,
|
|
14461
|
+
keyMaterial: key
|
|
14460
14462
|
},
|
|
14461
14463
|
publicParams: {
|
|
14462
14464
|
cipher: algo,
|
|
@@ -14509,14 +14511,14 @@ async function validateParams$6(algo, publicParams, privateParams) {
|
|
|
14509
14511
|
}
|
|
14510
14512
|
case enums.publicKey.hmac: {
|
|
14511
14513
|
const { cipher: algo, digest } = publicParams;
|
|
14512
|
-
const {
|
|
14513
|
-
const keySize = hash.getHashByteLength(algo);
|
|
14514
|
+
const { hashSeed, keyMaterial } = privateParams;
|
|
14515
|
+
const keySize = hash.getHashByteLength(algo.getValue());
|
|
14514
14516
|
return keySize === keyMaterial.length &&
|
|
14515
14517
|
util.equalsUint8Array(digest, await hash.sha256(hashSeed));
|
|
14516
14518
|
}
|
|
14517
14519
|
case enums.publicKey.aead: {
|
|
14518
14520
|
const { cipher: algo, digest } = publicParams;
|
|
14519
|
-
const {
|
|
14521
|
+
const { hashSeed, keyMaterial } = privateParams;
|
|
14520
14522
|
const { keySize } = getCipher(algo.getValue());
|
|
14521
14523
|
return keySize === keyMaterial.length &&
|
|
14522
14524
|
util.equalsUint8Array(digest, await hash.sha256(hashSeed));
|
|
@@ -23266,6 +23268,11 @@ class SignaturePacket {
|
|
|
23266
23268
|
// Add hashed subpackets
|
|
23267
23269
|
arr.push(this.writeHashedSubPackets());
|
|
23268
23270
|
|
|
23271
|
+
// Remove unhashed subpackets, in case some allowed unhashed
|
|
23272
|
+
// subpackets existed, in order not to duplicate them (in both
|
|
23273
|
+
// the hashed and unhashed subpackets) when re-signing.
|
|
23274
|
+
this.unhashedSubpackets = [];
|
|
23275
|
+
|
|
23269
23276
|
this.signatureData = util.concat(arr);
|
|
23270
23277
|
|
|
23271
23278
|
const toHash = this.toHash(this.signatureType, data, detached);
|
|
@@ -23328,6 +23335,11 @@ class SignaturePacket {
|
|
|
23328
23335
|
bytes = util.concat([bytes, this.revocationKeyFingerprint]);
|
|
23329
23336
|
arr.push(writeSubPacket(sub.revocationKey, bytes));
|
|
23330
23337
|
}
|
|
23338
|
+
if (!this.issuerKeyID.isNull() && this.issuerKeyVersion !== 5) {
|
|
23339
|
+
// If the version of [the] key is greater than 4, this subpacket
|
|
23340
|
+
// MUST NOT be included in the signature.
|
|
23341
|
+
arr.push(writeSubPacket(sub.issuer, this.issuerKeyID.write()));
|
|
23342
|
+
}
|
|
23331
23343
|
this.rawNotations.forEach(([{ name, value, humanReadable }]) => {
|
|
23332
23344
|
bytes = [new Uint8Array([humanReadable ? 0x80 : 0, 0, 0, 0])];
|
|
23333
23345
|
// 2 octets of name length
|
|
@@ -23381,6 +23393,14 @@ class SignaturePacket {
|
|
|
23381
23393
|
bytes = util.concat(bytes);
|
|
23382
23394
|
arr.push(writeSubPacket(sub.signatureTarget, bytes));
|
|
23383
23395
|
}
|
|
23396
|
+
if (this.embeddedSignature !== null) {
|
|
23397
|
+
arr.push(writeSubPacket(sub.embeddedSignature, this.embeddedSignature.write()));
|
|
23398
|
+
}
|
|
23399
|
+
if (this.issuerFingerprint !== null) {
|
|
23400
|
+
bytes = [new Uint8Array([this.issuerKeyVersion]), this.issuerFingerprint];
|
|
23401
|
+
bytes = util.concat(bytes);
|
|
23402
|
+
arr.push(writeSubPacket(sub.issuerFingerprint, bytes));
|
|
23403
|
+
}
|
|
23384
23404
|
if (this.preferredAEADAlgorithms !== null) {
|
|
23385
23405
|
bytes = util.stringToUint8Array(util.uint8ArrayToString(this.preferredAEADAlgorithms));
|
|
23386
23406
|
arr.push(writeSubPacket(sub.preferredAEADAlgorithms, bytes));
|
|
@@ -23393,26 +23413,11 @@ class SignaturePacket {
|
|
|
23393
23413
|
}
|
|
23394
23414
|
|
|
23395
23415
|
/**
|
|
23396
|
-
* Creates Uint8Array
|
|
23416
|
+
* Creates an Uint8Array containing the unhashed subpackets
|
|
23397
23417
|
* @returns {Uint8Array} Subpacket data.
|
|
23398
23418
|
*/
|
|
23399
23419
|
writeUnhashedSubPackets() {
|
|
23400
|
-
const sub = enums.signatureSubpacket;
|
|
23401
23420
|
const arr = [];
|
|
23402
|
-
let bytes;
|
|
23403
|
-
if (!this.issuerKeyID.isNull() && this.issuerKeyVersion !== 5) {
|
|
23404
|
-
// If the version of [the] key is greater than 4, this subpacket
|
|
23405
|
-
// MUST NOT be included in the signature.
|
|
23406
|
-
arr.push(writeSubPacket(sub.issuer, this.issuerKeyID.write()));
|
|
23407
|
-
}
|
|
23408
|
-
if (this.embeddedSignature !== null) {
|
|
23409
|
-
arr.push(writeSubPacket(sub.embeddedSignature, this.embeddedSignature.write()));
|
|
23410
|
-
}
|
|
23411
|
-
if (this.issuerFingerprint !== null) {
|
|
23412
|
-
bytes = [new Uint8Array([this.issuerKeyVersion]), this.issuerFingerprint];
|
|
23413
|
-
bytes = util.concat(bytes);
|
|
23414
|
-
arr.push(writeSubPacket(sub.issuerFingerprint, bytes));
|
|
23415
|
-
}
|
|
23416
23421
|
this.unhashedSubpackets.forEach(data => {
|
|
23417
23422
|
arr.push(writeSimpleLength(data.length));
|
|
23418
23423
|
arr.push(data);
|
|
@@ -23432,9 +23437,11 @@ class SignaturePacket {
|
|
|
23432
23437
|
const critical = bytes[mypos] & 0x80;
|
|
23433
23438
|
const type = bytes[mypos] & 0x7F;
|
|
23434
23439
|
|
|
23435
|
-
if (!hashed
|
|
23440
|
+
if (!hashed) {
|
|
23436
23441
|
this.unhashedSubpackets.push(bytes.subarray(mypos, bytes.length));
|
|
23437
|
-
|
|
23442
|
+
if (!allowedUnhashedSubpackets.has(type)) {
|
|
23443
|
+
return;
|
|
23444
|
+
}
|
|
23438
23445
|
}
|
|
23439
23446
|
|
|
23440
23447
|
mypos++;
|
|
@@ -30500,7 +30507,7 @@ class CleartextMessage {
|
|
|
30500
30507
|
* @param {Signature} signature - The detached signature or an empty signature for unsigned messages
|
|
30501
30508
|
*/
|
|
30502
30509
|
constructor(text, signature) {
|
|
30503
|
-
// normalize EOL to canonical form <CR><LF>
|
|
30510
|
+
// remove trailing whitespace and normalize EOL to canonical form <CR><LF>
|
|
30504
30511
|
this.text = util.removeTrailingSpaces(text).replace(/\r?\n/g, '\r\n');
|
|
30505
30512
|
if (signature && !(signature instanceof Signature)) {
|
|
30506
30513
|
throw new Error('Invalid signature input');
|
|
@@ -30901,7 +30908,7 @@ async function encryptKey({ privateKey, passphrase, config, ...rest }) {
|
|
|
30901
30908
|
|
|
30902
30909
|
|
|
30903
30910
|
/**
|
|
30904
|
-
* Encrypts a message using public keys, passwords or both at once. At least one of `encryptionKeys` or `
|
|
30911
|
+
* Encrypts a message using public keys, passwords or both at once. At least one of `encryptionKeys`, `passwords` or `sessionKeys`
|
|
30905
30912
|
* must be specified. If signing keys are specified, those will be used to sign the message.
|
|
30906
30913
|
* @param {Object} options
|
|
30907
30914
|
* @param {Message} options.message - Message to be encrypted as created by {@link createMessage}
|
|
@@ -31216,6 +31223,10 @@ async function encryptSessionKey({ data, algorithm, aeadAlgorithm, encryptionKey
|
|
|
31216
31223
|
if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.encryptSessionKey, pass `encryptionKeys` instead');
|
|
31217
31224
|
const unknownOptions = Object.keys(rest); if (unknownOptions.length > 0) throw new Error(`Unknown option: ${unknownOptions.join(', ')}`);
|
|
31218
31225
|
|
|
31226
|
+
if ((!encryptionKeys || encryptionKeys.length === 0) && (!passwords || passwords.length === 0)) {
|
|
31227
|
+
throw new Error('No encryption keys or passwords provided.');
|
|
31228
|
+
}
|
|
31229
|
+
|
|
31219
31230
|
try {
|
|
31220
31231
|
const message = await Message.encryptSessionKey(data, algorithm, aeadAlgorithm, encryptionKeys, passwords, wildcard, encryptionKeyIDs, date, encryptionUserIDs, config);
|
|
31221
31232
|
return formatObject(message, format, config);
|
package/dist/openpgp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
1
|
+
/*! OpenPGP.js v5.5.0 - 2022-10-31 - 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
|
|
|
@@ -1773,7 +1773,7 @@ var openpgp = (function (exports) {
|
|
|
1773
1773
|
*/
|
|
1774
1774
|
printDebug: function (str) {
|
|
1775
1775
|
if (debugMode) {
|
|
1776
|
-
console.log(str);
|
|
1776
|
+
console.log('[OpenPGP.js debug]', str);
|
|
1777
1777
|
}
|
|
1778
1778
|
},
|
|
1779
1779
|
|
|
@@ -1784,7 +1784,7 @@ var openpgp = (function (exports) {
|
|
|
1784
1784
|
*/
|
|
1785
1785
|
printDebugError: function (error) {
|
|
1786
1786
|
if (debugMode) {
|
|
1787
|
-
console.error(error);
|
|
1787
|
+
console.error('[OpenPGP.js debug]', error);
|
|
1788
1788
|
}
|
|
1789
1789
|
},
|
|
1790
1790
|
|
|
@@ -2004,12 +2004,12 @@ var openpgp = (function (exports) {
|
|
|
2004
2004
|
},
|
|
2005
2005
|
|
|
2006
2006
|
/**
|
|
2007
|
-
* Remove trailing spaces and tabs from each line
|
|
2007
|
+
* Remove trailing spaces, carriage returns and tabs from each line
|
|
2008
2008
|
*/
|
|
2009
2009
|
removeTrailingSpaces: function(text) {
|
|
2010
2010
|
return text.split('\n').map(line => {
|
|
2011
2011
|
let i = line.length - 1;
|
|
2012
|
-
for (; i >= 0 && (line[i] === ' ' || line[i] === '\t'); i--);
|
|
2012
|
+
for (; i >= 0 && (line[i] === ' ' || line[i] === '\t' || line[i] === '\r'); i--);
|
|
2013
2013
|
return line.substr(0, i + 1);
|
|
2014
2014
|
}).join('\n');
|
|
2015
2015
|
},
|
|
@@ -2887,7 +2887,7 @@ var openpgp = (function (exports) {
|
|
|
2887
2887
|
* @memberof module:config
|
|
2888
2888
|
* @property {String} versionString A version string to be included in armored messages
|
|
2889
2889
|
*/
|
|
2890
|
-
versionString: 'OpenPGP.js 5.
|
|
2890
|
+
versionString: 'OpenPGP.js 5.5.0',
|
|
2891
2891
|
/**
|
|
2892
2892
|
* @memberof module:config
|
|
2893
2893
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -3104,15 +3104,17 @@ var openpgp = (function (exports) {
|
|
|
3104
3104
|
}
|
|
3105
3105
|
|
|
3106
3106
|
/**
|
|
3107
|
-
* Verify armored headers.
|
|
3108
|
-
*
|
|
3107
|
+
* Verify armored headers. crypto-refresh-06, section 6.2:
|
|
3108
|
+
* "An OpenPGP implementation may consider improperly formatted Armor
|
|
3109
|
+
* Headers to be corruption of the ASCII Armor, but SHOULD make an
|
|
3110
|
+
* effort to recover."
|
|
3109
3111
|
* @private
|
|
3110
3112
|
* @param {Array<String>} headers - Armor headers
|
|
3111
3113
|
*/
|
|
3112
3114
|
function verifyHeaders(headers) {
|
|
3113
3115
|
for (let i = 0; i < headers.length; i++) {
|
|
3114
3116
|
if (!/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(headers[i])) {
|
|
3115
|
-
|
|
3117
|
+
util.printDebugError(new Error('Improperly formatted armor header: ' + headers[i]));
|
|
3116
3118
|
}
|
|
3117
3119
|
if (!/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(headers[i])) {
|
|
3118
3120
|
util.printDebugError(new Error('Unknown header: ' + headers[i]));
|
|
@@ -3306,7 +3308,7 @@ var openpgp = (function (exports) {
|
|
|
3306
3308
|
result.push('-----END PGP MESSAGE, PART ' + partIndex + '-----\n');
|
|
3307
3309
|
break;
|
|
3308
3310
|
case enums.armor.signed:
|
|
3309
|
-
result.push('
|
|
3311
|
+
result.push('-----BEGIN PGP SIGNED MESSAGE-----\n');
|
|
3310
3312
|
result.push('Hash: ' + hash + '\n\n');
|
|
3311
3313
|
result.push(text.replace(/^-/mg, '- -'));
|
|
3312
3314
|
result.push('\n-----BEGIN PGP SIGNATURE-----\n');
|
|
@@ -14291,16 +14293,17 @@ var openpgp = (function (exports) {
|
|
|
14291
14293
|
}
|
|
14292
14294
|
case enums.publicKey.hmac: {
|
|
14293
14295
|
const { cipher: algo } = publicParams;
|
|
14294
|
-
const keySize = hash.getHashByteLength(algo);
|
|
14296
|
+
const keySize = hash.getHashByteLength(algo.getValue());
|
|
14295
14297
|
const hashSeed = bytes.subarray(read, read + 32); read += 32;
|
|
14296
|
-
const
|
|
14297
|
-
return { read, privateParams: {
|
|
14298
|
+
const keyMaterial = bytes.subarray(read, read + keySize); read += keySize;
|
|
14299
|
+
return { read, privateParams: { hashSeed, keyMaterial } };
|
|
14298
14300
|
}
|
|
14299
14301
|
case enums.publicKey.aead: {
|
|
14300
14302
|
const { cipher: algo } = publicParams;
|
|
14303
|
+
const hashSeed = bytes.subarray(read, read + 32); read += 32;
|
|
14301
14304
|
const { keySize } = getCipher(algo.getValue());
|
|
14302
14305
|
const keyMaterial = bytes.subarray(read, read + keySize); read += keySize;
|
|
14303
|
-
return { read, privateParams: { keyMaterial } };
|
|
14306
|
+
return { read, privateParams: { hashSeed, keyMaterial } };
|
|
14304
14307
|
}
|
|
14305
14308
|
default:
|
|
14306
14309
|
throw new UnsupportedError('Unknown public key encryption algorithm.');
|
|
@@ -14346,13 +14349,12 @@ var openpgp = (function (exports) {
|
|
|
14346
14349
|
// - An authentication tag generated by the AEAD mode.
|
|
14347
14350
|
case enums.publicKey.aead: {
|
|
14348
14351
|
const aeadMode = new AEADEnum(); read += aeadMode.read(bytes.subarray(read));
|
|
14349
|
-
const {
|
|
14352
|
+
const { ivLength } = getAEADMode(aeadMode.getValue());
|
|
14350
14353
|
|
|
14351
14354
|
const iv = bytes.subarray(read, read + ivLength); read += ivLength;
|
|
14352
14355
|
const c = new ShortByteString(); read += c.read(bytes.subarray(read));
|
|
14353
|
-
const t = bytes.subarray(read, read + tagLength);
|
|
14354
14356
|
|
|
14355
|
-
return { aeadMode, iv, c
|
|
14357
|
+
return { aeadMode, iv, c };
|
|
14356
14358
|
}
|
|
14357
14359
|
default:
|
|
14358
14360
|
throw new UnsupportedError('Unknown public key encryption algorithm.');
|
|
@@ -14446,8 +14448,8 @@ var openpgp = (function (exports) {
|
|
|
14446
14448
|
const bindingHash = await hash.sha256(seed);
|
|
14447
14449
|
return {
|
|
14448
14450
|
privateParams: {
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
+
hashSeed: seed,
|
|
14452
|
+
keyMaterial: key
|
|
14451
14453
|
},
|
|
14452
14454
|
publicParams: {
|
|
14453
14455
|
cipher: algo,
|
|
@@ -14500,14 +14502,14 @@ var openpgp = (function (exports) {
|
|
|
14500
14502
|
}
|
|
14501
14503
|
case enums.publicKey.hmac: {
|
|
14502
14504
|
const { cipher: algo, digest } = publicParams;
|
|
14503
|
-
const {
|
|
14504
|
-
const keySize = hash.getHashByteLength(algo);
|
|
14505
|
+
const { hashSeed, keyMaterial } = privateParams;
|
|
14506
|
+
const keySize = hash.getHashByteLength(algo.getValue());
|
|
14505
14507
|
return keySize === keyMaterial.length &&
|
|
14506
14508
|
util.equalsUint8Array(digest, await hash.sha256(hashSeed));
|
|
14507
14509
|
}
|
|
14508
14510
|
case enums.publicKey.aead: {
|
|
14509
14511
|
const { cipher: algo, digest } = publicParams;
|
|
14510
|
-
const {
|
|
14512
|
+
const { hashSeed, keyMaterial } = privateParams;
|
|
14511
14513
|
const { keySize } = getCipher(algo.getValue());
|
|
14512
14514
|
return keySize === keyMaterial.length &&
|
|
14513
14515
|
util.equalsUint8Array(digest, await hash.sha256(hashSeed));
|
|
@@ -23257,6 +23259,11 @@ var openpgp = (function (exports) {
|
|
|
23257
23259
|
// Add hashed subpackets
|
|
23258
23260
|
arr.push(this.writeHashedSubPackets());
|
|
23259
23261
|
|
|
23262
|
+
// Remove unhashed subpackets, in case some allowed unhashed
|
|
23263
|
+
// subpackets existed, in order not to duplicate them (in both
|
|
23264
|
+
// the hashed and unhashed subpackets) when re-signing.
|
|
23265
|
+
this.unhashedSubpackets = [];
|
|
23266
|
+
|
|
23260
23267
|
this.signatureData = util.concat(arr);
|
|
23261
23268
|
|
|
23262
23269
|
const toHash = this.toHash(this.signatureType, data, detached);
|
|
@@ -23319,6 +23326,11 @@ var openpgp = (function (exports) {
|
|
|
23319
23326
|
bytes = util.concat([bytes, this.revocationKeyFingerprint]);
|
|
23320
23327
|
arr.push(writeSubPacket(sub.revocationKey, bytes));
|
|
23321
23328
|
}
|
|
23329
|
+
if (!this.issuerKeyID.isNull() && this.issuerKeyVersion !== 5) {
|
|
23330
|
+
// If the version of [the] key is greater than 4, this subpacket
|
|
23331
|
+
// MUST NOT be included in the signature.
|
|
23332
|
+
arr.push(writeSubPacket(sub.issuer, this.issuerKeyID.write()));
|
|
23333
|
+
}
|
|
23322
23334
|
this.rawNotations.forEach(([{ name, value, humanReadable }]) => {
|
|
23323
23335
|
bytes = [new Uint8Array([humanReadable ? 0x80 : 0, 0, 0, 0])];
|
|
23324
23336
|
// 2 octets of name length
|
|
@@ -23372,6 +23384,14 @@ var openpgp = (function (exports) {
|
|
|
23372
23384
|
bytes = util.concat(bytes);
|
|
23373
23385
|
arr.push(writeSubPacket(sub.signatureTarget, bytes));
|
|
23374
23386
|
}
|
|
23387
|
+
if (this.embeddedSignature !== null) {
|
|
23388
|
+
arr.push(writeSubPacket(sub.embeddedSignature, this.embeddedSignature.write()));
|
|
23389
|
+
}
|
|
23390
|
+
if (this.issuerFingerprint !== null) {
|
|
23391
|
+
bytes = [new Uint8Array([this.issuerKeyVersion]), this.issuerFingerprint];
|
|
23392
|
+
bytes = util.concat(bytes);
|
|
23393
|
+
arr.push(writeSubPacket(sub.issuerFingerprint, bytes));
|
|
23394
|
+
}
|
|
23375
23395
|
if (this.preferredAEADAlgorithms !== null) {
|
|
23376
23396
|
bytes = util.stringToUint8Array(util.uint8ArrayToString(this.preferredAEADAlgorithms));
|
|
23377
23397
|
arr.push(writeSubPacket(sub.preferredAEADAlgorithms, bytes));
|
|
@@ -23384,26 +23404,11 @@ var openpgp = (function (exports) {
|
|
|
23384
23404
|
}
|
|
23385
23405
|
|
|
23386
23406
|
/**
|
|
23387
|
-
* Creates Uint8Array
|
|
23407
|
+
* Creates an Uint8Array containing the unhashed subpackets
|
|
23388
23408
|
* @returns {Uint8Array} Subpacket data.
|
|
23389
23409
|
*/
|
|
23390
23410
|
writeUnhashedSubPackets() {
|
|
23391
|
-
const sub = enums.signatureSubpacket;
|
|
23392
23411
|
const arr = [];
|
|
23393
|
-
let bytes;
|
|
23394
|
-
if (!this.issuerKeyID.isNull() && this.issuerKeyVersion !== 5) {
|
|
23395
|
-
// If the version of [the] key is greater than 4, this subpacket
|
|
23396
|
-
// MUST NOT be included in the signature.
|
|
23397
|
-
arr.push(writeSubPacket(sub.issuer, this.issuerKeyID.write()));
|
|
23398
|
-
}
|
|
23399
|
-
if (this.embeddedSignature !== null) {
|
|
23400
|
-
arr.push(writeSubPacket(sub.embeddedSignature, this.embeddedSignature.write()));
|
|
23401
|
-
}
|
|
23402
|
-
if (this.issuerFingerprint !== null) {
|
|
23403
|
-
bytes = [new Uint8Array([this.issuerKeyVersion]), this.issuerFingerprint];
|
|
23404
|
-
bytes = util.concat(bytes);
|
|
23405
|
-
arr.push(writeSubPacket(sub.issuerFingerprint, bytes));
|
|
23406
|
-
}
|
|
23407
23412
|
this.unhashedSubpackets.forEach(data => {
|
|
23408
23413
|
arr.push(writeSimpleLength(data.length));
|
|
23409
23414
|
arr.push(data);
|
|
@@ -23423,9 +23428,11 @@ var openpgp = (function (exports) {
|
|
|
23423
23428
|
const critical = bytes[mypos] & 0x80;
|
|
23424
23429
|
const type = bytes[mypos] & 0x7F;
|
|
23425
23430
|
|
|
23426
|
-
if (!hashed
|
|
23431
|
+
if (!hashed) {
|
|
23427
23432
|
this.unhashedSubpackets.push(bytes.subarray(mypos, bytes.length));
|
|
23428
|
-
|
|
23433
|
+
if (!allowedUnhashedSubpackets.has(type)) {
|
|
23434
|
+
return;
|
|
23435
|
+
}
|
|
23429
23436
|
}
|
|
23430
23437
|
|
|
23431
23438
|
mypos++;
|
|
@@ -30491,7 +30498,7 @@ var openpgp = (function (exports) {
|
|
|
30491
30498
|
* @param {Signature} signature - The detached signature or an empty signature for unsigned messages
|
|
30492
30499
|
*/
|
|
30493
30500
|
constructor(text, signature) {
|
|
30494
|
-
// normalize EOL to canonical form <CR><LF>
|
|
30501
|
+
// remove trailing whitespace and normalize EOL to canonical form <CR><LF>
|
|
30495
30502
|
this.text = util.removeTrailingSpaces(text).replace(/\r?\n/g, '\r\n');
|
|
30496
30503
|
if (signature && !(signature instanceof Signature)) {
|
|
30497
30504
|
throw new Error('Invalid signature input');
|
|
@@ -30892,7 +30899,7 @@ var openpgp = (function (exports) {
|
|
|
30892
30899
|
|
|
30893
30900
|
|
|
30894
30901
|
/**
|
|
30895
|
-
* Encrypts a message using public keys, passwords or both at once. At least one of `encryptionKeys` or `
|
|
30902
|
+
* Encrypts a message using public keys, passwords or both at once. At least one of `encryptionKeys`, `passwords` or `sessionKeys`
|
|
30896
30903
|
* must be specified. If signing keys are specified, those will be used to sign the message.
|
|
30897
30904
|
* @param {Object} options
|
|
30898
30905
|
* @param {Message} options.message - Message to be encrypted as created by {@link createMessage}
|
|
@@ -31207,6 +31214,10 @@ var openpgp = (function (exports) {
|
|
|
31207
31214
|
if (rest.publicKeys) throw new Error('The `publicKeys` option has been removed from openpgp.encryptSessionKey, pass `encryptionKeys` instead');
|
|
31208
31215
|
const unknownOptions = Object.keys(rest); if (unknownOptions.length > 0) throw new Error(`Unknown option: ${unknownOptions.join(', ')}`);
|
|
31209
31216
|
|
|
31217
|
+
if ((!encryptionKeys || encryptionKeys.length === 0) && (!passwords || passwords.length === 0)) {
|
|
31218
|
+
throw new Error('No encryption keys or passwords provided.');
|
|
31219
|
+
}
|
|
31220
|
+
|
|
31210
31221
|
try {
|
|
31211
31222
|
const message = await Message.encryptSessionKey(data, algorithm, aeadAlgorithm, encryptionKeys, passwords, wildcard, encryptionKeyIDs, date, encryptionUserIDs, config);
|
|
31212
31223
|
return formatObject(message, format, config);
|