Compare commits
2 Commits
80cf1a7446
...
1f9b65e3d2
Author | SHA1 | Date |
---|---|---|
Paul Schaub | 1f9b65e3d2 | |
Paul Schaub | b96f22d0a9 |
|
@ -1,2 +1,3 @@
|
||||||
myst-parser>=0.17
|
myst-parser>=0.17
|
||||||
sphinxcontrib-mermaid>=0.7.1
|
sphinxcontrib-mermaid>=0.7.1
|
||||||
|
sphinx_rtd_theme>=2.0.0
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.pgpainless.PGPainless.Companion.getPolicy
|
||||||
import org.pgpainless.algorithm.CompressionAlgorithm
|
import org.pgpainless.algorithm.CompressionAlgorithm
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm
|
||||||
import org.pgpainless.algorithm.negotiation.SymmetricKeyAlgorithmNegotiator.Companion.byPopularity
|
import org.pgpainless.algorithm.negotiation.SymmetricKeyAlgorithmNegotiator.Companion.byPopularity
|
||||||
|
import org.pgpainless.util.NullOutputStream
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
@ -19,6 +20,10 @@ class EncryptionBuilder : EncryptionBuilderInterface {
|
||||||
return WithOptionsImpl(outputStream)
|
return WithOptionsImpl(outputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun discardOutput(): EncryptionBuilderInterface.WithOptions {
|
||||||
|
return onOutputStream(NullOutputStream())
|
||||||
|
}
|
||||||
|
|
||||||
class WithOptionsImpl(val outputStream: OutputStream) : EncryptionBuilderInterface.WithOptions {
|
class WithOptionsImpl(val outputStream: OutputStream) : EncryptionBuilderInterface.WithOptions {
|
||||||
|
|
||||||
override fun withOptions(options: ProducerOptions): EncryptionStream {
|
override fun withOptions(options: ProducerOptions): EncryptionStream {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.io.IOException
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import org.bouncycastle.openpgp.PGPException
|
import org.bouncycastle.openpgp.PGPException
|
||||||
|
|
||||||
fun interface EncryptionBuilderInterface {
|
interface EncryptionBuilderInterface {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a [EncryptionStream] wrapping an [OutputStream]. Data that is piped through the
|
* Create a [EncryptionStream] wrapping an [OutputStream]. Data that is piped through the
|
||||||
|
@ -19,6 +19,16 @@ fun interface EncryptionBuilderInterface {
|
||||||
*/
|
*/
|
||||||
fun onOutputStream(outputStream: OutputStream): WithOptions
|
fun onOutputStream(outputStream: OutputStream): WithOptions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an [EncryptionStream] that discards the data after processing it. This is useful, e.g.
|
||||||
|
* for generating detached signatures, where the resulting signature is retrieved from the
|
||||||
|
* [EncryptionResult] once the operation is finished. In this case, the plaintext data does not
|
||||||
|
* need to be retained.
|
||||||
|
*
|
||||||
|
* @return api handle
|
||||||
|
*/
|
||||||
|
fun discardOutput(): WithOptions
|
||||||
|
|
||||||
fun interface WithOptions {
|
fun interface WithOptions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.sop
|
package org.pgpainless.util
|
||||||
|
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
|
|
@ -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 {
|
try {
|
||||||
val signingStream =
|
val signingStream =
|
||||||
PGPainless.encryptAndOrSign()
|
PGPainless.encryptAndOrSign()
|
||||||
.onOutputStream(sink)
|
.discardOutput()
|
||||||
.withOptions(ProducerOptions.sign(signingOptions).setAsciiArmor(armor))
|
.withOptions(ProducerOptions.sign(signingOptions).setAsciiArmor(armor))
|
||||||
|
|
||||||
return object : ReadyWithResult<SigningResult>() {
|
return object : ReadyWithResult<SigningResult>() {
|
||||||
|
|
Loading…
Reference in New Issue