From f82093c666a443cda0985a017f907b6c25977565 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 12 Jul 2014 02:02:37 +0200 Subject: modifyKey: error out on integrity check fails --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 3e7e9d98e..bd8a9201e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -188,14 +188,14 @@ public class PgpKeyOperation { return null; } - PGPKeyPair keyPair = createKey(add.mAlgorithm, add.mKeysize, log, indent); - if (add.mAlgorithm == Constants.choice.algorithm.elgamal) { log.add(LogLevel.ERROR, LogType.MSG_CR_ERROR_MASTER_ELGAMAL, indent); return null; } - // return null if this failed (it will already have been logged by createKey) + PGPKeyPair keyPair = createKey(add.mAlgorithm, add.mKeysize, log, indent); + + // return null if this failed (an error will already have been logged by createKey) if (keyPair == null) { return null; } @@ -319,9 +319,10 @@ public class PgpKeyOperation { Iterator it = modifiedPublicKey.getSignaturesForID(userId); if (it != null) { for (PGPSignature cert : new IterableIterator(it)) { - // if it's not a self cert, never mind if (cert.getKeyID() != masterPublicKey.getKeyID()) { - continue; + // foreign certificate?! error error error + log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_INTEGRITY, indent); + return null; } if (cert.getSignatureType() == PGPSignature.CERTIFICATION_REVOCATION || cert.getSignatureType() == PGPSignature.NO_CERTIFICATION @@ -369,9 +370,10 @@ public class PgpKeyOperation { // noinspection unchecked for (PGPSignature cert : new IterableIterator( modifiedPublicKey.getSignaturesForID(userId))) { - // if it's not a self cert, never mind if (cert.getKeyID() != masterPublicKey.getKeyID()) { - continue; + // foreign certificate?! error error error + log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_INTEGRITY, indent); + return null; } // we know from canonicalization that if there is any revocation here, it // is valid and not superseded by a newer certification. -- cgit v1.2.3