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

Rename syntax checker enums to screaming snake case

This commit is contained in:
Paul Schaub 2023-08-24 16:35:40 +02:00
parent d27cd7f3f5
commit a3ab5de2f5
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
7 changed files with 108 additions and 108 deletions

View file

@ -342,7 +342,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
private void processLiteralData() throws IOException { private void processLiteralData() throws IOException {
LOGGER.debug("Literal Data Packet at depth " + metadata.depth + " encountered"); LOGGER.debug("Literal Data Packet at depth " + metadata.depth + " encountered");
syntaxVerifier.next(InputSymbol.LiteralData); syntaxVerifier.next(InputSymbol.LITERAL_DATA);
PGPLiteralData literalData = packetInputStream.readLiteralData(); PGPLiteralData literalData = packetInputStream.readLiteralData();
// Extract Metadata // Extract Metadata
this.metadata.setChild(new MessageMetadata.LiteralData( this.metadata.setChild(new MessageMetadata.LiteralData(
@ -354,7 +354,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
} }
private void processCompressedData() throws IOException, PGPException { private void processCompressedData() throws IOException, PGPException {
syntaxVerifier.next(InputSymbol.CompressedData); syntaxVerifier.next(InputSymbol.COMPRESSED_DATA);
signatures.enterNesting(); signatures.enterNesting();
PGPCompressedData compressedData = packetInputStream.readCompressedData(); PGPCompressedData compressedData = packetInputStream.readCompressedData();
// Extract Metadata // Extract Metadata
@ -368,7 +368,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
} }
private void processOnePassSignature() throws PGPException, IOException { private void processOnePassSignature() throws PGPException, IOException {
syntaxVerifier.next(InputSymbol.OnePassSignature); syntaxVerifier.next(InputSymbol.ONE_PASS_SIGNATURE);
PGPOnePassSignature onePassSignature = packetInputStream.readOnePassSignature(); PGPOnePassSignature onePassSignature = packetInputStream.readOnePassSignature();
LOGGER.debug("One-Pass-Signature Packet by key " + KeyIdUtil.formatKeyId(onePassSignature.getKeyID()) + LOGGER.debug("One-Pass-Signature Packet by key " + KeyIdUtil.formatKeyId(onePassSignature.getKeyID()) +
" at depth " + metadata.depth + " encountered"); " at depth " + metadata.depth + " encountered");
@ -377,8 +377,8 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
private void processSignature() throws PGPException, IOException { private void processSignature() throws PGPException, IOException {
// true if Signature corresponds to OnePassSignature // true if Signature corresponds to OnePassSignature
boolean isSigForOPS = syntaxVerifier.peekStack() == StackSymbol.ops; boolean isSigForOPS = syntaxVerifier.peekStack() == StackSymbol.OPS;
syntaxVerifier.next(InputSymbol.Signature); syntaxVerifier.next(InputSymbol.SIGNATURE);
PGPSignature signature; PGPSignature signature;
try { try {
signature = packetInputStream.readSignature(); signature = packetInputStream.readSignature();
@ -404,7 +404,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
private boolean processEncryptedData() throws IOException, PGPException { private boolean processEncryptedData() throws IOException, PGPException {
LOGGER.debug("Symmetrically Encrypted Data Packet at depth " + metadata.depth + " encountered"); LOGGER.debug("Symmetrically Encrypted Data Packet at depth " + metadata.depth + " encountered");
syntaxVerifier.next(InputSymbol.EncryptedData); syntaxVerifier.next(InputSymbol.ENCRYPTED_DATA);
PGPEncryptedDataList encDataList = packetInputStream.readEncryptedDataList(); PGPEncryptedDataList encDataList = packetInputStream.readEncryptedDataList();
if (!encDataList.isIntegrityProtected()) { if (!encDataList.isIntegrityProtected()) {
@ -749,7 +749,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
throws IOException { throws IOException {
if (nestedInputStream == null) { if (nestedInputStream == null) {
if (packetInputStream != null) { if (packetInputStream != null) {
syntaxVerifier.next(InputSymbol.EndOfSequence); syntaxVerifier.next(InputSymbol.END_OF_SEQUENCE);
syntaxVerifier.assertValid(); syntaxVerifier.assertValid();
} }
return -1; return -1;
@ -780,7 +780,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
super.close(); super.close();
if (closed) { if (closed) {
if (packetInputStream != null) { if (packetInputStream != null) {
syntaxVerifier.next(InputSymbol.EndOfSequence); syntaxVerifier.next(InputSymbol.END_OF_SEQUENCE);
syntaxVerifier.assertValid(); syntaxVerifier.assertValid();
} }
return; return;
@ -799,7 +799,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
} }
if (packetInputStream != null) { if (packetInputStream != null) {
syntaxVerifier.next(InputSymbol.EndOfSequence); syntaxVerifier.next(InputSymbol.END_OF_SEQUENCE);
syntaxVerifier.assertValid(); syntaxVerifier.assertValid();
packetInputStream.close(); packetInputStream.close();
} }

View file

@ -8,32 +8,32 @@ enum class InputSymbol {
/** /**
* A [PGPLiteralData] packet. * A [PGPLiteralData] packet.
*/ */
LiteralData, LITERAL_DATA,
/** /**
* A [PGPSignatureList] object. * A [PGPSignatureList] object.
*/ */
Signature, SIGNATURE,
/** /**
* A [PGPOnePassSignatureList] object. * A [PGPOnePassSignatureList] object.
*/ */
OnePassSignature, ONE_PASS_SIGNATURE,
/** /**
* A [PGPCompressedData] packet. * A [PGPCompressedData] packet.
* The contents of this packet MUST form a valid OpenPGP message, so a nested PDA is opened to verify * The contents of this packet MUST form a valid OpenPGP message, so a nested PDA is opened to verify
* its nested packet sequence. * its nested packet sequence.
*/ */
CompressedData, COMPRESSED_DATA,
/** /**
* A [PGPEncryptedDataList] object. * A [PGPEncryptedDataList] object.
* This object combines multiple ESKs and the corresponding Symmetrically Encrypted * This object combines multiple ESKs and the corresponding Symmetrically Encrypted
* (possibly Integrity Protected) Data packet. * (possibly Integrity Protected) Data packet.
*/ */
EncryptedData, ENCRYPTED_DATA,
/** /**
* Marks the end of a (sub-) sequence. * Marks the end of a (sub-) sequence.
* This input is given if the end of an OpenPGP message is reached. * This input is given if the end of an OpenPGP message is reached.
* This might be the case for the end of the whole ciphertext, or the end of a packet with nested contents * This might be the case for the end of the whole ciphertext, or the end of a packet with nested contents
* (e.g. the end of a Compressed Data packet). * (e.g. the end of a Compressed Data packet).
*/ */
EndOfSequence END_OF_SEQUENCE
} }

View file

@ -17,72 +17,72 @@ class OpenPgpMessageSyntax : Syntax {
override fun transition(from: State, input: InputSymbol, stackItem: StackSymbol?): Transition { override fun transition(from: State, input: InputSymbol, stackItem: StackSymbol?): Transition {
return when (from) { return when (from) {
State.OpenPgpMessage -> fromOpenPgpMessage(input, stackItem) State.OPENPGP_MESSAGE -> fromOpenPgpMessage(input, stackItem)
State.LiteralMessage -> fromLiteralMessage(input, stackItem) State.LITERAL_MESSAGE -> fromLiteralMessage(input, stackItem)
State.CompressedMessage -> fromCompressedMessage(input, stackItem) State.COMPRESSED_MESSAGE -> fromCompressedMessage(input, stackItem)
State.EncryptedMessage -> fromEncryptedMessage(input, stackItem) State.ENCRYPTED_MESSAGE -> fromEncryptedMessage(input, stackItem)
State.Valid -> fromValid(input, stackItem) State.VALID -> fromValid(input, stackItem)
else -> throw MalformedOpenPgpMessageException(from, input, stackItem) else -> throw MalformedOpenPgpMessageException(from, input, stackItem)
} }
} }
fun fromOpenPgpMessage(input: InputSymbol, stackItem: StackSymbol?): Transition { fun fromOpenPgpMessage(input: InputSymbol, stackItem: StackSymbol?): Transition {
if (stackItem !== StackSymbol.msg) { if (stackItem !== StackSymbol.MSG) {
throw MalformedOpenPgpMessageException(State.OpenPgpMessage, input, stackItem) throw MalformedOpenPgpMessageException(State.OPENPGP_MESSAGE, input, stackItem)
} }
return when (input) { return when (input) {
InputSymbol.LiteralData -> Transition(State.LiteralMessage) InputSymbol.LITERAL_DATA -> Transition(State.LITERAL_MESSAGE)
InputSymbol.Signature -> Transition(State.OpenPgpMessage, StackSymbol.msg) InputSymbol.SIGNATURE -> Transition(State.OPENPGP_MESSAGE, StackSymbol.MSG)
InputSymbol.OnePassSignature -> Transition(State.OpenPgpMessage, StackSymbol.ops, StackSymbol.msg) InputSymbol.ONE_PASS_SIGNATURE -> Transition(State.OPENPGP_MESSAGE, StackSymbol.OPS, StackSymbol.MSG)
InputSymbol.CompressedData -> Transition(State.CompressedMessage) InputSymbol.COMPRESSED_DATA -> Transition(State.COMPRESSED_MESSAGE)
InputSymbol.EncryptedData -> Transition(State.EncryptedMessage) InputSymbol.ENCRYPTED_DATA -> Transition(State.ENCRYPTED_MESSAGE)
InputSymbol.EndOfSequence -> throw MalformedOpenPgpMessageException(State.OpenPgpMessage, input, stackItem) InputSymbol.END_OF_SEQUENCE -> throw MalformedOpenPgpMessageException(State.OPENPGP_MESSAGE, input, stackItem)
else -> throw MalformedOpenPgpMessageException(State.OpenPgpMessage, input, stackItem) else -> throw MalformedOpenPgpMessageException(State.OPENPGP_MESSAGE, input, stackItem)
} }
} }
@Throws(MalformedOpenPgpMessageException::class) @Throws(MalformedOpenPgpMessageException::class)
fun fromLiteralMessage(input: InputSymbol, stackItem: StackSymbol?): Transition { fun fromLiteralMessage(input: InputSymbol, stackItem: StackSymbol?): Transition {
if (input == InputSymbol.Signature && stackItem == StackSymbol.ops) { if (input == InputSymbol.SIGNATURE && stackItem == StackSymbol.OPS) {
return Transition(State.LiteralMessage) return Transition(State.LITERAL_MESSAGE)
} }
if (input == InputSymbol.EndOfSequence && stackItem == StackSymbol.terminus) { if (input == InputSymbol.END_OF_SEQUENCE && stackItem == StackSymbol.TERMINUS) {
return Transition(State.Valid) return Transition(State.VALID)
} }
throw MalformedOpenPgpMessageException(State.LiteralMessage, input, stackItem) throw MalformedOpenPgpMessageException(State.LITERAL_MESSAGE, input, stackItem)
} }
@Throws(MalformedOpenPgpMessageException::class) @Throws(MalformedOpenPgpMessageException::class)
fun fromCompressedMessage(input: InputSymbol, stackItem: StackSymbol?): Transition { fun fromCompressedMessage(input: InputSymbol, stackItem: StackSymbol?): Transition {
if (input == InputSymbol.Signature && stackItem == StackSymbol.ops) { if (input == InputSymbol.SIGNATURE && stackItem == StackSymbol.OPS) {
return Transition(State.CompressedMessage) return Transition(State.COMPRESSED_MESSAGE)
} }
if (input == InputSymbol.EndOfSequence && stackItem == StackSymbol.terminus) { if (input == InputSymbol.END_OF_SEQUENCE && stackItem == StackSymbol.TERMINUS) {
return Transition(State.Valid) return Transition(State.VALID)
} }
throw MalformedOpenPgpMessageException(State.CompressedMessage, input, stackItem) throw MalformedOpenPgpMessageException(State.COMPRESSED_MESSAGE, input, stackItem)
} }
@Throws(MalformedOpenPgpMessageException::class) @Throws(MalformedOpenPgpMessageException::class)
fun fromEncryptedMessage(input: InputSymbol, stackItem: StackSymbol?): Transition { fun fromEncryptedMessage(input: InputSymbol, stackItem: StackSymbol?): Transition {
if (input == InputSymbol.Signature && stackItem == StackSymbol.ops) { if (input == InputSymbol.SIGNATURE && stackItem == StackSymbol.OPS) {
return Transition(State.EncryptedMessage) return Transition(State.ENCRYPTED_MESSAGE)
} }
if (input == InputSymbol.EndOfSequence && stackItem == StackSymbol.terminus) { if (input == InputSymbol.END_OF_SEQUENCE && stackItem == StackSymbol.TERMINUS) {
return Transition(State.Valid) return Transition(State.VALID)
} }
throw MalformedOpenPgpMessageException(State.EncryptedMessage, input, stackItem) throw MalformedOpenPgpMessageException(State.ENCRYPTED_MESSAGE, input, stackItem)
} }
@Throws(MalformedOpenPgpMessageException::class) @Throws(MalformedOpenPgpMessageException::class)
fun fromValid(input: InputSymbol, stackItem: StackSymbol?): Transition { fun fromValid(input: InputSymbol, stackItem: StackSymbol?): Transition {
if (input == InputSymbol.EndOfSequence) { if (input == InputSymbol.END_OF_SEQUENCE) {
// allow subsequent read() calls. // allow subsequent read() calls.
return Transition(State.Valid) return Transition(State.VALID)
} }
throw MalformedOpenPgpMessageException(State.Valid, input, stackItem) throw MalformedOpenPgpMessageException(State.VALID, input, stackItem)
} }
} }

View file

@ -33,7 +33,7 @@ class PDA constructor(
/** /**
* Default constructor which initializes the PDA to work with the [OpenPgpMessageSyntax]. * Default constructor which initializes the PDA to work with the [OpenPgpMessageSyntax].
*/ */
constructor(): this(OpenPgpMessageSyntax(), State.OpenPgpMessage, StackSymbol.terminus, StackSymbol.msg) constructor(): this(OpenPgpMessageSyntax(), State.OPENPGP_MESSAGE, StackSymbol.TERMINUS, StackSymbol.MSG)
/** /**
* Process the next [InputSymbol]. * Process the next [InputSymbol].
@ -78,7 +78,7 @@ class PDA constructor(
* *
* @return true if valid, false otherwise * @return true if valid, false otherwise
*/ */
fun isValid(): Boolean = state == State.Valid && stack.isEmpty() fun isValid(): Boolean = state == State.VALID && stack.isEmpty()
/** /**
* Throw a [MalformedOpenPgpMessageException] if the pda is not in a valid state right now. * Throw a [MalformedOpenPgpMessageException] if the pda is not in a valid state right now.

View file

@ -8,13 +8,13 @@ enum class StackSymbol {
/** /**
* OpenPGP Message. * OpenPGP Message.
*/ */
msg, MSG,
/** /**
* OnePassSignature (in case of BC this represents a OnePassSignatureList). * OnePassSignature (in case of BC this represents a OnePassSignatureList).
*/ */
ops, OPS,
/** /**
* Special symbol representing the end of the message. * Special symbol representing the end of the message.
*/ */
terminus TERMINUS
} }

View file

@ -8,9 +8,9 @@ package org.pgpainless.decryption_verification.syntax_check
* Set of states of the automaton. * Set of states of the automaton.
*/ */
enum class State { enum class State {
OpenPgpMessage, OPENPGP_MESSAGE,
LiteralMessage, LITERAL_MESSAGE,
CompressedMessage, COMPRESSED_MESSAGE,
EncryptedMessage, ENCRYPTED_MESSAGE,
Valid VALID
} }

View file

@ -21,8 +21,8 @@ public class PDATest {
@Test @Test
public void testSimpleLiteralMessageIsValid() throws MalformedOpenPgpMessageException { public void testSimpleLiteralMessageIsValid() throws MalformedOpenPgpMessageException {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@ -35,10 +35,10 @@ public class PDATest {
@Test @Test
public void testSimpleOpsSignedMesssageIsValid() throws MalformedOpenPgpMessageException { public void testSimpleOpsSignedMesssageIsValid() throws MalformedOpenPgpMessageException {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@ -52,9 +52,9 @@ public class PDATest {
@Test @Test
public void testSimplePrependSignedMessageIsValid() throws MalformedOpenPgpMessageException { public void testSimplePrependSignedMessageIsValid() throws MalformedOpenPgpMessageException {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@ -68,11 +68,11 @@ public class PDATest {
@Test @Test
public void testOPSSignedCompressedMessageIsValid() throws MalformedOpenPgpMessageException { public void testOPSSignedCompressedMessageIsValid() throws MalformedOpenPgpMessageException {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.CompressedData); check.next(InputSymbol.COMPRESSED_DATA);
// Here would be a nested PDA for the LiteralData packet // Here would be a nested PDA for the LiteralData packet
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@ -80,105 +80,105 @@ public class PDATest {
@Test @Test
public void testOPSSignedEncryptedMessageIsValid() { public void testOPSSignedEncryptedMessageIsValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.EncryptedData); check.next(InputSymbol.ENCRYPTED_DATA);
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@Test @Test
public void anyInputAfterEOSIsNotValid() { public void anyInputAfterEOSIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.Signature)); () -> check.next(InputSymbol.SIGNATURE));
} }
@Test @Test
public void testEncryptedMessageWithAppendedStandaloneSigIsNotValid() { public void testEncryptedMessageWithAppendedStandaloneSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.EncryptedData); check.next(InputSymbol.ENCRYPTED_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.Signature)); () -> check.next(InputSymbol.SIGNATURE));
} }
@Test @Test
public void testOPSSignedEncryptedMessageWithMissingSigIsNotValid() { public void testOPSSignedEncryptedMessageWithMissingSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.EncryptedData); check.next(InputSymbol.ENCRYPTED_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.EndOfSequence)); () -> check.next(InputSymbol.END_OF_SEQUENCE));
} }
@Test @Test
public void testTwoLiteralDataIsNotValid() { public void testTwoLiteralDataIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.LiteralData)); () -> check.next(InputSymbol.LITERAL_DATA));
} }
@Test @Test
public void testTrailingSigIsNotValid() { public void testTrailingSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.Signature)); () -> check.next(InputSymbol.SIGNATURE));
} }
@Test @Test
public void testOPSAloneIsNotValid() { public void testOPSAloneIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.EndOfSequence)); () -> check.next(InputSymbol.END_OF_SEQUENCE));
} }
@Test @Test
public void testOPSLitWithMissingSigIsNotValid() { public void testOPSLitWithMissingSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.EndOfSequence)); () -> check.next(InputSymbol.END_OF_SEQUENCE));
} }
@Test @Test
public void testCompressedMessageWithStandalongAppendedSigIsNotValid() { public void testCompressedMessageWithStandalongAppendedSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.CompressedData); check.next(InputSymbol.COMPRESSED_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.Signature)); () -> check.next(InputSymbol.SIGNATURE));
} }
@Test @Test
public void testOPSCompressedDataWithMissingSigIsNotValid() { public void testOPSCompressedDataWithMissingSigIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.CompressedData); check.next(InputSymbol.COMPRESSED_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.EndOfSequence)); () -> check.next(InputSymbol.END_OF_SEQUENCE));
} }
@Test @Test
public void testCompressedMessageFollowedByTrailingLiteralDataIsNotValid() { public void testCompressedMessageFollowedByTrailingLiteralDataIsNotValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.CompressedData); check.next(InputSymbol.COMPRESSED_DATA);
assertThrows(MalformedOpenPgpMessageException.class, assertThrows(MalformedOpenPgpMessageException.class,
() -> check.next(InputSymbol.LiteralData)); () -> check.next(InputSymbol.LITERAL_DATA));
} }
@Test @Test
public void testOPSWithPrependedSigIsValid() { public void testOPSWithPrependedSigIsValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }
@ -186,11 +186,11 @@ public class PDATest {
@Test @Test
public void testPrependedSigInsideOPSSignedMessageIsValid() { public void testPrependedSigInsideOPSSignedMessageIsValid() {
PDA check = new PDA(); PDA check = new PDA();
check.next(InputSymbol.OnePassSignature); check.next(InputSymbol.ONE_PASS_SIGNATURE);
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.LiteralData); check.next(InputSymbol.LITERAL_DATA);
check.next(InputSymbol.Signature); check.next(InputSymbol.SIGNATURE);
check.next(InputSymbol.EndOfSequence); check.next(InputSymbol.END_OF_SEQUENCE);
assertTrue(check.isValid()); assertTrue(check.isValid());
} }