Bug 1891241 - Remove EnigmailCryptoAPI indirection. r=mkmelin

Differential Revision: https://phabricator.services.mozilla.com/D211271

--HG--
extra : amend_source : 8e559b4628db8e4bbebd79b74265f8cacdcb0623
This commit is contained in:
Kai Engert 2024-05-24 09:20:50 +12:00
Родитель 5e7817a193
Коммит 7f2fdb39c0
17 изменённых файлов: 45 добавлений и 304 удалений

Просмотреть файл

@ -28,9 +28,6 @@ var { EnigmailKeyserverURIs } = ChromeUtils.importESModule(
var { EnigmailKeyServer } = ChromeUtils.importESModule( var { EnigmailKeyServer } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/keyserver.sys.mjs" "chrome://openpgp/content/modules/keyserver.sys.mjs"
); );
var { EnigmailCryptoAPI } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/cryptoAPI.sys.mjs"
);
var { PgpSqliteDb2 } = ChromeUtils.importESModule( var { PgpSqliteDb2 } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/sqliteDb.sys.mjs" "chrome://openpgp/content/modules/sqliteDb.sys.mjs"
); );
@ -1189,8 +1186,7 @@ async function enigmailDeleteKey(key) {
return; return;
} }
const cApi = EnigmailCryptoAPI(); await RNP.deleteKey(key.fpr, key.secretAvailable);
await cApi.deleteKey(key.fpr, key.secretAvailable);
await PgpSqliteDb2.deleteAcceptance(key.fpr); await PgpSqliteDb2.deleteAcceptance(key.fpr);
EnigmailKeyRing.clearCache(); EnigmailKeyRing.clearCache();

Просмотреть файл

@ -1540,6 +1540,7 @@ export var RNP = {
return is_revoked.value; return is_revoked.value;
}, },
/* unused
getKeySignatures(keyId, ignoreUnknownUid) { getKeySignatures(keyId, ignoreUnknownUid) {
const handle = this.getKeyHandleByKeyIdOrFingerprint( const handle = this.getKeyHandleByKeyIdOrFingerprint(
RNPLib.ffi, RNPLib.ffi,
@ -1563,6 +1564,7 @@ export var RNP = {
RNPLib.rnp_key_handle_destroy(handle); RNPLib.rnp_key_handle_destroy(handle);
return result; return result;
}, },
*/
getKeyObjSignatures(keyObj, ignoreUnknownUid) { getKeyObjSignatures(keyObj, ignoreUnknownUid) {
const handle = this.getKeyHandleByKeyIdOrFingerprint( const handle = this.getKeyHandleByKeyIdOrFingerprint(
@ -5136,4 +5138,8 @@ export var RNP = {
return unsupportedFeatures != 0; return unsupportedFeatures != 0;
}, },
async verifyAttachment(_dataFile, _sigFile) {
throw new Error("verifyAttachment not implemented");
},
}; };

Просмотреть файл

@ -1,17 +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/.
*/
var gCurrentApi = null;
export function EnigmailCryptoAPI() {
if (!gCurrentApi) {
const { getRNPAPI } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/cryptoAPI/RNPCryptoAPI.sys.mjs"
);
gCurrentApi = getRNPAPI();
}
return gCurrentApi;
}

Просмотреть файл

