diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-30 16:22:55 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-07-30 16:22:55 +0200 |
commit | 64aac8023ef9c9b08d17346e41d06a667480a118 (patch) | |
tree | 3a3bf0835dea12099b887c50a118c1b5d4ad0418 /OpenKeychain/src/main/java/org | |
parent | fcc535a57381009b173bbe455e67e6825be6b684 (diff) | |
download | open-keychain-64aac8023ef9c9b08d17346e41d06a667480a118.tar.gz open-keychain-64aac8023ef9c9b08d17346e41d06a667480a118.tar.bz2 open-keychain-64aac8023ef9c9b08d17346e41d06a667480a118.zip |
couple of fixes in save*KeyRing methods
Diffstat (limited to 'OpenKeychain/src/main/java/org')
2 files changed, 14 insertions, 23 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 2d524f5b0..998cf25c3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -567,20 +567,15 @@ public class ProviderHelper { } if (!keyRing.isCanonicalized()) { - log(LogLevel.ERROR, LogType.MSG_IS_BAD_TYPE_PUBLIC); + log(LogLevel.ERROR, LogType.MSG_IS_BAD_TYPE_UNCANON); return SaveKeyringResult.RESULT_ERROR; } long masterKeyId = keyRing.getMasterKeyId(); log(LogLevel.START, LogType.MSG_IS, PgpKeyHelper.convertKeyIdToHex(masterKeyId)); mIndent += 1; - try { - // Canonicalize this key, to assert a number of assumptions made about it. - keyRing = keyRing.canonicalize(mLog, mIndent); - if (keyRing == null) { - return SaveKeyringResult.RESULT_ERROR; - } + try { // IF this is successful, it's a secret key int result = SaveKeyringResult.SAVED_SECRET; @@ -798,31 +793,26 @@ public class ProviderHelper { return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog); } - // If nothing changed, never mind - if (Arrays.hashCode(publicRing.getEncoded()) - == Arrays.hashCode(oldPublicRing.getEncoded())) { - publicRing = null; - } - } catch (NotFoundException e) { log(LogLevel.DEBUG, LogType.MSG_IS_PUBRING_GENERATE); publicRing = secretRing.extractPublicKeyRing(); } - if (publicRing != null) { - publicRing = publicRing.canonicalize(mLog, mIndent); - if (publicRing == null) { - return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog); - } + publicRing = publicRing.canonicalize(mLog, mIndent); + if (publicRing == null) { + return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog); + } - int result = internalSavePublicKeyRing(publicRing, progress, true); - if ((result & SaveKeyringResult.RESULT_ERROR) == SaveKeyringResult.RESULT_ERROR) { - return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog); - } + int result; + + result = internalSavePublicKeyRing(publicRing, progress, true); + if ((result & SaveKeyringResult.RESULT_ERROR) == SaveKeyringResult.RESULT_ERROR) { + return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog); } progress.setProgress(LogType.MSG_IP_REINSERT_SECRET.getMsgId(), 90, 100); - int result = internalSaveSecretKeyRing(secretRing); + result = internalSaveSecretKeyRing(secretRing); + return new SaveKeyringResult(result, mLog); } catch (IOException e) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java index 99cafd3f9..bfe06dca7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java @@ -260,6 +260,7 @@ public class OperationResultParcel implements Parcelable { // import secret MSG_IS(R.string.msg_is), MSG_IS_BAD_TYPE_PUBLIC (R.string.msg_is_bad_type_public), + MSG_IS_BAD_TYPE_UNCANON (R.string.msg_is_bad_type_uncanon), MSG_IS_DB_EXCEPTION (R.string.msg_is_db_exception), MSG_IS_FAIL_IO_EXC (R.string.msg_is_io_exc), MSG_IS_IMPORTING_SUBKEYS (R.string.msg_is_importing_subkeys), |