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

Port OpenPGPInputStream to Kotlin as OpenPGPAnimalSnifferInputStream

This commit is contained in:
Paul Schaub 2025-05-08 14:38:48 +02:00
parent bef30223fa
commit 62fe69db75
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
8 changed files with 340 additions and 367 deletions

View file

@ -10,7 +10,7 @@ import java.io.OutputStream
import kotlin.jvm.Throws
import org.bouncycastle.util.io.Streams
import org.pgpainless.PGPainless
import org.pgpainless.decryption_verification.OpenPgpInputStream
import org.pgpainless.decryption_verification.OpenPGPAnimalSnifferInputStream
import org.pgpainless.util.ArmoredOutputStreamFactory
import sop.Ready
import sop.exception.SOPGPException
@ -27,7 +27,7 @@ class ArmorImpl(private val api: PGPainless) : Armor {
val bufferedOutputStream = BufferedOutputStream(outputStream)
// Determine the nature of the given data
val openPgpIn = OpenPgpInputStream(data)
val openPgpIn = OpenPGPAnimalSnifferInputStream(data)
openPgpIn.reset()
if (openPgpIn.isAsciiArmored) {

View file

@ -15,7 +15,7 @@ import org.bouncycastle.openpgp.PGPOnePassSignatureList
import org.bouncycastle.openpgp.PGPSignatureList
import org.bouncycastle.util.io.Streams
import org.pgpainless.PGPainless
import org.pgpainless.decryption_verification.OpenPgpInputStream
import org.pgpainless.decryption_verification.OpenPGPAnimalSnifferInputStream
import org.pgpainless.decryption_verification.cleartext_signatures.ClearsignedMessageUtil
import org.pgpainless.exception.WrongConsumingMethodException
import org.pgpainless.util.ArmoredOutputStreamFactory
@ -35,7 +35,7 @@ class InlineDetachImpl(private val api: PGPainless) : InlineDetach {
private val sigOut = ByteArrayOutputStream()
override fun writeTo(outputStream: OutputStream): Signatures {
var pgpIn = OpenPgpInputStream(messageInputStream)
var pgpIn = OpenPGPAnimalSnifferInputStream(messageInputStream)
if (pgpIn.isNonOpenPgp) {
throw SOPGPException.BadData("Data appears to be non-OpenPGP.")
}
@ -61,7 +61,7 @@ class InlineDetachImpl(private val api: PGPainless) : InlineDetach {
}
// else just dearmor
pgpIn = OpenPgpInputStream(armorIn)
pgpIn = OpenPGPAnimalSnifferInputStream(armorIn)
}
// If data was not using cleartext signature framework