diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-02 01:57:49 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-01-02 01:58:16 +0100 |
commit | b52fb903803c2dfca578c140dfdc776927c6fc4b (patch) | |
tree | 6bae0cdc0b31b9a5e2f51a8af3374f378efa3618 /OpenKeychain-Test/src/test/java/org/sufficientlysecure | |
parent | 704fc2dd45f20c7edc68b2930e2a73179d5fbdae (diff) | |
download | open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.tar.gz open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.tar.bz2 open-keychain-b52fb903803c2dfca578c140dfdc776927c6fc4b.zip |
fix and test for bad certificate version numbers (#1012)
closes #1012
Diffstat (limited to 'OpenKeychain-Test/src/test/java/org/sufficientlysecure')
-rw-r--r-- | OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/UncachedKeyringTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/UncachedKeyringTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/UncachedKeyringTest.java index 34c637abf..89fefb767 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/UncachedKeyringTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/UncachedKeyringTest.java @@ -34,6 +34,7 @@ import org.sufficientlysecure.keychain.service.SaveKeyringParcel.ChangeUnlockPar import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.util.Iterator; @RunWith(RobolectricTestRunner.class) @@ -129,4 +130,20 @@ public class UncachedKeyringTest { pubRing.extractPublicKeyRing(); } + @Test(expected = IOException.class) + public void testBrokenVersionCert() throws Throwable { + // this is a test for one of the patches we use on top of stock bouncycastle, which + // returns an IOException rather than a RuntimeException in case of a bad certificate + // version byte + readRingFromResource("/test-keys/broken_cert_version.asc"); + } + + UncachedKeyRing readRingFromResource(String name) throws Throwable { + try { + return UncachedKeyRing.fromStream(UncachedKeyringTest.class.getResourceAsStream(name)).next(); + } catch (RuntimeException e) { + throw e.getCause(); + } + } + } |