1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-25 22:02:05 +01:00

Add support for LibrePGP OED packet

This commit is contained in:
Paul Schaub 2024-10-14 11:58:04 +02:00
parent ad2976dbcc
commit 5dfebc5bde
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 13 additions and 2 deletions

View file

@ -22,6 +22,7 @@ enum class OpenPgpPacket(val tag: Int) {
UATTR(17), UATTR(17),
SEIPD(18), SEIPD(18),
MDC(19), MDC(19),
OED(20),
PADDING(21), PADDING(21),
EXP_1(60), EXP_1(60),
EXP_2(61), EXP_2(61),

View file

@ -163,7 +163,8 @@ class OpenPgpMessageInputStream(
OpenPgpPacket.PKESK, OpenPgpPacket.PKESK,
OpenPgpPacket.SKESK, OpenPgpPacket.SKESK,
OpenPgpPacket.SED, OpenPgpPacket.SED,
OpenPgpPacket.SEIPD -> { OpenPgpPacket.SEIPD,
OpenPgpPacket.OED -> {
if (processEncryptedData()) { if (processEncryptedData()) {
break@layer break@layer
} }
@ -185,6 +186,10 @@ class OpenPgpMessageInputStream(
OpenPgpPacket.UID, OpenPgpPacket.UID,
OpenPgpPacket.UATTR -> OpenPgpPacket.UATTR ->
throw MalformedOpenPgpMessageException("Illegal Packet in Stream: $packet") throw MalformedOpenPgpMessageException("Illegal Packet in Stream: $packet")
OpenPgpPacket.PADDING -> {
LOGGER.debug("Padding packet")
pIn.readPadding()
}
OpenPgpPacket.EXP_1, OpenPgpPacket.EXP_1,
OpenPgpPacket.EXP_2, OpenPgpPacket.EXP_2,
OpenPgpPacket.EXP_3, OpenPgpPacket.EXP_3,
@ -319,7 +324,7 @@ class OpenPgpMessageInputStream(
"Symmetrically Encrypted Data Packet at depth ${layerMetadata.depth} encountered.") "Symmetrically Encrypted Data Packet at depth ${layerMetadata.depth} encountered.")
syntaxVerifier.next(InputSymbol.ENCRYPTED_DATA) syntaxVerifier.next(InputSymbol.ENCRYPTED_DATA)
val encDataList = packetInputStream!!.readEncryptedDataList() val encDataList = packetInputStream!!.readEncryptedDataList()
if (!encDataList.isIntegrityProtected) { if (!encDataList.isIntegrityProtected && !encDataList.get(0).isAEAD) {
LOGGER.warn("Symmetrically Encrypted Data Packet is not integrity-protected.") LOGGER.warn("Symmetrically Encrypted Data Packet is not integrity-protected.")
if (!options.isIgnoreMDCErrors()) { if (!options.isIgnoreMDCErrors()) {
throw MessageNotIntegrityProtectedException() throw MessageNotIntegrityProtectedException()

View file

@ -14,6 +14,7 @@ import org.bouncycastle.openpgp.PGPCompressedData
import org.bouncycastle.openpgp.PGPEncryptedDataList import org.bouncycastle.openpgp.PGPEncryptedDataList
import org.bouncycastle.openpgp.PGPLiteralData import org.bouncycastle.openpgp.PGPLiteralData
import org.bouncycastle.openpgp.PGPOnePassSignature import org.bouncycastle.openpgp.PGPOnePassSignature
import org.bouncycastle.openpgp.PGPPadding
import org.bouncycastle.openpgp.PGPSignature import org.bouncycastle.openpgp.PGPSignature
import org.pgpainless.algorithm.OpenPgpPacket import org.pgpainless.algorithm.OpenPgpPacket
@ -75,6 +76,10 @@ class TeeBCPGInputStream(inputStream: BCPGInputStream, outputStream: OutputStrea
return (readPacket() as MarkerPacket).also { delayedTee.squeeze() } return (readPacket() as MarkerPacket).also { delayedTee.squeeze() }
} }
fun readPadding(): PGPPadding {
return PGPPadding(packetInputStream).also { delayedTee.squeeze() }
}
fun close() { fun close() {
packetInputStream.close() packetInputStream.close()
} }