1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 02:09:38 +02:00

Tests: Remove unused throws declarations

This commit is contained in:
Paul Schaub 2025-02-07 13:29:51 +01:00
parent 7991af06d4
commit ead93345e4
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
57 changed files with 171 additions and 307 deletions

View file

@ -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"));

View file

@ -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<PGPSignature> signatureList = SignatureUtils.readSignatures(ARMORED_SIGNATURE_WITH_MISSING_CRC_SUM);
assertEquals(1, signatureList.size());
}

View file

@ -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 <a href="https://security.stackexchange.com/questions/92635/is-it-possible-to-assign-different-uids-to-subkeys-for-the-purpose-of-having-mul>Stackexchange link</a>
*/
@Test
public void subkeysDoNotHaveUserIDsTest() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException {
public void subkeysDoNotHaveUserIDsTest() {
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("primary@user.id");
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys);
PGPPublicKey primaryKey = publicKeys.getPublicKey();
@ -45,7 +42,7 @@ public class PGPPublicKeyRingTest {
}
@Test
public void removeUserIdTest() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
public void removeUserIdTest() {
String userId = "alice@wonderland.lit";
PGPSecretKeyRing secretKeyRing = PGPainless.generateKeyRing().simpleEcKeyRing(userId);
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeyRing);

View file

@ -16,8 +16,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import org.bouncycastle.openpgp.PGPException;
@ -216,7 +214,7 @@ public class CleartextSignatureVerificationTest {
@Test
public void testDecryptionOfVeryLongClearsignedMessage()
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
throws PGPException, IOException {
String message = randomString(28, 4000);
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing("Alice");

View file

@ -13,8 +13,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.Random;
import org.bouncycastle.bcpg.ArmoredInputStream;
@ -736,7 +734,7 @@ public class OpenPgpInputStreamTest {
}
@Test
public void testSignedMessageConsumption() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
public void testSignedMessageConsumption() throws PGPException, IOException {
ByteArrayInputStream plaintext = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8));
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
.modernKeyRing("Sigmund <sigmund@exmplample.com>");

View file

@ -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 <alice@pgpainless.org>"),
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<String, MessageMetadata> 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<String, MessageMetadata> 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);

View file

@ -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 <hardy@hard.ware>");
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKeys);

View file

@ -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());

View file

@ -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");

View file

@ -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"));

View file

@ -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);
}

View file

@ -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 <alice@pgpainless.org>");
PGPPublicKeyRing certificate = PGPainless.extractCertificate(secretKeys);

View file

@ -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);

View file

@ -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);

View file

@ -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" +

View file

@ -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);

View file

@ -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();

View file

@ -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 <alice@pgpainless.org>");
String bobUserId = "Bob <bob@pgpainless.org>";
@ -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 <alice@pgpainless.org>");
PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("Bob <bob@pgpainless.org>");
@ -110,7 +108,7 @@ public class CertifyCertificateTest {
}
@Test
public void testPetNameCertification() throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
public void testPetNameCertification() {
PGPSecretKeyRing aliceKey = PGPainless.generateKeyRing()
.modernKeyRing("Alice <alice@pgpainless.org>");
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 <alice@pgpainless.org>");
PGPSecretKeyRing caKey = PGPainless.generateKeyRing()

View file

@ -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);

View file

@ -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)

View file

@ -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),

View file

@ -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()

View file

@ -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))

View file

@ -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()

View file

@ -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(

View file

@ -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<PublicKeyAlgorithm, Integer> bitStrengths = new HashMap<>();
bitStrengths.put(PublicKeyAlgorithm.RSA_GENERAL, 512);

View file

@ -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))

View file

@ -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())

View file

@ -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),

View file

@ -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<Long> keyIdsBefore = new ArrayList<>();

View file

@ -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");

View file

@ -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);

View file

@ -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();

View file

@ -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

View file

@ -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;

View file

@ -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");

View file

@ -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 <alice@example.org>");
PGPPublicKeyRing minimalRevocationCert = PGPainless.modifyKeyRing(secretKeys).createMinimalRevocationCertificate(

View file

@ -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);

View file

@ -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 <alice@pgpainless.org>");
PGPSecretKeyRing bob = PGPainless.generateKeyRing().modernKeyRing("Bob <bob@pgpainless.org>");
@ -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" +

View file

@ -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<PGPPublicKeyRing> 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 <alice@pgpainless.org>");
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 <alice@pgpainless.org>");
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 <alice@pgpainless.org>");
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 <alice@pgpainless.org>");
String armored = PGPainless.asciiArmor(secretKeys);

View file

@ -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");

View file

@ -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<PGPPublicKey> it = secretKeys.getPublicKeys(); it.hasNext(); ) {

View file

@ -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 =

View file

@ -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();

View file

@ -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());

View file

@ -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);

View file

@ -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" +

View file

@ -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" +

View file

@ -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");

View file

@ -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" +

View file

@ -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" +

View file

@ -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);
}

View file

@ -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");

View file

@ -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" +

View file

@ -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),

View file

@ -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)

View file

@ -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),