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:
parent
6f48a1a261
commit
e07998f99d
1 changed files with 10 additions and 7 deletions
|
@ -10,6 +10,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSignature;
|
import org.bouncycastle.openpgp.PGPSignature;
|
||||||
import org.bouncycastle.util.io.Streams;
|
import org.bouncycastle.util.io.Streams;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.encryption_signing.EncryptionBuilderInterface;
|
||||||
import org.pgpainless.encryption_signing.EncryptionStream;
|
import org.pgpainless.encryption_signing.EncryptionStream;
|
||||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||||
import org.pgpainless.sop.Print;
|
import org.pgpainless.sop.Print;
|
||||||
|
@ -48,13 +49,15 @@ public class Sign implements Runnable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
EncryptionStream encryptionStream = PGPainless.createEncryptor()
|
EncryptionBuilderInterface.DocumentType documentType = PGPainless.encryptAndOrSign()
|
||||||
.onOutputStream(out)
|
.onOutputStream(out)
|
||||||
.doNotEncrypt()
|
.doNotEncrypt()
|
||||||
.createDetachedSignature()
|
.createDetachedSignature()
|
||||||
.signWith(new UnprotectedKeysProtector(), secretKeys)
|
.signWith(new UnprotectedKeysProtector(), secretKeys);
|
||||||
.noArmor();
|
|
||||||
|
EncryptionBuilderInterface.Armor armor = type == Type.text ? documentType.signCanonicalText() : documentType.signBinaryDocument();
|
||||||
|
EncryptionStream encryptionStream = noArmor ? armor.noArmor() : armor.asciiArmor();
|
||||||
|
|
||||||
Streams.pipeAll(System.in, encryptionStream);
|
Streams.pipeAll(System.in, encryptionStream);
|
||||||
encryptionStream.close();
|
encryptionStream.close();
|
||||||
|
|
Loading…
Reference in a new issue