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