mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 12:27:58 +01:00
Rename automaton package to syntax_check
This commit is contained in:
parent
380dcf3f65
commit
ef8eb2f55e
7 changed files with 28 additions and 27 deletions
|
@ -43,9 +43,9 @@ import org.pgpainless.algorithm.EncryptionPurpose;
|
||||||
import org.pgpainless.algorithm.OpenPgpPacket;
|
import org.pgpainless.algorithm.OpenPgpPacket;
|
||||||
import org.pgpainless.algorithm.StreamEncoding;
|
import org.pgpainless.algorithm.StreamEncoding;
|
||||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||||
import org.pgpainless.decryption_verification.automaton.InputAlphabet;
|
import org.pgpainless.decryption_verification.syntax_check.InputAlphabet;
|
||||||
import org.pgpainless.decryption_verification.automaton.PDA;
|
import org.pgpainless.decryption_verification.syntax_check.PDA;
|
||||||
import org.pgpainless.decryption_verification.automaton.StackAlphabet;
|
import org.pgpainless.decryption_verification.syntax_check.StackAlphabet;
|
||||||
import org.pgpainless.decryption_verification.cleartext_signatures.ClearsignedMessageUtil;
|
import org.pgpainless.decryption_verification.cleartext_signatures.ClearsignedMessageUtil;
|
||||||
import org.pgpainless.decryption_verification.cleartext_signatures.MultiPassStrategy;
|
import org.pgpainless.decryption_verification.cleartext_signatures.MultiPassStrategy;
|
||||||
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
||||||
|
@ -80,7 +80,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
// Options to consume the data
|
// Options to consume the data
|
||||||
protected final ConsumerOptions options;
|
protected final ConsumerOptions options;
|
||||||
// Pushdown Automaton to verify validity of OpenPGP packet sequence in an OpenPGP message
|
// Pushdown Automaton to verify validity of OpenPGP packet sequence in an OpenPGP message
|
||||||
protected final PDA automaton = new PDA();
|
protected final PDA syntaxVerifier = new PDA();
|
||||||
// InputStream of OpenPGP packets
|
// InputStream of OpenPGP packets
|
||||||
protected TeeBCPGInputStream packetInputStream;
|
protected TeeBCPGInputStream packetInputStream;
|
||||||
// InputStream of a nested data packet
|
// InputStream of a nested data packet
|
||||||
|
@ -266,7 +266,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");
|
||||||
automaton.next(InputAlphabet.LiteralData);
|
syntaxVerifier.next(InputAlphabet.LiteralData);
|
||||||
PGPLiteralData literalData = packetInputStream.readLiteralData();
|
PGPLiteralData literalData = packetInputStream.readLiteralData();
|
||||||
this.metadata.setChild(new MessageMetadata.LiteralData(
|
this.metadata.setChild(new MessageMetadata.LiteralData(
|
||||||
literalData.getFileName(),
|
literalData.getFileName(),
|
||||||
|
@ -276,7 +276,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processCompressedData() throws IOException, PGPException {
|
private void processCompressedData() throws IOException, PGPException {
|
||||||
automaton.next(InputAlphabet.CompressedData);
|
syntaxVerifier.next(InputAlphabet.CompressedData);
|
||||||
signatures.enterNesting();
|
signatures.enterNesting();
|
||||||
PGPCompressedData compressedData = packetInputStream.readCompressedData();
|
PGPCompressedData compressedData = packetInputStream.readCompressedData();
|
||||||
MessageMetadata.CompressedData compressionLayer = new MessageMetadata.CompressedData(
|
MessageMetadata.CompressedData compressionLayer = new MessageMetadata.CompressedData(
|
||||||
|
@ -288,7 +288,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOnePassSignature() throws PGPException, IOException {
|
private void processOnePassSignature() throws PGPException, IOException {
|
||||||
automaton.next(InputAlphabet.OnePassSignature);
|
syntaxVerifier.next(InputAlphabet.OnePassSignature);
|
||||||
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");
|
||||||
|
@ -297,8 +297,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 = automaton.peekStack() == StackAlphabet.ops;
|
boolean isSigForOPS = syntaxVerifier.peekStack() == StackAlphabet.ops;
|
||||||
automaton.next(InputAlphabet.Signature);
|
syntaxVerifier.next(InputAlphabet.Signature);
|
||||||
PGPSignature signature = packetInputStream.readSignature();
|
PGPSignature signature = packetInputStream.readSignature();
|
||||||
long keyId = SignatureUtils.determineIssuerKeyId(signature);
|
long keyId = SignatureUtils.determineIssuerKeyId(signature);
|
||||||
if (isSigForOPS) {
|
if (isSigForOPS) {
|
||||||
|
@ -317,7 +317,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");
|
||||||
automaton.next(InputAlphabet.EncryptedData);
|
syntaxVerifier.next(InputAlphabet.EncryptedData);
|
||||||
PGPEncryptedDataList encDataList = packetInputStream.readEncryptedDataList();
|
PGPEncryptedDataList encDataList = packetInputStream.readEncryptedDataList();
|
||||||
|
|
||||||
// TODO: Replace with !encDataList.isIntegrityProtected()
|
// TODO: Replace with !encDataList.isIntegrityProtected()
|
||||||
|
@ -601,7 +601,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (nestedInputStream == null) {
|
if (nestedInputStream == null) {
|
||||||
automaton.assertValid();
|
syntaxVerifier.assertValid();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
|
|
||||||
if (nestedInputStream == null) {
|
if (nestedInputStream == null) {
|
||||||
if (packetInputStream != null) {
|
if (packetInputStream != null) {
|
||||||
automaton.assertValid();
|
syntaxVerifier.assertValid();
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,7 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
super.close();
|
super.close();
|
||||||
if (closed) {
|
if (closed) {
|
||||||
if (packetInputStream != null) {
|
if (packetInputStream != null) {
|
||||||
automaton.assertValid();
|
syntaxVerifier.assertValid();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -686,8 +686,8 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetInputStream != null) {
|
if (packetInputStream != null) {
|
||||||
automaton.next(InputAlphabet.EndOfSequence);
|
syntaxVerifier.next(InputAlphabet.EndOfSequence);
|
||||||
automaton.assertValid();
|
syntaxVerifier.assertValid();
|
||||||
packetInputStream.close();
|
packetInputStream.close();
|
||||||
}
|
}
|
||||||
closed = true;
|
closed = true;
|
||||||
|
@ -717,7 +717,8 @@ public class OpenPgpMessageInputStream extends DecryptionStream {
|
||||||
for (PGPEncryptedData esk : esks) {
|
for (PGPEncryptedData esk : esks) {
|
||||||
if (esk instanceof PGPPBEEncryptedData) {
|
if (esk instanceof PGPPBEEncryptedData) {
|
||||||
skesks.add((PGPPBEEncryptedData) esk);
|
skesks.add((PGPPBEEncryptedData) esk);
|
||||||
} else if (esk instanceof PGPPublicKeyEncryptedData) {
|
}
|
||||||
|
else if (esk instanceof PGPPublicKeyEncryptedData) {
|
||||||
PGPPublicKeyEncryptedData pkesk = (PGPPublicKeyEncryptedData) esk;
|
PGPPublicKeyEncryptedData pkesk = (PGPPublicKeyEncryptedData) esk;
|
||||||
if (pkesk.getKeyID() != 0) {
|
if (pkesk.getKeyID() != 0) {
|
||||||
pkesks.add(pkesk);
|
pkesks.add(pkesk);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.decryption_verification.automaton;
|
package org.pgpainless.decryption_verification.syntax_check;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPCompressedData;
|
import org.bouncycastle.openpgp.PGPCompressedData;
|
||||||
import org.bouncycastle.openpgp.PGPEncryptedDataList;
|
import org.bouncycastle.openpgp.PGPEncryptedDataList;
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.decryption_verification.automaton;
|
package org.pgpainless.decryption_verification.syntax_check;
|
||||||
|
|
||||||
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -10,9 +10,9 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import static org.pgpainless.decryption_verification.automaton.StackAlphabet.msg;
|
import static org.pgpainless.decryption_verification.syntax_check.StackAlphabet.msg;
|
||||||
import static org.pgpainless.decryption_verification.automaton.StackAlphabet.ops;
|
import static org.pgpainless.decryption_verification.syntax_check.StackAlphabet.ops;
|
||||||
import static org.pgpainless.decryption_verification.automaton.StackAlphabet.terminus;
|
import static org.pgpainless.decryption_verification.syntax_check.StackAlphabet.terminus;
|
||||||
|
|
||||||
public class PDA {
|
public class PDA {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package org.pgpainless.decryption_verification.automaton;
|
package org.pgpainless.decryption_verification.syntax_check;
|
||||||
|
|
||||||
public enum StackAlphabet {
|
public enum StackAlphabet {
|
||||||
/**
|
/**
|
|
@ -5,4 +5,4 @@
|
||||||
/**
|
/**
|
||||||
* Pushdown Automaton to verify validity of packet sequences according to the OpenPGP Message format.
|
* Pushdown Automaton to verify validity of packet sequences according to the OpenPGP Message format.
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.decryption_verification.automaton;
|
package org.pgpainless.decryption_verification.syntax_check;
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
package org.pgpainless.exception;
|
package org.pgpainless.exception;
|
||||||
|
|
||||||
import org.pgpainless.decryption_verification.automaton.InputAlphabet;
|
import org.pgpainless.decryption_verification.syntax_check.InputAlphabet;
|
||||||
import org.pgpainless.decryption_verification.automaton.PDA;
|
import org.pgpainless.decryption_verification.syntax_check.PDA;
|
||||||
import org.pgpainless.decryption_verification.automaton.StackAlphabet;
|
import org.pgpainless.decryption_verification.syntax_check.StackAlphabet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception that gets thrown if the OpenPGP message is malformed.
|
* Exception that gets thrown if the OpenPGP message is malformed.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.pgpainless.decryption_verification.automaton;
|
package org.pgpainless.decryption_verification.syntax_check;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
Loading…
Reference in a new issue