diff --git a/pgpainless-core/src/test/java/investigations/ModifiedPublicKeysInvestigation.java b/pgpainless-core/src/test/java/investigations/ModifiedPublicKeysInvestigation.java index 6930f78f..e3d6bd19 100644 --- a/pgpainless-core/src/test/java/investigations/ModifiedPublicKeysInvestigation.java +++ b/pgpainless-core/src/test/java/investigations/ModifiedPublicKeysInvestigation.java @@ -8,8 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKey; @@ -252,7 +250,7 @@ public class ModifiedPublicKeysInvestigation { } @Test - public void assertUnmodifiedRSAKeyDoesNotThrow() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void assertUnmodifiedRSAKeyDoesNotThrow() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .simpleRsaKeyRing("Unmodified", RsaLength._4096, "987654321"); SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAnyKeyWith(Passphrase.fromPassword("987654321")); @@ -264,7 +262,7 @@ public class ModifiedPublicKeysInvestigation { } @Test - public void assertUnmodifiedECKeyDoesNotThrow() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void assertUnmodifiedECKeyDoesNotThrow() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .simpleEcKeyRing("Unmodified", "987654321"); SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAnyKeyWith(Passphrase.fromPassword("987654321")); @@ -276,7 +274,7 @@ public class ModifiedPublicKeysInvestigation { } @Test - public void assertUnmodifiedModernKeyDoesNotThrow() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void assertUnmodifiedModernKeyDoesNotThrow() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Unmodified", "987654321"); SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAnyKeyWith(Passphrase.fromPassword("987654321")); diff --git a/pgpainless-core/src/test/java/org/bouncycastle/AsciiArmorCRCTests.java b/pgpainless-core/src/test/java/org/bouncycastle/AsciiArmorCRCTests.java index f9bd7a61..eb9e7ef5 100644 --- a/pgpainless-core/src/test/java/org/bouncycastle/AsciiArmorCRCTests.java +++ b/pgpainless-core/src/test/java/org/bouncycastle/AsciiArmorCRCTests.java @@ -15,7 +15,6 @@ import java.nio.charset.StandardCharsets; import java.util.List; import org.bouncycastle.bcpg.ArmoredInputStream; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.util.io.Streams; @@ -270,7 +269,7 @@ public class AsciiArmorCRCTests { "-----END PGP SIGNATURE-----"; @Test - public void assertMissingCRCSumInSignatureArmorIsOkay() throws PGPException, IOException { + public void assertMissingCRCSumInSignatureArmorIsOkay() { List signatureList = SignatureUtils.readSignatures(ARMORED_SIGNATURE_WITH_MISSING_CRC_SUM); assertEquals(1, signatureList.size()); } diff --git a/pgpainless-core/src/test/java/org/bouncycastle/PGPPublicKeyRingTest.java b/pgpainless-core/src/test/java/org/bouncycastle/PGPPublicKeyRingTest.java index ebb344b0..53317bde 100644 --- a/pgpainless-core/src/test/java/org/bouncycastle/PGPPublicKeyRingTest.java +++ b/pgpainless-core/src/test/java/org/bouncycastle/PGPPublicKeyRingTest.java @@ -8,12 +8,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.List; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; @@ -31,7 +28,7 @@ public class PGPPublicKeyRingTest { * @see "); diff --git a/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/OpenPgpMessageInputStreamTest.java b/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/OpenPgpMessageInputStreamTest.java index 6102372a..e8345d1c 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/OpenPgpMessageInputStreamTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/OpenPgpMessageInputStreamTest.java @@ -15,8 +15,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Iterator; import java.util.stream.Stream; @@ -240,7 +238,7 @@ public class OpenPgpMessageInputStreamTest { armorOut.close(); } - public static void genKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public static void genKey() { PGPainless.asciiArmor( PGPainless.generateKeyRing().modernKeyRing("Alice "), System.out); @@ -654,7 +652,7 @@ public class OpenPgpMessageInputStreamTest { } @Test - public void readAfterCloseTest() throws PGPException, IOException { + public void readAfterCloseTest() throws IOException { OpenPgpMessageInputStream pgpIn = get(SENC_LIT, ConsumerOptions.get() .addMessagePassphrase(Passphrase.fromPassword(PASSPHRASE))); Streams.drain(pgpIn); // read all @@ -670,7 +668,7 @@ public class OpenPgpMessageInputStreamTest { } private static Tuple processReadBuffered(String armoredMessage, ConsumerOptions options) - throws PGPException, IOException { + throws IOException { OpenPgpMessageInputStream in = get(armoredMessage, options); ByteArrayOutputStream out = new ByteArrayOutputStream(); Streams.pipeAll(in, out); @@ -680,7 +678,7 @@ public class OpenPgpMessageInputStreamTest { } private static Tuple processReadSequential(String armoredMessage, ConsumerOptions options) - throws PGPException, IOException { + throws IOException { OpenPgpMessageInputStream in = get(armoredMessage, options); ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -695,7 +693,7 @@ public class OpenPgpMessageInputStreamTest { } private static OpenPgpMessageInputStream get(String armored, ConsumerOptions options) - throws IOException, PGPException { + throws IOException { ByteArrayInputStream bytesIn = new ByteArrayInputStream(armored.getBytes(StandardCharsets.UTF_8)); ArmoredInputStream armorIn = ArmoredInputStreamFactory.get(bytesIn); OpenPgpMessageInputStream pgpIn = OpenPgpMessageInputStream.create(armorIn, options); diff --git a/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/TryDecryptWithUnavailableGnuDummyKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/TryDecryptWithUnavailableGnuDummyKeyTest.java index 640025b1..859e2a29 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/TryDecryptWithUnavailableGnuDummyKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/decryption_verification/TryDecryptWithUnavailableGnuDummyKeyTest.java @@ -19,8 +19,6 @@ import org.pgpainless.exception.MissingDecryptionMethodException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -28,7 +26,7 @@ public class TryDecryptWithUnavailableGnuDummyKeyTest { @Test public void testAttemptToDecryptWithRemovedPrivateKeysThrows() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws PGPException, IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Hardy Hardware "); PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKeys); diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/BcHashContextSignerTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/BcHashContextSignerTest.java index 1346e6b7..61858395 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/BcHashContextSignerTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/BcHashContextSignerTest.java @@ -11,7 +11,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -66,13 +65,13 @@ public class BcHashContextSignerTest { } @Test - public void signContextWithRSAKeys() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void signContextWithRSAKeys() throws PGPException, NoSuchAlgorithmException, IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleRsaKeyRing("Sigfried", RsaLength._3072); signWithKeys(secretKeys); } @Test - public void signContextWithEcKeys() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void signContextWithEcKeys() throws PGPException, NoSuchAlgorithmException, IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("Sigfried"); signWithKeys(secretKeys); } @@ -110,7 +109,7 @@ public class BcHashContextSignerTest { } private PGPSignature signMessage(byte[] message, HashAlgorithm hashAlgorithm, PGPSecretKeyRing secretKeys) - throws NoSuchAlgorithmException, PGPException { + throws NoSuchAlgorithmException { // Prepare the hash context // This would be done by the caller application MessageDigest messageDigest = MessageDigest.getInstance(hashAlgorithm.getAlgorithmName(), new BouncyCastleProvider()); diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptDecryptTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptDecryptTest.java index 4d81e32f..4e2fb744 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptDecryptTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptDecryptTest.java @@ -14,8 +14,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.Charset; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Set; import org.bouncycastle.bcpg.ArmoredOutputStream; @@ -69,7 +67,7 @@ public class EncryptDecryptTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void freshKeysRsaToRsaTest() - throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException { + throws PGPException, IOException { PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("romeo@montague.lit", RsaLength._3072); PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("juliet@capulet.lit", RsaLength._3072); @@ -79,7 +77,7 @@ public class EncryptDecryptTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void freshKeysEcToEcTest() - throws IOException, PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { + throws IOException, PGPException { PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("romeo@montague.lit"); PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("juliet@capulet.lit"); @@ -89,7 +87,7 @@ public class EncryptDecryptTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void freshKeysEcToRsaTest() - throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException { + throws PGPException, IOException { PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("romeo@montague.lit"); PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("juliet@capulet.lit", RsaLength._3072); @@ -99,7 +97,7 @@ public class EncryptDecryptTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void freshKeysRsaToEcTest() - throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException { + throws PGPException, IOException { PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("romeo@montague.lit", RsaLength._3072); PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("juliet@capulet.lit"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java index 5f6c6c15..cd20ebdd 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptionOptionsTest.java @@ -9,8 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -18,7 +16,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; @@ -49,7 +46,7 @@ public class EncryptionOptionsTest { private static SubkeyIdentifier encryptStorage; @BeforeAll - public static void generateKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public static void generateKey() { secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.CERTIFY_OTHER) .build()) @@ -135,7 +132,7 @@ public class EncryptionOptionsTest { } @Test - public void testAddRecipient_KeyWithoutEncryptionKeyFails() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testAddRecipient_KeyWithoutEncryptionKeyFails() { EncryptionOptions options = new EncryptionOptions(); PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)) @@ -169,7 +166,7 @@ public class EncryptionOptionsTest { } @Test - public void testAddRecipients_PGPPublicKeyRingCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testAddRecipients_PGPPublicKeyRingCollection() { PGPPublicKeyRing secondKeyRing = KeyRingUtils.publicKeyRingFrom( PGPainless.generateKeyRing().modernKeyRing("other@pgpainless.org")); diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/FileInformationTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/FileInformationTest.java index 50e9722b..57a13452 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/FileInformationTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/FileInformationTest.java @@ -13,8 +13,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import org.bouncycastle.openpgp.PGPException; @@ -38,7 +36,7 @@ public class FileInformationTest { private static PGPPublicKeyRing certificate; @BeforeAll - public static void generateKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public static void generateKey() { secretKey = PGPainless.generateKeyRing().modernKeyRing("alice@wonderland.lit"); certificate = PGPainless.extractCertificate(secretKey); } diff --git a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/HiddenRecipientEncryptionTest.java b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/HiddenRecipientEncryptionTest.java index 1cb0d3cb..0c510514 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/HiddenRecipientEncryptionTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/HiddenRecipientEncryptionTest.java @@ -11,8 +11,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; @@ -31,7 +29,7 @@ import org.pgpainless.key.SubkeyIdentifier; public class HiddenRecipientEncryptionTest { @Test - public void testAnonymousRecipientRoundtrip() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testAnonymousRecipientRoundtrip() throws PGPException, IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Alice "); PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKeys); diff --git a/pgpainless-core/src/test/java/org/pgpainless/example/ConvertKeys.java b/pgpainless-core/src/test/java/org/pgpainless/example/ConvertKeys.java index fc99fa44..caae8355 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/example/ConvertKeys.java +++ b/pgpainless-core/src/test/java/org/pgpainless/example/ConvertKeys.java @@ -7,10 +7,6 @@ package org.pgpainless.example; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; @@ -23,7 +19,7 @@ public class ConvertKeys { * This example demonstrates how to extract a public key certificate from a secret key. */ @Test - public void secretKeyToCertificate() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void secretKeyToCertificate() { String userId = "alice@wonderland.lit"; PGPSecretKeyRing secretKey = PGPainless.generateKeyRing() .modernKeyRing(userId); diff --git a/pgpainless-core/src/test/java/org/pgpainless/example/ModifyKeys.java b/pgpainless-core/src/test/java/org/pgpainless/example/ModifyKeys.java index 404858d1..08543f3d 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/example/ModifyKeys.java +++ b/pgpainless-core/src/test/java/org/pgpainless/example/ModifyKeys.java @@ -9,9 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.List; @@ -157,7 +154,7 @@ public class ModifyKeys { * Once the subkey is added, it can be decrypted using the provided subkey passphrase. */ @Test - public void addSubkey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void addSubkey() { // Protector for unlocking the existing secret key SecretKeyRingProtector protector = SecretKeyRingProtector.unlockEachKeyWith(Passphrase.fromPassword(originalPassphrase), secretKey); diff --git a/pgpainless-core/src/test/java/org/pgpainless/example/ReadKeys.java b/pgpainless-core/src/test/java/org/pgpainless/example/ReadKeys.java index 54e00c26..1559c1c1 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/example/ReadKeys.java +++ b/pgpainless-core/src/test/java/org/pgpainless/example/ReadKeys.java @@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.PGPSecretKeyRing; @@ -89,7 +88,7 @@ public class ReadKeys { * and a single public key block containing multiple public key packets. */ @Test - public void readKeyRingCollection() throws PGPException, IOException { + public void readKeyRingCollection() throws IOException { String certificateCollection = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "Comment: Alice's OpenPGP certificate\n" + "\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/SelfCertifyingRevocationTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/SelfCertifyingRevocationTest.java index 5923f352..0631526a 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/SelfCertifyingRevocationTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/SelfCertifyingRevocationTest.java @@ -10,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; @@ -162,7 +161,7 @@ public class SelfCertifyingRevocationTest { } @Test - public void mergeCertificatesResultsInRevokedKey() throws IOException, PGPException { + public void mergeCertificatesResultsInRevokedKey() throws IOException { PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(SECRET_KEY); assertNotNull(secretKeys); PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/WeirdKeys.java b/pgpainless-core/src/test/java/org/pgpainless/key/WeirdKeys.java index 4b0bb9de..3a0c24a3 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/WeirdKeys.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/WeirdKeys.java @@ -9,8 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Collections; import org.bouncycastle.bcpg.HashAlgorithmTags; @@ -104,7 +102,7 @@ public class WeirdKeys { @Test public void generateCertAndTestWithNonUTF8UserId() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws PGPException, IOException { PGPSecretKeyRing nakedKey = PGPainless.generateKeyRing().modernKeyRing(null); PGPPublicKey pubKey = nakedKey.getPublicKey(); PGPSecretKey secKey = nakedKey.getSecretKey(); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/certification/CertifyCertificateTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/certification/CertifyCertificateTest.java index eb0069f5..deb2877c 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/certification/CertifyCertificateTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/certification/CertifyCertificateTest.java @@ -10,8 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.List; import org.bouncycastle.bcpg.sig.TrustSignature; @@ -36,7 +34,7 @@ import org.pgpainless.util.DateUtil; public class CertifyCertificateTest { @Test - public void testUserIdCertification() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testUserIdCertification() throws PGPException, IOException { SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("Alice "); String bobUserId = "Bob "; @@ -71,7 +69,7 @@ public class CertifyCertificateTest { } @Test - public void testKeyDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testKeyDelegation() throws PGPException, IOException { SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("Alice "); PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("Bob "); @@ -110,7 +108,7 @@ public class CertifyCertificateTest { } @Test - public void testPetNameCertification() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testPetNameCertification() { PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing() .modernKeyRing("Alice "); PGPSecretKeyRing bobKey = PGPainless.generateKeyRing() @@ -140,7 +138,7 @@ public class CertifyCertificateTest { } @Test - public void testScopedDelegation() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testScopedDelegation() { PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing() .modernKeyRing("Alice "); PGPSecretKeyRing caKey = PGPainless.generateKeyRing() diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/collection/PGPKeyRingCollectionTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/collection/PGPKeyRingCollectionTest.java index fd5530ba..ca311091 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/collection/PGPKeyRingCollectionTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/collection/PGPKeyRingCollectionTest.java @@ -7,10 +7,7 @@ package org.pgpainless.key.collection; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Collection; @@ -25,7 +22,7 @@ import org.pgpainless.key.util.KeyRingUtils; public class PGPKeyRingCollectionTest { @Test - public void constructorThrowsForInvalidInput() throws PGPException, IOException { + public void constructorThrowsForInvalidInput() { // This is neither a public key, nor a private key String invalidKeyRing = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + @@ -56,7 +53,7 @@ public class PGPKeyRingCollectionTest { } @Test - public void testConstructorFromCollection() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testConstructorFromCollection() { PGPSecretKeyRing first = PGPainless.generateKeyRing().simpleEcKeyRing("alice@wonderland.lit"); PGPSecretKeyRing second = PGPainless.generateKeyRing().simpleEcKeyRing("bob@the-builder.tv"); PGPPublicKeyRing secondPub = KeyRingUtils.publicKeyRingFrom(second); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/BrainpoolKeyGenerationTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/BrainpoolKeyGenerationTest.java index 77023908..0a973d6f 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/BrainpoolKeyGenerationTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/BrainpoolKeyGenerationTest.java @@ -9,11 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; @@ -36,8 +33,7 @@ public class BrainpoolKeyGenerationTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void generateEcKeysTest() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void generateEcKeysTest() { for (EllipticCurve curve : EllipticCurve.values()) { PGPSecretKeyRing secretKeys = generateKey( @@ -65,8 +61,7 @@ public class BrainpoolKeyGenerationTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void generateEdDSAKeyTest() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void generateEdDSAKeyTest() { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( @@ -113,7 +108,7 @@ public class BrainpoolKeyGenerationTest { assertEquals(3072, rsaSub.getPublicKey().getBitStrength()); } - public PGPSecretKeyRing generateKey(KeySpec primaryKey, KeySpec subKey, String userId) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public PGPSecretKeyRing generateKey(KeySpec primaryKey, KeySpec subKey, String userId) { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(primaryKey) .addSubkey(subKey) diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateEllipticCurveKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateEllipticCurveKeyTest.java index 4cb992db..a9ab1668 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateEllipticCurveKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateEllipticCurveKeyTest.java @@ -6,9 +6,6 @@ package org.pgpainless.key.generation; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.TestTemplate; @@ -29,7 +26,7 @@ public class GenerateEllipticCurveKeyTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void generateEllipticCurveKeys() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + throws PGPException { PGPSecretKeyRing keyRing = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithAdditionalUserIdTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithAdditionalUserIdTest.java index cf12ab57..6c9ccbe5 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithAdditionalUserIdTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithAdditionalUserIdTest.java @@ -7,12 +7,9 @@ package org.pgpainless.key.generation; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Iterator; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.JUtils; @@ -32,7 +29,7 @@ public class GenerateKeyWithAdditionalUserIdTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void test() { Date now = DateUtil.now(); Date expiration = TestTimeFrameProvider.defaultExpirationForCreationDate(now); PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutPrimaryKeyFlagsTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutPrimaryKeyFlagsTest.java index ea0dbc73..ad375512 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutPrimaryKeyFlagsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutPrimaryKeyFlagsTest.java @@ -12,8 +12,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.bcpg.KeyIdentifier; import org.bouncycastle.openpgp.PGPException; @@ -43,7 +41,7 @@ import org.pgpainless.key.protection.SecretKeyRingProtector; public class GenerateKeyWithoutPrimaryKeyFlagsTest { @Test - public void generateKeyWithoutCertifyKeyFlag_cannotCertifyThirdParties() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void generateKeyWithoutCertifyKeyFlag_cannotCertifyThirdParties() throws PGPException, IOException { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing().setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519))) .addSubkey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.SIGN_DATA)) .addSubkey(KeySpec.getBuilder(KeyType.XDH_LEGACY(XDHLegacySpec._X25519), KeyFlag.ENCRYPT_STORAGE, KeyFlag.ENCRYPT_COMMS)) diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutUserIdTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutUserIdTest.java index e6a5c96a..88cc2b26 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutUserIdTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateKeyWithoutUserIdTest.java @@ -32,8 +32,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.List; @@ -43,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class GenerateKeyWithoutUserIdTest { @Test - public void generateKeyWithoutUserId() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void generateKeyWithoutUserId() throws PGPException, IOException { Date now = new Date(); Date expirationDate = TestTimeFrameProvider.defaultExpirationForCreationDate(now); PGPSecretKeyRing secretKey = PGPainless.buildKeyRing() diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateWithEmptyPassphraseTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateWithEmptyPassphraseTest.java index c1375883..ef649d86 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateWithEmptyPassphraseTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GenerateWithEmptyPassphraseTest.java @@ -6,10 +6,6 @@ package org.pgpainless.key.generation; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - -import org.bouncycastle.openpgp.PGPException; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.pgpainless.PGPainless; @@ -30,8 +26,7 @@ public class GenerateWithEmptyPassphraseTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testGeneratingKeyWithEmptyPassphraseDoesNotThrow() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void testGeneratingKeyWithEmptyPassphraseDoesNotThrow() { assertNotNull(PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GeneratingWeakKeyThrowsTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GeneratingWeakKeyThrowsTest.java index 6fbf0572..65dea167 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/generation/GeneratingWeakKeyThrowsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/generation/GeneratingWeakKeyThrowsTest.java @@ -6,12 +6,9 @@ package org.pgpainless.key.generation; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; -import org.bouncycastle.openpgp.PGPException; import org.junit.jupiter.api.Test; import org.pgpainless.PGPainless; import org.pgpainless.algorithm.KeyFlag; @@ -50,8 +47,7 @@ public class GeneratingWeakKeyThrowsTest { } @Test - public void allowToAddWeakKeysWithWeakPolicy() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void allowToAddWeakKeysWithWeakPolicy() { // set a weak algorithm policy Map bitStrengths = new HashMap<>(); bitStrengths.put(PublicKeyAlgorithm.RSA_GENERAL, 512); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java index 8b1877ee..fccd02fb 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/info/KeyRingInfoTest.java @@ -12,8 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Calendar; import java.util.Collections; @@ -558,7 +556,7 @@ public class KeyRingInfoTest { } @Test - public void testGetExpirationDateForUse_NoSuchKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testGetExpirationDateForUse_NoSuchKey() { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .addUserId("Alice") .setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.CERTIFY_OTHER)) diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/info/PrimaryUserIdTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/info/PrimaryUserIdTest.java index d2ec8598..30601f99 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/info/PrimaryUserIdTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/info/PrimaryUserIdTest.java @@ -6,9 +6,6 @@ package org.pgpainless.key.info; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; @@ -18,7 +15,7 @@ import org.pgpainless.key.protection.SecretKeyRingProtector; public class PrimaryUserIdTest { @Test - public void testGetPrimaryUserId() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void testGetPrimaryUserId() throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("alice@wonderland.lit"); secretKeys = PGPainless.modifyKeyRing(secretKeys) .addUserId("mad_alice@wonderland.lit", SecretKeyRingProtector.unprotectedKeys()) diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/info/UserIdRevocationTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/info/UserIdRevocationTest.java index abb067d1..9738bb0a 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/info/UserIdRevocationTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/info/UserIdRevocationTest.java @@ -11,8 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.List; import java.util.NoSuchElementException; @@ -38,7 +36,7 @@ import org.pgpainless.key.util.RevocationAttributes; public class UserIdRevocationTest { @Test - public void testRevocationWithoutRevocationAttributes() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testRevocationWithoutRevocationAttributes() throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), @@ -76,7 +74,7 @@ public class UserIdRevocationTest { } @Test - public void testRevocationWithRevocationReason() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void testRevocationWithRevocationReason() { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddSubKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddSubKeyTest.java index afcf9c98..ab58bc75 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddSubKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddSubKeyTest.java @@ -8,8 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -39,7 +37,7 @@ public class AddSubKeyTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void testAddSubKey() - throws IOException, PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + throws IOException, PGPException { PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing(); List keyIdsBefore = new ArrayList<>(); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddUserIdTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddUserIdTest.java index 7e15c998..69921f13 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddUserIdTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/AddUserIdTest.java @@ -10,8 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import java.util.Iterator; import java.util.NoSuchElementException; @@ -37,7 +35,7 @@ public class AddUserIdTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void addUserIdToExistingKeyRing() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("alice@wonderland.lit", "rabb1th0le"); KeyRingInfo info = PGPainless.inspectKeyRing(secretKeys); @@ -114,7 +112,7 @@ public class AddUserIdTest { } @Test - public void addNewPrimaryUserIdTest() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void addNewPrimaryUserIdTest() { Date now = new Date(); PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Alice"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java index c029a317..2eac921b 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeExpirationOnKeyWithDifferentSignatureTypesTest.java @@ -7,7 +7,6 @@ package org.pgpainless.key.modification; import java.io.IOException; import java.util.Date; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.JUtils; import org.junit.jupiter.api.TestTemplate; @@ -138,7 +137,7 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void setExpirationDate_keyHasSigClass10() - throws PGPException, IOException { + throws IOException { PGPSecretKeyRing keys = PGPainless.readKeyRing().secretKeyRing(keyWithGenericCertification); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); executeTestForKeys(keys, protector); @@ -147,14 +146,13 @@ public class ChangeExpirationOnKeyWithDifferentSignatureTypesTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void setExpirationDate_keyHasSigClass12() - throws PGPException, IOException { + throws IOException { PGPSecretKeyRing keys = PGPainless.readKeyRing().secretKeyRing(keyWithCasualCertification); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); executeTestForKeys(keys, protector); } - private void executeTestForKeys(PGPSecretKeyRing keys, SecretKeyRingProtector protector) - throws PGPException { + private void executeTestForKeys(PGPSecretKeyRing keys, SecretKeyRingProtector protector) { Date expirationDate = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 14); // round date for test stability expirationDate = DateUtil.toSecondsPrecision(expirationDate); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangePrimaryUserIdAndExpirationDatesTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangePrimaryUserIdAndExpirationDatesTest.java index 834497ac..e9bbab7a 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangePrimaryUserIdAndExpirationDatesTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangePrimaryUserIdAndExpirationDatesTest.java @@ -12,8 +12,6 @@ import org.pgpainless.PGPainless; import org.pgpainless.key.info.KeyRingInfo; import org.pgpainless.key.protection.SecretKeyRingProtector; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,7 +25,7 @@ public class ChangePrimaryUserIdAndExpirationDatesTest { @Test public void generateA_primaryB_revokeA_cantSecondaryA() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("A"); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); @@ -72,8 +70,7 @@ public class ChangePrimaryUserIdAndExpirationDatesTest { } @Test - public void generateA_primaryExpire_isExpired() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void generateA_primaryExpire_isExpired() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("A"); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); @@ -95,8 +92,7 @@ public class ChangePrimaryUserIdAndExpirationDatesTest { } @Test - public void generateA_primaryB_primaryExpire_bIsStillPrimary() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void generateA_primaryB_primaryExpire_bIsStillPrimary() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("A"); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); @@ -137,8 +133,7 @@ public class ChangePrimaryUserIdAndExpirationDatesTest { } @Test - public void generateA_expire_certify() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void generateA_expire_certify() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("A"); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); @@ -161,7 +156,7 @@ public class ChangePrimaryUserIdAndExpirationDatesTest { @Test public void generateA_expire_primaryB_expire_isPrimaryB() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("A"); SecretKeyRingProtector protector = SecretKeyRingProtector.unprotectedKeys(); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeSecretKeyRingPassphraseTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeSecretKeyRingPassphraseTest.java index a0ea6984..7bb41920 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeSecretKeyRingPassphraseTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/ChangeSecretKeyRingPassphraseTest.java @@ -11,8 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import org.bouncycastle.openpgp.PGPException; @@ -39,7 +37,7 @@ public class ChangeSecretKeyRingPassphraseTest { private final PGPSecretKeyRing keyRing = PGPainless.generateKeyRing().simpleEcKeyRing("password@encryp.ted", "weakPassphrase"); - public ChangeSecretKeyRingPassphraseTest() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public ChangeSecretKeyRingPassphraseTest() { } @TestTemplate diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/OldSignatureSubpacketsArePreservedOnNewSigTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/OldSignatureSubpacketsArePreservedOnNewSigTest.java index 5dc47a2a..d908191f 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/OldSignatureSubpacketsArePreservedOnNewSigTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/OldSignatureSubpacketsArePreservedOnNewSigTest.java @@ -8,11 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Date; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RefuseToAddWeakSubkeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RefuseToAddWeakSubkeyTest.java index 04197d6f..d5a3396a 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RefuseToAddWeakSubkeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RefuseToAddWeakSubkeyTest.java @@ -7,13 +7,9 @@ package org.pgpainless.key.modification; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.EnumMap; import java.util.Map; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; import org.pgpainless.PGPainless; @@ -31,8 +27,7 @@ import org.pgpainless.util.Passphrase; public class RefuseToAddWeakSubkeyTest { @Test - public void testEditorRefusesToAddWeakSubkey() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testEditorRefusesToAddWeakSubkey() { // ensure default policy is set PGPainless.getPolicy().setPublicKeyAlgorithmPolicy(Policy.PublicKeyAlgorithmPolicy.bsi2021PublicKeyAlgorithmPolicy()); @@ -46,8 +41,7 @@ public class RefuseToAddWeakSubkeyTest { } @Test - public void testEditorAllowsToAddWeakSubkeyIfCompliesToPublicKeyAlgorithmPolicy() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testEditorAllowsToAddWeakSubkeyIfCompliesToPublicKeyAlgorithmPolicy() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Alice"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevocationCertificateTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevocationCertificateTest.java index 48b5d5b7..27f0a9e1 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevocationCertificateTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevocationCertificateTest.java @@ -12,8 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; @@ -75,8 +73,7 @@ public class RevocationCertificateTest { } @Test - public void createMinimalRevocationCertificateForFreshKeyTest() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void createMinimalRevocationCertificateForFreshKeyTest() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice "); PGPPublicKeyRing minimalRevocationCert = PGPainless.modifyKeyRing(secretKeys).createMinimalRevocationCertificate( diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey.java b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey.java index 2cbbbe87..c4a177ed 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/modification/RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey.java @@ -7,7 +7,6 @@ package org.pgpainless.key.modification; import java.io.IOException; import java.util.Date; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.JUtils; import org.junit.jupiter.api.TestTemplate; @@ -99,7 +98,7 @@ public class RevokeKeyWithoutPreferredAlgorithmsOnPrimaryKey { @TestTemplate @ExtendWith(TestAllImplementations.class) public void testChangingExpirationTimeWithKeyWithoutPrefAlgos() - throws IOException, PGPException { + throws IOException { Date expirationDate = DateUtil.now(); PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KEY); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingCollectionReaderTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingCollectionReaderTest.java index 552ae25f..cd0a6c7b 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingCollectionReaderTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingCollectionReaderTest.java @@ -7,11 +7,8 @@ package org.pgpainless.key.parsing; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; import org.bouncycastle.openpgp.PGPSecretKeyRing; @@ -25,7 +22,7 @@ import org.pgpainless.util.ArmorUtils; public class KeyRingCollectionReaderTest { @Test - public void writeAndParseKeyRingCollections() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void writeAndParseKeyRingCollections() throws IOException { // secret keys PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("Alice "); PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("Bob "); @@ -48,7 +45,7 @@ public class KeyRingCollectionReaderTest { } @Test - public void parseSeparatedSecretKeyRingCollection() throws PGPException, IOException { + public void parseSeparatedSecretKeyRingCollection() throws IOException { String ascii = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" + "Version: PGPainless\n" + "Comment: 58F2 0119 232F BBC0 B624 CCA7 7BED B6B3 2279 0657\n" + @@ -107,7 +104,7 @@ public class KeyRingCollectionReaderTest { } @Test - public void parseConcatenatedSecretKeyRingCollection() throws PGPException, IOException { + public void parseConcatenatedSecretKeyRingCollection() throws IOException { // same key ring collection as above, but concatenated in a single armor block String ascii = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" + "Version: BCPG v1.68\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingReaderTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingReaderTest.java index 5ae6d9b2..a3b817e8 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingReaderTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/parsing/KeyRingReaderTest.java @@ -14,8 +14,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -70,15 +68,14 @@ class KeyRingReaderTest { } @Test - void publicKeyRingCollectionFromStream() throws IOException, PGPException { + void publicKeyRingCollectionFromStream() throws IOException { InputStream inputStream = requireResource("pub_keys_10_pieces.asc"); PGPPublicKeyRingCollection rings = PGPainless.readKeyRing().publicKeyRingCollection(inputStream); assertEquals(10, rings.size()); } @Test - void publicKeyRingCollectionFromNotArmoredStream() throws IOException, PGPException, - InvalidAlgorithmParameterException, NoSuchAlgorithmException { + void publicKeyRingCollectionFromNotArmoredStream() throws IOException { Collection collection = new ArrayList<>(); for (int i = 0; i < 10; i++) { @@ -96,7 +93,7 @@ class KeyRingReaderTest { } @Test - void publicKeyRingCollectionFromString() throws IOException, PGPException { + void publicKeyRingCollectionFromString() throws IOException { String armoredString = new String(readFromResource("pub_keys_10_pieces.asc")); InputStream inputStream = new ByteArrayInputStream(armoredString.getBytes(StandardCharsets.UTF_8)); PGPPublicKeyRingCollection rings = PGPainless.readKeyRing().publicKeyRingCollection(inputStream); @@ -104,7 +101,7 @@ class KeyRingReaderTest { } @Test - void publicKeyRingCollectionFromBytes() throws IOException, PGPException { + void publicKeyRingCollectionFromBytes() throws IOException { byte[] bytes = readFromResource("pub_keys_10_pieces.asc"); InputStream byteArrayInputStream = new ByteArrayInputStream(bytes); PGPPublicKeyRingCollection rings = PGPainless.readKeyRing().publicKeyRingCollection(byteArrayInputStream); @@ -115,7 +112,7 @@ class KeyRingReaderTest { * One armored pub key. */ @Test - void parsePublicKeysSingleArmored() throws IOException, PGPException { + void parsePublicKeysSingleArmored() throws IOException { assertEquals(1, getPgpPublicKeyRingsFromResource("single_pub_key_armored.asc").size()); } @@ -123,7 +120,7 @@ class KeyRingReaderTest { * One binary pub key. */ @Test - void parsePublicKeysSingleBinary() throws IOException, PGPException { + void parsePublicKeysSingleBinary() throws IOException { assertEquals(1, getPgpPublicKeyRingsFromResource("single_pub_key_binary.key").size()); } @@ -131,7 +128,7 @@ class KeyRingReaderTest { * Many armored pub keys with a single -----BEGIN PGP PUBLIC KEY BLOCK-----...-----END PGP PUBLIC KEY BLOCK-----. */ @Test - void parsePublicKeysMultiplyArmoredSingleHeader() throws IOException, PGPException { + void parsePublicKeysMultiplyArmoredSingleHeader() throws IOException { assertEquals(10, getPgpPublicKeyRingsFromResource("10_pub_keys_armored_single_header.asc").size()); } @@ -139,7 +136,7 @@ class KeyRingReaderTest { * Many armored pub keys where each has own -----BEGIN PGP PUBLIC KEY BLOCK-----...-----END PGP PUBLIC KEY BLOCK-----. */ @Test - void parsePublicKeysMultiplyArmoredOwnHeader() throws IOException, PGPException { + void parsePublicKeysMultiplyArmoredOwnHeader() throws IOException { assertEquals(10, getPgpPublicKeyRingsFromResource("10_pub_keys_armored_own_header.asc").size()); } @@ -148,7 +145,7 @@ class KeyRingReaderTest { * Each of those blocks can have a different count of keys. */ @Test - void parsePublicKeysMultiplyArmoredOwnWithSingleHeader() throws IOException, PGPException { + void parsePublicKeysMultiplyArmoredOwnWithSingleHeader() throws IOException { assertEquals(10, getPgpPublicKeyRingsFromResource("10_pub_keys_armored_own_with_single_header.asc").size()); } @@ -156,7 +153,7 @@ class KeyRingReaderTest { * Many binary pub keys. */ @Test - void parsePublicKeysMultiplyBinary() throws IOException, PGPException { + void parsePublicKeysMultiplyBinary() throws IOException { assertEquals(10, getPgpPublicKeyRingsFromResource("10_pub_keys_binary.key").size()); } @@ -164,7 +161,7 @@ class KeyRingReaderTest { * One armored private key. */ @Test - void parseSecretKeysSingleArmored() throws IOException, PGPException { + void parseSecretKeysSingleArmored() throws IOException { assertEquals(1, getPgpSecretKeyRingsFromResource("single_prv_key_armored.asc").size()); } @@ -172,7 +169,7 @@ class KeyRingReaderTest { * One binary private key. */ @Test - void parseSecretKeysSingleBinary() throws IOException, PGPException { + void parseSecretKeysSingleBinary() throws IOException { assertEquals(1, getPgpSecretKeyRingsFromResource("single_prv_key_binary.key").size()); } @@ -181,7 +178,7 @@ class KeyRingReaderTest { * -----BEGIN PGP PRIVATE KEY BLOCK-----...-----END PGP PRIVATE KEY BLOCK----- */ @Test - void parseSecretKeysMultiplyArmoredSingleHeader() throws IOException, PGPException { + void parseSecretKeysMultiplyArmoredSingleHeader() throws IOException { assertEquals(10, getPgpSecretKeyRingsFromResource("10_prv_keys_armored_single_header.asc").size()); } @@ -189,7 +186,7 @@ class KeyRingReaderTest { * Many armored private keys where each has own -----BEGIN PGP PRIVATE KEY BLOCK-----...-----END PGP PRIVATE KEY BLOCK-----. */ @Test - void parseSecretKeysMultiplyArmoredOwnHeader() throws IOException, PGPException { + void parseSecretKeysMultiplyArmoredOwnHeader() throws IOException { assertEquals(10, getPgpSecretKeyRingsFromResource("10_prv_keys_armored_own_header.asc").size()); } @@ -198,7 +195,7 @@ class KeyRingReaderTest { * Each of those blocks can have a different count of keys. */ @Test - void parseSecretKeysMultiplyArmoredOwnWithSingleHeader() throws IOException, PGPException { + void parseSecretKeysMultiplyArmoredOwnWithSingleHeader() throws IOException { assertEquals(10, getPgpSecretKeyRingsFromResource("10_prv_keys_armored_own_with_single_header.asc").size()); } @@ -206,7 +203,7 @@ class KeyRingReaderTest { * Many binary private keys. */ @Test - void parseSecretKeysMultiplyBinary() throws IOException, PGPException { + void parseSecretKeysMultiplyBinary() throws IOException { assertEquals(10, getPgpSecretKeyRingsFromResource("10_prv_keys_binary.key").size()); } @@ -214,7 +211,7 @@ class KeyRingReaderTest { * Many armored keys(private or pub) where each has own -----BEGIN PGP ... KEY BLOCK-----...-----END PGP ... KEY BLOCK-----. */ @Test - void parseKeysMultiplyArmoredOwnHeader() throws IOException, PGPException { + void parseKeysMultiplyArmoredOwnHeader() throws IOException { assertEquals(10, getPGPKeyRingsFromResource("10_prv_and_pub_keys_armored_own_header.asc").size()); } @@ -223,7 +220,7 @@ class KeyRingReaderTest { * Each of those blocks can have a different count of keys. */ @Test - void parseKeysMultiplyArmoredOwnWithSingleHeader() throws IOException, PGPException { + void parseKeysMultiplyArmoredOwnWithSingleHeader() throws IOException { assertEquals(10, getPGPKeyRingsFromResource("10_prv_and_pub_keys_armored_own_with_single_header.asc").size()); } @@ -231,22 +228,22 @@ class KeyRingReaderTest { * Many binary keys(private or pub). */ @Test - void parseKeysMultiplyBinary() throws IOException, PGPException { + void parseKeysMultiplyBinary() throws IOException { assertEquals(10, getPGPKeyRingsFromResource("10_prv_and_pub_keys_binary.key").size()); } private PGPKeyRingCollection getPGPKeyRingsFromResource(String fileName) - throws IOException, PGPException { + throws IOException { return PGPainless.readKeyRing().keyRingCollection(requireResource(fileName), true); } private PGPPublicKeyRingCollection getPgpPublicKeyRingsFromResource(String fileName) - throws IOException, PGPException { + throws IOException { return PGPainless.readKeyRing().publicKeyRingCollection(requireResource(fileName)); } private PGPSecretKeyRingCollection getPgpSecretKeyRingsFromResource(String fileName) - throws IOException, PGPException { + throws IOException { return PGPainless.readKeyRing().secretKeyRingCollection(requireResource(fileName)); } @@ -312,7 +309,7 @@ class KeyRingReaderTest { } @Test - public void testReadSecretKeyCollectionIgnoresMarkerPackets() throws PGPException, IOException { + public void testReadSecretKeyCollectionIgnoresMarkerPackets() throws IOException { // Marker // Alice // Marker @@ -380,7 +377,7 @@ class KeyRingReaderTest { } @Test - public void testReadCertificateCollectionIgnoresMarkerPackets() throws PGPException, IOException { + public void testReadCertificateCollectionIgnoresMarkerPackets() throws IOException { String markersAndCerts = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "Version: PGPainless\n" + "Comment: Certificates with injected Marker Packets\n" + @@ -434,7 +431,7 @@ class KeyRingReaderTest { } @Test - public void testReadSignatureIgnoresMarkerPacket() throws PGPException, IOException { + public void testReadSignatureIgnoresMarkerPacket() { String markerAndSignature = "-----BEGIN PGP SIGNATURE-----\n" + "Version: PGPainless\n" + "Comment: Signature with prepended Marker Packet\n" + @@ -449,7 +446,7 @@ class KeyRingReaderTest { } @Test - public void testReadSecretKeysIgnoresMultipleMarkers() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testReadSecretKeysIgnoresMultipleMarkers() throws IOException { PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("alice@pgpainless.org"); PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("bob@pgpainless.org"); MarkerPacket marker = TestUtils.getMarkerPacket(); @@ -483,7 +480,7 @@ class KeyRingReaderTest { @Test public void testReadingSecretKeysExceedsIterationLimit() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws IOException { PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("alice@pgpainless.org"); MarkerPacket marker = TestUtils.getMarkerPacket(); @@ -502,7 +499,7 @@ class KeyRingReaderTest { @Test public void testReadingSecretKeyCollectionExceedsIterationLimit() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws IOException { PGPSecretKeyRing alice = PGPainless.generateKeyRing().modernKeyRing("alice@pgpainless.org"); PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("bob@pgpainless.org"); MarkerPacket marker = TestUtils.getMarkerPacket(); @@ -524,7 +521,7 @@ class KeyRingReaderTest { @Test public void testReadingPublicKeysExceedsIterationLimit() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("alice@pgpainless.org"); PGPPublicKeyRing alice = PGPainless.extractCertificate(secretKeys); MarkerPacket marker = TestUtils.getMarkerPacket(); @@ -544,7 +541,7 @@ class KeyRingReaderTest { @Test public void testReadingPublicKeyCollectionExceedsIterationLimit() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws IOException { PGPSecretKeyRing sec1 = PGPainless.generateKeyRing().modernKeyRing("alice@pgpainless.org"); PGPSecretKeyRing sec2 = PGPainless.generateKeyRing().modernKeyRing("bob@pgpainless.org"); PGPPublicKeyRing alice = PGPainless.extractCertificate(sec1); @@ -566,7 +563,7 @@ class KeyRingReaderTest { } @Test - public void testReadKeyRingWithBinaryPublicKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testReadKeyRingWithBinaryPublicKey() throws IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice "); PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys); byte[] bytes = publicKeys.getEncoded(); @@ -579,7 +576,7 @@ class KeyRingReaderTest { } @Test - public void testReadKeyRingWithBinarySecretKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testReadKeyRingWithBinarySecretKey() throws IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice "); byte[] bytes = secretKeys.getEncoded(); @@ -591,7 +588,7 @@ class KeyRingReaderTest { } @Test - public void testReadKeyRingWithArmoredPublicKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testReadKeyRingWithArmoredPublicKey() throws IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice "); PGPPublicKeyRing publicKeys = PGPainless.extractCertificate(secretKeys); String armored = PGPainless.asciiArmor(publicKeys); @@ -604,7 +601,7 @@ class KeyRingReaderTest { } @Test - public void testReadKeyRingWithArmoredSecretKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + public void testReadKeyRingWithArmoredSecretKey() throws IOException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice "); String armored = PGPainless.asciiArmor(secretKeys); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/CachingSecretKeyRingProtectorTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/CachingSecretKeyRingProtectorTest.java index 3f7a9e6e..f77f1177 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/CachingSecretKeyRingProtectorTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/CachingSecretKeyRingProtectorTest.java @@ -10,8 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Random; @@ -51,13 +49,13 @@ public class CachingSecretKeyRingProtectorTest { } @Test - public void noCallbackReturnsNullForUnknownKeyId() throws PGPException { + public void noCallbackReturnsNullForUnknownKeyId() { assertNull(protector.getDecryptor(123L)); assertNull(protector.getEncryptor(123L)); } @Test - public void testAddPassphrase() throws PGPException { + public void testAddPassphrase() { Passphrase passphrase = Passphrase.fromPassword("HelloWorld"); protector.addPassphrase(123L, passphrase); assertEquals(passphrase, protector.getPassphraseFor(123L)); @@ -77,7 +75,7 @@ public class CachingSecretKeyRingProtectorTest { } @Test - public void testAddPassphraseForKeyRing() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testAddPassphraseForKeyRing() { PGPSecretKeyRing keys = PGPainless.generateKeyRing() .modernKeyRing("test@test.test", "Passphrase123"); Passphrase passphrase = Passphrase.fromPassword("Passphrase123"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java index 370cfd85..6b90ba19 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/PassphraseProtectedKeyTest.java @@ -7,8 +7,6 @@ package org.pgpainless.key.protection; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import javax.annotation.Nullable; @@ -46,19 +44,19 @@ public class PassphraseProtectedKeyTest { }); @Test - public void testReturnsNonNullDecryptorEncryptorForPassword() throws PGPException { + public void testReturnsNonNullDecryptorEncryptorForPassword() { assertNotNull(protector.getEncryptor(TestKeys.CRYPTIE_KEY_ID)); assertNotNull(protector.getDecryptor(TestKeys.CRYPTIE_KEY_ID)); } @Test - public void testReturnsNullDecryptorEncryptorForNoPassword() throws PGPException { + public void testReturnsNullDecryptorEncryptorForNoPassword() { assertNull(protector.getEncryptor(TestKeys.JULIET_KEY_ID)); assertNull(protector.getDecryptor(TestKeys.JULIET_KEY_ID)); } @Test - public void testReturnsNonNullDecryptorForSubkeys() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void testReturnsNonNullDecryptorForSubkeys() throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("alice", "passphrase"); SecretKeyRingProtector protector = PasswordBasedSecretKeyRingProtector.forKey(secretKeys, Passphrase.fromPassword("passphrase")); for (Iterator it = secretKeys.getPublicKeys(); it.hasNext(); ) { diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/SecretKeyRingProtectorTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/SecretKeyRingProtectorTest.java index a5030f74..193e9223 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/SecretKeyRingProtectorTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/SecretKeyRingProtectorTest.java @@ -10,8 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Map; import java.util.Random; @@ -35,7 +33,7 @@ public class SecretKeyRingProtectorTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void testUnlockAllKeysWithSamePassword() - throws IOException, PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + throws IOException, PGPException { PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing(); SecretKeyRingProtector protector = diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/UnlockSecretKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/UnlockSecretKeyTest.java index c6a35ea9..2bb0e3ac 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/UnlockSecretKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/UnlockSecretKeyTest.java @@ -7,9 +7,6 @@ package org.pgpainless.key.protection; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPSecretKey; @@ -22,7 +19,7 @@ import org.pgpainless.util.Passphrase; public class UnlockSecretKeyTest { @Test - public void testUnlockSecretKey() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testUnlockSecretKey() throws PGPException { PGPSecretKeyRing secretKeyRing = PGPainless.generateKeyRing() .simpleEcKeyRing("alice@wonderland.lit", "heureka!"); PGPSecretKey secretKey = secretKeyRing.getSecretKey(); diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/protection/fixes/S2KUsageFixTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/protection/fixes/S2KUsageFixTest.java index ba6673e5..dca08b2d 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/protection/fixes/S2KUsageFixTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/protection/fixes/S2KUsageFixTest.java @@ -11,8 +11,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.bcpg.SecretKeyPacket; import org.bouncycastle.openpgp.PGPException; @@ -68,7 +66,7 @@ public class S2KUsageFixTest { @Test public void verifyOutFixInChangePassphraseWorks() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + throws PGPException { PGPSecretKeyRing before = PGPainless.generateKeyRing().modernKeyRing("Alice", "before"); for (PGPSecretKey key : before) { assertEquals(SecretKeyPacket.USAGE_SHA1, key.getS2KUsage()); diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/BindingSignatureSubpacketsTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/BindingSignatureSubpacketsTest.java index 331ca07a..bf3d7a0d 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/BindingSignatureSubpacketsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/BindingSignatureSubpacketsTest.java @@ -13,7 +13,6 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Date; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSignature; import org.junit.jupiter.api.TestTemplate; @@ -53,7 +52,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void baseCase() throws IOException, PGPException { + public void baseCase() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -114,7 +113,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingIssuerFpOnly() throws IOException, PGPException { + public void subkeyBindingIssuerFpOnly() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -175,7 +174,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingIssuerV6IssuerFp() throws IOException, PGPException { + public void subkeyBindingIssuerV6IssuerFp() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -236,7 +235,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingIssuerFakeIssuer() throws IOException, PGPException { + public void subkeyBindingIssuerFakeIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -297,7 +296,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingFakeIssuerIssuer() throws IOException, PGPException { + public void subkeyBindingFakeIssuerIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -358,7 +357,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingFakeIssuer() throws IOException, PGPException { + public void subkeyBindingFakeIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -419,7 +418,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingNoIssuer() throws IOException, PGPException { + public void subkeyBindingNoIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -479,7 +478,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void unknownSubpacketHashed() throws IOException, PGPException { + public void unknownSubpacketHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -540,7 +539,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingUnknownCriticalSubpacket() throws IOException, PGPException { + public void subkeyBindingUnknownCriticalSubpacket() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -601,7 +600,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingUnknownSubpacketUnhashed() throws IOException, PGPException { + public void subkeyBindingUnknownSubpacketUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -662,7 +661,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingUnknownCriticalSubpacketUnhashed() throws IOException, PGPException { + public void subkeyBindingUnknownCriticalSubpacketUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -723,7 +722,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingUnknownNotationHashed() throws IOException, PGPException { + public void subkeyBindingUnknownNotationHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -785,7 +784,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingCriticalUnknownNotationHashed() throws IOException, PGPException { + public void subkeyBindingCriticalUnknownNotationHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -847,7 +846,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingUnknownNotationUnhashed() throws IOException, PGPException { + public void subkeyBindingUnknownNotationUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -909,7 +908,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingCriticalUnknownNotationUnhashed() throws IOException, PGPException { + public void subkeyBindingCriticalUnknownNotationUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -971,7 +970,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingBackSigFakeBackSig() throws IOException, PGPException { + public void subkeyBindingBackSigFakeBackSig() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1043,7 +1042,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeyBindingFakeBackSigBackSig() throws IOException, PGPException { + public void subkeyBindingFakeBackSigBackSig() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1115,7 +1114,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingIssuerFpOnly() throws IOException, PGPException { + public void primaryBindingIssuerFpOnly() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1176,7 +1175,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingIssuerV6IssuerFp() throws IOException, PGPException { + public void primaryBindingIssuerV6IssuerFp() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1237,7 +1236,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingIssuerFakeIssuer() throws IOException, PGPException { + public void primaryBindingIssuerFakeIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1298,7 +1297,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingFakeIssuerIssuer() throws IOException, PGPException { + public void primaryBindingFakeIssuerIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1359,7 +1358,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingFakeIssuer() throws IOException, PGPException { + public void primaryBindingFakeIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1420,7 +1419,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingNoIssuer() throws IOException, PGPException { + public void primaryBindingNoIssuer() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1480,7 +1479,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingUnknownSubpacketHashed() throws IOException, PGPException { + public void primaryBindingUnknownSubpacketHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1541,7 +1540,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingCriticalUnknownSubpacketHashed() throws IOException, PGPException { + public void primaryBindingCriticalUnknownSubpacketHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1602,7 +1601,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingUnknownSubpacketUnhashed() throws IOException, PGPException { + public void primaryBindingUnknownSubpacketUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1663,7 +1662,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingCriticalUnknownSubpacketUnhashed() throws IOException, PGPException { + public void primaryBindingCriticalUnknownSubpacketUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1724,7 +1723,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingUnknownNotationHashed() throws IOException, PGPException { + public void primaryBindingUnknownNotationHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1786,7 +1785,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingCriticalUnknownNotationHashed() throws IOException, PGPException { + public void primaryBindingCriticalUnknownNotationHashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1848,7 +1847,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingUnknownNotationUnhashed() throws IOException, PGPException { + public void primaryBindingUnknownNotationUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1910,7 +1909,7 @@ public class BindingSignatureSubpacketsTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void primaryBindingCriticalUnknownNotationUnhashed() throws IOException, PGPException { + public void primaryBindingCriticalUnknownNotationUnhashed() throws IOException { String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "\n" + @@ -1970,7 +1969,7 @@ public class BindingSignatureSubpacketsTest { expectSignatureValidationSucceeds(key, "Critical unknown notation is acceptable in unhashed area of primary key binding sig."); } - private void expectSignatureValidationSucceeds(String key, String message) throws IOException, PGPException { + private void expectSignatureValidationSucceeds(String key, String message) throws IOException { PGPPublicKeyRing publicKeys = PGPainless.readKeyRing().publicKeyRing(key); PGPSignature signature = SignatureUtils.readSignatures(sig).get(0); @@ -1984,7 +1983,7 @@ public class BindingSignatureSubpacketsTest { } } - private void expectSignatureValidationFails(String key, String message) throws IOException, PGPException { + private void expectSignatureValidationFails(String key, String message) throws IOException { PGPPublicKeyRing publicKeys = PGPainless.readKeyRing().publicKeyRing(key); PGPSignature signature = SignatureUtils.readSignatures(sig).get(0); diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/CertificateValidatorTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/CertificateValidatorTest.java index 175ce101..0aba7e18 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/CertificateValidatorTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/CertificateValidatorTest.java @@ -39,7 +39,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testPrimaryKeySignsAndIsHardRevokedUnknown() throws IOException, PGPException { + public void testPrimaryKeySignsAndIsHardRevokedUnknown() throws IOException { String key = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -190,7 +190,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testSubkeySignsPrimaryKeyIsHardRevokedUnknown() throws IOException, PGPException { + public void testSubkeySignsPrimaryKeyIsHardRevokedUnknown() throws IOException { String key = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -342,7 +342,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testSubkeySignsAndIsHardRevokedUnknown() throws IOException, PGPException { + public void testSubkeySignsAndIsHardRevokedUnknown() throws IOException { String keyWithHardRev = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -494,7 +494,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testPrimaryKeySignsAndIsSoftRevokedSuperseded() throws IOException, PGPException { + public void testPrimaryKeySignsAndIsSoftRevokedSuperseded() throws IOException { String keyWithSoftRev = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -651,7 +651,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testSubkeySignsPrimaryKeyIsSoftRevokedSuperseded() throws IOException, PGPException { + public void testSubkeySignsPrimaryKeyIsSoftRevokedSuperseded() throws IOException { String key = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -804,7 +804,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testPrimaryKeySignsAndIsSoftRevokedRetired() throws IOException, PGPException { + public void testPrimaryKeySignsAndIsSoftRevokedRetired() throws IOException { String key = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + @@ -957,7 +957,7 @@ public class CertificateValidatorTest { */ @TestTemplate @ExtendWith(TestAllImplementations.class) - public void testTemporaryValidity() throws IOException, PGPException { + public void testTemporaryValidity() throws IOException { String keyA = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "Comment: D1A6 6E1A 23B1 82C9 980F 788C FBFC C82A 015E 7330\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/KeyRevocationTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/KeyRevocationTest.java index 67f5cf4c..87059847 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/KeyRevocationTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/KeyRevocationTest.java @@ -27,7 +27,7 @@ public class KeyRevocationTest { @TestTemplate @ExtendWith(TestAllImplementations.class) - public void subkeySignsPrimaryKeyRevokedNoReason() throws IOException, PGPException { + public void subkeySignsPrimaryKeyRevokedNoReason() throws IOException { String key = "-----BEGIN PGP ARMORED FILE-----\n" + "Comment: ASCII Armor added by openpgp-interoperability-test-suite\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/OnePassSignatureBracketingTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/OnePassSignatureBracketingTest.java index fd7c53e9..a0dcf141 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/OnePassSignatureBracketingTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/OnePassSignatureBracketingTest.java @@ -12,8 +12,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import org.bouncycastle.openpgp.PGPCompressedData; import org.bouncycastle.openpgp.PGPEncryptedData; @@ -54,7 +52,7 @@ public class OnePassSignatureBracketingTest { @TestTemplate @ExtendWith(TestAllImplementations.class) public void onePassSignaturePacketsAndSignaturesAreBracketedTest() - throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException { + throws PGPException, IOException { PGPSecretKeyRing key1 = PGPainless.generateKeyRing().modernKeyRing("Alice"); PGPSecretKeyRing key2 = PGPainless.generateKeyRing().modernKeyRing("Bob"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureStructureTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureStructureTest.java index 0d957309..83c7c2a8 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureStructureTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureStructureTest.java @@ -7,12 +7,10 @@ package org.pgpainless.signature; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.io.IOException; import java.util.List; import org.bouncycastle.bcpg.sig.IssuerKeyID; import org.bouncycastle.bcpg.sig.NotationData; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.util.encoders.Hex; import org.junit.jupiter.api.BeforeAll; @@ -30,7 +28,7 @@ public class SignatureStructureTest { private static PGPSignature signature; @BeforeAll - public static void parseSignature() throws IOException, PGPException { + public static void parseSignature() { // see https://tests.sequoia-pgp.org/#Detached_signature_with_Subpackets (base case) signature = SignatureUtils.readSignatures("-----BEGIN PGP SIGNATURE-----\n" + "\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureUtilsTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureUtilsTest.java index f57ed2c4..1415eff9 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureUtilsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureUtilsTest.java @@ -9,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.List; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSignature; @@ -19,7 +18,7 @@ import org.pgpainless.PGPainless; public class SignatureUtilsTest { @Test - public void readSignaturesFromCompressedDataDoesNotAttemptDecompression() throws PGPException, IOException { + public void readSignaturesFromCompressedDataDoesNotAttemptDecompression() { String compressed = "-----BEGIN PGP MESSAGE-----\n" + "Version: PGPainless\n" + "\n" + @@ -35,7 +34,7 @@ public class SignatureUtilsTest { } @Test - public void noIssuerResultsInKeyId0() throws PGPException, IOException { + public void noIssuerResultsInKeyId0() { String sig = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsEaBAABCABOBYJhVBVcRxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -55,7 +54,7 @@ public class SignatureUtilsTest { } @Test - public void skipInvalidSignatures() throws PGPException, IOException { + public void skipInvalidSignatures() { // Sig version 23 (invalid), sig version 4 String sigs = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureWasPossiblyMadeByKeyTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureWasPossiblyMadeByKeyTest.java index c7424af1..ebd414bf 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureWasPossiblyMadeByKeyTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/SignatureWasPossiblyMadeByKeyTest.java @@ -76,7 +76,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void issuer() throws PGPException, IOException { + public void issuer() throws PGPException { String sigWithIssuer = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsE7BAABCABlBYJgyf21RxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -96,7 +96,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void hashedIssuer() throws PGPException, IOException { + public void hashedIssuer() throws PGPException { String sigWithHashedIssuer = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsE7BAABCABvBYJgyf21CRD7/MgqAV5zMEcUAAAAAAAeACBzYWx0QG5vdGF0aW9u\n" + @@ -116,7 +116,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void noIssuerNoFingerprint() throws PGPException, IOException { + public void noIssuerNoFingerprint() throws PGPException { String sigWithNoIssuerNoFingerprint = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsEaBAABCABOBYJgyf21RxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -137,7 +137,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void noIssuerUnhashedFingerprint() throws PGPException, IOException { + public void noIssuerUnhashedFingerprint() throws PGPException { String sigWithNoIssuerUnhashedFingerprint = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsExBAABCABOBYJgyf21RxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -158,7 +158,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void issuerMismatch() throws PGPException, IOException { + public void issuerMismatch() { String sig = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsE7BAABCABlBYJgyf21RxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -178,7 +178,7 @@ public class SignatureWasPossiblyMadeByKeyTest { } @Test - public void noIssuer_fingerprintMismatch() throws PGPException, IOException { + public void noIssuer_fingerprintMismatch() { String sigWithNoIssuerAndWrongFingerprint = "-----BEGIN PGP SIGNATURE-----\n" + "\n" + "wsExBAABCABlBYJgyf21RxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNlcXVvaWEt\n" + @@ -198,7 +198,7 @@ public class SignatureWasPossiblyMadeByKeyTest { assertWasNotPossiblyMadeByKey(NOSIGKEY, get(sigWithNoIssuerAndWrongFingerprint)); } - private PGPSignature get(String encoded) throws PGPException, IOException { + private PGPSignature get(String encoded) { return SignatureUtils.readSignatures(encoded).get(0); } diff --git a/pgpainless-core/src/test/java/org/pgpainless/signature/builder/ThirdPartyCertificationSignatureBuilderTest.java b/pgpainless-core/src/test/java/org/pgpainless/signature/builder/ThirdPartyCertificationSignatureBuilderTest.java index 2b0f4d35..35726ee6 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/signature/builder/ThirdPartyCertificationSignatureBuilderTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/signature/builder/ThirdPartyCertificationSignatureBuilderTest.java @@ -17,9 +17,6 @@ import org.pgpainless.key.protection.SecretKeyRingProtector; import org.pgpainless.signature.subpackets.CertificationSubpackets; import org.pgpainless.signature.subpackets.SignatureSubpacketsUtil; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -30,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class ThirdPartyCertificationSignatureBuilderTest { @Test - public void testInvalidSignatureTypeThrows() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testInvalidSignatureTypeThrows() { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Alice"); assertThrows(IllegalArgumentException.class, () -> @@ -41,7 +38,7 @@ public class ThirdPartyCertificationSignatureBuilderTest { } @Test - public void testUserIdCertification() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { + public void testUserIdCertification() throws PGPException { PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing() .modernKeyRing("Alice"); diff --git a/pgpainless-core/src/test/java/org/pgpainless/util/ArmorUtilsTest.java b/pgpainless-core/src/test/java/org/pgpainless/util/ArmorUtilsTest.java index c0a6e00c..22f98512 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/util/ArmorUtilsTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/util/ArmorUtilsTest.java @@ -130,7 +130,7 @@ public class ArmorUtilsTest { } @Test - public void signatureToAsciiArmoredString() throws PGPException, IOException { + public void signatureToAsciiArmoredString() { String SIG = "-----BEGIN PGP SIGNATURE-----\n" + "Version: PGPainless\n" + "\n" + diff --git a/pgpainless-core/src/test/java/org/pgpainless/util/BCUtilTest.java b/pgpainless-core/src/test/java/org/pgpainless/util/BCUtilTest.java index 821d9e30..6e7b94cc 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/util/BCUtilTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/util/BCUtilTest.java @@ -8,11 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRingCollection; @@ -34,8 +31,7 @@ public class BCUtilTest { private static final Logger LOGGER = LoggerFactory.getLogger(BCUtilTest.class); @Test - public void keyRingToCollectionTest() - throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException { + public void keyRingToCollectionTest() { PGPSecretKeyRing sec = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( KeyType.RSA(RsaLength._3072), diff --git a/pgpainless-core/src/test/java/org/pgpainless/util/GuessPreferredHashAlgorithmTest.java b/pgpainless-core/src/test/java/org/pgpainless/util/GuessPreferredHashAlgorithmTest.java index e276ba8f..bf991236 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/util/GuessPreferredHashAlgorithmTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/util/GuessPreferredHashAlgorithmTest.java @@ -6,11 +6,8 @@ package org.pgpainless.util; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; import java.util.Collections; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; @@ -27,8 +24,7 @@ import org.pgpainless.key.util.OpenPgpKeyAttributeUtil; public class GuessPreferredHashAlgorithmTest { @Test - public void guessPreferredHashAlgorithmsAssumesHashAlgoUsedBySelfSig() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void guessPreferredHashAlgorithmsAssumesHashAlgoUsedBySelfSig() { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA) diff --git a/pgpainless-core/src/test/java/org/pgpainless/weird_keys/TestEncryptCommsStorageFlagsDifferentiated.java b/pgpainless-core/src/test/java/org/pgpainless/weird_keys/TestEncryptCommsStorageFlagsDifferentiated.java index b96d95e5..8c9da177 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/weird_keys/TestEncryptCommsStorageFlagsDifferentiated.java +++ b/pgpainless-core/src/test/java/org/pgpainless/weird_keys/TestEncryptCommsStorageFlagsDifferentiated.java @@ -6,10 +6,6 @@ package org.pgpainless.weird_keys; import static org.junit.jupiter.api.Assertions.assertThrows; -import java.security.InvalidAlgorithmParameterException; -import java.security.NoSuchAlgorithmException; - -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.junit.jupiter.api.Test; @@ -25,8 +21,7 @@ import org.pgpainless.key.util.KeyRingUtils; public class TestEncryptCommsStorageFlagsDifferentiated { @Test - public void testThatEncryptionDifferentiatesBetweenPurposeKeyFlags() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException { + public void testThatEncryptionDifferentiatesBetweenPurposeKeyFlags() { PGPSecretKeyRing secretKeys = PGPainless.buildKeyRing() .setPrimaryKey(KeySpec.getBuilder( KeyType.RSA(RsaLength._3072),