mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-26 00:48: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()) {
|
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;
|
return SaveKeyringResult.RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
long masterKeyId = keyRing.getMasterKeyId();
|
long masterKeyId = keyRing.getMasterKeyId();
|
||||||
log(LogLevel.START, LogType.MSG_IS, PgpKeyHelper.convertKeyIdToHex(masterKeyId));
|
log(LogLevel.START, LogType.MSG_IS, PgpKeyHelper.convertKeyIdToHex(masterKeyId));
|
||||||
mIndent += 1;
|
mIndent += 1;
|
||||||
try {
|
|
||||||
|
|
||||||
// Canonicalize this key, to assert a number of assumptions made about it.
|
try {
|
||||||
keyRing = keyRing.canonicalize(mLog, mIndent);
|
|
||||||
if (keyRing == null) {
|
|
||||||
return SaveKeyringResult.RESULT_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IF this is successful, it's a secret key
|
// IF this is successful, it's a secret key
|
||||||
int result = SaveKeyringResult.SAVED_SECRET;
|
int result = SaveKeyringResult.SAVED_SECRET;
|
||||||
@ -798,31 +793,26 @@ public class ProviderHelper {
|
|||||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
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) {
|
} catch (NotFoundException e) {
|
||||||
log(LogLevel.DEBUG, LogType.MSG_IS_PUBRING_GENERATE);
|
log(LogLevel.DEBUG, LogType.MSG_IS_PUBRING_GENERATE);
|
||||||
publicRing = secretRing.extractPublicKeyRing();
|
publicRing = secretRing.extractPublicKeyRing();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicRing != null) {
|
publicRing = publicRing.canonicalize(mLog, mIndent);
|
||||||
publicRing = publicRing.canonicalize(mLog, mIndent);
|
if (publicRing == null) {
|
||||||
if (publicRing == null) {
|
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int result = internalSavePublicKeyRing(publicRing, progress, true);
|
int result;
|
||||||
if ((result & SaveKeyringResult.RESULT_ERROR) == SaveKeyringResult.RESULT_ERROR) {
|
|
||||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
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);
|
progress.setProgress(LogType.MSG_IP_REINSERT_SECRET.getMsgId(), 90, 100);
|
||||||
int result = internalSaveSecretKeyRing(secretRing);
|
result = internalSaveSecretKeyRing(secretRing);
|
||||||
|
|
||||||
return new SaveKeyringResult(result, mLog);
|
return new SaveKeyringResult(result, mLog);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -260,6 +260,7 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
// import secret
|
// import secret
|
||||||
MSG_IS(R.string.msg_is),
|
MSG_IS(R.string.msg_is),
|
||||||
MSG_IS_BAD_TYPE_PUBLIC (R.string.msg_is_bad_type_public),
|
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_DB_EXCEPTION (R.string.msg_is_db_exception),
|
||||||
MSG_IS_FAIL_IO_EXC (R.string.msg_is_io_exc),
|
MSG_IS_FAIL_IO_EXC (R.string.msg_is_io_exc),
|
||||||
MSG_IS_IMPORTING_SUBKEYS (R.string.msg_is_importing_subkeys),
|
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_processing">Processing user id %s</string>
|
||||||
<string name="msg_ip_uid_revoked">User id is revoked</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_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 -->
|
<!-- Import Secret log entries -->
|
||||||
<string name="msg_is">Importing secret key %s</string>
|
<string name="msg_is">Importing secret key %s</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user