summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/NEWS13
-rw-r--r--openpgp/src/parse.rs6
-rw-r--r--openpgp/src/parse/map.rs5
3 files changed, 23 insertions, 1 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index 9813c082..ba31c24e 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -8,6 +8,19 @@
- Sequoia now ignores some formatting errors when reading secret
keys. Being lenient in this case helps the user recover their
valuable key material.
+ - Previously, Sequoia would buffer packet bodies when mapping is
+ enabled in the parser, even if the packet parser is not
+ configured to buffer the bodies. This adds considerable
+ overhead.
+
+ Starting with this version, Sequoia no longer includes the packet
+ bodies in the maps unless the parser is configured to buffer any
+ unread content.
+
+ This makes parsing packets faster if you don't rely on the packet
+ body in the map, but changes the default behavior. If you need
+ the old behavior, please do adjust your code to buffer unread
+ content.
** New functionality
- crypto::SessionKey::as_protected
- types::AEADAlgorithm::GCM
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index f5b3bff8..b6289219 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -530,7 +530,11 @@ impl<'a> PacketHeaderParser<'a> {
if self.state.settings.map {
// Steal the body for the map.
self.reader.rewind();
- let body = self.reader.steal_eof()?;
+ let body = if self.state.settings.buffer_unread_content {
+ self.reader.steal_eof()?
+ } else {
+ self.reader.steal(total_out)?
+ };
if body.len() > total_out {
self.field("body", body.len() - total_out);
}
diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs
index 996f1c09..2657e1ed 100644
--- a/openpgp/src/parse/map.rs
+++ b/openpgp/src/parse/map.rs
@@ -14,6 +14,7 @@
//! let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.";
//! let pp = PacketParserBuilder::from_bytes(message_data)?
//! .map(true) // Enable mapping.
+//! .buffer_unread_content() // For the packet body.
//! .build()?
//! .expect("One packet, not EOF");
//! let map = pp.map().expect("Mapping is enabled");
@@ -83,6 +84,7 @@ impl Map {
/// let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.";
/// let pp = PacketParserBuilder::from_bytes(message_data)?
/// .map(true) // Enable mapping.
+ /// .buffer_unread_content() // For the packet body.
/// .build()?
/// .expect("One packet, not EOF");
/// let map = pp.map().expect("Mapping is enabled");
@@ -170,6 +172,7 @@ impl<'a> Field<'a> {
/// let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.";
/// let pp = PacketParserBuilder::from_bytes(message_data)?
/// .map(true) // Enable mapping.
+ /// .buffer_unread_content() // For the packet body.
/// .build()?
/// .expect("One packet, not EOF");
/// let map = pp.map().expect("Mapping is enabled");
@@ -199,6 +202,7 @@ impl<'a> Field<'a> {
/// let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.";
/// let pp = PacketParserBuilder::from_bytes(message_data)?
/// .map(true) // Enable mapping.
+ /// .buffer_unread_content() // For the packet body.
/// .build()?
/// .expect("One packet, not EOF");
/// let map = pp.map().expect("Mapping is enabled");
@@ -228,6 +232,7 @@ impl<'a> Field<'a> {
/// let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world.";
/// let pp = PacketParserBuilder::from_bytes(message_data)?
/// .map(true) // Enable mapping.
+ /// .buffer_unread_content() // For the packet body.
/// .build()?
/// .expect("One packet, not EOF");
/// let map = pp.map().expect("Mapping is enabled");