pgpainless/pgpainless-core/src/test/java/org/pgpainless/encryption_signing/EncryptDecryptTest.java

352 lines
19 KiB
Java
Raw Normal View History

/*
* Copyright 2018 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2020-01-11 13:11:14 +01:00
package org.pgpainless.encryption_signing;
2018-06-07 18:12:13 +02:00
2020-11-13 16:31:59 +01:00
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
2021-04-26 13:38:12 +02:00
import static org.junit.jupiter.api.Assertions.assertThrows;
2020-11-13 16:31:59 +01:00
import static org.junit.jupiter.api.Assertions.assertTrue;
2018-06-07 18:12:13 +02:00
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
2018-06-08 15:29:09 +02:00
import java.nio.charset.Charset;
2018-06-10 17:12:44 +02:00
import java.security.InvalidAlgorithmParameterException;
import java.security.NoSuchAlgorithmException;
2020-08-24 14:55:06 +02:00
import java.util.Set;
2018-06-07 18:12:13 +02:00
2020-08-24 14:55:06 +02:00
import org.bouncycastle.bcpg.ArmoredOutputStream;
2018-06-07 18:12:13 +02:00
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
2020-08-24 14:55:06 +02:00
import org.bouncycastle.openpgp.PGPSignature;
2021-07-31 20:40:31 +02:00
import org.bouncycastle.util.io.Streams;
import org.junit.jupiter.api.BeforeEach;
2021-04-26 13:38:12 +02:00
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
2020-01-11 13:11:14 +01:00
import org.pgpainless.PGPainless;
2021-05-06 00:04:03 +02:00
import org.pgpainless.algorithm.DocumentSignatureType;
import org.pgpainless.algorithm.KeyFlag;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.decryption_verification.ConsumerOptions;
import org.pgpainless.decryption_verification.DecryptionStream;
import org.pgpainless.decryption_verification.OpenPgpMetadata;
import org.pgpainless.implementation.ImplementationFactory;
2021-05-06 00:04:03 +02:00
import org.pgpainless.key.SubkeyIdentifier;
import org.pgpainless.key.TestKeys;
import org.pgpainless.key.generation.KeySpec;
2020-11-07 18:24:12 +01:00
import org.pgpainless.key.generation.type.KeyType;
import org.pgpainless.key.generation.type.elgamal.ElGamal;
2020-12-08 20:02:41 +01:00
import org.pgpainless.key.generation.type.elgamal.ElGamalLength;
import org.pgpainless.key.generation.type.rsa.RsaLength;
import org.pgpainless.key.protection.SecretKeyRingProtector;
import org.pgpainless.key.protection.UnprotectedKeysProtector;
2020-12-08 19:14:52 +01:00
import org.pgpainless.key.util.KeyRingUtils;
import org.pgpainless.policy.Policy;
import org.pgpainless.util.ArmoredOutputStreamFactory;
2018-06-07 18:12:13 +02:00
public class EncryptDecryptTest {
2018-06-07 18:12:13 +02:00
// Don't use StandardCharsets.UTF_8 because of Android API level.
2018-06-10 17:12:44 +02:00
private static final Charset UTF8 = Charset.forName("UTF-8");
2018-06-07 18:12:13 +02:00
private static final String testMessage =
"Ah, Juliet, if the measure of thy joy\n" +
"Be heaped like mine, and that thy skill be more\n" +
"To blazon it, then sweeten with thy breath\n" +
"This neighbor air, and let rich musics tongue\n" +
"Unfold the imagined happiness that both\n" +
"Receive in either by this dear encounter.";
@BeforeEach
public void setDefaultPolicy() {
PGPainless.getPolicy().setSymmetricKeyEncryptionAlgorithmPolicy(
Policy.SymmetricKeyAlgorithmPolicy.defaultSymmetricKeyEncryptionAlgorithmPolicy());
PGPainless.getPolicy().setSymmetricKeyDecryptionAlgorithmPolicy(
Policy.SymmetricKeyAlgorithmPolicy.defaultSymmetricKeyDecryptionAlgorithmPolicy());
}
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void freshKeysRsaToElGamalTest(ImplementationFactory implementationFactory)
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("romeo@montague.lit", RsaLength._3072);
PGPSecretKeyRing recipient = PGPainless.generateKeyRing()
.setPrimaryKey(KeySpec.getBuilder(
2021-09-13 19:20:19 +02:00
KeyType.RSA(RsaLength._4096),
KeyFlag.SIGN_DATA, KeyFlag.CERTIFY_OTHER))
.addSubkey(KeySpec.getBuilder(
ElGamal.withLength(ElGamalLength._3072),
KeyFlag.ENCRYPT_STORAGE, KeyFlag.ENCRYPT_COMMS))
.addUserId("juliet@capulet.lit").build();
2018-06-28 13:23:40 +02:00
encryptDecryptForSecretKeyRings(sender, recipient);
}
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void freshKeysRsaToRsaTest(ImplementationFactory implementationFactory)
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("romeo@montague.lit", RsaLength._3072);
PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("juliet@capulet.lit", RsaLength._3072);
2018-06-10 17:12:44 +02:00
encryptDecryptForSecretKeyRings(sender, recipient);
2018-06-07 18:12:13 +02:00
}
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void freshKeysEcToEcTest(ImplementationFactory implementationFactory)
throws IOException, PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("romeo@montague.lit");
PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("juliet@capulet.lit");
2018-06-10 17:12:44 +02:00
encryptDecryptForSecretKeyRings(sender, recipient);
2018-06-07 18:12:13 +02:00
}
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void freshKeysEcToRsaTest(ImplementationFactory implementationFactory)
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleEcKeyRing("romeo@montague.lit");
PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleRsaKeyRing("juliet@capulet.lit", RsaLength._3072);
2018-06-07 18:12:13 +02:00
encryptDecryptForSecretKeyRings(sender, recipient);
2018-06-10 17:12:44 +02:00
}
2018-06-07 18:12:13 +02:00
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void freshKeysRsaToEcTest(ImplementationFactory implementationFactory)
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, IOException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = PGPainless.generateKeyRing().simpleRsaKeyRing("romeo@montague.lit", RsaLength._3072);
PGPSecretKeyRing recipient = PGPainless.generateKeyRing().simpleEcKeyRing("juliet@capulet.lit");
2018-06-07 18:12:13 +02:00
encryptDecryptForSecretKeyRings(sender, recipient);
2018-06-10 17:12:44 +02:00
}
2018-06-07 18:12:13 +02:00
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void existingRsaKeysTest(ImplementationFactory implementationFactory) throws IOException, PGPException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing sender = TestKeys.getJulietSecretKeyRing();
PGPSecretKeyRing recipient = TestKeys.getRomeoSecretKeyRing();
encryptDecryptForSecretKeyRings(sender, recipient);
}
2020-12-08 19:14:52 +01:00
private void encryptDecryptForSecretKeyRings(PGPSecretKeyRing senderSec, PGPSecretKeyRing recipientSec)
throws PGPException, IOException {
2020-12-08 19:14:52 +01:00
PGPPublicKeyRing recipientPub = KeyRingUtils.publicKeyRingFrom(recipientSec);
PGPPublicKeyRing senderPub = KeyRingUtils.publicKeyRingFrom(senderSec);
2018-06-07 18:12:13 +02:00
2018-06-10 17:12:44 +02:00
SecretKeyRingProtector keyDecryptor = new UnprotectedKeysProtector();
2018-06-07 18:12:13 +02:00
2018-06-21 15:35:40 +02:00
byte[] secretMessage = testMessage.getBytes(UTF8);
2018-06-07 18:12:13 +02:00
2018-06-10 17:12:44 +02:00
ByteArrayOutputStream envelope = new ByteArrayOutputStream();
2018-06-07 18:12:13 +02:00
EncryptionStream encryptor = PGPainless.encryptAndOrSign()
2018-06-10 17:12:44 +02:00
.onOutputStream(envelope)
2021-06-29 16:43:37 +02:00
.withOptions(ProducerOptions.signAndEncrypt(
EncryptionOptions.encryptCommunications().addRecipient(recipientPub),
new SigningOptions().addInlineSignature(keyDecryptor, senderSec, DocumentSignatureType.BINARY_DOCUMENT)
));
2018-06-07 18:12:13 +02:00
2021-07-31 20:40:31 +02:00
Streams.pipeAll(new ByteArrayInputStream(secretMessage), encryptor);
encryptor.close();
byte[] encryptedSecretMessage = envelope.toByteArray();
2021-05-06 00:04:03 +02:00
EncryptionResult encryptionResult = encryptor.getResult();
2021-05-06 00:04:03 +02:00
assertFalse(encryptionResult.getRecipients().isEmpty());
for (SubkeyIdentifier encryptionKey : encryptionResult.getRecipients()) {
2021-05-29 12:43:31 +02:00
assertTrue(KeyRingUtils.keyRingContainsKeyWithId(recipientPub, encryptionKey.getKeyId()));
}
2021-06-10 12:42:03 +02:00
assertEquals(SymmetricKeyAlgorithm.AES_256, encryptionResult.getEncryptionAlgorithm());
2018-06-10 17:12:44 +02:00
// Juliet trieth to comprehend Romeos words
2018-06-07 18:12:13 +02:00
2018-06-10 17:12:44 +02:00
ByteArrayInputStream envelopeIn = new ByteArrayInputStream(encryptedSecretMessage);
DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
2018-06-10 17:12:44 +02:00
.onInputStream(envelopeIn)
.withOptions(new ConsumerOptions()
.addDecryptionKey(recipientSec, keyDecryptor)
.addVerificationCert(senderPub)
);
2018-06-07 18:12:13 +02:00
2018-06-21 15:35:40 +02:00
ByteArrayOutputStream decryptedSecretMessage = new ByteArrayOutputStream();
2018-06-10 17:12:44 +02:00
2021-07-31 20:40:31 +02:00
Streams.pipeAll(decryptor, decryptedSecretMessage);
2018-06-07 18:12:13 +02:00
decryptor.close();
assertArrayEquals(secretMessage, decryptedSecretMessage.toByteArray());
OpenPgpMetadata result = decryptor.getResult();
assertTrue(result.containsVerifiedSignatureFrom(senderPub));
assertTrue(result.isSigned());
assertTrue(result.isEncrypted());
assertTrue(result.isVerified());
2018-06-07 18:12:13 +02:00
}
2020-08-24 14:55:06 +02:00
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void testDetachedSignatureCreationAndVerification(ImplementationFactory implementationFactory) throws IOException, PGPException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing signingKeys = TestKeys.getJulietSecretKeyRing();
2020-08-24 14:55:06 +02:00
SecretKeyRingProtector keyRingProtector = new UnprotectedKeysProtector();
byte[] data = testMessage.getBytes();
ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
ByteArrayOutputStream dummyOut = new ByteArrayOutputStream();
EncryptionStream signer = PGPainless.encryptAndOrSign().onOutputStream(dummyOut)
2021-06-29 16:43:37 +02:00
.withOptions(ProducerOptions.sign(
new SigningOptions().addDetachedSignature(keyRingProtector, signingKeys, DocumentSignatureType.BINARY_DOCUMENT)
));
2021-07-31 20:40:31 +02:00
Streams.pipeAll(inputStream, signer);
2020-08-24 14:55:06 +02:00
signer.close();
2021-05-06 00:04:03 +02:00
EncryptionResult metadata = signer.getResult();
Set<PGPSignature> signatureSet = metadata.getDetachedSignatures().get(metadata.getDetachedSignatures().keySet().iterator().next());
2020-08-24 14:55:06 +02:00
ByteArrayOutputStream sigOut = new ByteArrayOutputStream();
ArmoredOutputStream armorOut = ArmoredOutputStreamFactory.get(sigOut);
2020-08-24 14:55:06 +02:00
signatureSet.iterator().next().encode(armorOut);
armorOut.close();
String armorSig = sigOut.toString();
2020-08-24 16:26:29 +02:00
// CHECKSTYLE:OFF
2020-08-24 14:55:06 +02:00
System.out.println(armorSig);
2020-08-24 16:26:29 +02:00
// CHECKSTYLE:ON
2020-08-24 14:55:06 +02:00
inputStream = new ByteArrayInputStream(testMessage.getBytes());
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
.onInputStream(inputStream)
.withOptions(new ConsumerOptions()
.addVerificationOfDetachedSignatures(new ByteArrayInputStream(armorSig.getBytes()))
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(signingKeys))
);
2020-08-24 14:55:06 +02:00
dummyOut = new ByteArrayOutputStream();
2021-07-31 20:40:31 +02:00
Streams.pipeAll(verifier, dummyOut);
2020-08-24 14:55:06 +02:00
verifier.close();
2021-05-06 00:04:03 +02:00
OpenPgpMetadata decryptionResult = verifier.getResult();
assertFalse(decryptionResult.getVerifiedSignatures().isEmpty());
2020-08-24 14:55:06 +02:00
}
2020-08-30 13:16:47 +02:00
@ParameterizedTest
@MethodSource("org.pgpainless.util.TestImplementationFactoryProvider#provideImplementationFactories")
public void testOnePassSignatureCreationAndVerification(ImplementationFactory implementationFactory) throws IOException, PGPException {
ImplementationFactory.setFactoryImplementation(implementationFactory);
2020-12-08 19:14:52 +01:00
PGPSecretKeyRing signingKeys = TestKeys.getJulietSecretKeyRing();
2020-08-30 13:16:47 +02:00
SecretKeyRingProtector keyRingProtector = new UnprotectedKeysProtector();
byte[] data = testMessage.getBytes();
ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
ByteArrayOutputStream signOut = new ByteArrayOutputStream();
EncryptionStream signer = PGPainless.encryptAndOrSign().onOutputStream(signOut)
2021-06-29 16:43:37 +02:00
.withOptions(ProducerOptions.sign(
SigningOptions.get()
2021-09-13 19:20:19 +02:00
.addInlineSignature(keyRingProtector, signingKeys, DocumentSignatureType.BINARY_DOCUMENT)
2021-06-29 16:43:37 +02:00
).setAsciiArmor(true));
2021-07-31 20:40:31 +02:00
Streams.pipeAll(inputStream, signer);
2020-08-30 13:16:47 +02:00
signer.close();
inputStream = new ByteArrayInputStream(signOut.toByteArray());
DecryptionStream verifier = PGPainless.decryptAndOrVerify()
.onInputStream(inputStream)
.withOptions(new ConsumerOptions()
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(signingKeys))
);
2020-08-30 13:16:47 +02:00
signOut = new ByteArrayOutputStream();
2021-07-31 20:40:31 +02:00
Streams.pipeAll(verifier, signOut);
2020-08-30 13:16:47 +02:00
verifier.close();
OpenPgpMetadata metadata = verifier.getResult();
assertFalse(metadata.getVerifiedSignatures().isEmpty());
}
2021-04-26 13:38:12 +02:00
@Test
public void expiredSubkeyBacksigTest() throws IOException {
String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
"\n" +
"xsDNBF2lnPIBDAC5cL9PQoQLTMuhjbYvb4Ncuuo0bfmgPRFywX53jPhoFf4Zg6mv\n" +
"/seOXpgecTdOcVttfzC8ycIKrt3aQTiwOG/ctaR4Bk/t6ayNFfdUNxHWk4WCKzdz\n" +
"/56fW2O0F23qIRd8UUJp5IIlN4RDdRCtdhVQIAuzvp2oVy/LaS2kxQoKvph/5pQ/\n" +
"5whqsyroEWDJoSV0yOb25B/iwk/pLUFoyhDG9bj0kIzDxrEqW+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i/N3TwdWA=\n" +
"=j1TE\n" +
"-----END PGP PUBLIC KEY BLOCK-----\n";
PGPPublicKeyRing publicKeys = PGPainless.readKeyRing().publicKeyRing(key);
2021-06-29 16:43:37 +02:00
2021-04-26 13:38:12 +02:00
assertThrows(IllegalArgumentException.class, () ->
2021-06-29 16:43:37 +02:00
EncryptionOptions.encryptCommunications()
.addRecipient(publicKeys));
2021-04-26 13:38:12 +02:00
}
2018-06-07 18:12:13 +02:00
}