mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 03:02:15 -05:00
prevent keybase key replacing keyserver key
This commit is contained in:
parent
5d87872245
commit
93f3a98eae
@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.Operat
|
|||||||
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
@ -244,25 +243,25 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
try {
|
try {
|
||||||
log.add(LogType.MSG_IMPORT_FETCH_KEYBASE, 2, entry.mKeybaseName);
|
log.add(LogType.MSG_IMPORT_FETCH_KEYBASE, 2, entry.mKeybaseName);
|
||||||
byte[] data = keybaseServer.get(entry.mKeybaseName).getBytes();
|
byte[] data = keybaseServer.get(entry.mKeybaseName).getBytes();
|
||||||
key = UncachedKeyRing.decodeFromData(data);
|
UncachedKeyRing keybaseKey = UncachedKeyRing.decodeFromData(data);
|
||||||
|
|
||||||
// If there already is a key (of keybase origin), merge the two
|
// If there already is a key, merge the two
|
||||||
if (key != null) {
|
if (key != null && keybaseKey != null) {
|
||||||
log.add(LogType.MSG_IMPORT_MERGE, 3);
|
log.add(LogType.MSG_IMPORT_MERGE, 3);
|
||||||
UncachedKeyRing merged = UncachedKeyRing.decodeFromData(data);
|
keybaseKey = key.merge(keybaseKey, log, 4);
|
||||||
merged = key.merge(merged, log, 4);
|
|
||||||
// If the merge didn't fail, use the new merged key
|
// If the merge didn't fail, use the new merged key
|
||||||
if (merged != null) {
|
if (keybaseKey != null) {
|
||||||
key = merged;
|
key = keybaseKey;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3);
|
log.add(LogType.MSG_IMPORT_MERGE_ERROR, 4);
|
||||||
key = UncachedKeyRing.decodeFromData(data);
|
}
|
||||||
|
} else if (keybaseKey != null) {
|
||||||
|
key = keybaseKey;
|
||||||
}
|
}
|
||||||
} catch (Keyserver.QueryFailedException e) {
|
} catch (Keyserver.QueryFailedException e) {
|
||||||
// download failed, too bad. just proceed
|
// download failed, too bad. just proceed
|
||||||
Log.e(Constants.TAG, "query failed", e);
|
Log.e(Constants.TAG, "query failed", e);
|
||||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3);
|
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_ERROR, 3, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,6 +696,7 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
MSG_IMPORT_FETCH_KEYBASE (LogLevel.INFO, R.string.msg_import_fetch_keybase),
|
MSG_IMPORT_FETCH_KEYBASE (LogLevel.INFO, R.string.msg_import_fetch_keybase),
|
||||||
MSG_IMPORT_KEYSERVER (LogLevel.DEBUG, R.string.msg_import_keyserver),
|
MSG_IMPORT_KEYSERVER (LogLevel.DEBUG, R.string.msg_import_keyserver),
|
||||||
MSG_IMPORT_MERGE (LogLevel.DEBUG, R.string.msg_import_merge),
|
MSG_IMPORT_MERGE (LogLevel.DEBUG, R.string.msg_import_merge),
|
||||||
|
MSG_IMPORT_MERGE_ERROR (LogLevel.ERROR, R.string.msg_import_merge_error),
|
||||||
MSG_IMPORT_FINGERPRINT_ERROR (LogLevel.ERROR, R.string.msg_import_fingerprint_error),
|
MSG_IMPORT_FINGERPRINT_ERROR (LogLevel.ERROR, R.string.msg_import_fingerprint_error),
|
||||||
MSG_IMPORT_FINGERPRINT_OK (LogLevel.DEBUG, R.string.msg_import_fingerprint_ok),
|
MSG_IMPORT_FINGERPRINT_OK (LogLevel.DEBUG, R.string.msg_import_fingerprint_ok),
|
||||||
MSG_IMPORT_ERROR (LogLevel.ERROR, R.string.msg_import_error),
|
MSG_IMPORT_ERROR (LogLevel.ERROR, R.string.msg_import_error),
|
||||||
|
@ -1154,6 +1154,7 @@
|
|||||||
<string name="msg_import_fingerprint_error">"Fingerprint of fetched key didn't match expected!"</string>
|
<string name="msg_import_fingerprint_error">"Fingerprint of fetched key didn't match expected!"</string>
|
||||||
<string name="msg_import_fingerprint_ok">"Fingerprint check OK"</string>
|
<string name="msg_import_fingerprint_ok">"Fingerprint check OK"</string>
|
||||||
<string name="msg_import_merge">"Merging retrieved data"</string>
|
<string name="msg_import_merge">"Merging retrieved data"</string>
|
||||||
|
<string name="msg_import_merge_error">"Error merging retrieved data!"</string>
|
||||||
<string name="msg_import_error">"Import operation failed!"</string>
|
<string name="msg_import_error">"Import operation failed!"</string>
|
||||||
<string name="msg_import_error_io">"Import operation failed due to i/o error!"</string>
|
<string name="msg_import_error_io">"Import operation failed due to i/o error!"</string>
|
||||||
<string name="msg_import_partial">"Import operation successful, with errors!"</string>
|
<string name="msg_import_partial">"Import operation successful, with errors!"</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user