From d9e3c6ed91503f066c77e54d9c85cf531eec9a7e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 1 Jan 2022 18:11:00 +0100 Subject: [PATCH] Remove investigative test with expired key --- .../InvestigateThunderbirdDecryption.java | 257 ------------------ 1 file changed, 257 deletions(-) delete mode 100644 pgpainless-core/src/test/java/investigations/InvestigateThunderbirdDecryption.java diff --git a/pgpainless-core/src/test/java/investigations/InvestigateThunderbirdDecryption.java b/pgpainless-core/src/test/java/investigations/InvestigateThunderbirdDecryption.java deleted file mode 100644 index d96f7f48..00000000 --- a/pgpainless-core/src/test/java/investigations/InvestigateThunderbirdDecryption.java +++ /dev/null @@ -1,257 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -package investigations; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Date; - -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; -import org.pgpainless.decryption_verification.ConsumerOptions; -import org.pgpainless.decryption_verification.DecryptionStream; -import org.pgpainless.encryption_signing.EncryptionOptions; -import org.pgpainless.encryption_signing.EncryptionStream; -import org.pgpainless.encryption_signing.ProducerOptions; -import org.pgpainless.encryption_signing.SigningOptions; -import org.pgpainless.key.protection.SecretKeyRingProtector; -import org.pgpainless.util.ArmorUtils; - -public class InvestigateThunderbirdDecryption { - - String OUR_KEY = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" + - "Version: PGPainless\n" + - "Comment: 47D2 3A5E 1455 1FD2 0599 C1FC B57B 5451 9E2D 8FE4\n" + - "Comment: Alice \n" + - "\n" + - "lFgEYP8FlBYJKwYBBAHaRw8BAQdAeJ7fL4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flQU=\n" + - "=IEzi\n" + - "-----END PGP PRIVATE KEY BLOCK-----"; - - String THEIR_CERT = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" + - "Version: FlowCrypt [BUILD_REPLACEABLE_VERSION] Gmail Encryption\n" + - "Comment: Seamlessly send and receive encrypted email\n" + - "\n" + - "xjMEYL/CRRYJKwYBBAHaRw8BAQdAxaJrnD/gWRGqaAVtQ8R9PI0ZGu/YESJ4\n" + - "HsJeeCxUZOvNF0RlbiA8ZGVuQGZsb3djcnlwdC5jb20+wn4EExYKACYFAmC/\n" + - "wkUCGwMFFgIDAQAECwkIBwUVCgkICwIeAQIZAQWJAQ/XOQAKCRCGwF2G4DXc\n" + - "cttHAP9Axna+jmFhZEajILW7BZ8UJpgz7mCC48RMtRj/pre4nQD/bKJXB+sD\n" + - "zti+tRbi7KNncgkSQeau+Vy/ZnpBUUHBWwjOOARgv8JFEgorBgEEAZdVAQUB\n" + - "AQdA3dN8Hh18Pqd6OevXWl36y7cM58ZRmUVEEZukXRIholYDAQgHwnUEGBYK\n" + - "AB0FAmC/wkUCGwwFFgIDAQAECwkIBwUVCgkICwIeAQAKCRCGwF2G4DXcclpK\n" + - "AQC0uUHWUFNao1Fl85+4c8WecGKsGCihNU9H3q+I1gz22gEAtVo1dWnc0t1f\n" + - "h1MUYq5FmME+KeFCBZZ9lrMAxRhvigI=\n" + - "=+XVJ\n" + - "-----END PGP PUBLIC KEY BLOCK-----\n"; - - @Test - public void generateMessage() throws PGPException, IOException { - // CHECKSTYLE:OFF - System.out.println("Decryption Key"); - System.out.println(OUR_KEY); - // CHECKSTYLE:ON - - PGPSecretKeyRing ourKey = PGPainless.readKeyRing().secretKeyRing(OUR_KEY); - PGPPublicKeyRing ourCert = PGPainless.extractCertificate(ourKey); - PGPPublicKeyRing theirCert = PGPainless.readKeyRing().publicKeyRing(THEIR_CERT); - - // CHECKSTYLE:OFF - System.out.println("Certificate:"); - System.out.println(ArmorUtils.toAsciiArmoredString(ourCert)); - - System.out.println("Crypt-Only:"); - // CHECKSTYLE:ON - ProducerOptions producerOptions = ProducerOptions - .encrypt(new EncryptionOptions().addRecipient(ourCert).addRecipient(theirCert)) - .setFileName("msg.txt") - .setModificationDate(new Date()); - - generateMessage(producerOptions); - - // CHECKSTYLE:OFF - System.out.println("Sign-Crypt:"); - // CHECKSTYLE:ON - - producerOptions = ProducerOptions - .signAndEncrypt(new EncryptionOptions().addRecipient(ourCert).addRecipient(theirCert), - new SigningOptions().addInlineSignature(SecretKeyRingProtector.unprotectedKeys(), ourKey, DocumentSignatureType.BINARY_DOCUMENT)) - .setFileName("msg.txt") - .setModificationDate(new Date()); - - generateMessage(producerOptions); - } - - private void generateMessage(ProducerOptions producerOptions) throws PGPException, IOException { - String data = "Hello World\n"; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - EncryptionStream encryptionStream = PGPainless.encryptAndOrSign() - .onOutputStream(out) - .withOptions(producerOptions); - - Streams.pipeAll(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)), encryptionStream); - encryptionStream.close(); - - // CHECKSTYLE:OFF - System.out.println(out); - // CHECKSTYLE:ON - } - - @Test - public void testWithSuspiciousKey() throws PGPException, IOException { - String KEY = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" + - "Comment: 4409 A346 1359 96C9 4595 510E 5A18 53D1 5656 CB7A\n" + - "Comment: Alice (Created with pgpkeygen.com)