@ -1,215 +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/.
*/
import { RNP } from "chrome://openpgp/content/modules/RNP.sys.mjs";
import { EnigmailConstants } from "chrome://openpgp/content/modules/constants.sys.mjs";
class RNPCryptoAPI {
constructor() {}
/**
* Get the list of all known keys (including their secret keys).
*
* @param {string[]} [onlyKeys] - Only load data for these specified key IDs.
* @returns {Promise<object[]>} the keys
*/
async getKeys(onlyKeys = null) {
return RNP.getKeys(onlyKeys);
}
/**
* 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[]>} signatures. See extractSignatures()
*/
async getKeySignatures(keyId, ignoreUnknownUid = false) {
return RNP.getKeySignatures(keyId, ignoreUnknownUid);
}
/**
* Obtain signatures for a given key.
*
* @param {string} keyId - The signatures of this key will be returned.
* @param {boolean} [ignoreUnknownUid=false] - If true, filter out unknown signer's UIDs.
* @returns {Promise<object[]>} signatures. See extractSignatures()
*/
async getKeyObjSignatures(keyId, ignoreUnknownUid = false) {
return RNP.getKeyObjSignatures(keyId, ignoreUnknownUid);
}
/**
* @param {window} win
* @param {string} keyBlock - An block of OpenPGP key data.
* @param {string} acceptance - The key acceptance level that should
* be assigned to imported public keys.
* @param {boolean} permissive - Whether it's allowed to fall back
* to a permissive import, if strict import fails.
* See RNP documentation for RNP_LOAD_SAVE_PERMISSIVE.
* @param {string[]} limitedFPRs - This is a filtering parameter.
* If the array is empty, all keys will be imported.
* If the array contains at least one entry, a key will be imported
* only if its fingerprint (of the primary key) is listed in this
* array.
*/
async importPubkeyBlockAutoAcceptAPI(
win,
keyBlock,
acceptance,
permissive,
limitedFPRs = []
) {
const res = await RNP.importPubkeyBlockAutoAcceptImpl(
win,
keyBlock,
acceptance,
permissive,
limitedFPRs
);
return res;
}
async importRevBlockAPI(data) {
return RNP.importRevImpl(data);
}
/**
* 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>} 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 extractSecretKey(_keyId, _minimalKey) {
throw new Error("extractSecretKey not implemented");
}
/**
* @param {byte} _byteData - The encrypted data.
* @returns {?string} the name of the attached file, or null.
*/
async getFileName(_byteData) {
throw new Error("getFileName not implemented");
}
/**
*
* @param {string} _filePath - The signed file.
* @param {string} _sigPath - The signature to verify.
* @returns {Promise<string>} - A message from the verification.
*/
async verifyAttachment(_filePath, _sigPath) {
throw new Error("verifyAttachment not implemented");
}
/**
* @param {byte[]} encrypted - The encrypted data.
*
* @returns {Promise<object>} the object with decryptedData and
* status information
*/
async decryptAttachment(encrypted) {
const options = {};
options.fromAddr = "";
options.msgDate = null;
return RNP.decrypt(encrypted, options);
}
/**
* @param {string} encrypted - The encrypted data.
* @param {object} options - Decryption options.
* @returns {Promise<object>} the object with decryptedData and
* status information
*
* Use Promise.catch to handle failed decryption.
* retObj.errorMsg will be an error message in this case.
* XXX: it's not... ^^^ This should be changed to always reject
* by throwing an Error (subclass?) for failures to decrypt.
*/
async decrypt(encrypted, options) {
return RNP.decrypt(encrypted, options);
}
/**
*
* @param {string} encrypted - The encrypted data.
* @param {object} options - Decryption options.
* @returns {Promise<object>} the object with decryptedData and
* status information.
*/
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 = EnigmailConstants.UI_PGP_MIME;
return this.decrypt(encrypted, options);
}
/**
* @param {string} signed - The signed data.
* @param {object} options - Decryption options.
* @returns {Promise<object>} the object with decryptedData and
* status information.
*/
async verifyMime(signed, options) {
if (!options.mimeSignatureData) {
throw new Error("inline verify not yet implemented");
}
return RNP.verifyDetached(signed, options);
}
async getKeyListFromKeyBlockAPI(
keyBlockStr,
pubkey,
seckey,
permissive,
withPubKey
) {
return RNP.getKeyListFromKeyBlockImpl(
keyBlockStr,
pubkey,
seckey,
permissive,
withPubKey
);
}
async genKey(userId, keyType, keySize, expiryTime, passphrase) {
const id = RNP.genKey(userId, keyType, keySize, expiryTime, passphrase);
await RNP.saveKeyRings();
return id;
}
async deleteKey(keyFingerprint, deleteSecret) {
return RNP.deleteKey(keyFingerprint, deleteSecret);
}
async encryptAndOrSign(plaintext, args, resultStatus) {
return RNP.encryptAndOrSign(plaintext, args, resultStatus);
}
async unlockAndGetNewRevocation(id, pass) {
return RNP.unlockAndGetNewRevocation(id, pass);
}
async getPublicKey(id) {
return RNP.getPublicKey(id);
}
}
export function getRNPAPI() {
return new RNPCryptoAPI();
}

Просмотреть файл

