mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 04:42:06 +01:00
Reformat issuer-fingerprint inclusion code
This commit is contained in:
parent
bd04e35a53
commit
b674a412b5
2 changed files with 14 additions and 4 deletions
|
@ -267,7 +267,9 @@ public final class SigningOptions {
|
|||
boolean detached)
|
||||
throws PGPException {
|
||||
SubkeyIdentifier signingKeyIdentifier = new SubkeyIdentifier(secretKey, signingSubkey.getKeyID());
|
||||
PGPSignatureGenerator generator = createSignatureGenerator(secretKey.getSecretKey(signingSubkey.getKeyID()), signingSubkey, hashAlgorithm, signatureType);
|
||||
PGPSecretKey signingSecretKey = secretKey.getSecretKey(signingSubkey.getKeyID());
|
||||
PGPSignatureGenerator generator = createSignatureGenerator(signingSubkey, hashAlgorithm, signatureType);
|
||||
generator.setUnhashedSubpackets(unhashedSubpackets(signingSecretKey).generate());
|
||||
SigningMethod signingMethod = detached ? SigningMethod.detachedSignature(generator) : SigningMethod.inlineSignature(generator);
|
||||
signingMethods.put(signingKeyIdentifier, signingMethod);
|
||||
}
|
||||
|
@ -303,8 +305,7 @@ public final class SigningOptions {
|
|||
return algorithm;
|
||||
}
|
||||
|
||||
private PGPSignatureGenerator createSignatureGenerator(PGPSecretKey secretKey,
|
||||
PGPPrivateKey privateKey,
|
||||
private PGPSignatureGenerator createSignatureGenerator(PGPPrivateKey privateKey,
|
||||
HashAlgorithm hashAlgorithm,
|
||||
DocumentSignatureType signatureType)
|
||||
throws PGPException {
|
||||
|
@ -312,7 +313,6 @@ public final class SigningOptions {
|
|||
PGPContentSignerBuilder signerBuilder = ImplementationFactory.getInstance()
|
||||
.getPGPContentSignerBuilder(publicKeyAlgorithm, hashAlgorithm.getAlgorithmId());
|
||||
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(signerBuilder);
|
||||
signatureGenerator.setUnhashedSubpackets(unhashedSubpackets(secretKey).generate());
|
||||
signatureGenerator.init(signatureType.getSignatureType().getCode(), privateKey);
|
||||
|
||||
return signatureGenerator;
|
||||
|
|
|
@ -79,16 +79,21 @@ public class InvestigateThunderbirdDecryption {
|
|||
|
||||
@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")
|
||||
|
@ -96,7 +101,10 @@ public class InvestigateThunderbirdDecryption {
|
|||
|
||||
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))
|
||||
|
@ -116,6 +124,8 @@ public class InvestigateThunderbirdDecryption {
|
|||
Streams.pipeAll(new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)), encryptionStream);
|
||||
encryptionStream.close();
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(out);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue