mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
couple of fixes in save*KeyRing methods
This commit is contained in:
parent
fcc535a573
commit
64aac8023e
@ -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) {
|
||||
|
@ -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),
|
||||
|
@ -580,6 +580,7 @@
|
||||
<string name="msg_ip_uid_processing">Processing user id %s</string>
|
||||
<string name="msg_ip_uid_revoked">User id is revoked</string>
|
||||
<string name="msg_is_bad_type_public">Tried to import public keyring as secret. This is a bug, please file a report!</string>
|
||||
<string name="msg_is_bad_type_uncanon">Tried to import a keyring without canonicalization. This is a bug, please file a report!</string>
|
||||
|
||||
<!-- Import Secret log entries -->
|
||||
<string name="msg_is">Importing secret key %s</string>
|
||||
|
Loading…
Reference in New Issue
Block a user