diff --git a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt index 40ac811d..2a5dd6e7 100644 --- a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt +++ b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/ArmorImpl.kt @@ -14,6 +14,7 @@ import org.pgpainless.util.ArmoredOutputStreamFactory import sop.Ready import sop.exception.SOPGPException import sop.operation.Armor +import java.io.IOException /** Implementation of the `armor` operation using PGPainless. */ class ArmorImpl : Armor { @@ -26,8 +27,14 @@ class ArmorImpl : Armor { val bufferedOutputStream = BufferedOutputStream(outputStream) // Determine the nature of the given data - val openPgpIn = OpenPgpInputStream(data) - openPgpIn.reset() + val openPgpIn = OpenPgpInputStream(data, false).apply { + try { + inspectBuffer() + } catch (e: IOException) { + // ignore + } + reset() + } if (openPgpIn.isAsciiArmored) { // armoring already-armored data is an idempotent operation