mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
fix dumb mistake in modifySecretKey
This commit is contained in:
parent
827a958e12
commit
f555447011
@ -34,6 +34,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@ -202,8 +203,8 @@ public class PgpKeyOperationTest {
|
|||||||
Assert.assertEquals("number of user ids must be two",
|
Assert.assertEquals("number of user ids must be two",
|
||||||
2, ring.getPublicKey().getUnorderedUserIds().size());
|
2, ring.getPublicKey().getUnorderedUserIds().size());
|
||||||
|
|
||||||
Assert.assertEquals("number of subkeys must be three",
|
List<UncachedPublicKey> subkeys = KeyringTestingHelper.itToList(ring.getPublicKeys());
|
||||||
3, KeyringTestingHelper.itToList(ring.getPublicKeys()).size());
|
Assert.assertEquals("number of subkeys must be three", 3, subkeys.size());
|
||||||
|
|
||||||
Assert.assertTrue("key ring should have been created in the last 120 seconds",
|
Assert.assertTrue("key ring should have been created in the last 120 seconds",
|
||||||
ring.getPublicKey().getCreationTime().after(new Date(new Date().getTime()-1000*120)));
|
ring.getPublicKey().getCreationTime().after(new Date(new Date().getTime()-1000*120)));
|
||||||
@ -211,24 +212,21 @@ public class PgpKeyOperationTest {
|
|||||||
Assert.assertNull("key ring should not expire",
|
Assert.assertNull("key ring should not expire",
|
||||||
ring.getPublicKey().getExpiryTime());
|
ring.getPublicKey().getExpiryTime());
|
||||||
|
|
||||||
Iterator<UncachedPublicKey> it = ring.getPublicKeys();
|
|
||||||
|
|
||||||
Assert.assertEquals("first (master) key can certify",
|
Assert.assertEquals("first (master) key can certify",
|
||||||
KeyFlags.CERTIFY_OTHER, it.next().getKeyUsage());
|
KeyFlags.CERTIFY_OTHER, subkeys.get(0).getKeyUsage());
|
||||||
|
|
||||||
UncachedPublicKey signingKey = it.next();
|
|
||||||
Assert.assertEquals("second key can sign",
|
Assert.assertEquals("second key can sign",
|
||||||
KeyFlags.SIGN_DATA, signingKey.getKeyUsage());
|
KeyFlags.SIGN_DATA, subkeys.get(1).getKeyUsage());
|
||||||
ArrayList<WrappedSignature> sigs = signingKey.getSignatures().next().getEmbeddedSignatures();
|
ArrayList<WrappedSignature> sigs = subkeys.get(1).getSignatures().next().getEmbeddedSignatures();
|
||||||
Assert.assertEquals("signing key signature should have one embedded signature",
|
Assert.assertEquals("signing key signature should have one embedded signature",
|
||||||
1, sigs.size());
|
1, sigs.size());
|
||||||
Assert.assertEquals("embedded signature should be of primary key binding type",
|
Assert.assertEquals("embedded signature should be of primary key binding type",
|
||||||
PGPSignature.PRIMARYKEY_BINDING, sigs.get(0).getSignatureType());
|
PGPSignature.PRIMARYKEY_BINDING, sigs.get(0).getSignatureType());
|
||||||
Assert.assertEquals("primary key binding signature issuer should be signing subkey",
|
Assert.assertEquals("primary key binding signature issuer should be signing subkey",
|
||||||
signingKey.getKeyId(), sigs.get(0).getKeyId());
|
subkeys.get(1).getKeyId(), sigs.get(0).getKeyId());
|
||||||
|
|
||||||
Assert.assertEquals("third key can encrypt",
|
Assert.assertEquals("third key can encrypt",
|
||||||
KeyFlags.ENCRYPT_COMMS, it.next().getKeyUsage());
|
KeyFlags.ENCRYPT_COMMS, subkeys.get(2).getKeyUsage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +609,7 @@ public class PgpKeyOperation {
|
|||||||
for (int i = 0; i < saveParcel.mAddSubKeys.size(); i++) {
|
for (int i = 0; i < saveParcel.mAddSubKeys.size(); i++) {
|
||||||
|
|
||||||
progress(R.string.progress_modify_subkeyadd, (i-1) * (100 / saveParcel.mAddSubKeys.size()));
|
progress(R.string.progress_modify_subkeyadd, (i-1) * (100 / saveParcel.mAddSubKeys.size()));
|
||||||
SaveKeyringParcel.SubkeyAdd add = saveParcel.mAddSubKeys.get(0);
|
SaveKeyringParcel.SubkeyAdd add = saveParcel.mAddSubKeys.get(i);
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_NEW, indent);
|
log.add(LogLevel.INFO, LogType.MSG_MF_SUBKEY_NEW, indent);
|
||||||
|
|
||||||
if (add.mExpiry != null && new Date(add.mExpiry*1000).before(new Date())) {
|
if (add.mExpiry != null && new Date(add.mExpiry*1000).before(new Date())) {
|
||||||
|
@ -169,6 +169,7 @@ public class UncachedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
// TODO make this safe
|
||||||
public int getKeyUsage() {
|
public int getKeyUsage() {
|
||||||
if(mCacheUsage == null) {
|
if(mCacheUsage == null) {
|
||||||
mCacheUsage = 0;
|
mCacheUsage = 0;
|
||||||
@ -182,11 +183,6 @@ public class UncachedPublicKey {
|
|||||||
if (hashed != null) {
|
if (hashed != null) {
|
||||||
mCacheUsage |= hashed.getKeyFlags();
|
mCacheUsage |= hashed.getKeyFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets();
|
|
||||||
if (unhashed != null) {
|
|
||||||
mCacheUsage |= unhashed.getKeyFlags();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user