Fix tests for min requirement of 2048 bits

This commit is contained in:
Dominik Schürmann
2015-10-04 23:37:03 +02:00
parent d3d73f5f85
commit dfc396a44c
5 changed files with 41 additions and 41 deletions

View File

@@ -78,11 +78,11 @@ public class CertifyOperationTest {
{ {
SaveKeyringParcel parcel = new SaveKeyringParcel(); SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.DSA, 1024, null, KeyFlags.SIGN_DATA, 0L)); Algorithm.DSA, 2048, null, KeyFlags.SIGN_DATA, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.ELGAMAL, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L)); Algorithm.ELGAMAL, 2048, null, KeyFlags.ENCRYPT_COMMS, 0L));
parcel.mAddUserIds.add("derp"); parcel.mAddUserIds.add("derp");
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1); parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhrase1);
@@ -96,11 +96,11 @@ public class CertifyOperationTest {
{ {
SaveKeyringParcel parcel = new SaveKeyringParcel(); SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.DSA, 1024, null, KeyFlags.SIGN_DATA, 0L)); Algorithm.DSA, 2048, null, KeyFlags.SIGN_DATA, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.ELGAMAL, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L)); Algorithm.ELGAMAL, 2048, null, KeyFlags.ENCRYPT_COMMS, 0L));
parcel.mAddUserIds.add("ditz"); parcel.mAddUserIds.add("ditz");
byte[] uatdata = new byte[random.nextInt(150)+10]; byte[] uatdata = new byte[random.nextInt(150)+10];

View File

@@ -77,7 +77,7 @@ public class PgpEncryptDecryptTest {
static UncachedKeyRing mStaticRing1, mStaticRing2, mStaticRingInsecure; static UncachedKeyRing mStaticRing1, mStaticRing2, mStaticRingInsecure;
static Passphrase mKeyPhrase1 = TestingUtils.genPassphrase(true); static Passphrase mKeyPhrase1 = TestingUtils.genPassphrase(true);
static Passphrase mKeyPhrase2 = TestingUtils.genPassphrase(true); static Passphrase mKeyPhrase2 = TestingUtils.genPassphrase(true);
static Passphrase mKeyPhraseInsecure = TestingUtils.genPassphrase(true); // static Passphrase mKeyPhraseInsecure = TestingUtils.genPassphrase(true);
static PrintStream oldShadowStream; static PrintStream oldShadowStream;
@@ -127,24 +127,24 @@ public class PgpEncryptDecryptTest {
mStaticRing2 = result.getRing(); mStaticRing2 = result.getRing();
} }
{ // {
// insecure (1024 bit) RSA key // // insecure (1024 bit) RSA key
SaveKeyringParcel parcel = new SaveKeyringParcel(); // SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( // parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L)); // Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( // parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, 0L)); // Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( // parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 2048, null, KeyFlags.ENCRYPT_COMMS, 0L)); // Algorithm.RSA, 1024, null, KeyFlags.ENCRYPT_COMMS, 0L));
parcel.mAddUserIds.add("eve"); // parcel.mAddUserIds.add("eve");
parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhraseInsecure); // parcel.mNewUnlock = new ChangeUnlockParcel(mKeyPhraseInsecure);
//
PgpEditKeyResult result = op.createSecretKeyRing(parcel); // PgpEditKeyResult result = op.createSecretKeyRing(parcel);
Assert.assertTrue("initial test key creation must succeed", result.success()); // Assert.assertTrue("initial test key creation must succeed", result.success());
Assert.assertNotNull("initial test key creation must succeed", result.getRing()); // Assert.assertNotNull("initial test key creation must succeed", result.getRing());
//
mStaticRingInsecure = result.getRing(); // mStaticRingInsecure = result.getRing();
} // }
} }

View File

