Skip to content

Commit

Permalink
OPS packet: throw UnsupportedPacketVersionException for version other…
Browse files Browse the repository at this point in the history
… than 3,6
  • Loading branch information
vanitasvitae committed Apr 22, 2024
1 parent 128ec07 commit f86327d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pg/src/main/java/org/bouncycastle/bcpg/OnePassSignaturePacket.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.bouncycastle.bcpg;

import org.bouncycastle.util.io.Streams;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

Expand Down Expand Up @@ -32,9 +34,12 @@ public class OnePassSignaturePacket
hashAlgorithm = in.read();
keyAlgorithm = in.read();

if (version == VERSION_3) {
if (version == VERSION_3)
{
keyID = StreamUtil.readKeyID(in);
} else if (version == VERSION_6) {
}
else if (version == VERSION_6)
{
int saltLen = in.read();
if (saltLen < 0) {
throw new IOException("Version 6 OPS packet has invalid salt length.");
Expand All @@ -45,6 +50,11 @@ public class OnePassSignaturePacket
fingerprint = new byte[32];
in.readFully(fingerprint);
}
else
{
Streams.drain(in);
throw new UnsupportedPacketVersionException("Unsupported OnePassSignature packet version encountered: " + version);
}

isContaining = in.read();
}
Expand Down

0 comments on commit f86327d

Please sign in to comment.