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

Replace static decryptAndOrVerify() method with non-static processMessage() function

This commit is contained in:
Paul Schaub 2025-05-06 22:21:02 +02:00
parent 3bc07f045c
commit 244113bc2f
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
53 changed files with 141 additions and 129 deletions

View file

@ -112,6 +112,12 @@ class PGPainless(
/** Generate an encrypted and/or signed OpenPGP message. */ /** Generate an encrypted and/or signed OpenPGP message. */
fun generateMessage(): EncryptionBuilder = EncryptionBuilder(this) fun generateMessage(): EncryptionBuilder = EncryptionBuilder(this)
/**
* Process an OpenPGP message. This method attempts decryption of encrypted messages and
* performs signature verification.
*/
fun processMessage(): DecryptionBuilder = DecryptionBuilder(this)
/** /**
* Create certification signatures on third-party [OpenPGPCertificates][OpenPGPCertificate]. * Create certification signatures on third-party [OpenPGPCertificates][OpenPGPCertificate].
* *
@ -253,7 +259,11 @@ class PGPainless(
* *
* @return builder * @return builder
*/ */
@JvmStatic fun decryptAndOrVerify(): DecryptionBuilder = DecryptionBuilder(getInstance()) @Deprecated(
"Call processMessage() on an instance of PGPainless instead.",
replaceWith = ReplaceWith("processMessage()"))
@JvmStatic
fun decryptAndOrVerify(): DecryptionBuilder = getInstance().processMessage()
/** /**
* Make changes to a secret key at the given reference time. This method can be used to * Make changes to a secret key at the given reference time. This method can be used to

View file

@ -35,7 +35,7 @@ interface SymmetricKeyAlgorithmNegotiator {
override: SymmetricKeyAlgorithm?, override: SymmetricKeyAlgorithm?,
keyPreferences: List<Set<SymmetricKeyAlgorithm>> keyPreferences: List<Set<SymmetricKeyAlgorithm>>
): SymmetricKeyAlgorithm { ): SymmetricKeyAlgorithm {
require (override != SymmetricKeyAlgorithm.NULL) { require(override != SymmetricKeyAlgorithm.NULL) {
"Algorithm override cannot be NULL (plaintext)." "Algorithm override cannot be NULL (plaintext)."
} }

View file

@ -405,10 +405,11 @@ class EncryptionOptions(private val purpose: EncryptionPurpose, private val api:
} }
fun overrideEncryptionMechanism(encryptionMechanism: MessageEncryptionMechanism) = apply { fun overrideEncryptionMechanism(encryptionMechanism: MessageEncryptionMechanism) = apply {
require(api.algorithmPolicy.symmetricKeyEncryptionAlgorithmPolicy.isAcceptable( require(
encryptionMechanism.symmetricKeyAlgorithm)) { api.algorithmPolicy.symmetricKeyEncryptionAlgorithmPolicy.isAcceptable(
"Provided symmetric encryption algorithm is not acceptable." encryptionMechanism.symmetricKeyAlgorithm)) {
} "Provided symmetric encryption algorithm is not acceptable."
}
_encryptionMechanismOverride = encryptionMechanism _encryptionMechanismOverride = encryptionMechanism
} }

View file

@ -187,7 +187,7 @@ public class InvestigateMultiSEIPMessageHandlingTest {
.addVerificationCert(ring2) .addVerificationCert(ring2)
.addDecryptionKey(ring1); .addDecryptionKey(ring1);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(MESSAGE.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(MESSAGE.getBytes(StandardCharsets.UTF_8)))
.withOptions(options); .withOptions(options);

View file

@ -122,7 +122,7 @@ public class OnePassSignatureVerificationWithPartialLengthLiteralDataRegressionT
ByteArrayInputStream in = new ByteArrayInputStream(dearmored.toByteArray()); ByteArrayInputStream in = new ByteArrayInputStream(dearmored.toByteArray());
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(cert) .addVerificationCert(cert)

View file

@ -542,7 +542,7 @@ public class AsciiArmorCRCTests {
OpenPGPKey key = PGPainless.getInstance().readKey().parseKey(ASCII_KEY); OpenPGPKey key = PGPainless.getInstance().readKey().parseKey(ASCII_KEY);
assertThrows(IOException.class, () -> { assertThrows(IOException.class, () -> {
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get().addDecryptionKey( .withOptions(ConsumerOptions.get().addDecryptionKey(
key, SecretKeyRingProtector.unlockAnyKeyWith(passphrase) key, SecretKeyRingProtector.unlockAnyKeyWith(passphrase)

View file

@ -76,7 +76,7 @@ public class CachingBcPublicKeyDataDecryptorFactoryTest {
privateKey, decryptionKey); privateKey, decryptionKey);
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(MSG.getBytes()); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(MSG.getBytes());
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addCustomDecryptorFactory(cachingFactory)); .addCustomDecryptorFactory(cachingFactory));
@ -87,7 +87,7 @@ public class CachingBcPublicKeyDataDecryptorFactoryTest {
assertEquals("Hello, World!\n", out.toString()); assertEquals("Hello, World!\n", out.toString());
ciphertextIn = new ByteArrayInputStream(MSG.getBytes()); ciphertextIn = new ByteArrayInputStream(MSG.getBytes());
decryptionStream = PGPainless.decryptAndOrVerify() decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addCustomDecryptorFactory(cachingFactory)); .addCustomDecryptorFactory(cachingFactory));

View file

@ -297,7 +297,7 @@ public class CanonicalizedDataEncryptionTest {
String encrypted = encryptAndSign(before, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, true); String encrypted = encryptAndSign(before, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, true);
ByteArrayInputStream in = new ByteArrayInputStream(encrypted.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(encrypted.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys())
@ -327,7 +327,7 @@ public class CanonicalizedDataEncryptionTest {
String encrypted = encryptAndSign(beforeAndAfter, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, false); String encrypted = encryptAndSign(beforeAndAfter, DocumentSignatureType.BINARY_DOCUMENT, StreamEncoding.TEXT, false);
ByteArrayInputStream in = new ByteArrayInputStream(encrypted.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(encrypted.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys())
@ -359,7 +359,7 @@ public class CanonicalizedDataEncryptionTest {
options.applyCRLFEncoding(); options.applyCRLFEncoding();
} }
EncryptionStream encryptionStream = PGPainless.encryptAndOrSign() EncryptionStream encryptionStream = PGPainless.getInstance().generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(options); .withOptions(options);
@ -373,7 +373,7 @@ public class CanonicalizedDataEncryptionTest {
private MessageMetadata decryptAndVerify(String msg) throws PGPException, IOException { private MessageMetadata decryptAndVerify(String msg) throws PGPException, IOException {
ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKey(secretKeys, SecretKeyRingProtector.unprotectedKeys())
@ -444,7 +444,7 @@ public class CanonicalizedDataEncryptionTest {
ByteArrayInputStream cipherIn = new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream cipherIn = new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream decrypted = new ByteArrayOutputStream(); ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(cipherIn) .onInputStream(cipherIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(publicKeys)); .addVerificationCert(publicKeys));

View file

@ -144,7 +144,7 @@ public class CertificateWithMissingSecretKeyTest {
.addDecryptionKey(missingDecryptionSecKey); .addDecryptionKey(missingDecryptionSecKey);
assertThrows(MissingDecryptionMethodException.class, () -> assertThrows(MissingDecryptionMethodException.class, () ->
PGPainless.decryptAndOrVerify() api.processMessage()
.onInputStream(cipherIn) .onInputStream(cipherIn)
.withOptions(consumerOptions)); // <- cannot find decryption key .withOptions(consumerOptions)); // <- cannot find decryption key
} }

View file

@ -83,7 +83,7 @@ public class CleartextSignatureVerificationTest {
InMemoryMultiPassStrategy multiPassStrategy = MultiPassStrategy.keepMessageInMemory(); InMemoryMultiPassStrategy multiPassStrategy = MultiPassStrategy.keepMessageInMemory();
options.setMultiPassStrategy(multiPassStrategy); options.setMultiPassStrategy(multiPassStrategy);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(MESSAGE_SIGNED)) .onInputStream(new ByteArrayInputStream(MESSAGE_SIGNED))
.withOptions(options); .withOptions(options);
@ -112,7 +112,7 @@ public class CleartextSignatureVerificationTest {
File file = new File(tempDir, "file"); File file = new File(tempDir, "file");
MultiPassStrategy multiPassStrategy = MultiPassStrategy.writeMessageToFile(file); MultiPassStrategy multiPassStrategy = MultiPassStrategy.writeMessageToFile(file);
options.setMultiPassStrategy(multiPassStrategy); options.setMultiPassStrategy(multiPassStrategy);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(MESSAGE_SIGNED)) .onInputStream(new ByteArrayInputStream(MESSAGE_SIGNED))
.withOptions(options); .withOptions(options);
@ -152,7 +152,7 @@ public class CleartextSignatureVerificationTest {
.addVerificationCert(TestKeys.getEmilCertificate()) .addVerificationCert(TestKeys.getEmilCertificate())
.addVerificationOfDetachedSignature(signature); .addVerificationOfDetachedSignature(signature);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(MESSAGE_BODY)) .onInputStream(new ByteArrayInputStream(MESSAGE_BODY))
.withOptions(options); .withOptions(options);
@ -183,7 +183,7 @@ public class CleartextSignatureVerificationTest {
String signed = signedOut.toString(); String signed = signedOut.toString();
ByteArrayInputStream signedIn = new ByteArrayInputStream(signed.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream signedIn = new ByteArrayInputStream(signed.getBytes(StandardCharsets.UTF_8));
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify() DecryptionStream verificationStream = api.processMessage()
.onInputStream(signedIn) .onInputStream(signedIn)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationCert(TestKeys.getEmilCertificate())); .addVerificationCert(TestKeys.getEmilCertificate()));
@ -217,7 +217,7 @@ public class CleartextSignatureVerificationTest {
String cleartextSigned = out.toString(); String cleartextSigned = out.toString();
ByteArrayInputStream in = new ByteArrayInputStream(cleartextSigned.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(cleartextSigned.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(secretKeys.toCertificate())); .addVerificationCert(secretKeys.toCertificate()));

View file

@ -68,7 +68,7 @@ public class CustomPublicKeyDataDecryptorFactoryTest {
}; };
// Decrypt // Decrypt
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray())) .onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addCustomDecryptorFactory( .addCustomDecryptorFactory(

View file

@ -56,7 +56,7 @@ public class DecryptAndVerifyMessageTest {
.addDecryptionKey(juliet) .addDecryptionKey(juliet)
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet)); .addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet));
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes())) .onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes()))
.withOptions(options); .withOptions(options);
@ -91,7 +91,7 @@ public class DecryptAndVerifyMessageTest {
.addDecryptionKey(juliet) .addDecryptionKey(juliet)
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet)); .addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet));
try (DecryptionStream decryptor = PGPainless.decryptAndOrVerify() try (DecryptionStream decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes())) .onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes()))
.withOptions(options); .withOptions(options);
ByteArrayOutputStream toPlain = new ByteArrayOutputStream()) { ByteArrayOutputStream toPlain = new ByteArrayOutputStream()) {
@ -109,7 +109,7 @@ public class DecryptAndVerifyMessageTest {
.addDecryptionKey(juliet) .addDecryptionKey(juliet)
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet)); .addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet));
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes())) .onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes()))
.withOptions(options); .withOptions(options);
@ -150,7 +150,7 @@ public class DecryptAndVerifyMessageTest {
"-----END PGP MESSAGE-----"; "-----END PGP MESSAGE-----";
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertext.getBytes()); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertext.getBytes());
assertThrows(MissingDecryptionMethodException.class, assertThrows(MissingDecryptionMethodException.class,
() -> PGPainless.decryptAndOrVerify() () -> PGPainless.getInstance().processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh")))); .addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh"))));

View file

@ -131,7 +131,7 @@ public class DecryptHiddenRecipientMessageTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.addDecryptionKey(secretKeys); .addDecryptionKey(secretKeys);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(options); .withOptions(options);

View file

@ -176,7 +176,7 @@ public class IgnoreUnknownSignatureVersionsTest {
} }
private MessageMetadata verifySignature(PGPPublicKeyRing cert, String BASE_CASE) throws PGPException, IOException { private MessageMetadata verifySignature(PGPPublicKeyRing cert, String BASE_CASE) throws PGPException, IOException {
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify().onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))) DecryptionStream decryptionStream = PGPainless.getInstance().processMessage().onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(cert) .addVerificationCert(cert)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(BASE_CASE.getBytes(StandardCharsets.UTF_8)))); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(BASE_CASE.getBytes(StandardCharsets.UTF_8))));

View file

@ -77,7 +77,7 @@ public class MissingPassphraseForDecryptionTest {
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.INTERACTIVE) .setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.INTERACTIVE)
.addDecryptionKey(secretKeys, SecretKeyRingProtector.defaultSecretKeyRingProtector(callback)); .addDecryptionKey(secretKeys, SecretKeyRingProtector.defaultSecretKeyRingProtector(callback));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(message)) .onInputStream(new ByteArrayInputStream(message))
.withOptions(options); .withOptions(options);
@ -112,7 +112,7 @@ public class MissingPassphraseForDecryptionTest {
.addDecryptionKey(secretKeys, SecretKeyRingProtector.defaultSecretKeyRingProtector(callback)); .addDecryptionKey(secretKeys, SecretKeyRingProtector.defaultSecretKeyRingProtector(callback));
try { try {
PGPainless.decryptAndOrVerify() api.processMessage()
.onInputStream(new ByteArrayInputStream(message)) .onInputStream(new ByteArrayInputStream(message))
.withOptions(options); .withOptions(options);
fail("Expected exception!"); fail("Expected exception!");

View file

@ -215,7 +215,7 @@ public class ModificationDetectionTests {
PGPSecretKeyRingCollection secretKeyRings = getDecryptionKey(); PGPSecretKeyRingCollection secretKeyRings = getDecryptionKey();
InputStream in = new ByteArrayInputStream(MESSAGE_MISSING_MDC.getBytes(StandardCharsets.UTF_8)); InputStream in = new ByteArrayInputStream(MESSAGE_MISSING_MDC.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(secretKeyRings, SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(secretKeyRings, SecretKeyRingProtector.unprotectedKeys())
@ -232,7 +232,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testTamperedCiphertextThrows() throws IOException, PGPException { public void testTamperedCiphertextThrows() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -249,7 +249,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testIgnoreTamperedCiphertext() throws IOException, PGPException { public void testIgnoreTamperedCiphertext() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_CIPHERTEXT.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -265,7 +265,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testTamperedMDCThrowsByDefault() throws IOException, PGPException { public void testTamperedMDCThrowsByDefault() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -282,7 +282,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testIgnoreTamperedMDC() throws IOException, PGPException { public void testIgnoreTamperedMDC() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TAMPERED_MDC.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -297,7 +297,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testTruncatedMDCThrows() throws IOException, PGPException { public void testTruncatedMDCThrows() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TRUNCATED_MDC.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_TRUNCATED_MDC.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -311,7 +311,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testMDCWithBadCTBThrows() throws IOException, PGPException { public void testMDCWithBadCTBThrows() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -328,7 +328,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testIgnoreMDCWithBadCTB() throws IOException, PGPException { public void testIgnoreMDCWithBadCTB() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_CTB.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -344,7 +344,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testMDCWithBadLengthThrows() throws IOException, PGPException { public void testMDCWithBadLengthThrows() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -361,7 +361,7 @@ public class ModificationDetectionTests {
@ExtendWith(TestAllImplementations.class) @ExtendWith(TestAllImplementations.class)
public void testIgnoreMDCWithBadLength() throws IOException, PGPException { public void testIgnoreMDCWithBadLength() throws IOException, PGPException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE_MDC_WITH_BAD_LENGTH.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKeys(getDecryptionKey(), SecretKeyRingProtector.unprotectedKeys())
@ -532,13 +532,13 @@ public class ModificationDetectionTests {
"-----END PGP MESSAGE-----\n" + "-----END PGP MESSAGE-----\n" +
"\n"; "\n";
assertThrows(MessageNotIntegrityProtectedException.class, () -> PGPainless.decryptAndOrVerify() assertThrows(MessageNotIntegrityProtectedException.class, () -> PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeyRing, .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeyRing,
SecretKeyRingProtector.unlockAnyKeyWith(passphrase))) SecretKeyRingProtector.unlockAnyKeyWith(passphrase)))
); );
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(ciphertext.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeyRing, .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeyRing,
SecretKeyRingProtector.unlockAnyKeyWith(passphrase)) SecretKeyRingProtector.unlockAnyKeyWith(passphrase))

View file

@ -135,7 +135,7 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
}); });
SecretKeyRingProtector protector2 = SecretKeyRingProtector.unlockEachKeyWith(p2, k2); SecretKeyRingProtector protector2 = SecretKeyRingProtector.unlockEachKeyWith(p2, k2);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K1_K2.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K1_K2.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(k1, protector1) .addDecryptionKey(k1, protector1)
@ -164,7 +164,7 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
} }
}); });
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K1_K2.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K1_K2.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(k1, protector1) .addDecryptionKey(k1, protector1)
@ -193,7 +193,7 @@ public class PostponeDecryptionUsingKeyWithMissingPassphraseTest {
}; };
SecretKeyRingProtector protector = new CachingSecretKeyRingProtector(provider); SecretKeyRingProtector protector = new CachingSecretKeyRingProtector(provider);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K2_PASS_K1.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(ENCRYPTED_FOR_K2_PASS_K1.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addMessagePassphrase(PASSPHRASE) .addMessagePassphrase(PASSPHRASE)

View file

@ -177,7 +177,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(ENCRYPTION_CAPABLE_KEY); PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(ENCRYPTION_CAPABLE_KEY);
ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(msgIn) .onInputStream(msgIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)); .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys));
@ -193,7 +193,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(ENCRYPTION_INCAPABLE_KEY); PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(ENCRYPTION_INCAPABLE_KEY);
ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(msgIn) .onInputStream(msgIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setAllowDecryptionWithMissingKeyFlags() .setAllowDecryptionWithMissingKeyFlags()
@ -213,7 +213,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8));
assertThrows(MissingDecryptionMethodException.class, () -> assertThrows(MissingDecryptionMethodException.class, () ->
PGPainless.decryptAndOrVerify() PGPainless.getInstance().processMessage()
.onInputStream(msgIn) .onInputStream(msgIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys))); .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)));
} }
@ -224,7 +224,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(msgIn) .onInputStream(msgIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setAllowDecryptionWithMissingKeyFlags() .setAllowDecryptionWithMissingKeyFlags()

View file

@ -144,7 +144,7 @@ public class RecursionDepthTest {
assertThrows(MalformedOpenPgpMessageException.class, () -> { assertThrows(MalformedOpenPgpMessageException.class, () -> {
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKey)); .withOptions(ConsumerOptions.get().addDecryptionKey(secretKey));

View file

@ -138,7 +138,7 @@ public class RejectWeakSymmetricAlgorithmDuringDecryptionTest {
InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
assertThrows(UnacceptableAlgorithmException.class, () -> assertThrows(UnacceptableAlgorithmException.class, () ->
PGPainless.decryptAndOrVerify() PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)) .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys))
); );
@ -166,7 +166,7 @@ public class RejectWeakSymmetricAlgorithmDuringDecryptionTest {
InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
assertThrows(UnacceptableAlgorithmException.class, () -> assertThrows(UnacceptableAlgorithmException.class, () ->
PGPainless.decryptAndOrVerify() PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)) .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys))
); );
@ -193,7 +193,7 @@ public class RejectWeakSymmetricAlgorithmDuringDecryptionTest {
InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
assertThrows(UnacceptableAlgorithmException.class, () -> assertThrows(UnacceptableAlgorithmException.class, () ->
PGPainless.decryptAndOrVerify().onInputStream(messageIn) PGPainless.getInstance().processMessage().onInputStream(messageIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)) .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys))
); );
} }
@ -218,7 +218,7 @@ public class RejectWeakSymmetricAlgorithmDuringDecryptionTest {
"-----END PGP ARMORED FILE-----\n"; "-----END PGP ARMORED FILE-----\n";
InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
PGPainless.decryptAndOrVerify().onInputStream(messageIn) PGPainless.getInstance().processMessage().onInputStream(messageIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys)); .withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys));
} }

View file

@ -31,7 +31,7 @@ public class SignedMessageVerificationWithoutCertIsStillSignedTest {
@Test @Test
public void verifyMissingVerificationCertOptionStillResultsInMessageIsSigned() throws IOException, PGPException { public void verifyMissingVerificationCertOptionStillResultsInMessageIsSigned() throws IOException, PGPException {
ConsumerOptions withoutVerificationCert = ConsumerOptions.get(); ConsumerOptions withoutVerificationCert = ConsumerOptions.get();
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify() DecryptionStream verificationStream = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)))
.withOptions(withoutVerificationCert); .withOptions(withoutVerificationCert);

View file

@ -44,7 +44,7 @@ public class TestDecryptionOfMessageWithoutESKUsingSessionKey {
@Test @Test
public void decryptMessageWithSKESK() throws PGPException, IOException { public void decryptMessageWithSKESK() throws PGPException, IOException {
ByteArrayInputStream in = new ByteArrayInputStream(encryptedMessageWithSKESK.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(encryptedMessageWithSKESK.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setSessionKey(sessionKey)); .setSessionKey(sessionKey));
@ -57,7 +57,7 @@ public class TestDecryptionOfMessageWithoutESKUsingSessionKey {
@Test @Test
public void decryptMessageWithoutSKESK() throws PGPException, IOException { public void decryptMessageWithoutSKESK() throws PGPException, IOException {
ByteArrayInputStream in = new ByteArrayInputStream(encryptedMessageWithoutESK.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(encryptedMessageWithoutESK.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setSessionKey(sessionKey)); .setSessionKey(sessionKey));

View file

@ -46,7 +46,7 @@ public class TryDecryptWithUnavailableGnuDummyKeyTest {
.removePrivateKeys(GnuPGDummyKeyUtil.KeyFilter.any())); .removePrivateKeys(GnuPGDummyKeyUtil.KeyFilter.any()));
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertextOut.toByteArray()); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertextOut.toByteArray());
assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.decryptAndOrVerify() assertThrows(MissingDecryptionMethodException.class, () -> api.processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get(api).addDecryptionKey(removedKeys))); .withOptions(ConsumerOptions.get(api).addDecryptionKey(removedKeys)));
} }

View file

@ -392,7 +392,7 @@ public class UnsupportedPacketVersionsTest {
public void decryptAndCompare(String msg, String plain) throws IOException, PGPException { public void decryptAndCompare(String msg, String plain) throws IOException, PGPException {
// noinspection CharsetObjectCanBeUsed // noinspection CharsetObjectCanBeUsed
ByteArrayInputStream inputStream = new ByteArrayInputStream(msg.getBytes(Charset.forName("UTF8"))); ByteArrayInputStream inputStream = new ByteArrayInputStream(msg.getBytes(Charset.forName("UTF8")));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(inputStream) .onInputStream(inputStream)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(key) .addDecryptionKey(key)

View file

@ -54,7 +54,7 @@ public class VerifyDetachedSignatureTest {
"-----END PGP PUBLIC KEY BLOCK-----\n"; "-----END PGP PUBLIC KEY BLOCK-----\n";
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(signedContent.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(signedContent.getBytes(StandardCharsets.UTF_8)))
.withOptions( .withOptions(
ConsumerOptions.get() ConsumerOptions.get()
@ -129,7 +129,7 @@ public class VerifyDetachedSignatureTest {
"=pXF6\n" + "=pXF6\n" +
"-----END PGP PUBLIC KEY BLOCK-----\n"; "-----END PGP PUBLIC KEY BLOCK-----\n";
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(signedContent.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(signedContent.getBytes(StandardCharsets.UTF_8)))
.withOptions( .withOptions(
ConsumerOptions.get() ConsumerOptions.get()

View file

@ -64,7 +64,7 @@ public class VerifyNotBeforeNotAfterTest {
public void noConstraintsVerifyInlineSig() throws PGPException, IOException { public void noConstraintsVerifyInlineSig() throws PGPException, IOException {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.addVerificationCert(certificate); .addVerificationCert(certificate);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(inlineSigned)) .onInputStream(new ByteArrayInputStream(inlineSigned))
.withOptions(options); .withOptions(options);
@ -77,7 +77,7 @@ public class VerifyNotBeforeNotAfterTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature)); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(data)) .onInputStream(new ByteArrayInputStream(data))
.withOptions(options); .withOptions(options);
@ -90,7 +90,7 @@ public class VerifyNotBeforeNotAfterTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.verifyNotBefore(T1) .verifyNotBefore(T1)
.addVerificationCert(certificate); .addVerificationCert(certificate);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(inlineSigned)) .onInputStream(new ByteArrayInputStream(inlineSigned))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -103,7 +103,7 @@ public class VerifyNotBeforeNotAfterTest {
.verifyNotBefore(T1) .verifyNotBefore(T1)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature)); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(data)) .onInputStream(new ByteArrayInputStream(data))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -115,7 +115,7 @@ public class VerifyNotBeforeNotAfterTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.verifyNotBefore(T2) .verifyNotBefore(T2)
.addVerificationCert(certificate); .addVerificationCert(certificate);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(inlineSigned)) .onInputStream(new ByteArrayInputStream(inlineSigned))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -128,7 +128,7 @@ public class VerifyNotBeforeNotAfterTest {
.verifyNotBefore(T2) .verifyNotBefore(T2)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature)); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(data)) .onInputStream(new ByteArrayInputStream(data))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -140,7 +140,7 @@ public class VerifyNotBeforeNotAfterTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.verifyNotAfter(T1) .verifyNotAfter(T1)
.addVerificationCert(certificate); .addVerificationCert(certificate);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(inlineSigned)) .onInputStream(new ByteArrayInputStream(inlineSigned))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -153,7 +153,7 @@ public class VerifyNotBeforeNotAfterTest {
.verifyNotAfter(T1) .verifyNotAfter(T1)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature)); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(data)) .onInputStream(new ByteArrayInputStream(data))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -165,7 +165,7 @@ public class VerifyNotBeforeNotAfterTest {
ConsumerOptions options = ConsumerOptions.get() ConsumerOptions options = ConsumerOptions.get()
.verifyNotAfter(T0) .verifyNotAfter(T0)
.addVerificationCert(certificate); .addVerificationCert(certificate);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(inlineSigned)) .onInputStream(new ByteArrayInputStream(inlineSigned))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);
@ -178,7 +178,7 @@ public class VerifyNotBeforeNotAfterTest {
.verifyNotAfter(T0) .verifyNotAfter(T0)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature)); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(detachedSignature));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(data)) .onInputStream(new ByteArrayInputStream(data))
.withOptions(options); .withOptions(options);
MessageMetadata metadata = processSignedData(verifier); MessageMetadata metadata = processSignedData(verifier);

View file

@ -213,7 +213,7 @@ public class VerifySignatureByCertificationKeyFailsTest {
public void testSignatureByNonSigningPrimaryKeyIsRejected() throws Exception { public void testSignatureByNonSigningPrimaryKeyIsRejected() throws Exception {
PGPSecretKeyRing key = PGPainless.readKeyRing().secretKeyRing(KEY); PGPSecretKeyRing key = PGPainless.readKeyRing().secretKeyRing(KEY);
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(DATA)) .onInputStream(new ByteArrayInputStream(DATA))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(PGPainless.extractCertificate(key)) .addVerificationCert(PGPainless.extractCertificate(key))

View file

@ -39,7 +39,7 @@ class VerifyVersion3SignaturePacketTest {
.addVerificationCert(TestKeys.getEmilPublicKeyRing()) .addVerificationCert(TestKeys.getEmilPublicKeyRing())
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(version3Signature.getEncoded())); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(version3Signature.getEncoded()));
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(DATA)) .onInputStream(new ByteArrayInputStream(DATA))
.withOptions(options); .withOptions(options);

View file

@ -52,7 +52,7 @@ public class VerifyWithMissingPublicKeyCallbackTest {
String msg = "Arguing that you don't care about the right to privacy because you have nothing to hide" + String msg = "Arguing that you don't care about the right to privacy because you have nothing to hide" +
"is no different than saying you don't care about free speech because you have nothing to say."; "is no different than saying you don't care about free speech because you have nothing to say.";
ByteArrayOutputStream signOut = new ByteArrayOutputStream(); ByteArrayOutputStream signOut = new ByteArrayOutputStream();
EncryptionStream signingStream = PGPainless.encryptAndOrSign().onOutputStream(signOut) EncryptionStream signingStream = api.generateMessage().onOutputStream(signOut)
.withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature( .withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature(
SecretKeyRingProtector.unprotectedKeys(), SecretKeyRingProtector.unprotectedKeys(),
signingSecKeys.getPGPSecretKeyRing(), DocumentSignatureType.CANONICAL_TEXT_DOCUMENT signingSecKeys.getPGPSecretKeyRing(), DocumentSignatureType.CANONICAL_TEXT_DOCUMENT
@ -60,7 +60,7 @@ public class VerifyWithMissingPublicKeyCallbackTest {
Streams.pipeAll(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)), signingStream); Streams.pipeAll(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)), signingStream);
signingStream.close(); signingStream.close();
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify() DecryptionStream verificationStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(signOut.toByteArray())) .onInputStream(new ByteArrayInputStream(signOut.toByteArray()))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(unrelatedKeys) .addVerificationCert(unrelatedKeys)

View file

@ -96,7 +96,7 @@ public class BcHashContextSignerTest {
OpenPGPSignature.OpenPGPDocumentSignature signature = signMessage(messageBytes, hashAlgorithm, secretKeys); OpenPGPSignature.OpenPGPDocumentSignature signature = signMessage(messageBytes, hashAlgorithm, secretKeys);
assertEquals(hashAlgorithm.getAlgorithmId(), signature.getSignature().getHashAlgorithm()); assertEquals(hashAlgorithm.getAlgorithmId(), signature.getSignature().getHashAlgorithm());
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(certificate) .addVerificationCert(certificate)

View file

@ -157,7 +157,7 @@ public class EncryptDecryptTest {
// Juliet trieth to comprehend Romeos words // Juliet trieth to comprehend Romeos words
ByteArrayInputStream envelopeIn = new ByteArrayInputStream(encryptedSecretMessage); ByteArrayInputStream envelopeIn = new ByteArrayInputStream(encryptedSecretMessage);
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = api.processMessage()
.onInputStream(envelopeIn) .onInputStream(envelopeIn)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addDecryptionKey(recipientSec, keyDecryptor) .addDecryptionKey(recipientSec, keyDecryptor)
@ -208,7 +208,7 @@ public class EncryptDecryptTest {
// CHECKSTYLE:ON // CHECKSTYLE:ON
inputStream = new ByteArrayInputStream(testMessage.getBytes()); inputStream = new ByteArrayInputStream(testMessage.getBytes());
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = api.processMessage()
.onInputStream(inputStream) .onInputStream(inputStream)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(armorSig.getBytes())) .addVerificationOfDetachedSignatures(new ByteArrayInputStream(armorSig.getBytes()))
@ -241,7 +241,7 @@ public class EncryptDecryptTest {
signer.close(); signer.close();
inputStream = new ByteArrayInputStream(signOut.toByteArray()); inputStream = new ByteArrayInputStream(signOut.toByteArray());
DecryptionStream verifier = PGPainless.decryptAndOrVerify() DecryptionStream verifier = api.processMessage()
.onInputStream(inputStream) .onInputStream(inputStream)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationCert(signingKeys.toCertificate()) .addVerificationCert(signingKeys.toCertificate())
@ -349,7 +349,7 @@ public class EncryptDecryptTest {
result.getEncryptionMechanism()); result.getEncryptionMechanism());
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray()); ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
DecryptionStream decIn = PGPainless.decryptAndOrVerify() DecryptionStream decIn = api.processMessage()
.onInputStream(bIn) .onInputStream(bIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(keyWithoutSEIPD2Feature)); .addDecryptionKey(keyWithoutSEIPD2Feature));
@ -387,7 +387,7 @@ public class EncryptDecryptTest {
result.getEncryptionMechanism()); result.getEncryptionMechanism());
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray()); ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
DecryptionStream decIn = PGPainless.decryptAndOrVerify() DecryptionStream decIn = api.processMessage()
.onInputStream(bIn) .onInputStream(bIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh"))); .addMessagePassphrase(Passphrase.fromPassword("sw0rdf1sh")));

View file

@ -164,7 +164,7 @@ public class EncryptionWithMissingKeyFlagsTest {
// Prepare encryption // Prepare encryption
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream encOut = PGPainless.encryptAndOrSign() EncryptionStream encOut = PGPainless.getInstance().generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(ProducerOptions.encrypt(EncryptionOptions.get() .withOptions(ProducerOptions.encrypt(EncryptionOptions.get()
.setEvaluationDate(evaluationDate) .setEvaluationDate(evaluationDate)
@ -177,7 +177,7 @@ public class EncryptionWithMissingKeyFlagsTest {
// Prepare decryption // Prepare decryption
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setAllowDecryptionWithMissingKeyFlags() .setAllowDecryptionWithMissingKeyFlags()

View file

@ -73,7 +73,7 @@ public class FileInformationTest {
ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray()); ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray());
ByteArrayOutputStream plainOut = new ByteArrayOutputStream(); ByteArrayOutputStream plainOut = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(cryptIn) .onInputStream(cryptIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKey)); .addDecryptionKey(secretKey));
@ -112,7 +112,7 @@ public class FileInformationTest {
ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray()); ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray());
ByteArrayOutputStream plainOut = new ByteArrayOutputStream(); ByteArrayOutputStream plainOut = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(cryptIn) .onInputStream(cryptIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKey)); .addDecryptionKey(secretKey));
@ -156,7 +156,7 @@ public class FileInformationTest {
ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray()); ByteArrayInputStream cryptIn = new ByteArrayInputStream(dataOut.toByteArray());
ByteArrayOutputStream plainOut = new ByteArrayOutputStream(); ByteArrayOutputStream plainOut = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(cryptIn) .onInputStream(cryptIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKey)); .addDecryptionKey(secretKey));

View file

@ -52,7 +52,7 @@ public class HiddenRecipientEncryptionTest {
byte[] ciphertext = ciphertextOut.toByteArray(); byte[] ciphertext = ciphertextOut.toByteArray();
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertext); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertext);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys)); .addDecryptionKey(secretKeys));

View file

@ -128,7 +128,7 @@ public class MechanismNegotiationTest {
eOut.close(); eOut.close();
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray()); ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
DecryptionStream dIn = PGPainless.decryptAndOrVerify() DecryptionStream dIn = api.processMessage()
.onInputStream(bIn) .onInputStream(bIn)
.withOptions(ConsumerOptions.get().addDecryptionKey(keyList.get(0))); .withOptions(ConsumerOptions.get().addDecryptionKey(keyList.get(0)));

View file

@ -49,7 +49,8 @@ public class MultiSigningSubkeyTest {
@BeforeAll @BeforeAll
public static void generateKey() { public static void generateKey() {
signingKey = PGPainless.buildKeyRing() PGPainless api = PGPainless.getInstance();
signingKey = api.buildKey()
.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))
.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.RSA(RsaLength._3072), KeyFlag.SIGN_DATA)) .addSubkey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072), KeyFlag.SIGN_DATA))
@ -69,7 +70,7 @@ public class MultiSigningSubkeyTest {
public void detachedSignWithAllSubkeys() throws PGPException, IOException { public void detachedSignWithAllSubkeys() throws PGPException, IOException {
ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream signingStream = PGPainless.encryptAndOrSign() EncryptionStream signingStream = PGPainless.getInstance().generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(ProducerOptions.sign(SigningOptions.get().addDetachedSignature(protector, signingKey, DocumentSignatureType.BINARY_DOCUMENT))); .withOptions(ProducerOptions.sign(SigningOptions.get().addDetachedSignature(protector, signingKey, DocumentSignatureType.BINARY_DOCUMENT)));
Streams.pipeAll(dataIn, signingStream); Streams.pipeAll(dataIn, signingStream);
@ -85,7 +86,7 @@ public class MultiSigningSubkeyTest {
public void detachedSignWithSingleSubkey() throws PGPException, IOException { public void detachedSignWithSingleSubkey() throws PGPException, IOException {
ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream signingStream = PGPainless.encryptAndOrSign() EncryptionStream signingStream = PGPainless.getInstance().generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(ProducerOptions.sign(SigningOptions.get().addDetachedSignature(protector, signingKey, signingKey1.getKeyId()))); .withOptions(ProducerOptions.sign(SigningOptions.get().addDetachedSignature(protector, signingKey, signingKey1.getKeyId())));
Streams.pipeAll(dataIn, signingStream); Streams.pipeAll(dataIn, signingStream);
@ -98,16 +99,17 @@ public class MultiSigningSubkeyTest {
@Test @Test
public void inlineSignWithAllSubkeys() throws PGPException, IOException { public void inlineSignWithAllSubkeys() throws PGPException, IOException {
PGPainless api = PGPainless.getInstance();
ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream signingStream = PGPainless.encryptAndOrSign() EncryptionStream signingStream = api.generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature(protector, signingKey, DocumentSignatureType.BINARY_DOCUMENT))); .withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature(protector, signingKey, DocumentSignatureType.BINARY_DOCUMENT)));
Streams.pipeAll(dataIn, signingStream); Streams.pipeAll(dataIn, signingStream);
signingStream.close(); signingStream.close();
ByteArrayInputStream signedIn = new ByteArrayInputStream(out.toByteArray()); ByteArrayInputStream signedIn = new ByteArrayInputStream(out.toByteArray());
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify().onInputStream(signedIn) DecryptionStream verificationStream = api.processMessage().onInputStream(signedIn)
.withOptions(ConsumerOptions.get().addVerificationCert(signingCert)); .withOptions(ConsumerOptions.get().addVerificationCert(signingCert));
Streams.drain(verificationStream); Streams.drain(verificationStream);
verificationStream.close(); verificationStream.close();
@ -122,16 +124,17 @@ public class MultiSigningSubkeyTest {
@Test @Test
public void inlineSignWithSingleSubkey() throws PGPException, IOException { public void inlineSignWithSingleSubkey() throws PGPException, IOException {
PGPainless api = PGPainless.getInstance();
ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream dataIn = new ByteArrayInputStream("Hello, World!\n".getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream signingStream = PGPainless.encryptAndOrSign() EncryptionStream signingStream = api.generateMessage()
.onOutputStream(out) .onOutputStream(out)
.withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature(protector, signingKey, signingKey1.getKeyId()))); .withOptions(ProducerOptions.sign(SigningOptions.get().addInlineSignature(protector, signingKey, signingKey1.getKeyId())));
Streams.pipeAll(dataIn, signingStream); Streams.pipeAll(dataIn, signingStream);
signingStream.close(); signingStream.close();
ByteArrayInputStream signedIn = new ByteArrayInputStream(out.toByteArray()); ByteArrayInputStream signedIn = new ByteArrayInputStream(out.toByteArray());
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify().onInputStream(signedIn) DecryptionStream verificationStream = api.processMessage().onInputStream(signedIn)
.withOptions(ConsumerOptions.get().addVerificationCert(signingCert)); .withOptions(ConsumerOptions.get().addVerificationCert(signingCert));
Streams.drain(verificationStream); Streams.drain(verificationStream);
verificationStream.close(); verificationStream.close();

View file

@ -82,7 +82,7 @@ public class SigningTest {
OpenPGPKey romeoKey = TestKeys.getRomeoKey(); OpenPGPKey romeoKey = TestKeys.getRomeoKey();
OpenPGPKey julietKey = TestKeys.getJulietKey(); OpenPGPKey julietKey = TestKeys.getJulietKey();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(cryptIn) .onInputStream(cryptIn)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addDecryptionKey(romeoKey, SecretKeyRingProtector.unprotectedKeys()) .addDecryptionKey(romeoKey, SecretKeyRingProtector.unprotectedKeys())

View file

@ -159,7 +159,7 @@ public class DecryptOrVerify {
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ENCRYPTED.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ENCRYPTED.getBytes(StandardCharsets.UTF_8));
// The decryption stream is an input stream from which we read the decrypted data // The decryption stream is an input stream from which we read the decrypted data
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(consumerOptions); .withOptions(consumerOptions);
@ -189,7 +189,7 @@ public class DecryptOrVerify {
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream(); ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ENCRYPTED_AND_SIGNED.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ENCRYPTED_AND_SIGNED.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(consumerOptions); .withOptions(consumerOptions);
@ -219,7 +219,7 @@ public class DecryptOrVerify {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream(signed.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(signed.getBytes(StandardCharsets.UTF_8));
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify() DecryptionStream verificationStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(options); .withOptions(options);
@ -270,7 +270,7 @@ public class DecryptOrVerify {
ByteArrayInputStream signedIn = new ByteArrayInputStream(signedMessage); ByteArrayInputStream signedIn = new ByteArrayInputStream(signedMessage);
// and pass it to the decryption stream // and pass it to the decryption stream
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify() DecryptionStream verificationStream = api.processMessage()
.onInputStream(signedIn) .onInputStream(signedIn)
.withOptions(ConsumerOptions.get(api).addVerificationCert(certificate)); .withOptions(ConsumerOptions.get(api).addVerificationCert(certificate));

View file

@ -166,7 +166,7 @@ public class Encrypt {
String encryptedMessage = ciphertext.toString(); String encryptedMessage = ciphertext.toString();
// Decrypt and verify signatures // Decrypt and verify signatures
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = api.processMessage()
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addDecryptionKey(keyBob, protectorBob) .addDecryptionKey(keyBob, protectorBob)
@ -209,7 +209,7 @@ public class Encrypt {
String asciiCiphertext = ciphertext.toString(); String asciiCiphertext = ciphertext.toString();
// Decrypt // Decrypt
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = api.processMessage()
.onInputStream(new ByteArrayInputStream(asciiCiphertext.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(asciiCiphertext.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get(api).addMessagePassphrase(Passphrase.fromPassword("p4ssphr4s3"))); .withOptions(ConsumerOptions.get(api).addMessagePassphrase(Passphrase.fromPassword("p4ssphr4s3")));
@ -274,7 +274,7 @@ public class Encrypt {
// also test, that decryption still works... // also test, that decryption still works...
// Decrypt and verify signatures // Decrypt and verify signatures
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = api.processMessage()
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addDecryptionKey(keyBob, protectorBob) .addDecryptionKey(keyBob, protectorBob)

View file

@ -77,7 +77,7 @@ public class GenerateKeyWithoutPrimaryKeyFlagsTest {
EncryptionResult result = encryptionStream.getResult(); EncryptionResult result = encryptionStream.getResult();
assertTrue(result.isEncryptedFor(cert)); assertTrue(result.isEncryptedFor(cert));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext.toByteArray())) .onInputStream(new ByteArrayInputStream(ciphertext.toByteArray()))
.withOptions(ConsumerOptions.get().addDecryptionKey(key) .withOptions(ConsumerOptions.get().addDecryptionKey(key)
.addVerificationCert(cert)); .addVerificationCert(cert));

View file

@ -78,7 +78,7 @@ public class GenerateKeyWithoutUserIdTest {
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertextOut.toByteArray()); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(ciphertextOut.toByteArray());
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream(); ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKey) .addDecryptionKey(secretKey)

View file

@ -160,7 +160,7 @@ public class FixUserIdDoesNotBreakEncryptionCapabilityTest {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
ByteArrayOutputStream plain = new ByteArrayOutputStream(); ByteArrayOutputStream plain = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(edited)); .addDecryptionKey(edited));

View file

@ -111,7 +111,7 @@ public class S2KUsageFixTest {
private void testCanStillDecrypt(OpenPGPKey keys, SecretKeyRingProtector protector) private void testCanStillDecrypt(OpenPGPKey keys, SecretKeyRingProtector protector)
throws PGPException, IOException { throws PGPException, IOException {
ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream in = new ByteArrayInputStream(MESSAGE.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(in) .onInputStream(in)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(keys, protector)); .addDecryptionKey(keys, protector));

View file

@ -185,7 +185,7 @@ public class WeakRSAKeyTest {
ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(encryptOut.toByteArray()); ByteArrayInputStream ciphertextIn = new ByteArrayInputStream(encryptOut.toByteArray());
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream(); ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(ciphertextIn) .onInputStream(ciphertextIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys)); .addDecryptionKey(secretKeys));

View file

@ -1970,7 +1970,7 @@ public class BindingSignatureSubpacketsTest {
PGPainless api = PGPainless.getInstance(); PGPainless api = PGPainless.getInstance();
OpenPGPCertificate certificate = api.readKey().parseCertificate(key); OpenPGPCertificate certificate = api.readKey().parseCertificate(key);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify().onInputStream(getSignedData(data)) DecryptionStream decryptionStream = api.processMessage().onInputStream(getSignedData(data))
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(SignatureUtils.readSignatures(sig))); .addVerificationOfDetachedSignatures(SignatureUtils.readSignatures(sig)));
@ -1990,7 +1990,7 @@ public class BindingSignatureSubpacketsTest {
PGPainless api = PGPainless.getInstance(); PGPainless api = PGPainless.getInstance();
OpenPGPCertificate certificate = api.readKey().parseCertificate(key); OpenPGPCertificate certificate = api.readKey().parseCertificate(key);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify().onInputStream(getSignedData(data)) DecryptionStream decryptionStream = api.processMessage().onInputStream(getSignedData(data))
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationCert(certificate) .addVerificationCert(certificate)
.addVerificationOfDetachedSignatures(SignatureUtils.readSignatures(sig))); .addVerificationOfDetachedSignatures(SignatureUtils.readSignatures(sig)));

View file

@ -1305,7 +1305,7 @@ public class CertificateValidatorTest {
PGPainless api = PGPainless.getInstance(); PGPainless api = PGPainless.getInstance();
OpenPGPCertificate certificate = api.toCertificate(cert); OpenPGPCertificate certificate = api.toCertificate(cert);
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(dataIn) .onInputStream(dataIn)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationOfDetachedSignature(signature) .addVerificationOfDetachedSignature(signature)
@ -1385,11 +1385,12 @@ public class CertificateValidatorTest {
"=NXei\n" + "=NXei\n" +
"-----END PGP PUBLIC KEY BLOCK-----\n"; "-----END PGP PUBLIC KEY BLOCK-----\n";
String DATA = "Hello World :)"; String DATA = "Hello World :)";
PGPainless api = PGPainless.getInstance();
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(new ByteArrayInputStream(DATA.getBytes(StandardCharsets.UTF_8))) .onInputStream(new ByteArrayInputStream(DATA.getBytes(StandardCharsets.UTF_8)))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(PGPainless.readKeyRing().publicKeyRing(CERT)) .addVerificationCert(api.readKey().parseCertificate(CERT))
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(SIG.getBytes(StandardCharsets.UTF_8)))); .addVerificationOfDetachedSignatures(new ByteArrayInputStream(SIG.getBytes(StandardCharsets.UTF_8))));
Streams.drain(decryptionStream); Streams.drain(decryptionStream);

View file

@ -142,7 +142,7 @@ public class IgnoreMarkerPacketsTest {
PGPSignature signature = SignatureUtils.readSignatures(sig).get(0); PGPSignature signature = SignatureUtils.readSignatures(sig).get(0);
InputStream messageIn = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addVerificationCert(publicKeys) .addVerificationCert(publicKeys)
@ -191,7 +191,7 @@ public class IgnoreMarkerPacketsTest {
String data = "Marker + Encrypted Message"; String data = "Marker + Encrypted Message";
InputStream messageIn = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)); InputStream messageIn = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8));
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = PGPainless.getInstance().processMessage()
.onInputStream(messageIn) .onInputStream(messageIn)
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKey(secretKeys) .addDecryptionKey(secretKeys)

View file

@ -269,7 +269,7 @@ public class KeyRevocationTest {
private void verify(PGPSignature signature, InputStream dataIn, OpenPGPCertificate certificate, PGPainless api) private void verify(PGPSignature signature, InputStream dataIn, OpenPGPCertificate certificate, PGPainless api)
throws PGPException, IOException { throws PGPException, IOException {
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify() DecryptionStream decryptionStream = api.processMessage()
.onInputStream(dataIn) .onInputStream(dataIn)
.withOptions(ConsumerOptions.get(api) .withOptions(ConsumerOptions.get(api)
.addVerificationOfDetachedSignature(signature) .addVerificationOfDetachedSignature(signature)

View file

@ -31,7 +31,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
"the decryptor finds the session key encrypted for the right passphrase."; "the decryptor finds the session key encrypted for the right passphrase.";
ByteArrayInputStream plaintextIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); ByteArrayInputStream plaintextIn = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream ciphertextOut = new ByteArrayOutputStream(); ByteArrayOutputStream ciphertextOut = new ByteArrayOutputStream();
EncryptionStream encryptor = PGPainless.encryptAndOrSign() EncryptionStream encryptor = PGPainless.getInstance().generateMessage()
.onOutputStream(ciphertextOut) .onOutputStream(ciphertextOut)
.withOptions(ProducerOptions.encrypt( .withOptions(ProducerOptions.encrypt(
EncryptionOptions.encryptCommunications() EncryptionOptions.encryptCommunications()
@ -46,7 +46,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
// decrypting the p1 package with p2 first will not work. Test if it is handled correctly. // decrypting the p1 package with p2 first will not work. Test if it is handled correctly.
for (Passphrase passphrase : new Passphrase[] {Passphrase.fromPassword("p2"), Passphrase.fromPassword("p1")}) { for (Passphrase passphrase : new Passphrase[] {Passphrase.fromPassword("p2"), Passphrase.fromPassword("p1")}) {
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext)) .onInputStream(new ByteArrayInputStream(ciphertext))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addMessagePassphrase(passphrase)); .addMessagePassphrase(passphrase));

View file

@ -63,7 +63,7 @@ public class SymmetricEncryptionTest {
byte[] ciphertext = ciphertextOut.toByteArray(); byte[] ciphertext = ciphertextOut.toByteArray();
// Test symmetric decryption // Test symmetric decryption
DecryptionStream decryptor = PGPainless.decryptAndOrVerify() DecryptionStream decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext)) .onInputStream(new ByteArrayInputStream(ciphertext))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addMessagePassphrase(encryptionPassphrase)); .addMessagePassphrase(encryptionPassphrase));
@ -80,7 +80,7 @@ public class SymmetricEncryptionTest {
SecretKeyRingProtector protector = new PasswordBasedSecretKeyRingProtector( SecretKeyRingProtector protector = new PasswordBasedSecretKeyRingProtector(
KeyRingProtectionSettings.secureDefaultSettings(), KeyRingProtectionSettings.secureDefaultSettings(),
new SolitaryPassphraseProvider(Passphrase.fromPassword(TestKeys.CRYPTIE_PASSWORD))); new SolitaryPassphraseProvider(Passphrase.fromPassword(TestKeys.CRYPTIE_PASSWORD)));
decryptor = PGPainless.decryptAndOrVerify() decryptor = PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertext)) .onInputStream(new ByteArrayInputStream(ciphertext))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.addDecryptionKeys(decryptionKeys, protector)); .addDecryptionKeys(decryptionKeys, protector));
@ -100,7 +100,7 @@ public class SymmetricEncryptionTest {
new Random().nextBytes(bytes); new Random().nextBytes(bytes);
ByteArrayOutputStream ciphertextOut = new ByteArrayOutputStream(); ByteArrayOutputStream ciphertextOut = new ByteArrayOutputStream();
EncryptionStream encryptor = PGPainless.encryptAndOrSign().onOutputStream(ciphertextOut) EncryptionStream encryptor = PGPainless.getInstance().generateMessage().onOutputStream(ciphertextOut)
.withOptions(ProducerOptions.encrypt( .withOptions(ProducerOptions.encrypt(
EncryptionOptions.encryptCommunications() EncryptionOptions.encryptCommunications()
.addMessagePassphrase(Passphrase.fromPassword("mellon")))); .addMessagePassphrase(Passphrase.fromPassword("mellon"))));
@ -108,7 +108,7 @@ public class SymmetricEncryptionTest {
Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor); Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor);
encryptor.close(); encryptor.close();
assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.decryptAndOrVerify() assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.getInstance().processMessage()
.onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray())) .onInputStream(new ByteArrayInputStream(ciphertextOut.toByteArray()))
.withOptions(ConsumerOptions.get() .withOptions(ConsumerOptions.get()
.setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION) .setMissingKeyPassphraseStrategy(MissingKeyPassphraseStrategy.THROW_EXCEPTION)

View file

@ -39,9 +39,7 @@ class DecryptImpl(private val api: PGPainless) : Decrypt {
val decryptionStream = val decryptionStream =
try { try {
PGPainless.decryptAndOrVerify() api.processMessage().onInputStream(ciphertext).withOptions(consumerOptions)
.onInputStream(ciphertext)
.withOptions(consumerOptions)
} catch (e: MissingDecryptionMethodException) { } catch (e: MissingDecryptionMethodException) {
throw SOPGPException.CannotDecrypt( throw SOPGPException.CannotDecrypt(
"No usable decryption key or password provided.", e) "No usable decryption key or password provided.", e)

View file

@ -28,8 +28,7 @@ class DetachedVerifyImpl(private val api: PGPainless) : DetachedVerify {
override fun data(data: InputStream): List<Verification> { override fun data(data: InputStream): List<Verification> {
try { try {
val verificationStream = val verificationStream = api.processMessage().onInputStream(data).withOptions(options)
PGPainless.decryptAndOrVerify().onInputStream(data).withOptions(options)
Streams.drain(verificationStream) Streams.drain(verificationStream)
verificationStream.close() verificationStream.close()

View file

@ -32,7 +32,7 @@ class InlineVerifyImpl(private val api: PGPainless) : InlineVerify {
override fun writeTo(outputStream: OutputStream): List<Verification> { override fun writeTo(outputStream: OutputStream): List<Verification> {
try { try {
val verificationStream = val verificationStream =
PGPainless.decryptAndOrVerify().onInputStream(data).withOptions(options) api.processMessage().onInputStream(data).withOptions(options)
Streams.pipeAll(verificationStream, outputStream) Streams.pipeAll(verificationStream, outputStream)
verificationStream.close() verificationStream.close()