mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 04:39:39 +02:00
Revert introduction of StreamUtil
This commit is contained in:
parent
b8f719d3eb
commit
311c842196
27 changed files with 78 additions and 137 deletions
|
@ -23,11 +23,11 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.bouncycastle.bcpg.ArmoredInputStream;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.signature.SignatureUtils;
|
||||
import org.pgpainless.util.ArmoredInputStreamFactory;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class WrongArmorChecksumTest {
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class WrongArmorChecksumTest {
|
|||
|
||||
assertThrows(IOException.class, () -> {
|
||||
ArmoredInputStream armorIn = ArmoredInputStreamFactory.get(bytes);
|
||||
StreamUtil.pipeAll(armorIn, out);
|
||||
Streams.pipeAll(armorIn, out);
|
||||
armorIn.close();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ import java.nio.charset.StandardCharsets;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class BrokenAsciiArmorOnMessageDecryptionThrows {
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class BrokenAsciiArmorOnMessageDecryptionThrows {
|
|||
));
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
assertThrows(IOException.class, decryptionStream::close);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ import java.nio.charset.StandardCharsets;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
import org.pgpainless.signature.cleartext_signatures.CleartextSignatureProcessor;
|
||||
import org.pgpainless.signature.cleartext_signatures.InMemoryMultiPassStrategy;
|
||||
import org.pgpainless.signature.cleartext_signatures.MultiPassStrategy;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
import org.pgpainless.util.TestUtils;
|
||||
|
||||
public class CleartextSignatureVerificationTest {
|
||||
|
@ -116,7 +116,7 @@ public class CleartextSignatureVerificationTest {
|
|||
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
|
||||
FileInputStream fileIn = new FileInputStream(file);
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(fileIn, bytes);
|
||||
Streams.pipeAll(fileIn, bytes);
|
||||
fileIn.close();
|
||||
assertArrayEquals(message.getBytes(StandardCharsets.UTF_8), bytes.toByteArray());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.nio.charset.Charset;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
@ -36,7 +37,6 @@ import org.pgpainless.implementation.ImplementationFactory;
|
|||
import org.pgpainless.key.SubkeyIdentifier;
|
||||
import org.pgpainless.key.TestKeys;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class DecryptAndVerifyMessageTest {
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class DecryptAndVerifyMessageTest {
|
|||
.withOptions(options);
|
||||
|
||||
ByteArrayOutputStream toPlain = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptor, toPlain);
|
||||
Streams.pipeAll(decryptor, toPlain);
|
||||
decryptor.close();
|
||||
toPlain.close();
|
||||
OpenPgpMetadata metadata = decryptor.getResult();
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
@ -33,7 +34,6 @@ import org.pgpainless.algorithm.EncryptionPurpose;
|
|||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.SubkeyIdentifier;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class DecryptHiddenRecipientMessage {
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class DecryptHiddenRecipientMessage {
|
|||
.withOptions(options);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptionStream, out);
|
||||
Streams.pipeAll(decryptionStream, out);
|
||||
decryptionStream.close();
|
||||
|
||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
@ -37,7 +38,6 @@ import org.pgpainless.exception.ModificationDetectionException;
|
|||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class ModificationDetectionTests {
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class ModificationDetectionTests {
|
|||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
assertThrows(EOFException.class, () -> {
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
decryptionStream.close();
|
||||
});
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ public class ModificationDetectionTests {
|
|||
);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptionStream, out);
|
||||
Streams.pipeAll(decryptionStream, out);
|
||||
assertThrows(ModificationDetectionException.class, decryptionStream::close);
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ public class ModificationDetectionTests {
|
|||
);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptionStream, out);
|
||||
Streams.pipeAll(decryptionStream, out);
|
||||
assertThrows(ModificationDetectionException.class, decryptionStream::close);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ import java.nio.charset.StandardCharsets;
|
|||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class RecursionDepthTest {
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class RecursionDepthTest {
|
|||
.withOptions(new ConsumerOptions().addDecryptionKey(secretKey));
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
|
@ -42,7 +43,6 @@ import org.pgpainless.key.TestKeys;
|
|||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
/**
|
||||
* Test functionality of the {@link MissingPublicKeyCallback} which is called when during signature verification,
|
||||
|
@ -66,7 +66,7 @@ public class VerifyWithMissingPublicKeyCallback {
|
|||
SecretKeyRingProtector.unprotectedKeys(),
|
||||
signingSecKeys, DocumentSignatureType.CANONICAL_TEXT_DOCUMENT
|
||||
)));
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)), signingStream);
|
||||
Streams.pipeAll(new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8)), signingStream);
|
||||
signingStream.close();
|
||||
|
||||
DecryptionStream verificationStream = PGPainless.decryptAndOrVerify()
|
||||
|
@ -83,7 +83,7 @@ public class VerifyWithMissingPublicKeyCallback {
|
|||
}));
|
||||
|
||||
ByteArrayOutputStream plainOut = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(verificationStream, plainOut);
|
||||
Streams.pipeAll(verificationStream, plainOut);
|
||||
verificationStream.close();
|
||||
|
||||
assertArrayEquals(msg.getBytes(StandardCharsets.UTF_8), plainOut.toByteArray());
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -58,7 +59,6 @@ import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
|||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.policy.Policy;
|
||||
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class EncryptDecryptTest {
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class EncryptDecryptTest {
|
|||
new SigningOptions().addInlineSignature(keyDecryptor, senderSec, DocumentSignatureType.BINARY_DOCUMENT)
|
||||
));
|
||||
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(secretMessage), encryptor);
|
||||
Streams.pipeAll(new ByteArrayInputStream(secretMessage), encryptor);
|
||||
encryptor.close();
|
||||
byte[] encryptedSecretMessage = envelope.toByteArray();
|
||||
|
||||
|
@ -193,7 +193,7 @@ public class EncryptDecryptTest {
|
|||
|
||||
ByteArrayOutputStream decryptedSecretMessage = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptor, decryptedSecretMessage);
|
||||
Streams.pipeAll(decryptor, decryptedSecretMessage);
|
||||
decryptor.close();
|
||||
|
||||
assertArrayEquals(secretMessage, decryptedSecretMessage.toByteArray());
|
||||
|
@ -218,7 +218,7 @@ public class EncryptDecryptTest {
|
|||
.withOptions(ProducerOptions.sign(
|
||||
new SigningOptions().addDetachedSignature(keyRingProtector, signingKeys, DocumentSignatureType.BINARY_DOCUMENT)
|
||||
));
|
||||
StreamUtil.pipeAll(inputStream, signer);
|
||||
Streams.pipeAll(inputStream, signer);
|
||||
signer.close();
|
||||
|
||||
EncryptionResult metadata = signer.getResult();
|
||||
|
@ -243,7 +243,7 @@ public class EncryptDecryptTest {
|
|||
);
|
||||
|
||||
dummyOut = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(verifier, dummyOut);
|
||||
Streams.pipeAll(verifier, dummyOut);
|
||||
verifier.close();
|
||||
|
||||
OpenPgpMetadata decryptionResult = verifier.getResult();
|
||||
|
@ -264,7 +264,7 @@ public class EncryptDecryptTest {
|
|||
SigningOptions.get()
|
||||
.addInlineSignature(keyRingProtector, signingKeys, DocumentSignatureType.BINARY_DOCUMENT)
|
||||
).setAsciiArmor(true));
|
||||
StreamUtil.pipeAll(inputStream, signer);
|
||||
Streams.pipeAll(inputStream, signer);
|
||||
signer.close();
|
||||
|
||||
inputStream = new ByteArrayInputStream(signOut.toByteArray());
|
||||
|
@ -274,7 +274,7 @@ public class EncryptDecryptTest {
|
|||
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(signingKeys))
|
||||
);
|
||||
signOut = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(verifier, signOut);
|
||||
Streams.pipeAll(verifier, signOut);
|
||||
verifier.close();
|
||||
|
||||
OpenPgpMetadata metadata = verifier.getResult();
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPLiteralData;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.JUtils;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -39,7 +40,6 @@ import org.pgpainless.algorithm.StreamEncoding;
|
|||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
||||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class FileInformationTest {
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class FileInformationTest {
|
|||
.setEncoding(encoding)
|
||||
);
|
||||
|
||||
StreamUtil.pipeAll(dataIn, encryptionStream);
|
||||
Streams.pipeAll(dataIn, encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
EncryptionResult encResult = encryptionStream.getResult();
|
||||
|
@ -87,7 +87,7 @@ public class FileInformationTest {
|
|||
.onInputStream(cryptIn)
|
||||
.withOptions(new ConsumerOptions()
|
||||
.addDecryptionKey(secretKey));
|
||||
StreamUtil.pipeAll(decryptionStream, plainOut);
|
||||
Streams.pipeAll(decryptionStream, plainOut);
|
||||
|
||||
decryptionStream.close();
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class FileInformationTest {
|
|||
.addRecipient(certificate))
|
||||
);
|
||||
|
||||
StreamUtil.pipeAll(dataIn, encryptionStream);
|
||||
Streams.pipeAll(dataIn, encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
EncryptionResult encResult = encryptionStream.getResult();
|
||||
|
@ -126,7 +126,7 @@ public class FileInformationTest {
|
|||
.onInputStream(cryptIn)
|
||||
.withOptions(new ConsumerOptions()
|
||||
.addDecryptionKey(secretKey));
|
||||
StreamUtil.pipeAll(decryptionStream, plainOut);
|
||||
Streams.pipeAll(decryptionStream, plainOut);
|
||||
|
||||
decryptionStream.close();
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class FileInformationTest {
|
|||
.setForYourEyesOnly()
|
||||
);
|
||||
|
||||
StreamUtil.pipeAll(dataIn, encryptionStream);
|
||||
Streams.pipeAll(dataIn, encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
EncryptionResult encResult = encryptionStream.getResult();
|
||||
|
@ -167,7 +167,7 @@ public class FileInformationTest {
|
|||
.onInputStream(cryptIn)
|
||||
.withOptions(new ConsumerOptions()
|
||||
.addDecryptionKey(secretKey));
|
||||
StreamUtil.pipeAll(decryptionStream, plainOut);
|
||||
Streams.pipeAll(decryptionStream, plainOut);
|
||||
|
||||
decryptionStream.close();
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
|||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
@ -48,7 +49,6 @@ import org.pgpainless.key.info.KeyRingInfo;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class SigningTest {
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class SigningTest {
|
|||
byte[] messageBytes = "This message is signed and encrypted to Romeo and Juliet.".getBytes(StandardCharsets.UTF_8);
|
||||
ByteArrayInputStream message = new ByteArrayInputStream(messageBytes);
|
||||
|
||||
StreamUtil.pipeAll(message, encryptionStream);
|
||||
Streams.pipeAll(message, encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
byte[] encrypted = out.toByteArray();
|
||||
|
@ -102,7 +102,7 @@ public class SigningTest {
|
|||
|
||||
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptionStream, plaintextOut);
|
||||
Streams.pipeAll(decryptionStream, plaintextOut);
|
||||
decryptionStream.close();
|
||||
|
||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.DocumentSignatureType;
|
||||
|
@ -41,7 +42,6 @@ import org.pgpainless.encryption_signing.SigningOptions;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class Encrypt {
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class Encrypt {
|
|||
);
|
||||
|
||||
// Pipe data trough and CLOSE the stream (important)
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)), encryptor);
|
||||
Streams.pipeAll(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)), encryptor);
|
||||
encryptor.close();
|
||||
String encryptedMessage = ciphertext.toString();
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class Encrypt {
|
|||
|
||||
ByteArrayOutputStream plaintext = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptor, plaintext);
|
||||
Streams.pipeAll(decryptor, plaintext);
|
||||
decryptor.close();
|
||||
|
||||
// Check the metadata to see how the message was encrypted/signed
|
||||
|
@ -126,7 +126,7 @@ public class Encrypt {
|
|||
).setAsciiArmor(true)
|
||||
);
|
||||
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)), encryptor);
|
||||
Streams.pipeAll(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)), encryptor);
|
||||
encryptor.close();
|
||||
|
||||
String asciiCiphertext = ciphertext.toString();
|
||||
|
@ -137,7 +137,7 @@ public class Encrypt {
|
|||
.withOptions(new ConsumerOptions().addDecryptionPassphrase(Passphrase.fromPassword("p4ssphr4s3")));
|
||||
|
||||
ByteArrayOutputStream plaintext = new ByteArrayOutputStream();
|
||||
StreamUtil.pipeAll(decryptor, plaintext);
|
||||
Streams.pipeAll(decryptor, plaintext);
|
||||
|
||||
decryptor.close();
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor;
|
|||
import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider;
|
||||
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
|
||||
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
@ -46,7 +47,6 @@ import org.pgpainless.key.protection.KeyRingProtectionSettings;
|
|||
import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class ChangeSecretKeyRingPassphraseTest {
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class ChangeSecretKeyRingPassphraseTest {
|
|||
.addInlineSignature(PasswordBasedSecretKeyRingProtector.forKey(keyRing, passphrase),
|
||||
keyRing, DocumentSignatureType.BINARY_DOCUMENT)));
|
||||
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(dummyMessage.getBytes()), stream);
|
||||
Streams.pipeAll(new ByteArrayInputStream(dummyMessage.getBytes()), stream);
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
||||
|
@ -37,7 +38,6 @@ import org.pgpainless.decryption_verification.DecryptionStream;
|
|||
import org.pgpainless.decryption_verification.OpenPgpMetadata;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
/**
|
||||
* Test if marker packets are being ignored properly.
|
||||
|
@ -162,7 +162,7 @@ public class IgnoreMarkerPackets {
|
|||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
|
||||
decryptionStream.close();
|
||||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
||||
|
@ -211,7 +211,7 @@ public class IgnoreMarkerPackets {
|
|||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptionStream, outputStream);
|
||||
Streams.pipeAll(decryptionStream, outputStream);
|
||||
|
||||
decryptionStream.close();
|
||||
assertArrayEquals(data.getBytes(StandardCharsets.UTF_8), outputStream.toByteArray());
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
@ -31,7 +32,6 @@ import org.pgpainless.encryption_signing.EncryptionStream;
|
|||
import org.pgpainless.encryption_signing.ProducerOptions;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class MultiPassphraseSymmetricEncryptionTest {
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
|
|||
.addPassphrase(Passphrase.fromPassword("p2"))
|
||||
).setAsciiArmor(false));
|
||||
|
||||
StreamUtil.pipeAll(plaintextIn, encryptor);
|
||||
Streams.pipeAll(plaintextIn, encryptor);
|
||||
encryptor.close();
|
||||
|
||||
byte[] ciphertext = ciphertextOut.toByteArray();
|
||||
|
@ -65,7 +65,7 @@ public class MultiPassphraseSymmetricEncryptionTest {
|
|||
|
||||
ByteArrayOutputStream plaintextOut = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptor, plaintextOut);
|
||||
Streams.pipeAll(decryptor, plaintextOut);
|
||||
|
||||
decryptor.close();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Random;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
@ -43,7 +44,6 @@ import org.pgpainless.key.protection.PasswordBasedSecretKeyRingProtector;
|
|||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.passphrase_provider.SolitaryPassphraseProvider;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
/**
|
||||
* Test parallel symmetric and public key encryption/decryption.
|
||||
|
@ -68,7 +68,7 @@ public class SymmetricEncryptionTest {
|
|||
.addRecipient(encryptionKey)
|
||||
));
|
||||
|
||||
StreamUtil.pipeAll(plaintextIn, encryptor);
|
||||
Streams.pipeAll(plaintextIn, encryptor);
|
||||
encryptor.close();
|
||||
|
||||
byte[] ciphertext = ciphertextOut.toByteArray();
|
||||
|
@ -81,7 +81,7 @@ public class SymmetricEncryptionTest {
|
|||
|
||||
ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptor, decrypted);
|
||||
Streams.pipeAll(decryptor, decrypted);
|
||||
decryptor.close();
|
||||
|
||||
assertArrayEquals(plaintext, decrypted.toByteArray());
|
||||
|
@ -98,7 +98,7 @@ public class SymmetricEncryptionTest {
|
|||
|
||||
decrypted = new ByteArrayOutputStream();
|
||||
|
||||
StreamUtil.pipeAll(decryptor, decrypted);
|
||||
Streams.pipeAll(decryptor, decrypted);
|
||||
decryptor.close();
|
||||
|
||||
assertArrayEquals(plaintext, decrypted.toByteArray());
|
||||
|
@ -118,7 +118,7 @@ public class SymmetricEncryptionTest {
|
|||
EncryptionOptions.encryptCommunications()
|
||||
.addPassphrase(Passphrase.fromPassword("mellon"))));
|
||||
|
||||
StreamUtil.pipeAll(new ByteArrayInputStream(bytes), encryptor);
|
||||
Streams.pipeAll(new ByteArrayInputStream(bytes), encryptor);
|
||||
encryptor.close();
|
||||
|
||||
assertThrows(MissingDecryptionMethodException.class, () -> PGPainless.decryptAndOrVerify()
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.util.io.Streams;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
|
@ -34,7 +35,6 @@ import org.pgpainless.encryption_signing.EncryptionStream;
|
|||
import org.pgpainless.encryption_signing.ProducerOptions;
|
||||
import org.pgpainless.key.WeirdKeys;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.StreamUtil;
|
||||
|
||||
public class TestTwoSubkeysEncryption {
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class TestTwoSubkeysEncryption {
|
|||
.setAsciiArmor(false)
|
||||
);
|
||||
|
||||
StreamUtil.pipeAll(getPlainIn(), encryptionStream);
|
||||
Streams.pipeAll(getPlainIn(), encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
EncryptionResult metadata = encryptionStream.getResult();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue