summaryrefslogtreecommitdiffstats
path: root/autocrypt/src
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-03-03 23:20:33 +0100
committerNeal H. Walfield <neal@pep.foundation>2020-03-03 23:52:03 +0100
commita61bfdab687e9c0b6c5e263ed304f48183059a45 (patch)
tree545d516b6b2fe513f63caf3bcc81024338459583 /autocrypt/src
parent93dbeb3160262726d4c60b4811cf352c08dfc5b3 (diff)
openpgp: Only impl Serialize for objects that are normally exported.
- Add two new traits: `Marshal` and `MarshalInto`. - Implement them instead of `Serialize` and `SerializeInto`. - Only implement `Serialize` and `SerializeInto` for data structures that are normally exported. - This should prevent users from accidentally serializing a bare signature (`Signature`) when they meant to serialize a signature packet (`Packet`), for instance. - Fixes #368.
Diffstat (limited to 'autocrypt/src')
-rw-r--r--autocrypt/src/serialize.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/autocrypt/src/serialize.rs b/autocrypt/src/serialize.rs
index 0375c774..85979057 100644
--- a/autocrypt/src/serialize.rs
+++ b/autocrypt/src/serialize.rs
@@ -1,5 +1,5 @@
use sequoia_openpgp as openpgp;
-use openpgp::serialize::Serialize;
+use openpgp::serialize::Marshal;
use super::{
AutocryptHeader,
@@ -7,7 +7,9 @@ use super::{
Result,
};
-impl Serialize for AutocryptHeader {
+impl openpgp::serialize::Serialize for AutocryptHeader {}
+
+impl Marshal for AutocryptHeader {
fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> {
if self.key.is_none() {
return Err(Error::InvalidOperation("No key".into()).into());