@ -11,12 +11,12 @@ ChromeUtils.defineESModuleGetters(lazy, {
EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs", EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs",
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs", EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs", EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs", EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailKey: "chrome://openpgp/content/modules/key.sys.mjs", EnigmailKey: "chrome://openpgp/content/modules/key.sys.mjs",
EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs", EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs",
MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs", MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "log", () => { ChromeUtils.defineLazyGetter(lazy, "log", () => {
return console.createInstance({ return console.createInstance({
@ -279,8 +279,7 @@ export var EnigmailDecryption = {
uiFlags, uiFlags,
msgDate, msgDate,
}; };
const cApi = lazy.EnigmailCryptoAPI(); const result = lazy.EnigmailFuncs.sync(lazy.RNP.decrypt(pgpBlock, options));
const result = lazy.EnigmailFuncs.sync(cApi.decrypt(pgpBlock, options));
if (!result) { if (!result) {
lazy.log.warn("Decryption message finished with no result."); lazy.log.warn("Decryption message finished with no result.");
return ""; return "";
@ -584,8 +583,8 @@ export var EnigmailDecryption = {
lazy.log.debug(`Decrypting attachment to ${outFile.path}`); lazy.log.debug(`Decrypting attachment to ${outFile.path}`);
const cApi = lazy.EnigmailCryptoAPI(); const options = { fromAddr: "", msgDate: null };
const result = await cApi.decryptAttachment(byteData); const result = await lazy.RNP.decrypt(byteData, options);
if (!result) { if (!result) {
lazy.log.warn("Decrypt attachment finished with no result."); lazy.log.warn("Decrypt attachment finished with no result.");
return false; return false;

Просмотреть файл

@ -7,11 +7,11 @@
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs", EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs", EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs", EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs",
PgpSqliteDb2: "chrome://openpgp/content/modules/sqliteDb.sys.mjs", PgpSqliteDb2: "chrome://openpgp/content/modules/sqliteDb.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "l10n", () => { ChromeUtils.defineLazyGetter(lazy, "l10n", () => {
@ -403,9 +403,8 @@ export var EnigmailEncryption = {
} }
const resultStatus = {}; const resultStatus = {};
const cApi = lazy.EnigmailCryptoAPI();
const encrypted = lazy.EnigmailFuncs.sync( const encrypted = lazy.EnigmailFuncs.sync(
cApi.encryptAndOrSign( lazy.RNP.encryptAndOrSign(
listener.getInputForCrypto(), listener.getInputForCrypto(),
encryptArgs, encryptArgs,
resultStatus resultStatus

Просмотреть файл

@ -8,9 +8,9 @@
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs", EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs",
MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs", MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "l10n", () => { ChromeUtils.defineLazyGetter(lazy, "l10n", () => {
@ -181,14 +181,13 @@ export var EnigmailKey = {
this._keyListCache.delete(this._keyListCache.keys().next().value); this._keyListCache.delete(this._keyListCache.keys().next().value);
} }
const cApi = lazy.EnigmailCryptoAPI();
let keyList; let keyList;
let key = {}; let key = {};
let blocks; let blocks;
errorMsgObj.value = ""; errorMsgObj.value = "";
try { try {
keyList = await cApi.getKeyListFromKeyBlockAPI( keyList = await lazy.RNP.getKeyListFromKeyBlockImpl(
keyBlockStr, keyBlockStr,
pubkey, pubkey,
seckey, seckey,

Просмотреть файл

@ -6,7 +6,6 @@
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailKey: "chrome://openpgp/content/modules/key.sys.mjs", EnigmailKey: "chrome://openpgp/content/modules/key.sys.mjs",
}); });
@ -514,19 +513,6 @@ export class EnigmailKeyObj {
} }
} }
/**
* @param {boolean} minimalKey - If true, reduce key to minimum required.
*
* @returns {object} object
* @returns {integer} object.exitCode - Result code (0: OK)
* @returns {string} object.keyData - ASCII armored key data material.
* @returns {string} object.errorMsg - Error message in case exitCode !== 0.
*/
getSecretKey(minimalKey) {
const cApi = lazy.EnigmailCryptoAPI();
return lazy.EnigmailFuncs.sync(cApi.extractSecretKey(this.fpr, minimalKey));
}
iSimpleOneSubkeySameExpiry() { iSimpleOneSubkeySameExpiry() {
if (this.subKeys.length == 0) { if (this.subKeys.length == 0) {
return true; return true;

Просмотреть файл

@ -11,7 +11,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
CollectedKeysDB: "chrome://openpgp/content/modules/CollectedKeysDB.sys.mjs", CollectedKeysDB: "chrome://openpgp/content/modules/CollectedKeysDB.sys.mjs",
OpenPGPAlias: "chrome://openpgp/content/modules/OpenPGPAlias.sys.mjs", OpenPGPAlias: "chrome://openpgp/content/modules/OpenPGPAlias.sys.mjs",
EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs", EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailTrust: "chrome://openpgp/content/modules/trust.sys.mjs", EnigmailTrust: "chrome://openpgp/content/modules/trust.sys.mjs",
EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs", EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs",
@ -350,8 +349,7 @@ export var EnigmailKeyRing = {
endIndexObj.value - beginIndexObj.value + 1 endIndexObj.value - beginIndexObj.value + 1
); );
const cApi = lazy.EnigmailCryptoAPI(); const res = await lazy.RNP.importRevImpl(pgpBlock);
const res = await cApi.importRevBlockAPI(pgpBlock);
if (res.exitCode) { if (res.exitCode) {
return; return;
} }
@ -886,7 +884,6 @@ export var EnigmailKeyRing = {
throw new Error("importKeyAsync with minimizeKey not implemented"); throw new Error("importKeyAsync with minimizeKey not implemented");
} }
const cApi = lazy.EnigmailCryptoAPI();
let result = undefined; let result = undefined;
let tryAgain; let tryAgain;
let permissive = false; let permissive = false;
@ -894,7 +891,10 @@ export var EnigmailKeyRing = {
// strict on first attempt, permissive on optional second attempt // strict on first attempt, permissive on optional second attempt
const blockParam = isBinary ? keyBlock : pgpBlock; const blockParam = isBinary ? keyBlock : pgpBlock;
result = await cApi.importPubkeyBlockAutoAcceptAPI( // TODO: The filtering might not work, because the underlying
// implementation wants to filter by fingerprint, but the filter
// input is apparently user IDs? Really?
result = await lazy.RNP.importPubkeyBlockAutoAcceptImpl(
parent, parent,
blockParam, blockParam,
acceptance, acceptance,
@ -2021,9 +2021,7 @@ function loadKeyList(win, sortColumn, sortDirection, onlyKeys = null) {
} }
gLoadingKeys = true; gLoadingKeys = true;
const cApi = lazy.EnigmailCryptoAPI(); lazy.RNP.getKeys(onlyKeys)
cApi
.getKeys(onlyKeys)
.then(keyList => { .then(keyList => {
createAndSortKeyList( createAndSortKeyList(
keyList, keyList,

Просмотреть файл

@ -7,11 +7,11 @@
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs", EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs", EnigmailKeyRing: "chrome://openpgp/content/modules/keyRing.sys.mjs",
FeedUtils: "resource:///modules/FeedUtils.sys.mjs", FeedUtils: "resource:///modules/FeedUtils.sys.mjs",
MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs", MailStringUtils: "resource:///modules/MailStringUtils.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "log", () => { ChromeUtils.defineLazyGetter(lazy, "log", () => {
return console.createInstance({ return console.createInstance({
@ -1294,8 +1294,7 @@ const accessVksServer = {
listener listener
); );
const cApi = lazy.EnigmailCryptoAPI(); const keyList = await lazy.RNP.getKeyListFromKeyBlockImpl(
const keyList = await cApi.getKeyListFromKeyBlockAPI(
r, r,
true, true,
false, false,

Просмотреть файл

@ -14,13 +14,13 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs", EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs", EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs", EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs",
EnigmailDecryption: "chrome://openpgp/content/modules/decryption.sys.mjs", EnigmailDecryption: "chrome://openpgp/content/modules/decryption.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailMime: "chrome://openpgp/content/modules/mime.sys.mjs", EnigmailMime: "chrome://openpgp/content/modules/mime.sys.mjs",
EnigmailURIs: "chrome://openpgp/content/modules/uris.sys.mjs", EnigmailURIs: "chrome://openpgp/content/modules/uris.sys.mjs",
EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.sys.mjs", EnigmailVerify: "chrome://openpgp/content/modules/mimeVerify.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "log", () => { ChromeUtils.defineLazyGetter(lazy, "log", () => {
return console.createInstance({ return console.createInstance({
@ -449,9 +449,12 @@ MimeDecryptHandler.prototype = {
LAST_MSG.lastMessageURI = currMsg; LAST_MSG.lastMessageURI = currMsg;
LAST_MSG.mimePartNumber = this.mimePartNumber; LAST_MSG.mimePartNumber = this.mimePartNumber;
const cApi = lazy.EnigmailCryptoAPI(); options.noOutput = false;
options.verifyOnly = false;
options.uiFlags = lazy.EnigmailConstants.UI_PGP_MIME;
this.returnStatus = lazy.EnigmailFuncs.sync( this.returnStatus = lazy.EnigmailFuncs.sync(
cApi.decryptMime(this.outQueue, options) lazy.RNP.decrypt(this.outQueue, options)
); );
if (!this.returnStatus) { if (!this.returnStatus) {

Просмотреть файл

@ -11,12 +11,12 @@ import { EnigmailConstants } from "chrome://openpgp/content/modules/constants.sy
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs", EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs", EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs",
EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs", EnigmailFuncs: "chrome://openpgp/content/modules/funcs.sys.mjs",
EnigmailMime: "chrome://openpgp/content/modules/mime.sys.mjs", EnigmailMime: "chrome://openpgp/content/modules/mime.sys.mjs",
EnigmailSingletons: "chrome://openpgp/content/modules/singletons.sys.mjs", EnigmailSingletons: "chrome://openpgp/content/modules/singletons.sys.mjs",
EnigmailURIs: "chrome://openpgp/content/modules/uris.sys.mjs", EnigmailURIs: "chrome://openpgp/content/modules/uris.sys.mjs",
RNP: "chrome://openpgp/content/modules/RNP.sys.mjs",
}); });
ChromeUtils.defineLazyGetter(lazy, "log", () => { ChromeUtils.defineLazyGetter(lazy, "log", () => {
return console.createInstance({ return console.createInstance({
@ -537,8 +537,6 @@ MimeVerify.prototype = {
} }
} }
const cApi = lazy.EnigmailCryptoAPI();
// ensure all lines end with CRLF as specified in RFC 3156, section 5 // ensure all lines end with CRLF as specified in RFC 3156, section 5
if (this.signedData.search(/[^\r]\n/) >= 0) { if (this.signedData.search(/[^\r]\n/) >= 0) {
this.signedData = this.signedData this.signedData = this.signedData
@ -546,8 +544,12 @@ MimeVerify.prototype = {
.replace(/\n/g, "\r\n"); .replace(/\n/g, "\r\n");
} }
if (!options.mimeSignatureData) {
throw new Error("inline verify not yet implemented");
}
this.returnStatus = lazy.EnigmailFuncs.sync( this.returnStatus = lazy.EnigmailFuncs.sync(
cApi.verifyMime(this.signedData, options) lazy.RNP.verifyDetached(this.signedData, options)
); );
if (!this.returnStatus) { if (!this.returnStatus) {

Просмотреть файл

@ -27,9 +27,6 @@ var { EnigmailWindows } = ChromeUtils.importESModule(
var { EnigmailKeyServer } = ChromeUtils.importESModule( var { EnigmailKeyServer } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/keyserver.sys.mjs" "chrome://openpgp/content/modules/keyserver.sys.mjs"
); );
var { EnigmailCryptoAPI } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/cryptoAPI.sys.mjs"
);
var { KeyLookupHelper } = ChromeUtils.importESModule( var { KeyLookupHelper } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/keyLookupHelper.sys.mjs" "chrome://openpgp/content/modules/keyLookupHelper.sys.mjs"
); );
@ -393,10 +390,9 @@ async function enigmailDeleteKey() {
return; return;
} }
const cApi = EnigmailCryptoAPI();
for (const j in keyList) { for (const j in keyList) {
const fpr = gKeyList[keyList[j]].fpr; const fpr = gKeyList[keyList[j]].fpr;
await cApi.deleteKey(fpr, deleteSecret); await lazy.RNP.deleteKey(fpr, deleteSecret);
await PgpSqliteDb2.deleteAcceptance(fpr); await PgpSqliteDb2.deleteAcceptance(fpr);
} }
clearKeyCache(); clearKeyCache();

Просмотреть файл

@ -25,7 +25,6 @@ ChromeUtils.defineESModuleGetters(this, {
EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs", EnigmailArmor: "chrome://openpgp/content/modules/armor.sys.mjs",
EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs", EnigmailConstants: "chrome://openpgp/content/modules/constants.sys.mjs",
EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs", EnigmailCore: "chrome://openpgp/content/modules/core.sys.mjs",
EnigmailCryptoAPI: "chrome://openpgp/content/modules/cryptoAPI.sys.mjs",
EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs", EnigmailData: "chrome://openpgp/content/modules/data.sys.mjs",
EnigmailDecryption: "chrome://openpgp/content/modules/decryption.sys.mjs", EnigmailDecryption: "chrome://openpgp/content/modules/decryption.sys.mjs",
EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs", EnigmailDialog: "chrome://openpgp/content/modules/dialog.sys.mjs",
@ -1955,8 +1954,7 @@ Enigmail.msg = {
} }
await IOUtils.writeUTF8(outFile2.path, await response2.text()); await IOUtils.writeUTF8(outFile2.path, await response2.text());
const cApi = EnigmailCryptoAPI(); const promise = RNP.verifyAttachment(outFile1.path, outFile2.path);
const promise = cApi.verifyAttachment(outFile1.path, outFile2.path);
promise.then(async function (message) { promise.then(async function (message) {
Services.prompt.alert( Services.prompt.alert(
window, window,
@ -2043,8 +2041,7 @@ Enigmail.msg = {
// from an encrypted data block. // from an encrypted data block.
/* /*
if (callbackArg.actionType != "importKey") { if (callbackArg.actionType != "importKey") {
let cApi = EnigmailCryptoAPI(); let origFilename = await ???.getFileName(window, callbackArg.data);
let origFilename = await cApi.getFileName(window, callbackArg.data);
if (origFilename && origFilename.length > rawFileName.length) { if (origFilename && origFilename.length > rawFileName.length) {
rawFileName = origFilename; rawFileName = origFilename;
} }

Просмотреть файл

@ -19,9 +19,6 @@ var { EnigmailKeyRing } = ChromeUtils.importESModule(
var { PgpSqliteDb2 } = ChromeUtils.importESModule( var { PgpSqliteDb2 } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/sqliteDb.sys.mjs" "chrome://openpgp/content/modules/sqliteDb.sys.mjs"
); );
var { EnigmailCryptoAPI } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/cryptoAPI.sys.mjs"
);
var { KeyLookupHelper } = ChromeUtils.importESModule( var { KeyLookupHelper } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/keyLookupHelper.sys.mjs" "chrome://openpgp/content/modules/keyLookupHelper.sys.mjs"
); );
@ -392,8 +389,7 @@ async function reloadData(firstLoad) {
} }
gSigTree = document.getElementById("signatures_tree"); gSigTree = document.getElementById("signatures_tree");
const cApi = EnigmailCryptoAPI(); const signatures = await RNP.getKeyObjSignatures(keyObj, false);
const signatures = await cApi.getKeyObjSignatures(keyObj);
gSigTree.view = new SigListView(signatures); gSigTree.view = new SigListView(signatures);
document.getElementById("subkeyList").view = new SubkeyListView(keyObj); document.getElementById("subkeyList").view = new SubkeyListView(keyObj);

Просмотреть файл

@ -10,9 +10,6 @@ var { MailServices } = ChromeUtils.importESModule(
var { AppConstants } = ChromeUtils.importESModule( var { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs" "resource://gre/modules/AppConstants.sys.mjs"
); );
var { EnigmailCryptoAPI } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/cryptoAPI.sys.mjs"
);
var { OpenPGPMasterpass } = ChromeUtils.importESModule( var { OpenPGPMasterpass } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/masterpass.sys.mjs" "chrome://openpgp/content/modules/masterpass.sys.mjs"
); );
@ -34,6 +31,9 @@ var { PgpSqliteDb2 } = ChromeUtils.importESModule(
var { EnigmailCore } = ChromeUtils.importESModule( var { EnigmailCore } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/core.sys.mjs" "chrome://openpgp/content/modules/core.sys.mjs"
); );
var { RNP } = ChromeUtils.importESModule(
"chrome://openpgp/content/modules/RNP.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, { ChromeUtils.defineESModuleGetters(this, {
LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs", LoginHelper: "resource://gre/modules/LoginHelper.sys.mjs",
@ -654,7 +654,6 @@ async function openPgpKeygenConfirm() {
kGenerating = true; kGenerating = true;
let password; let password;
const cApi = EnigmailCryptoAPI();
let newId = null; let newId = null;
const sepPassphraseEnabled = Services.prefs.getBoolPref( const sepPassphraseEnabled = Services.prefs.getBoolPref(
@ -669,7 +668,7 @@ async function openPgpKeygenConfirm() {
} else { } else {
password = document.getElementById("passwordInput").value; password = document.getElementById("passwordInput").value;
} }
newId = await cApi.genKey( newId = await RNP.genKey(
`${gIdentity.fullName} <${gIdentity.email}>`, `${gIdentity.fullName} <${gIdentity.email}>`,
document.getElementById("keyType").value, document.getElementById("keyType").value,
Number(document.getElementById("keySize").value), Number(document.getElementById("keySize").value),
@ -679,6 +678,7 @@ async function openPgpKeygenConfirm() {
Number(document.getElementById("timeScale").value), Number(document.getElementById("timeScale").value),
password password
); );
await RNP.saveKeyRings();
gGeneratedKey = newId; gGeneratedKey = newId;
@ -706,7 +706,7 @@ async function openPgpKeygenConfirm() {
closeOverlay(); closeOverlay();
EnigmailKeyRing.clearCache(); EnigmailKeyRing.clearCache();
const rev = await cApi.unlockAndGetNewRevocation( const rev = await RNP.unlockAndGetNewRevocation(
`0x${gGeneratedKey}`, `0x${gGeneratedKey}`,
password, password,
true true

Просмотреть файл

@ -10,7 +10,6 @@ openpgp.jar:
content/openpgp/modules/CollectedKeysDB.sys.mjs (content/modules/CollectedKeysDB.sys.mjs) content/openpgp/modules/CollectedKeysDB.sys.mjs (content/modules/CollectedKeysDB.sys.mjs)
content/openpgp/modules/constants.sys.mjs (content/modules/constants.sys.mjs) content/openpgp/modules/constants.sys.mjs (content/modules/constants.sys.mjs)
content/openpgp/modules/core.sys.mjs (content/modules/core.sys.mjs) content/openpgp/modules/core.sys.mjs (content/modules/core.sys.mjs)
content/openpgp/modules/cryptoAPI.sys.mjs (content/modules/cryptoAPI.sys.mjs)
content/openpgp/modules/data.sys.mjs (content/modules/data.sys.mjs) content/openpgp/modules/data.sys.mjs (content/modules/data.sys.mjs)
content/openpgp/modules/decryption.sys.mjs (content/modules/decryption.sys.mjs) content/openpgp/modules/decryption.sys.mjs (content/modules/decryption.sys.mjs)
content/openpgp/modules/dialog.sys.mjs (content/modules/dialog.sys.mjs) content/openpgp/modules/dialog.sys.mjs (content/modules/dialog.sys.mjs)
@ -47,8 +46,6 @@ openpgp.jar:
content/openpgp/modules/wkdLookup.sys.mjs (content/modules/wkdLookup.sys.mjs) content/openpgp/modules/wkdLookup.sys.mjs (content/modules/wkdLookup.sys.mjs)
content/openpgp/modules/zbase32.sys.mjs (content/modules/zbase32.sys.mjs) 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/ui/backupKeyPassword.js (content/ui/backupKeyPassword.js) content/openpgp/ui/backupKeyPassword.js (content/ui/backupKeyPassword.js)
content/openpgp/ui/changeExpiryDlg.js (content/ui/changeExpiryDlg.js) content/openpgp/ui/changeExpiryDlg.js (content/ui/changeExpiryDlg.js)
content/openpgp/ui/commonWorkflows.js (content/ui/commonWorkflows.js) content/openpgp/ui/commonWorkflows.js (content/ui/commonWorkflows.js)