1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-22 20:32:05 +01:00

SOP: Respect signature type

This commit is contained in:
Paul Schaub 2020-12-16 16:43:58 +01:00
parent 6f48a1a261
commit e07998f99d

View file

@ -10,6 +10,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.util.io.Streams;
import org.pgpainless.PGPainless;
import org.pgpainless.encryption_signing.EncryptionBuilderInterface;
import org.pgpainless.encryption_signing.EncryptionStream;
import org.pgpainless.key.protection.UnprotectedKeysProtector;
import org.pgpainless.sop.Print;
@ -49,12 +50,14 @@ public class Sign implements Runnable {
}
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
EncryptionStream encryptionStream = PGPainless.createEncryptor()
EncryptionBuilderInterface.DocumentType documentType = PGPainless.encryptAndOrSign()
.onOutputStream(out)
.doNotEncrypt()
.createDetachedSignature()
.signWith(new UnprotectedKeysProtector(), secretKeys)
.noArmor();
.signWith(new UnprotectedKeysProtector(), secretKeys);
EncryptionBuilderInterface.Armor armor = type == Type.text ? documentType.signCanonicalText() : documentType.signBinaryDocument();
EncryptionStream encryptionStream = noArmor ? armor.noArmor() : armor.asciiArmor();
Streams.pipeAll(System.in, encryptionStream);
encryptionStream.close();