aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java37
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java6
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java11
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml7
5 files changed, 61 insertions, 8 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index 5f1c2cac3..5cd13c4a2 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -643,6 +643,7 @@ public class UncachedKeyRing {
*
* TODO work with secret keys
*
+ * @param list The list of UncachedKeyRings. Must not be empty, and all of the same masterKeyId
* @return A consolidated UncachedKeyRing with the data of all input keyrings.
*
*/
@@ -650,15 +651,12 @@ public class UncachedKeyRing {
OperationLog log, int indent) {
long masterKeyId = list.get(0).getMasterKeyId();
- for (UncachedKeyRing ring : new IterableIterator<UncachedKeyRing>(list.iterator())) {
- if (ring.getMasterKeyId() != masterKeyId) {
- // log.add(LogLevel.ERROR, LogType.MSG_KO, null, indent);
- return null;
- }
- }
- // log.add(LogLevel.START, LogType.MSG_KO,
- // new String[]{PgpKeyHelper.convertKeyIdToHex(masterKeyId)}, indent);
+ log.add(LogLevel.START, LogType.MSG_KO,
+ new String[]{
+ Integer.toString(list.size()),
+ PgpKeyHelper.convertKeyIdToHex(masterKeyId)
+ }, indent);
indent += 1;
// remember which certs we already added
@@ -666,13 +664,28 @@ public class UncachedKeyRing {
try {
PGPPublicKeyRing result = null;
+ int num = 1;
for (UncachedKeyRing uring : new IterableIterator<UncachedKeyRing>(list.iterator())) {
+
PGPPublicKeyRing ring = (PGPPublicKeyRing) uring.mRing;
+ if (uring.getMasterKeyId() != masterKeyId) {
+ log.add(LogLevel.ERROR, LogType.MSG_KO_HETEROGENEOUS, null, indent);
+ return null;
+ }
+
+ // If this is the first ring, just take it
if (result == null) {
result = ring;
continue;
}
+ log.add(LogLevel.DEBUG, LogType.MSG_KO_MERGING,
+ new String[] { Integer.toString(num++) }, indent);
+ indent += 1;
+
+ // keep track of the number of new certs we add
+ int newCerts = 0;
+
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(ring.getPublicKeys())) {
final PGPPublicKey resultkey = result.getPublicKey(key.getKeyID());
@@ -702,6 +715,7 @@ public class UncachedKeyRing {
}
certs.add(hash);
modified = PGPPublicKey.addCertification(modified, cert);
+ newCerts += 1;
}
// If this is a subkey, stop here
@@ -718,6 +732,7 @@ public class UncachedKeyRing {
if (certs.contains(hash)) {
continue;
}
+ newCerts += 1;
certs.add(hash);
modified = PGPPublicKey.addCertification(modified, userId, cert);
}
@@ -726,13 +741,19 @@ public class UncachedKeyRing {
if (modified != resultkey) {
result = PGPPublicKeyRing.insertPublicKey(result, modified);
}
+
}
+ log.add(LogLevel.DEBUG, LogType.MSG_KO_FOUND_NEW,
+ new String[] { Integer.toString(newCerts) }, indent);
+
+
}
return new UncachedKeyRing(result);
} catch (IOException e) {
+ log.add(LogLevel.ERROR, LogType.MSG_KO_FATAL_ENCODE, null, indent);
return null;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java
index 71d237c05..632a04fc3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java
@@ -91,6 +91,12 @@ public abstract class WrappedKeyRing extends KeyRing {
getRing().encode(stream);
}
+ /** Returns an UncachedKeyRing which wraps the same data as this ring. This method should
+ * only be used */
+ public UncachedKeyRing getUncachedKeyRing() {
+ return new UncachedKeyRing(getRing());
+ }
+
abstract PGPKeyRing getRing();
abstract public IterableIterator<WrappedPublicKey> publicKeyIterator();
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 22454b20f..cbdf6a64b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -284,6 +284,14 @@ public class ProviderHelper {
new String[]{ PgpKeyHelper.convertKeyIdToHex(masterKeyId) });
mIndent += 1;
+ try {
+ WrappedPublicKeyRing ring = getWrappedPublicKeyRing(KeyRings.buildUnifiedKeyRingUri(masterKeyId));
+ // ring.get
+
+ } catch(NotFoundException e) {
+ // no biggie
+ }
+
// Canonicalize this key, to assert a number of assumptions made about it.
keyRing = keyRing.canonicalizePublic(mLog, mIndent);
if (keyRing == null) {
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 f1f6c304a..408715fdf 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java
@@ -3,8 +3,10 @@ package org.sufficientlysecure.keychain.service;
import android.os.Parcel;
import android.os.Parcelable;
+import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.util.IterableIterator;
+import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList;
@@ -218,6 +220,14 @@ public class OperationResultParcel implements Parcelable {
MSG_KC_UID_NO_CERT (R.string.msg_kc_uid_no_cert),
MSG_KC_UID_REVOKE_DUP (R.string.msg_kc_uid_revoke_dup),
MSG_KC_UID_REVOKE_OLD (R.string.msg_kc_uid_revoke_old),
+
+ // keyring consolidation
+ MSG_KO (R.string.msg_ko),
+ MSG_KO_FATAL_ENCODE (R.string.msg_ko_fatal_encode),
+ MSG_KO_HETEROGENEOUS (R.string.msg_ko_heterogeneous),
+ MSG_KO_MERGING (R.string.msg_ko_merging),
+ MSG_KO_NEW_SUBKEY (R.string.msg_ko_new_subkey),
+ MSG_KO_FOUND_NEW (R.string.msg_ko_found_new),
;
private final int mMsgId;
@@ -264,6 +274,7 @@ public class OperationResultParcel implements Parcelable {
/// Simple convenience method
public void add(LogLevel level, LogType type, String[] parameters, int indent) {
+ Log.d(Constants.TAG, type.toString());
add(new OperationResultParcel.LogEntryParcel(level, type, parameters, indent));
}
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 5393ccca3..60c323df4 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -598,6 +598,13 @@
<string name="msg_kc_uid_revoke_old">Removing outdated revocation certificate for user id "%s"</string>
<string name="msg_kc_uid_no_cert">No valid self-certificate found for user id %s, removing from ring</string>
+ <string name="msg_ko">Consolidating %1$s keyrings into %2$s</string>
+ <string name="msg_ko_fatal_encode">Fatal error encoding signature</string>
+ <string name="msg_ko_heterogeneous">Tried to consolidate heterogeneous keyrings</string>
+ <string name="msg_ko_merging">Merging keyring #%s</string>
+ <string name="msg_ko_new_subkey">Adding new subkey %s</string>
+ <string name="msg_ko_found_new">Found %s new certificates in keyring</string>
+
<!-- unsorted -->
<string name="section_certifier_id">Certifier</string>
<string name="section_cert">Certificate Details</string>