@@ -94,11 +94,11 @@ public class PgpKeyOperationTest {
SaveKeyringParcel parcel = new SaveKeyringParcel(); SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.DSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.DSA, 3072, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, 0L)); Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, 0L));
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 2048, null, KeyFlags.ENCRYPT_COMMS, 0L)); Algorithm.RSA, 3072, null, KeyFlags.ENCRYPT_COMMS, 0L));
parcel.mAddUserIds.add("twi"); parcel.mAddUserIds.add("twi");
parcel.mAddUserIds.add("pink"); parcel.mAddUserIds.add("pink");
@@ -159,7 +159,7 @@ public class PgpKeyOperationTest {
{ {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.ELGAMAL, 1024, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.ELGAMAL, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddUserIds.add("shy"); parcel.mAddUserIds.add("shy");
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase); parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
@@ -170,7 +170,7 @@ public class PgpKeyOperationTest {
{ {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, null)); Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, null));
parcel.mAddUserIds.add("lotus"); parcel.mAddUserIds.add("lotus");
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase); parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
@@ -181,7 +181,7 @@ public class PgpKeyOperationTest {
{ {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L)); Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, 0L));
parcel.mAddUserIds.add("shy"); parcel.mAddUserIds.add("shy");
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase); parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
@@ -192,7 +192,7 @@ public class PgpKeyOperationTest {
{ {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mNewUnlock = new ChangeUnlockParcel(passphrase); parcel.mNewUnlock = new ChangeUnlockParcel(passphrase);
assertFailure("creating ring without user ids should fail", parcel, assertFailure("creating ring without user ids should fail", parcel,
@@ -216,7 +216,7 @@ public class PgpKeyOperationTest {
public void testMasterFlags() throws Exception { public void testMasterFlags() throws Exception {
SaveKeyringParcel parcel = new SaveKeyringParcel(); SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA, 0L)); Algorithm.RSA, 4096, null, KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA, 0L));
parcel.mAddUserIds.add("luna"); parcel.mAddUserIds.add("luna");
ring = assertCreateSuccess("creating ring with master key flags must succeed", parcel); ring = assertCreateSuccess("creating ring with master key flags must succeed", parcel);
@@ -256,8 +256,8 @@ public class PgpKeyOperationTest {
List<UncachedPublicKey> subkeys = KeyringTestingHelper.itToList(ring.getPublicKeys()); List<UncachedPublicKey> subkeys = KeyringTestingHelper.itToList(ring.getPublicKeys());
Assert.assertEquals("number of subkeys must be three", 3, subkeys.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 360 seconds",
ring.getPublicKey().getCreationTime().after(new Date(new Date().getTime()-1000*120))); ring.getPublicKey().getCreationTime().after(new Date(new Date().getTime()-1000*360)));
Assert.assertNull("key ring should not expire", Assert.assertNull("key ring should not expire",
ring.getPublicKey().getUnsafeExpiryTimeForTesting()); ring.getPublicKey().getUnsafeExpiryTimeForTesting());
@@ -347,7 +347,7 @@ public class PgpKeyOperationTest {
long expiry = new Date().getTime() / 1000 + 159; long expiry = new Date().getTime() / 1000 + 159;
int flags = KeyFlags.SIGN_DATA; int flags = KeyFlags.SIGN_DATA;
int bits = 1024 + new Random().nextInt(8); int bits = 2048 + new Random().nextInt(8);
parcel.mAddSubKeys.add(new SubkeyAdd(Algorithm.RSA, bits, null, flags, expiry)); parcel.mAddSubKeys.add(new SubkeyAdd(Algorithm.RSA, bits, null, flags, expiry));
UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB); UncachedKeyRing modified = applyModificationWithChecks(parcel, ring, onlyA, onlyB);
@@ -398,7 +398,7 @@ public class PgpKeyOperationTest {
{ {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, null)); Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, null));
assertModifyFailure("creating master key with null expiry should fail", ring, parcel, assertModifyFailure("creating master key with null expiry should fail", ring, parcel,
LogType.MSG_MF_ERROR_NULL_EXPIRY); LogType.MSG_MF_ERROR_NULL_EXPIRY);
@@ -406,7 +406,7 @@ public class PgpKeyOperationTest {
{ // a past expiry should fail { // a past expiry should fail
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SubkeyAdd(Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, parcel.mAddSubKeys.add(new SubkeyAdd(Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA,
new Date().getTime()/1000-10)); new Date().getTime()/1000-10));
assertModifyFailure("creating subkey with past expiry date should fail", ring, parcel, assertModifyFailure("creating subkey with past expiry date should fail", ring, parcel,
LogType.MSG_MF_ERROR_PAST_EXPIRY); LogType.MSG_MF_ERROR_PAST_EXPIRY);
@@ -837,7 +837,7 @@ public class PgpKeyOperationTest {
UncachedKeyRing modified; UncachedKeyRing modified;
{ // keytocard should fail with BAD_NFC_SIZE when presented with the RSA-1024 key { // keytocard should fail with BAD_NFC_SIZE when presented with the RSA-3072 key
long keyId = KeyringTestingHelper.getSubkeyId(ring, 2); long keyId = KeyringTestingHelper.getSubkeyId(ring, 2);
parcel.reset(); parcel.reset();
parcel.mChangeSubKeys.add(new SubkeyChange(keyId, false, true)); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));
@@ -846,7 +846,7 @@ public class PgpKeyOperationTest {
parcel, cryptoInput, LogType.MSG_MF_ERROR_BAD_NFC_SIZE); parcel, cryptoInput, LogType.MSG_MF_ERROR_BAD_NFC_SIZE);
} }
{ // keytocard should fail with BAD_NFC_ALGO when presented with the DSA-1024 key { // keytocard should fail with BAD_NFC_ALGO when presented with the DSA-3072 key
long keyId = KeyringTestingHelper.getSubkeyId(ring, 0); long keyId = KeyringTestingHelper.getSubkeyId(ring, 0);
parcel.reset(); parcel.reset();
parcel.mChangeSubKeys.add(new SubkeyChange(keyId, false, true)); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));

View File

@@ -358,7 +358,7 @@ public class UncachedKeyringCanonicalizeTest {
SaveKeyringParcel parcel = new SaveKeyringParcel(); SaveKeyringParcel parcel = new SaveKeyringParcel();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.CERTIFY_OTHER, 0L)); Algorithm.RSA, 2048, null, KeyFlags.CERTIFY_OTHER, 0L));
parcel.mAddUserIds.add("trix"); parcel.mAddUserIds.add("trix");
PgpKeyOperation op = new PgpKeyOperation(null); PgpKeyOperation op = new PgpKeyOperation(null);

View File

@@ -234,7 +234,7 @@ public class UncachedKeyringMergeTest {
parcel.reset(); parcel.reset();
parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd( parcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(
Algorithm.RSA, 1024, null, KeyFlags.SIGN_DATA, 0L)); Algorithm.RSA, 2048, null, KeyFlags.SIGN_DATA, 0L));
modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing(); modifiedA = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();
modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing(); modifiedB = op.modifySecretKeyRing(secretRing, new CryptoInputParcel(new Date(), new Passphrase()), parcel).getRing();