mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-10 14:35:59 +01:00
Compare commits
16 commits
Author | SHA1 | Date | |
---|---|---|---|
1981af77b2 | |||
8ec9f49b86 | |||
2f67df57df | |||
160e42c32b | |||
5a343a39d3 | |||
38db67df80 | |||
4f85a29e0c | |||
b7e8b56e3d | |||
|
c61a129e08 | ||
4b474b4683 | |||
0c5521f82a | |||
ab74e157d0 | |||
d812a2a8b6 | |||
d09b646011 | |||
e32d6ac34c | |||
93cf8cc8d9 |
11 changed files with 103 additions and 286 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -5,7 +5,19 @@ SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
# PGPainless Changelog
|
# PGPainless Changelog
|
||||||
|
|
||||||
# 1.6.2
|
## 1.6.4
|
||||||
|
- Bump `bcpg-jdk8on` to `1.77`
|
||||||
|
- Bump `bcprov-jdk18on` to `1.77`
|
||||||
|
- Bump `logback-core` and `logback-classic` to `1.4.13`
|
||||||
|
- Properly feed EOS tokens to the pushdown automaton when reaching the end of stream (thanks @iNPUTmice)
|
||||||
|
- Do not choke on unknown signature subpackets (thanks @Jerbell)
|
||||||
|
- Prevent timing issues resuting in subkey binding signatures predating the subkey (@thanks Jerbell)
|
||||||
|
|
||||||
|
## 1.6.3
|
||||||
|
- Bump `sop-java` to `7.0.1`
|
||||||
|
- `decrypt --verify-with`: Fix to not throw `NoSignature` exception (exit code 3) if `VERIFICATIONS` is empty
|
||||||
|
|
||||||
|
## 1.6.2
|
||||||
- Switch `bcpg` and `bcprov` artifacts from `-jdk15to18`variant to `-jdk18on`
|
- Switch `bcpg` and `bcprov` artifacts from `-jdk15to18`variant to `-jdk18on`
|
||||||
- Bump `bcpg-jdk8on` to `1.76`
|
- Bump `bcpg-jdk8on` to `1.76`
|
||||||
- Bump `bcprov-jdk18on` to `1.76`
|
- Bump `bcprov-jdk18on` to `1.76`
|
||||||
|
@ -13,7 +25,7 @@ SPDX-License-Identifier: CC0-1.0
|
||||||
encrypting to legacy keys which do not carry any key flags.
|
encrypting to legacy keys which do not carry any key flags.
|
||||||
- Allow overriding of reference time in `EncryptionOptions` and `SigningOptions`.
|
- Allow overriding of reference time in `EncryptionOptions` and `SigningOptions`.
|
||||||
|
|
||||||
# 1.6.1
|
## 1.6.1
|
||||||
- `KeyRingBuilder`: Require UTF8 when adding user-ID via `addUserId(byte[])`
|
- `KeyRingBuilder`: Require UTF8 when adding user-ID via `addUserId(byte[])`
|
||||||
- `pgpainless-sop`: Remove dependency on jetbrains annotations
|
- `pgpainless-sop`: Remove dependency on jetbrains annotations
|
||||||
- Add `CertificateAuthority` interface to allow integration with [`pgpainless-wot`](https://github.com/pgpainless/pgpainless-wot)
|
- Add `CertificateAuthority` interface to allow integration with [`pgpainless-wot`](https://github.com/pgpainless/pgpainless-wot)
|
||||||
|
|
|
@ -191,7 +191,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.pgpainless:pgpainless-core:1.6.2'
|
implementation 'org.pgpainless:pgpainless-core:1.6.4'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -712,6 +712,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (nestedInputStream == null) {
|
if (nestedInputStream == null) {
|
||||||
if (packetInputStream != null) {
|
if (packetInputStream != null) {
|
||||||
|
syntaxVerifier.next(InputSymbol.EndOfSequence);
|
||||||
syntaxVerifier.assertValid();
|
syntaxVerifier.assertValid();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -304,6 +304,16 @@ public class KeyRingBuilder implements KeyRingBuilderInterface<KeyRingBuilder> {
|
||||||
public static PGPKeyPair generateKeyPair(KeySpec spec)
|
public static PGPKeyPair generateKeyPair(KeySpec spec)
|
||||||
throws NoSuchAlgorithmException, PGPException,
|
throws NoSuchAlgorithmException, PGPException,
|
||||||
InvalidAlgorithmParameterException {
|
InvalidAlgorithmParameterException {
|
||||||
|
Date keyCreationDate = spec.getKeyCreationDate();
|
||||||
|
if (keyCreationDate == null) {
|
||||||
|
keyCreationDate = new Date();
|
||||||
|
}
|
||||||
|
return generateKeyPair(spec, keyCreationDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PGPKeyPair generateKeyPair(KeySpec spec, Date keyCreationDate)
|
||||||
|
throws NoSuchAlgorithmException, PGPException,
|
||||||
|
InvalidAlgorithmParameterException {
|
||||||
KeyType type = spec.getKeyType();
|
KeyType type = spec.getKeyType();
|
||||||
KeyPairGenerator certKeyGenerator = KeyPairGenerator.getInstance(type.getName(),
|
KeyPairGenerator certKeyGenerator = KeyPairGenerator.getInstance(type.getName(),
|
||||||
ProviderFactory.getProvider());
|
ProviderFactory.getProvider());
|
||||||
|
@ -312,8 +322,6 @@ public class KeyRingBuilder implements KeyRingBuilderInterface<KeyRingBuilder> {
|
||||||
// Create raw Key Pair
|
// Create raw Key Pair
|
||||||
KeyPair keyPair = certKeyGenerator.generateKeyPair();
|
KeyPair keyPair = certKeyGenerator.generateKeyPair();
|
||||||
|
|
||||||
Date keyCreationDate = spec.getKeyCreationDate() != null ? spec.getKeyCreationDate() : new Date();
|
|
||||||
|
|
||||||
// Form PGP key pair
|
// Form PGP key pair
|
||||||
PGPKeyPair pgpKeyPair = ImplementationFactory.getInstance()
|
PGPKeyPair pgpKeyPair = ImplementationFactory.getInstance()
|
||||||
.getPGPKeyPair(type.getAlgorithm(), keyPair, keyCreationDate);
|
.getPGPKeyPair(type.getAlgorithm(), keyPair, keyCreationDate);
|
||||||
|
|
|
@ -290,6 +290,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
||||||
@Override
|
@Override
|
||||||
public void modifyHashedSubpackets(SelfSignatureSubpackets hashedSubpackets) {
|
public void modifyHashedSubpackets(SelfSignatureSubpackets hashedSubpackets) {
|
||||||
SignatureSubpacketsHelper.applyFrom(keySpec.getSubpackets(), (SignatureSubpackets) hashedSubpackets);
|
SignatureSubpacketsHelper.applyFrom(keySpec.getSubpackets(), (SignatureSubpackets) hashedSubpackets);
|
||||||
|
hashedSubpackets.setSignatureCreationTime(referenceTime);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -307,7 +308,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
||||||
@Nullable SelfSignatureSubpackets.Callback subpacketsCallback,
|
@Nullable SelfSignatureSubpackets.Callback subpacketsCallback,
|
||||||
@Nonnull SecretKeyRingProtector secretKeyRingProtector)
|
@Nonnull SecretKeyRingProtector secretKeyRingProtector)
|
||||||
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, IOException {
|
||||||
PGPKeyPair keyPair = KeyRingBuilder.generateKeyPair(keySpec);
|
PGPKeyPair keyPair = KeyRingBuilder.generateKeyPair(keySpec, referenceTime);
|
||||||
|
|
||||||
SecretKeyRingProtector subKeyProtector = PasswordBasedSecretKeyRingProtector
|
SecretKeyRingProtector subKeyProtector = PasswordBasedSecretKeyRingProtector
|
||||||
.forKeyId(keyPair.getKeyID(), subkeyPassphrase);
|
.forKeyId(keyPair.getKeyID(), subkeyPassphrase);
|
||||||
|
|
|
@ -35,7 +35,13 @@ public class SignatureSubpacketsHelper {
|
||||||
|
|
||||||
public static SignatureSubpackets applyFrom(PGPSignatureSubpacketVector vector, SignatureSubpackets subpackets) {
|
public static SignatureSubpackets applyFrom(PGPSignatureSubpacketVector vector, SignatureSubpackets subpackets) {
|
||||||
for (SignatureSubpacket subpacket : vector.toArray()) {
|
for (SignatureSubpacket subpacket : vector.toArray()) {
|
||||||
org.pgpainless.algorithm.SignatureSubpacket type = org.pgpainless.algorithm.SignatureSubpacket.requireFromCode(subpacket.getType());
|
org.pgpainless.algorithm.SignatureSubpacket type = org.pgpainless.algorithm.SignatureSubpacket.fromCode(subpacket.getType());
|
||||||
|
if (type == null) {
|
||||||
|
// Unknown subpacket, ignore and just add to the residuals
|
||||||
|
subpackets.addResidualSubpacket(subpacket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case signatureCreationTime:
|
case signatureCreationTime:
|
||||||
case issuerKeyId:
|
case issuerKeyId:
|
||||||
|
|
|
@ -1,272 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <info@pgpainless.org>
|
|
||||||
//
|
|
||||||
// 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 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.algorithm.SymmetricKeyAlgorithm;
|
|
||||||
import org.pgpainless.decryption_verification.ConsumerOptions;
|
|
||||||
import org.pgpainless.decryption_verification.DecryptionStream;
|
|
||||||
import org.pgpainless.decryption_verification.MessageInspector;
|
|
||||||
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.implementation.ImplementationFactory;
|
|
||||||
import org.pgpainless.implementation.JceImplementationFactory;
|
|
||||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
|
||||||
|
|
||||||
public class KleopatraCompatibilityTest {
|
|
||||||
|
|
||||||
public static final String KLEOPATRA_PUBKEY = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
|
||||||
"\n" +
|
|
||||||
"mQGNBGF4StQBDADgAGvvtzCrSa5I9/jIZq0SKxoz7Hz61YM2Hs/hPedXfQeW7lrf\n" +
|
|
||||||
"qutyXSIb8L964v9u2RGnzteaPwciGSyoMal5teAPOsv6cp7kIDksQH8iJm/9FhoJ\n" +
|
|
||||||
"hFl2Yx5BX6sBtoXwY63Kf9Vpx/Std9tN34HHI7zrbO70rv6ZcDPFHyWoVdoDZOX1\n" +
|
|
||||||
"DWbBnOP3SoaNaPnbwEBfEkPwyN/NsnxTfe+IsCYC2byC3NZwYA5FscWFioeJ/UpF\n" +
|
|
||||||
"HMgZ6utn9mfTexOYEE0mL1mhrc7PbRjDlNasW3GLrpeVN55anT0jvtNXulG4POzG\n" +
|
|
||||||
"fJ8g3qddcbTXYhQItjurBlkYLV1JOhdCN83IJRect4EIKBkLuEKO0/a7bE6HC7nr\n" +
|
|
||||||
"PLw9MWGgcnDe2cTc4a6nAGC/eMeCONQlyAvOIEIXibbz4OB0dTNA5YYTMBHVO7n0\n" +
|
|
||||||
"GbNg8eqw+N+IijboLtJly+LshP81IdQMHg0h6K3+bfYV0rwC/XmR387s+pVpAp5k\n" +
|
|
||||||
"Lrw8Rt+BsQSY2O8AEQEAAbQhS2xlb3BhdHJhIDxrbGVvcGF0cmFAdGVzdC5kb21h\n" +
|
|
||||||
"aW4+iQHUBBMBCgA+FiEEzYzHEulLyE5PkaUp6EVgKKoTP1kFAmF4StQCGwMFCQPB\n" +
|
|
||||||
"7cwFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQ6EVgKKoTP1nClwv/exOrk3H0\n" +
|
|
||||||
"aKOqwB6gMtA9bOJgYG4Lm3v9EM39mGScTJgAaZMlJIVMZ7qBUCEbw9lOJMZLguVm\n" +
|
|
||||||
"VJN8sV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7tvIn\n" +
|
|
||||||
"3H94EiVc5FNpRfWrngwPnwt3m3QkmG3lkd5WnxuyjH/LbKMtuBC/3QuKNrrySvXF\n" +
|
|
||||||
"L4SL51cAEQEAAYkBvAQYAQoAJhYhBM2MxxLpS8hOT5GlKehFYCiqEz9ZBQJheErU\n" +
|
|
||||||
"AhsMBQkDwe3MAAoJEOhFYCiqEz9ZkhsL/itexY5+qkWjjGd8cLAtrJTzhQRlk6s7\n" +
|
|
||||||
"t7eBFSuTywlKC1f1wVpu5djOHTPH8H0JWMAAxtHQluk3IcQruBMFoao3xma+2HW1\n" +
|
|
||||||
"x4C0AfrL4C00zxUUxqtmfZi81NU0izmFNABdcEHGbE8jN86wIaiAnS1em61F+vju\n" +
|
|
||||||
"MTMLJVq56SQJhWSymf4z4d8gVIy7WzeSuHnHcDbMcCfFzN1kn2T/k5gav4wEcz3n\n" +
|
|
||||||
"LizUYsT+rFKizgVzSDLlSFcJQPd+a8Kwbo/hnzDt9zgmVirzU0/2Sgd0d6Iatplk\n" +
|
|
||||||
"YPzWmjATe3htmKrGXD4R/rF7aEnPCkR8k8WMLPleuenCRGQi5KKzNuevY2U8A4Mi\n" +
|
|
||||||
"KNt5EM8WdqcXD3Pv7nsVi4dNc8IK1TZ4BfN3YBFQL+hO/Fk7apiqZDu3sNpG7JR0\n" +
|
|
||||||
"V37ltHAK0HFdznyP79oixknV6pfdAVbIyzQXk/FqnpvbjCY4v/DWLz6a4n8tYQPh\n" +
|
|
||||||
"g94JEXpwhb9guKuzYzP/QeBp4qFu5FO87w==\n" +
|
|
||||||
"=Jz7i\n" +
|
|
||||||
"-----END PGP PUBLIC KEY BLOCK-----\n";
|
|
||||||
public static final String KLEOPATRA_SECKEY = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
|
||||||
"\n" +
|
|
||||||
"lQVYBGF4StQBDADgAGvvtzCrSa5I9/jIZq0SKxoz7Hz61YM2Hs/hPedXfQeW7lrf\n" +
|
|
||||||
"qutyXSIb8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
|
|
||||||
"JnwH5/F2kG9JAXC+0Y3R9Ji+wabVGMUHxugcXpQa0d/malCZaS/dviDUfZ1KbDjH\n" +
|
|
||||||
"Jlzew7cmfRtiw4tfczboekeSbQYA6bh6IFqQlcW7qj34TAg8h8t34Q2o2U0VMj96\n" +
|
|
||||||
"OiG8B/LARF89ue4CaQQMQt16BHeMhePBAhPCkkCEtmbXremHsrtn6C149cS9GAEt\n" +
|
|
||||||
"fSAHVGedVDHzke/K84uHzBbY0dS6O6u2ApvWOutgWpB5Le4A7WTslyAdLWRZ1l69\n" +
|
|
||||||
"H2706M9fgGClVsQByCNVksDEbOizIlAkFOq0b39u8dnb063A9ReAuk/argCA7JHU\n" +
|
|
||||||
"j3BFIF5crIn+YrWl6slFuoXGWTXlBgD1WsVhU4hXJ5g35TOso0rEND/wHrjW0W4F\n" +
|
|
||||||
"LViA5yAt9sVLNGgm9Ye3YSVIHId6HiJQZmsWJb81WD5dvBLl74icZmfSWtRTwvCZ\n" +
|
|
||||||
"0k3rYlu3Ex4bQUwoyhSlDoPJ9YMaumd1yaM3nMeyrlaHYIpV8NtqSuqJc7i2iNX1\n" +
|
|
||||||
"3s9AotipHYEUOlsp936bNEuh0m8xXEZ2C8qjpNenymg8XfNd/IH2M4Sjzz+pN5sS\n" +
|
|
||||||
"gQt+pQhYFnW0Gersb/X3OsAtLtRE5kMF/3v7GAz7usMcajqbh9qB+Ytp4n1u3aQC\n" +
|
|
||||||
"ck1exVOwdLDZgsHfojO1SEFd3IafO01xp+TmS8qIoZvKJegM+qq9px1PHSTRnb4D\n" +
|
|
||||||
"8tuBxtdoUE7n+g3Li74je7+DEdcq6g9ZjgyeosCHGItUwTcCMqnHa+ikjQjsnnzu\n" +
|
|
||||||
"eSwvVSfMJQYyZrZ5qYgQZKcovkFDvgXiC/jqfDd6GeAfbxzL2cyAYWvUdGln79O3\n" +
|
|
||||||
"Tc7ZWd0Xn6IaMPVPRBvH4RsaWqFdO0pIOuH7tCFLbGVvcGF0cmE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CmD7NQ7at1uCNbDktk8GIL90eRbJ0a/NaucCAOZ\n" +
|
|
||||||
"UCwmK1rYX4/HCaeLenmpTaEEmYm5WjXnDp6VJPVK+feOKbmCptdeGHYHANIM8SnS\n" +
|
|
||||||
"5FmVXqv1EyUf6Ozgi8qK94bN1dPOZs+XxT7gcfKc8zVNZHEJpc0XjDgGWeWrOCDS\n" +
|
|
||||||
"MVdXNXS1eTUclNw/guaajTGl/k4SxsJm/rWoMk7bRAwfD1j2pT+VwKxe+a0V8QNN\n" +
|
|
||||||
"lJ+8gQCWmju28ifcf3gSJVzkU2lF9aueDA+fC3ebdCSYbeWR3lafG7KMf8tsoy24\n" +
|
|
||||||
"EL/dC4o2uvJK9cUvhIvnVwARAQABAAv9ExmcWWGY6p1e1StACyKrvqO+lEBFPidb\n" +
|
|
||||||
"Jj7udODT8PXFFgW9c60cU0aUHLn/fZ5d/zI6XSKYj02nkaoQo6QIoM/i/iMY0En1\n" +
|
|
||||||
"aHRvDb7+51w1iDa/uwy8biVNgi8pYBw2l9gLiQdlR94ej6y1GBAIJR6ShD26VmSE\n" +
|
|
||||||
"F2O3osuEybtleEKt660/MiMWMBWzaqwAq2jY6c5/4xHVw+87oMv4k0AbeLOQKojK\n" +
|
|
||||||
"h2o5mi5jSpVvOWCAsOYAhHlEEUQPDFQ1rbJ3P3XcRZE4EIxP2eKDyfyOXRTihLDl\n" +
|
|
||||||
"/9hqOf57wo0C43bnc1BkD6sk+ptKgUifpUHHejg/i7HINFivh7jCgCtoskf2P9BL\n" +
|
|
||||||
"WFuaPZVLQSVE5X2PsgeIYK9/eGeNxfXgtwRyUd8DtBge11tsMaENUTm39p36my2K\n" +
|
|
||||||
"jBgoEdBIQo1Mpi1EZba+L6pyw9bPFnj5H+opSe+X9/spkS9DyPOPGY7rCSTgv+7q\n" +
|
|
||||||
"Ph2WbtRRJslitLEjT9tNgwMRGWsgdbcpBgDgzujDUQb1coCdgw1gsQSTPir9hJxF\n" +
|
|
||||||
"Q+2DA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abuXYzh0zx/B9CVjA\n" +
|
|
||||||
"AMbR0JbpNyHEK7gTBaGqN8Zmvth1tceAtAH6y+AtNM8VFMarZn2YvNTVNIs5hTQA\n" +
|
|
||||||
"XXBBxmxPIzfOsCGogJ0tXputRfr47jEzCyVauekkCYVkspn+M+HfIFSMu1s3krh5\n" +
|
|
||||||
"x3A2zHAnxczdZJ9k/5OYGr+MBHM95y4s1GLE/qxSos4Fc0gy5UhXCUD3fmvCsG6P\n" +
|
|
||||||
"4Z8w7fc4JlYq81NP9koHdHeiGraZZGD81powE3t4bZiqxlw+Ef6xe2hJzwpEfJPF\n" +
|
|
||||||
"jCz5XrnpwkRkIuSiszbnr2NlPAODIijbeRDPFnanFw9z7+57FYuHTXPCCtU2eAXz\n" +
|
|
||||||
"d2ARUC/oTvxZO2qYqmQ7t7DaRuyUdFd+5bRwCtBxXc58j+/aIsZJ1eqX3QFWyMs0\n" +
|
|
||||||
"F5Pxap6b24wmOL/w1i8+muJ/LWED4YPeCRF6cIW/YLirs2Mz/0HgaeKhbuRTvO8=\n" +
|
|
||||||
"=cgLL\n" +
|
|
||||||
"-----END PGP PRIVATE KEY BLOCK-----\n";
|
|
||||||
// signed and encrypted
|
|
||||||
public static final String KLEOPATRA_MESSAGE = "-----BEGIN PGP MESSAGE-----\n" +
|
|
||||||
"\n" +
|
|
||||||
"hQGMA2gglaIyvWSdAQv+NjugJ3Sqk7F9PnVOphT8TNc1i1rHlU9bDDeyZ2Czl6KA\n" +
|
|
||||||
"YXwSP5KmwgTJH+vt9N5xrbKOGCuSCJNeb0wzH/YpQHLL5Hx5Pk0KtNH8BCevApkM\n" +
|
|
||||||
"Rcn4EKiXMmTFyib0fCPlqvEvqdD1ni1IliHNLxR/TYCSxbmu3TqPie70PiLsB32l\n" +
|
|
||||||
"6QKDi1U3HftsZOLLgIPbd1IqnSMeT3E15oD8LTQe3k/CV+huA54wrIeqDxfJpcAu\n" +
|
|
||||||
"rvb4rLVvGmaF67FXekMEDjD3cdk2m6WJ8c1myh3EUpDRlMPobhgeEV+h28heGuhu\n" +
|
|
||||||
"g2Id97DMfUhxypGbQ/rlwHE3UMvdW3YS0KRT7UfPee0F2m737b/aWO341LOzJz94\n" +
|
|
||||||
"xggPafIC6IseQQVZirocG1CLl0lauWZoXbfmzrXCT+YGNuaNjlE01BYPBjgEygle\n" +
|
|
||||||
"7Kur60YkB0H6fACskcudWDRFTsjEgIZa3riHou7XmvqupvJC+hyYdH3QqyFMvdix\n" +
|
|
||||||
"03/E9ePUs051Bvzn+a/dhQGMAwAAAAAAAAAAAQv/RtljqQ2BsB0KkdzZtnfY+CZZ\n" +
|
|
||||||
"PBYvloxplK+Bs8aoLVujyI7g6weOvFD49tSowsvJ//DleDpcKe4UZA/WRj5HlB1J\n" +
|
|
||||||
"5zLK5qlWb8El6QKlwEKB02zHDv244Bm9ZROnSK3CrEqRcfdBQIx4ThEOZlG0cE60\n" +
|
|
||||||
"iTbrda2SYUDpHh4Re/qhw/wvc0uUf+59u8WU5AIpgfLBU2fNEjOr6LMIsR3Edvf8\n" +
|
|
||||||
"zIFUrHlfvKQaAnZYU79dA0ZnTYgLiwMWB19nvhnSIdWAC3tJUsiuEIzEzA+vVbG/\n" +
|
|
||||||
"YrTOMR+vFm+dVOcVanzn0vnV0n8+np1kM1V2JgGRKV6XybS1oUbNPvpv79FBgfPi\n" +
|
|
||||||
"F3WghBHZf9lTaj4w7LtQSojvC0YxSoxfTif/MMxNZUoexQbk0jE97ibeFk6rqrBn\n" +
|
|
||||||
"46G2WbrrReDyOUekSkM5MQ/bZ1GJuFfC+kGyHETBejsfn0ZKa2RUla9k3vYFcDJC\n" +
|
|
||||||
"Et7Vwv81SF4yzvSwiV0rFx1RcyZaGlJumjCkqaHHhQIMAwAAAAAAAAAAAQ/+KTsY\n" +
|
|
||||||
"vnPMOmjmLqu7BQwx3jUaEmCXTurv5XHMbAEcq0UAwHJ/XAcJe7B1707Fu1sSJJjV\n" +
|
|
||||||
"3rJVHGUv7+APg5/v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MLsJA\n" +
|
|
||||||
"JAiAOF/KNNZxSdMWIXqMyMviSPeU9+KclOG7iiR75Q5kIbpj9hWo5ullxr6XrHl2\n" +
|
|
||||||
"HFR+5jnmbSNwz/cf0vwkTnNG/Crofyy0kPTfGp5Ku4hp0wIhWXM9f8m7tuoxI3ep\n" +
|
|
||||||
"uNwB7FOs3xemsxAmoufyWcsyxnVf/3OJLWejIcIK1v3NmoiSxFQXl2cmiRVLTtAT\n" +
|
|
||||||
"oNjUT9QDQiyi8YR+CepV6RnBSmRomr7HfRAoACaCg6ToaXm0Dc8OQSge2X80ifdD\n" +
|
|
||||||
"NUcfhQAivaVAqhAogUIaPp9yqwTWaZ00N5cPH4HItPJtukb+Fsove2SoF+iPQre6\n" +
|
|
||||||
"hDjZCNyfUjT+wnca315nN+9D6Z1JgV5YEM23sFKp4M732Zdb5JlR0DXfDEuQH1NL\n" +
|
|
||||||
"hXOcpr9LpAvASH7weiVTEYxNz5KzFkUQA5YKLLeDwtcK\n" +
|
|
||||||
"=MgH4\n" +
|
|
||||||
"-----END PGP MESSAGE-----\n";
|
|
||||||
public static final String PGPAINLESS_MESSAGE = "-----BEGIN PGP MESSAGE-----\n" +
|
|
||||||
"Version: PGPainless\n" +
|
|
||||||
"\n" +
|
|
||||||
"hQGMA2gglaIyvWSdAQv/Y9Wx763qAM95+teCUPPNRc5Iwqbc5uFjxfbcwsHIWdiZ\n" +
|
|
||||||
"n2wHNUmd2dUqYgpqOcBwZ/fUJuoHj/uXKZ1pbz2QSVYaL9MulKpgWiVAo0K2w0Oc\n" +
|
|
||||||
"97KfZ0d66tcZIhslVpZW06+lXuwMyjjjExe32fAkPFnYyTNORljyYlb/RDSkh7Ke\n" +
|
|
||||||
"Q+48fLR2kitV0WyRZ+d9cMfx2+D2gWYiaFGek9SrhI8L+nNd4UKvM4K4sSq4JHYf\n" +
|
|
||||||
"DCxGPWYOaTculuX8dfDh3ftHbrmL2Ca7Iv4NB0kSduG8Gin2OWyeSIPIwpF2ci9g\n" +
|
|
||||||
"cIBssAYhmS88FQit5pW9z2RZ/e9XmYIP++kz3/EdI6DqkiPUv1fiHTrJBC93LvVg\n" +
|
|
||||||
"pq75h9RNFuUlqR09SVuB/uZB6tYgv77vy5lPFo+wmLjM41aS4+qI1hBI3Ym4XTc1\n" +
|
|
||||||
"spPA0sEHtQTQ/xRNYqGpwunJniMF3ukWpOB6UNvQld+p2lj8czexhEAcne1cjey/\n" +
|
|
||||||
"f0/WUnluSt0HIg8Mnd7s0ukBhb4YxjvARjuqi6PikGz4JPshRwB8dPtS9FQiRxL7\n" +
|
|
||||||
"obaPHXlmLwohEtT3akzoIj/9C3Y7qnfreSllDgRDxRVFPXy5QnQqpsTy2JuJ4cvo\n" +
|
|
||||||
"p55RE2kyJ3vBZlB6T53pSgC00hQnNxoqgy7aejRItlec7zx5DnEg8t4rA7LYEGLT\n" +
|
|
||||||
"MBLWbTRc/njH6GTyc/3x7j9k8V83exqpF6fXrE3GP1C3fBxHY2S9/5BFAlzimplz\n" +
|
|
||||||
"Mow4S15D04EllRRk6f9HKY598xS4QlDEW/f3utwkQ8+/lNqesVuV8n76WDldMv2O\n" +
|
|
||||||
"5gTqAZ/pKhDKRLY6km4B2+2IAt2zg+V141wryHJgE/4VyUbu7zZxDIcDouuATQvt\n" +
|
|
||||||
"wNMnntqy3NTbM7DefSiYe9IUsTUz/g0VQJikoJx+rdX6YzQnRk/cmwvELnskQjSk\n" +
|
|
||||||
"aGd92A4ousaM299IOkbpLvFaJdrs7cLH0rEQTG5S3tRJSLEnjr94BUVtpIhQDo3i\n" +
|
|
||||||
"455UahKcCx/KhyIzo+8OdH0TYZf5ZFGLdTrqgi0ybAHcLrXkM+g2JOsst99CeRUq\n" +
|
|
||||||
"f/T4oFvuDSlLU56iWlLVE7gvDBibXfWIJ65YBHY4ueEzBC/3xOVj+dmTM2JfUSX7\n" +
|
|
||||||
"mqD25NaDCOuN4WhJmZHC1wyipj3KYT2bLg4gasHr/LvEI+Df/DREdXtrYAqPqZYU\n" +
|
|
||||||
"0QuubMF4n3hMqmu2wA==\n" +
|
|
||||||
"=fMRM\n" +
|
|
||||||
"-----END PGP MESSAGE-----";
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMessageDecryptionAndVerification() throws PGPException, IOException {
|
|
||||||
ImplementationFactory.setFactoryImplementation(new JceImplementationFactory());
|
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KLEOPATRA_SECKEY);
|
|
||||||
PGPPublicKeyRing publicKeys = PGPainless.readKeyRing().publicKeyRing(KLEOPATRA_PUBKEY);
|
|
||||||
|
|
||||||
ConsumerOptions options = new ConsumerOptions()
|
|
||||||
.addDecryptionKey(secretKeys)
|
|
||||||
.addVerificationCert(publicKeys);
|
|
||||||
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
|
||||||
.onInputStream(new ByteArrayInputStream(KLEOPATRA_MESSAGE.getBytes(StandardCharsets.UTF_8)))
|
|
||||||
.withOptions(options);
|
|
||||||
|
|
||||||
Streams.pipeAll(decryptionStream, out);
|
|
||||||
decryptionStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEncryptAndSignMessage() throws PGPException, IOException {
|
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KLEOPATRA_SECKEY);
|
|
||||||
PGPPublicKeyRing publicKeys = PGPainless.readKeyRing().publicKeyRing(KLEOPATRA_PUBKEY);
|
|
||||||
|
|
||||||
ProducerOptions options = ProducerOptions.signAndEncrypt(
|
|
||||||
EncryptionOptions.encryptCommunications()
|
|
||||||
.addRecipient(publicKeys)
|
|
||||||
.overrideEncryptionAlgorithm(SymmetricKeyAlgorithm.AES_128),
|
|
||||||
SigningOptions.get()
|
|
||||||
.addInlineSignature(SecretKeyRingProtector.unprotectedKeys(), secretKeys, DocumentSignatureType.BINARY_DOCUMENT)
|
|
||||||
);
|
|
||||||
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
EncryptionStream encryptionStream = PGPainless.encryptAndOrSign()
|
|
||||||
.onOutputStream(out)
|
|
||||||
.withOptions(options);
|
|
||||||
|
|
||||||
ByteArrayInputStream in = new ByteArrayInputStream("Hallo, Welt!\n\n".getBytes(StandardCharsets.UTF_8));
|
|
||||||
Streams.pipeAll(in, encryptionStream);
|
|
||||||
encryptionStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMessageInspection() throws PGPException, IOException {
|
|
||||||
MessageInspector.EncryptionInfo info = MessageInspector.determineEncryptionInfoForMessage(
|
|
||||||
new ByteArrayInputStream(KLEOPATRA_MESSAGE.getBytes(StandardCharsets.UTF_8)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -83,6 +83,24 @@ public class DecryptAndVerifyMessageTest {
|
||||||
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestTemplate
|
||||||
|
@ExtendWith(TestAllImplementations.class)
|
||||||
|
public void decryptMessageAndReadBeyondEndTest() throws Exception {
|
||||||
|
final String encryptedMessage = TestKeys.MSG_SIGN_CRYPT_JULIET_JULIET;
|
||||||
|
|
||||||
|
final ConsumerOptions options = new ConsumerOptions()
|
||||||
|
.addDecryptionKey(juliet)
|
||||||
|
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet));
|
||||||
|
|
||||||
|
try (DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
||||||
|
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes()))
|
||||||
|
.withOptions(options);
|
||||||
|
ByteArrayOutputStream toPlain = new ByteArrayOutputStream()) {
|
||||||
|
Streams.pipeAll(decryptor, toPlain);
|
||||||
|
assertEquals(-1, decryptor.read());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
@ExtendWith(TestAllImplementations.class)
|
@ExtendWith(TestAllImplementations.class)
|
||||||
public void decryptMessageAndVerifySignatureByteByByteTest() throws Exception {
|
public void decryptMessageAndVerifySignatureByteByByteTest() throws Exception {
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package org.pgpainless.key;
|
||||||
|
|
||||||
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
public class KeyWithUnsupportedSignatureSubpacketTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCanSetExpirationDateOnKeyContainingUnknownSubpacket34() throws IOException, PGPException {
|
||||||
|
String KEY = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||||
|
"\n" +
|
||||||
|
"lFgEZWiyNhYJKwYBBAHaRw8BAQdA71QipJ0CAqOEqQWjuoQE4E7LarKSrNDwE/6K\n" +
|
||||||
|
"bQNrCLwAAQCtJ8kVG2AmbDfdVtr/7Ag+yBh0oCvjRvyUCOyIbruOeg+6tClTdWJw\n" +
|
||||||
|
"YWNrZXQzNCBUZXN0S2V5IDx0ZXN0QHBncGFpbmxlc3Mub3JnPoiTBBMWCgA7FiEE\n" +
|
||||||
|
"zhy5yrnZYU/iBza4G03SQVuWqx0FAmVosjYCGwMFCwkIBwICIgIGFQoJCAsCBBYC\n" +
|
||||||
|
"AwECHgcCF4AACgkQG03SQVuWqx1UGgD+IYLeh9t5eJCEnzueuOTYnTnrzyhnLgm9\n" +
|
||||||
|
"dw5qwMXU8VQA/28GCOb7610hyjiBbrrcshkWAKuMwp8bUSz5FOeS5cQEnF0EZWiy\n" +
|
||||||
|
"NhIKKwYBBAGXVQEFAQEHQK99ClLDYtn0I2b6Y26NhaL0RWcrNoI/ci0xgXEK2L0Y\n" +
|
||||||
|
"AwEIBwAA/06qciQHI0v7MP2LMWm/ZuTJwzlPqV8VsBhrDMyUPUD4D52IeAQYFgoA\n" +
|
||||||
|
"IBYhBM4cucq52WFP4gc2uBtN0kFblqsdBQJlaLI2AhsMAAoJEBtN0kFblqsdRQ0A\n" +
|
||||||
|
"/iUJ/Fp+D2RjZL+aiwByIxPCVvMJ7a28+GQGjg3hsU2BAP474dfOOVZiTDLWWxsB\n" +
|
||||||
|
"wxfzOAQxXDhgR9xd/Lk3MNJxDg==\n" +
|
||||||
|
"=YAt0\n" +
|
||||||
|
"-----END PGP PRIVATE KEY BLOCK-----";
|
||||||
|
PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(KEY);
|
||||||
|
assertNotNull(secretKeys);
|
||||||
|
PGPainless.modifyKeyRing(secretKeys)
|
||||||
|
.setExpirationDate(new Date(), SecretKeyRingProtector.unprotectedKeys())
|
||||||
|
.done();
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,7 @@ To start using pgpainless-sop in your code, include the following lines in your
|
||||||
...
|
...
|
||||||
dependencies {
|
dependencies {
|
||||||
...
|
...
|
||||||
implementation "org.pgpainless:pgpainless-sop:1.6.2"
|
implementation "org.pgpainless:pgpainless-sop:1.6.4"
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ dependencies {
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.pgpainless</groupId>
|
<groupId>org.pgpainless</groupId>
|
||||||
<artifactId>pgpainless-sop</artifactId>
|
<artifactId>pgpainless-sop</artifactId>
|
||||||
<version>1.6.2</version>
|
<version>1.6.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
...
|
...
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
ext {
|
ext {
|
||||||
shortVersion = '1.6.3'
|
shortVersion = '1.6.4'
|
||||||
isSnapshot = true
|
isSnapshot = false
|
||||||
pgpainlessMinAndroidSdk = 10
|
pgpainlessMinAndroidSdk = 10
|
||||||
javaSourceCompatibility = 1.8
|
javaSourceCompatibility = 1.8
|
||||||
bouncyCastleVersion = '1.76'
|
bouncyCastleVersion = '1.77'
|
||||||
bouncyPgVersion = bouncyCastleVersion
|
bouncyPgVersion = bouncyCastleVersion
|
||||||
junitVersion = '5.8.2'
|
junitVersion = '5.8.2'
|
||||||
logbackVersion = '1.2.11'
|
logbackVersion = '1.4.13'
|
||||||
mockitoVersion = '4.5.1'
|
mockitoVersion = '4.5.1'
|
||||||
slf4jVersion = '1.7.36'
|
slf4jVersion = '1.7.36'
|
||||||
sopJavaVersion = '7.0.0'
|
sopJavaVersion = '7.0.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue