Bug 1891241 - Remove unnecessary GnuPGCryptoAPI and some other code. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D211243 --HG-- extra : amend_source : da4e77ceea0b27e7ad5342cfe884e8c564704551
This commit is contained in:
Родитель
7c8bc3e00d
Коммит
4d39420062
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
|
||||
var gCurrentApi = null;
|
||||
var gGnuPGApi = null;
|
||||
|
||||
export function EnigmailCryptoAPI() {
|
||||
if (!gCurrentApi) {
|
||||
|
@ -16,13 +15,3 @@ export function EnigmailCryptoAPI() {
|
|||
}
|
||||
return gCurrentApi;
|
||||
}
|
||||
|
||||
export function EnigmailGnuPGAPI() {
|
||||
if (!gGnuPGApi) {
|
||||
const { getGnuPGAPI } = ChromeUtils.importESModule(
|
||||
"chrome://openpgp/content/modules/cryptoAPI/GnuPGCryptoAPI.sys.mjs"
|
||||
);
|
||||
gGnuPGApi = getGnuPGAPI();
|
||||
}
|
||||
return gGnuPGApi;
|
||||
}
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://openpgp/content/modules/cryptoAPI/interface.js",
|
||||
null,
|
||||
"UTF-8"
|
||||
);
|
||||
|
||||
/* global CryptoAPI */
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
|
||||
});
|
||||
|
||||
/**
|
||||
* GnuPG implementation of CryptoAPI
|
||||
*/
|
||||
|
||||
class GnuPGCryptoAPI extends CryptoAPI {
|
||||
constructor() {
|
||||
super();
|
||||
this.api_name = "GnuPG";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all known keys (including their secret keys).
|
||||
*
|
||||
* @param {string[]} [_onlyKeys] - Only load data for specified key IDs.
|
||||
* @returns {Promise<object[]>}
|
||||
*/
|
||||
async getKeys(_onlyKeys) {
|
||||
throw new Error("getKeys not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain signatures for a given set of key IDs.
|
||||
*
|
||||
* @param {string} _keyIds - Space-separated list of key IDs.
|
||||
* @param {boolean} _ignoreUnknownUid - If true, filter out unknown signer's UIDs.
|
||||
* @returns {Promise<object[]>} - see extractSignatures()
|
||||
*/
|
||||
async getKeySignatures(_keyIds, _ignoreUnknownUid) {
|
||||
throw new Error("getKeySignatures not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain signatures for a given key.
|
||||
*
|
||||
* @param {KeyObj} _keyObj - The signatures of this key will be returned.
|
||||
* @param {boolean} _ignoreUnknownUid - If true, filter out unknown signer's UIDs
|
||||
* @returns {Promise<object[]>} - see extractSignatures()
|
||||
*/
|
||||
async getKeyObjSignatures(_keyObj, _ignoreUnknownUid) {
|
||||
throw new Error("getKeyObjSignatures not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the minimum key for the public key object:
|
||||
* public key, primary user ID, newest encryption subkey
|
||||
*
|
||||
* @param {string} _fpr - A single fingerprint.
|
||||
* @param {string} [_email] - The email address of the desired user ID.
|
||||
* If the desired user ID cannot be found or is not valid, use the primary
|
||||
* UID instead
|
||||
* @param {integer[]} [_subkeyDates] - Remove subkeys with specific creation
|
||||
* dates.
|
||||
* @returns {Promise<object>} object
|
||||
* @returns {integer} object.exitCode - 0 = success.
|
||||
* @returns {string} object.errorMsg - Error message, if exitCode != 0.
|
||||
* @returns {string} object.keyData - BASE64-encoded string of key data.
|
||||
*/
|
||||
async getMinimalPubKey(_fpr, _email, _subkeyDates) {
|
||||
throw new Error("getMinimalPubKey not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Export secret key(s) to a file
|
||||
*
|
||||
* @param {string} _keyId - Specification by fingerprint or keyID.
|
||||
* @param {boolean} _minimalKey - If true, reduce key to minimum required.
|
||||
* @returns {Promise<object>} object
|
||||
* @returns {integer} object.exitCode - 0 = success
|
||||
* @returns {string} object.errorMsg - Error message, if exitCode != 0.
|
||||
* @returns {string} object.keyData - ASCII armored key data material.
|
||||
*/
|
||||
async extractSecretKey(_keyId, _minimalKey) {
|
||||
throw new Error("extractSecretKey not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byte} _byteData - The encrypted data
|
||||
* @returns {?string} the name of the attached file.
|
||||
*/
|
||||
async getFileName(_byteData) {
|
||||
throw new Error("getFileName not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify attachment.
|
||||
*/
|
||||
async verifyAttachment() {
|
||||
throw new Error("verifyAttachment not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt attachment.
|
||||
*/
|
||||
async decryptAttachment() {
|
||||
throw new Error("decryptAttachment not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Decrypt.
|
||||
*/
|
||||
async decrypt() {
|
||||
throw new Error("Decrypt not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} encrypted - The encrypted data.
|
||||
* @param {object} options - Decryption options.
|
||||
* @returns {Promise<object>} - Return object with decryptedData and
|
||||
* status information.
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async decryptMime(encrypted, options) {
|
||||
// write something to gpg such that the process doesn't get stuck
|
||||
if (encrypted.length === 0) {
|
||||
encrypted = "NO DATA\n";
|
||||
}
|
||||
|
||||
options.noOutput = false;
|
||||
options.verifyOnly = false;
|
||||
options.uiFlags = lazy.EnigmailConstants.UI_PGP_MIME;
|
||||
return this.decrypt(encrypted, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} signed - The signed data.
|
||||
* @param {object} options - Decryption options.
|
||||
* @returns {Promise<object>} - Return object with decryptedData and
|
||||
* status information.
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async verifyMime(signed, options) {
|
||||
options.noOutput = true;
|
||||
options.verifyOnly = true;
|
||||
options.uiFlags = lazy.EnigmailConstants.UI_PGP_MIME;
|
||||
return this.decrypt(signed, options);
|
||||
}
|
||||
|
||||
async getKeyListFromKeyBlockAPI() {
|
||||
throw new Error("getKeyListFromKeyBlockAPI not implemented");
|
||||
}
|
||||
|
||||
async genKey() {
|
||||
throw new Error("genKey not implemented");
|
||||
}
|
||||
|
||||
async deleteKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
async encryptAndOrSign() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function getGnuPGAPI() {
|
||||
return new GnuPGCryptoAPI();
|
||||
}
|
|
@ -12,8 +12,6 @@ Services.scriptloader.loadSubScript(
|
|||
"UTF-8"
|
||||
);
|
||||
|
||||
/* global CryptoAPI */
|
||||
|
||||
import { EnigmailConstants } from "chrome://openpgp/content/modules/constants.sys.mjs";
|
||||
|
||||
/**
|
||||
|
@ -22,7 +20,6 @@ import { EnigmailConstants } from "chrome://openpgp/content/modules/constants.sy
|
|||
class RNPCryptoAPI extends CryptoAPI {
|
||||
constructor() {
|
||||
super();
|
||||
this.api_name = "RNP";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,24 +54,6 @@ class RNPCryptoAPI extends CryptoAPI {
|
|||
return RNP.getKeyObjSignatures(keyId, ignoreUnknownUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the minimum key for the public key object:
|
||||
* public key, primary user ID, newest encryption subkey
|
||||
*
|
||||
* @param {string} _fpr - A a single fingerprint.
|
||||
* @param {string} [_email] - The email address of the desired user ID.
|
||||
* If the desired user ID cannot be found or is not valid, use the primary
|
||||
* UID instead
|
||||
* @param {integer[]} [_subkeyDates] - Remove subkeys with specific creation Dates.
|
||||
* @returns {Promise<object>} result
|
||||
* @returns {integer} result.exitCode - 0 for success.
|
||||
* @returns {string} result.errorMsg - Error message, if exitCode != 0.
|
||||
* @returns {string} result.keyData - key data in base64.
|
||||
*/
|
||||
async getMinimalPubKey(_fpr, _email, _subkeyDates) {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {window} win
|
||||
* @param {string} keyBlock - An block of OpenPGP key data.
|
||||
|
|
|
@ -12,11 +12,6 @@ var inspector;
|
|||
|
||||
class CryptoAPI {
|
||||
constructor() {
|
||||
this.api_name = "null";
|
||||
}
|
||||
|
||||
get apiName() {
|
||||
return this.api_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,225 +49,4 @@ class CryptoAPI {
|
|||
inspector.enterNestedEventLoop(0);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain signatures for a given set of key IDs.
|
||||
*
|
||||
* @param {string} _keyId - Space separated list of key IDs.
|
||||
* @param {boolean} [_ignoreUnknownUid] - If true, filter out unknown signer's UIDs.
|
||||
*
|
||||
* @returns {Promise<object[]>}
|
||||
*/
|
||||
async getKeySignatures(_keyId, _ignoreUnknownUid = false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain signatures for a given key.
|
||||
*
|
||||
* @param {KeyObj} _keyObj - The signatures of this key will be returned.
|
||||
* @param {boolean} [_ignoreUnknownUid] - if true, filter out unknown signer's UIDs.
|
||||
*
|
||||
* @returns {Promise<object[]>}
|
||||
*/
|
||||
async getKeyObjSignatures(_keyObj, _ignoreUnknownUid = false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the minimum key for the public key object:
|
||||
* public key, user ID, newest encryption subkey
|
||||
*
|
||||
* @param {string} _fpr - A single FPR
|
||||
* @param {string} _email - The email address of the desired user ID.
|
||||
* If the desired user ID cannot be found or is not valid, use the primary
|
||||
* UID instead
|
||||
*
|
||||
* @returns {Promise<object>} object
|
||||
* @returns {integer} object.exitCode - 0 = success
|
||||
* @returns {string} object.errorMsg - Error message, if exitCode != 0.
|
||||
* @returns {string} object.keyData - BASE64-encded string of key data.
|
||||
*/
|
||||
async getMinimalPubKey(_fpr, _email) {
|
||||
return {
|
||||
exitCode: -1,
|
||||
errorMsg: "",
|
||||
keyData: "",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all known keys (including their secret keys)
|
||||
*
|
||||
* @param {string[]} [_onlyKeys] - Only load data for specified key IDs.
|
||||
*
|
||||
* @returns {Promise<object[]>}
|
||||
*/
|
||||
async getKeys(_onlyKeys = null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
async importPubkeyBlockAutoAccept(_keyBlock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// return bool success
|
||||
async importRevBlockAPI(_data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export secret key(s) to a file
|
||||
*
|
||||
* @param {string} _keyId Specification by fingerprint or keyID
|
||||
* @param {boolean} _minimalKey - if true, reduce key to minimum required
|
||||
*
|
||||
* @returns {object} object
|
||||
* @returns {integer} object.exitCode - 0 = success
|
||||
* @returns {string} object.errorMsg - Error message, if exitCode != 0.
|
||||
* @returns {string} object.keyData - ASCII armored key data material.
|
||||
*/
|
||||
|
||||
async extractSecretKey(_keyId, _minimalKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the file name from OpenPGP data.
|
||||
*
|
||||
* @param {byte} _byteData - The encrypted data.
|
||||
*
|
||||
* @returns {string} the name of the attached file
|
||||
*/
|
||||
async getFileName(_byteData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the detached signature of an attachment (or in other words,
|
||||
* check the signature of a file, given the file and the signature).
|
||||
*
|
||||
* @param {Path} _filePath - The signed file
|
||||
* @param {Path} _sigPath - The signature to verify
|
||||
*
|
||||
* @returns {Promise<string>} - A message from the verification.
|
||||
*
|
||||
* Use Promise.catch to handle failed verifications.
|
||||
* The message will be an error message in this case.
|
||||
*/
|
||||
async verifyAttachment(_filePath, _sigPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt an attachment.
|
||||
*
|
||||
* @param {Bytes} _encrypted -The encrypted data
|
||||
*
|
||||
* @returns {Promise<object>} an object with decryptedData and
|
||||
* status information
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async decryptAttachment(_encrypted) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function to decrypt and/or verify an OpenPGP message.
|
||||
*
|
||||
* @param {string} _encrypted - The encrypted data
|
||||
* @param {object} _options - Decryption options
|
||||
*
|
||||
* @returns {Promise<object>} an object with decryptedData and
|
||||
* status information
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async decrypt(_encrypted, _options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a PGP/MIME-encrypted message
|
||||
*
|
||||
* @param {string} _encrypted - The encrypted data
|
||||
* @param {object} _options - Decryption options
|
||||
*
|
||||
* @returns {Promise<object>} am object with decryptedData and
|
||||
* status information
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async decryptMime(_encrypted, _options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a PGP/MIME-signed message
|
||||
*
|
||||
* @param {string} _signed - The signed data
|
||||
* @param {object} _options - Decryption options
|
||||
*
|
||||
* @returns {Promise<object>} an object with decryptedData and
|
||||
* status information
|
||||
*
|
||||
* Use Promise.catch to handle failed decryption.
|
||||
* retObj.errorMsg will be an error message in this case.
|
||||
*/
|
||||
async verifyMime(_signed, _options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get details (key ID, UID) of the data contained in a OpenPGP key block
|
||||
*
|
||||
* @param {string} _keyBlockStr - String: the contents of one or more public keys
|
||||
*
|
||||
* @returns {Promise<object[]>} objects
|
||||
* @returns {integer} objects.id - Key ID.
|
||||
* @returns {string} objects.fpr - Fingerprint.
|
||||
* @returns {string} objects.name - UID of the key.
|
||||
*/
|
||||
async getKeyListFromKeyBlockAPI(_keyBlockStr) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new private key pair, including appropriate sub key pair,
|
||||
* and store the new keys in the default keyrings.
|
||||
*
|
||||
* @param {string} _userId - User ID string, with name and email.
|
||||
* @param {"RSA"|"ECC"} _keyType - "RSA" or "ECC".
|
||||
* ECC uses EDDSA and ECDH/Curve25519.
|
||||
* @param {number} _keySize - RSA key size. Ignored for ECC.
|
||||
* @param {number} _expiryTime The number of days the key will remain valid
|
||||
* (after the creation date). Set to zero for no expiration.
|
||||
* @param {string} _passphrase The passphrase to protect the new key.
|
||||
* Set to null to use an empty passphrase.
|
||||
*
|
||||
* @returns {Promise<string>} the new KeyID
|
||||
*/
|
||||
async genKey(_userId, _keyType, _keySize, _expiryTime, _passphrase) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async deleteKey(_keyFingerprint, _deleteSecret) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async encryptAndOrSign(_plaintext, _args, _resultStatus) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async unlockAndGetNewRevocation(_id, _pass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async getPublicKey(_id) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -495,94 +495,6 @@ export class EnigmailKeyObj {
|
|||
return expiryDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the minimum key for the public key object:
|
||||
* public key, desired UID, newest signing/encryption subkey
|
||||
*
|
||||
* @param {?string} [emailAddr] - The email address of UID to extract.
|
||||
* Use primary UID if null.
|
||||
* @returns {object} minimal
|
||||
* @returns {integer} minimal.exitCode 0 for success.
|
||||
* @returns {string} minimal.errorMsg error message, if exitCode != 0.
|
||||
* @returns {string} minimal.keyData BASE64-encded string of key data.
|
||||
*/
|
||||
getMinimalPubKey(emailAddr) {
|
||||
if (emailAddr) {
|
||||
try {
|
||||
emailAddr = lazy.EnigmailFuncs.stripEmail(emailAddr.toLowerCase());
|
||||
} catch (x) {
|
||||
emailAddr = emailAddr.toLowerCase();
|
||||
}
|
||||
|
||||
let foundUid = false,
|
||||
uid = "";
|
||||
for (const i in this.userIds) {
|
||||
try {
|
||||
uid = lazy.EnigmailFuncs.stripEmail(
|
||||
this.userIds[i].userId.toLowerCase()
|
||||
);
|
||||
} catch (x) {
|
||||
uid = this.userIds[i].userId.toLowerCase();
|
||||
}
|
||||
|
||||
if (uid == emailAddr) {
|
||||
foundUid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundUid) {
|
||||
emailAddr = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!emailAddr) {
|
||||
emailAddr = this.userId;
|
||||
}
|
||||
|
||||
try {
|
||||
emailAddr = lazy.EnigmailFuncs.stripEmail(emailAddr.toLowerCase());
|
||||
} catch (x) {
|
||||
emailAddr = emailAddr.toLowerCase();
|
||||
}
|
||||
|
||||
let newestSigningKey = 0,
|
||||
newestEncryptionKey = 0,
|
||||
subkeysArr = null;
|
||||
|
||||
// search for valid subkeys
|
||||
for (const sk in this.subKeys) {
|
||||
if (!"indDre".includes(this.subKeys[sk].keyTrust)) {
|
||||
if (this.subKeys[sk].keyUseFor.search(/[sS]/) >= 0) {
|
||||
// found signing subkey
|
||||
if (this.subKeys[sk].keyCreated > newestSigningKey) {
|
||||
newestSigningKey = this.subKeys[sk].keyCreated;
|
||||
}
|
||||
}
|
||||
if (this.subKeys[sk].keyUseFor.search(/[eE]/) >= 0) {
|
||||
// found encryption subkey
|
||||
if (this.subKeys[sk].keyCreated > newestEncryptionKey) {
|
||||
newestEncryptionKey = this.subKeys[sk].keyCreated;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newestSigningKey > 0 && newestEncryptionKey > 0) {
|
||||
subkeysArr = [newestEncryptionKey, newestSigningKey];
|
||||
}
|
||||
|
||||
if (!this.minimalKeyBlock.has(emailAddr)) {
|
||||
const cApi = lazy.EnigmailCryptoAPI();
|
||||
const pubkey = cApi.sync(
|
||||
cApi.getMinimalPubKey(this.fpr, emailAddr, subkeysArr)
|
||||
);
|
||||
if (pubkey) {
|
||||
this.minimalKeyBlock.set(emailAddr, pubkey);
|
||||
}
|
||||
}
|
||||
return this.minimalKeyBlock.get(emailAddr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a "virtual" key size that allows to compare different algorithms with each other
|
||||
* e.g. elliptic curve keys have small key sizes with high cryptographic strength
|
||||
|
|
|
@ -48,7 +48,6 @@ openpgp.jar:
|
|||
content/openpgp/modules/zbase32.sys.mjs (content/modules/zbase32.sys.mjs)
|
||||
|
||||
content/openpgp/modules/cryptoAPI/RNPCryptoAPI.sys.mjs (content/modules/cryptoAPI/RNPCryptoAPI.sys.mjs)
|
||||
content/openpgp/modules/cryptoAPI/GnuPGCryptoAPI.sys.mjs (content/modules/cryptoAPI/GnuPGCryptoAPI.sys.mjs)
|
||||
content/openpgp/modules/cryptoAPI/interface.js (content/modules/cryptoAPI/interface.js)
|
||||
|
||||
content/openpgp/ui/backupKeyPassword.js (content/ui/backupKeyPassword.js)
|
||||
|
|
|
@ -645,7 +645,7 @@ need-online = The function you have selected is not available in offline mode. P
|
|||
no-key-found2 = We couldn’t find any usable key matching the specified search criteria.
|
||||
no-update-found = You already have the keys that were discovered online.
|
||||
|
||||
## Strings used in keyRing.sys.mjs & GnuPGCryptoAPI.sys.mjs
|
||||
## Strings used in keyRing.sys.mjs
|
||||
|
||||
fail-key-extract = Error - key extraction command failed
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче