1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 02:39:39 +02:00

Add EncryptionBuilder.discardOutput()

Also move NullOutputStream from pgpainless-sop to pgpainless-core
This commit is contained in:
Paul Schaub 2024-03-29 20:37:24 +01:00
parent 80cf1a7446
commit b96f22d0a9
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 18 additions and 8 deletions

View file

@ -53,15 +53,10 @@ class DetachedSignImpl : DetachedSign {
}
}
// When creating a detached signature, the output of the signing stream is actually
// the unmodified plaintext data, so we can discard it.
// The detached signature will later be retrieved from the metadata object instead.
val sink = NullOutputStream()
try {
val signingStream =
PGPainless.encryptAndOrSign()
.onOutputStream(sink)
.discardOutput()
.withOptions(ProducerOptions.sign(signingOptions).setAsciiArmor(armor))
return object : ReadyWithResult<SigningResult>() {

View file

@ -1,31 +0,0 @@
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.sop
import java.io.OutputStream
/** [OutputStream] that simply discards bytes written to it. */
class NullOutputStream : OutputStream() {
override fun write(p0: Int) {
// nop
}
override fun write(b: ByteArray) {
// nop
}
override fun write(b: ByteArray, off: Int, len: Int) {
// nop
}
override fun close() {
// nop
}
override fun flush() {
// nop
}
}