Skip to content

Commit

Permalink
Add test to verify exception behavior when parsing signature of versi…
Browse files Browse the repository at this point in the history
…on 0x99
  • Loading branch information
vanitasvitae committed Apr 22, 2024
1 parent 194c089 commit e45b4ad
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;

public class SignaturePacketTest extends SimpleTest
{
Expand All @@ -28,6 +27,7 @@ public void performTest()
{
testParseV6Signature();
testParseV4Ed25519LegacySignature();
testParseUnknownVersionSignaturePacket();
}

private void testParseV6Signature()
Expand Down Expand Up @@ -132,6 +132,24 @@ private void testParseV4Ed25519LegacySignature() throws IOException {
Arrays.areEqual(encSigPacket, bOut.toByteArray()));
}

private void testParseUnknownVersionSignaturePacket()
{
// Hex-encoded signature with version 0x99
byte[] encSigPacket = Hex.decode("885e990016080006050255f95f95000a09108cfde12197965a9af62200ff56f90cca98e2102637bd983fdb16c131dfd27ed82bf4dde5606e0d756aed33660100d09c4fa11527f038e0f57f2201d82f2ea2c9033265fa6ceb489e854bae61b404");
ByteArrayInputStream bIn = new ByteArrayInputStream(encSigPacket);
BCPGInputStream pIn = new BCPGInputStream(bIn);
Exception ex = testException("unsupported version: 153",
"UnsupportedPacketVersionException",
new TestExceptionOperation() {
@Override
public void operation() throws Exception {
SignaturePacket sig = (SignaturePacket) pIn.readPacket();
}
});
isTrue("Parsing SignaturePacket of version 0x99 MUST throw UnsupportedPacketVersionException.",
ex != null);
}

public static void main(String[] args)
{
runTest(new SignaturePacketTest());
Expand Down

0 comments on commit e45b4ad

Please sign in to comment.