Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/chrome/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ View.run(class SettingsView extends View {
await PassphraseStore.set('session', this.acctEmail!, { longid }, undefined);
this.reload(true);
} else {
Catch.report(`unexpected key type: ${family}`);
Catch.report(`unexpected key family: ${family}`);
}
}));
}
Expand Down
8 changes: 4 additions & 4 deletions extension/js/common/core/crypto/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export class KeyUtil {
} else if (key.family === 'x509') {
return await SmimeKey.decryptKey(key, passphrase, optionalBehaviorFlag);
} else {
throw new Error(`KeyUtil.decrypt does not support key type ${key.family}`);
throw new Error(`KeyUtil.decrypt does not support key family ${key.family}`);
}
};

Expand All @@ -359,23 +359,23 @@ export class KeyUtil {
} else if (key.family === 'x509') {
return await SmimeKey.encryptKey(key, passphrase);
} else {
throw new Error(`KeyUtil.encrypt does not support key type ${key.family}`);
throw new Error(`KeyUtil.encrypt does not support key family ${key.family}`);
}
};

public static reformatKey = async (privateKey: Key, passphrase: string, userIds: { email: string | undefined; name: string }[], expireSeconds: number) => {
if (privateKey.family === 'openpgp') {
return await OpenPGPKey.reformatKey(privateKey, passphrase, userIds, expireSeconds);
} else {
throw new Error(`KeyUtil.reformatKey does not support key type ${privateKey.family}`);
throw new Error(`KeyUtil.reformatKey does not support key family ${privateKey.family}`);
}
};

public static revoke = async (key: Key): Promise<string | undefined> => {
if (key.family === 'openpgp') {
return await OpenPGPKey.revoke(key);
} else {
throw new Error(`KeyUtil.revoke does not support key type ${key.family}`);
throw new Error(`KeyUtil.revoke does not support key family ${key.family}`);
}
};

Expand Down
8 changes: 4 additions & 4 deletions extension/js/common/core/crypto/pgp/msg-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ export class MsgUtil {
};

public static encryptMessage: PgpMsgMethod.Encrypt = async ({ pubkeys, signingPrv, pwd, data, filename, armor, date }) => {
const keyTypes = new Set(pubkeys.map(k => k.family));
if (keyTypes.has('openpgp') && keyTypes.has('x509')) {
throw new Error('Mixed key types are not allowed: ' + [...keyTypes]);
const keyFamilies = new Set(pubkeys.map(k => k.family));
if (keyFamilies.has('openpgp') && keyFamilies.has('x509')) {
throw new Error('Mixed key families are not allowed: ' + [...keyFamilies]);
}
const input = { pubkeys, signingPrv, pwd, data, filename, armor, date };
if (keyTypes.has('x509')) {
if (keyFamilies.has('x509')) {
return await SmimeKey.encryptMessage(input);
}
return await OpenPGPKey.encryptMessage(input);
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/core/crypto/smime/smime-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export class SmimeKey {
}
throw new UnreportableError("Certificate doesn't match the private key");
}
throw new UnreportableError("This key type is not supported");
throw new UnreportableError("This key family is not supported");
/* todo: edwards25519
const derivedPublicKey = forge.pki.ed25519.publicKeyFromPrivateKey({ privateKey: privateKey as forge.pki.ed25519.BinaryBuffer });
Buffer.from(derivedPublicKey).compare(Buffer.from(certificate.publicKey as forge.pki.ed25519.NativeBuffer)) === 0;
Expand Down
2 changes: 1 addition & 1 deletion extension/js/common/ui/key-import-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class KeyImportUi {
private normalize = async (type: KeyBlockType, armored: string): Promise<{ normalized: string }> => {
// non-OpenPGP keys are considered to be always normalized
// TODO: PgpKey.normalize depends on OpenPGP.key.Key objects, when this is resolved
// this check for key type should be moved to PgpKey.normalize function.
// this check for key family should be moved to PgpKey.normalize function.
if (KeyUtil.getKeyFamily(armored) !== 'openpgp') {
return { normalized: armored };
}
Expand Down
2 changes: 1 addition & 1 deletion test/source/tests/unit-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ WeNYP84Yjw6OFSHdi2W0VojRGhxm7PZCMqswN/XaBg==
await t.throwsAsync(() => KeyUtil.parse(httpsCert), { instanceOf: UnreportableError, message: 'This S/MIME x.509 certificate has an invalid recipient email: news.ycombinator.com' });
});

ava.default('[unit][KeyUtil.parse] Unknown key type parsing fails', async t => {
ava.default('[unit][KeyUtil.parse] Unknown key family parsing fails', async t => {
await t.throwsAsync(() => KeyUtil.parse('dummy string for unknown key'), { instanceOf: Error, message: 'Key type is unknown, expecting OpenPGP or x509 S/MIME' });
});

Expand Down