summaryrefslogtreecommitdiffstats
path: root/openpgp/src/message
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-10-09 17:50:22 +0200
committerJustus Winter <justus@sequoia-pgp.org>2018-10-11 16:27:23 +0200
commit12da5b662d965abeed98b4f1b0f74b6ab887cefe (patch)
tree8365e143ba859f175c27405449a69eda3499f65a /openpgp/src/message
parent99fbdcf9d73a469638e5d035e58e841451ff3579 (diff)
openpgp: Add support for the AEAD encrypted data packet.
- This adds a new packet type, and enough infrastructure to decrypt messages encrypted using AEAD.
Diffstat (limited to 'openpgp/src/message')
-rw-r--r--openpgp/src/message/grammar.lalrpop14
-rw-r--r--openpgp/src/message/lexer.rs2
-rw-r--r--openpgp/src/message/mod.rs34
3 files changed, 47 insertions, 3 deletions
diff --git a/openpgp/src/message/grammar.lalrpop b/openpgp/src/message/grammar.lalrpop
index 1fe2c2c7..d5c0ea36 100644
--- a/openpgp/src/message/grammar.lalrpop
+++ b/openpgp/src/message/grammar.lalrpop
@@ -21,10 +21,19 @@ SeipPart: () = {
SEIP OPAQUE_CONTENT POP,
}
-// An encrypted part is 0 or more ESKs followed by a SEIP packet.
+AedPart: () = {
+ AED Message POP,
+}
+
+// An encrypted part is 0 or more ESKs followed by an encryption container.
EncryptedPart: () = {
+ EncryptionContainer,
+ ESKS EncryptionContainer,
+};
+
+EncryptionContainer: () = {
SeipPart,
- ESKS SeipPart,
+ AedPart,
};
ESKS: () = {
@@ -61,6 +70,7 @@ extern {
PKESK => lexer::Token::PKESK,
SEIP => lexer::Token::SEIP,
MDC => lexer::Token::MDC,
+ AED => lexer::Token::AED,
OPS => lexer::Token::OPS,
SIG => lexer::Token::SIG,
POP => lexer::Token::Pop,
diff --git a/openpgp/src/message/lexer.rs b/openpgp/src/message/lexer.rs
index 778735d3..fc561d62 100644
--- a/openpgp/src/message/lexer.rs
+++ b/openpgp/src/message/lexer.rs
@@ -23,6 +23,8 @@ pub enum Token {
SEIP,
/// An MDC packet.
MDC,
+ /// An AED packet.
+ AED,
/// A OnePassSig packet.
OPS,
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs
index 557c94e0..dfa332a9 100644
--- a/openpgp/src/message/mod.rs
+++ b/openpgp/src/message/mod.rs
@@ -209,6 +209,7 @@ impl MessageValidator {
Tag::PKESK => Token::PKESK,
Tag::SEIP => Token::SEIP,
Tag::MDC => Token::MDC,
+ Tag::AED => Token::AED,
Tag::OnePassSig => Token::OPS,
Tag::Signature => Token::SIG,
_ => {
@@ -307,7 +308,8 @@ impl Message {
v.push(packet.tag(), path.len() as isize - 1);
match packet {
- Packet::CompressedData(_) | Packet::SEIP(_) => {
+ Packet::CompressedData(_) | Packet::SEIP(_) | Packet::AED(_) =>
+ {
// If a container's content is not unpacked, then
// we treat the content as an opaque message.
@@ -467,6 +469,36 @@ mod tests {
},
TestVector {
+ s: &[AED, Literal, Pop],
+ result: true,
+ },
+ TestVector {
+ s: &[CompressedData, AED, Literal, Pop, Pop],
+ result: true,
+ },
+ TestVector {
+ s: &[CompressedData, AED, CompressedData, Literal,
+ Pop, Pop, Pop],
+ result: true,
+ },
+ TestVector {
+ s: &[AED, Pop],
+ result: false,
+ },
+ TestVector {
+ s: &[SKESK, AED, Literal, Pop],
+ result: true,
+ },
+ TestVector {
+ s: &[PKESK, AED, Literal, Pop],
+ result: true,
+ },
+ TestVector {
+ s: &[SKESK, SKESK, AED, Literal, Pop],
+ result: true,
+ },
+
+ TestVector {
s: &[OPS, Literal, SIG],
result: true,
},