diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-01 15:39:32 +0100 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-11-01 17:25:21 +0100 |
commit | 0167aa2e0cf5feea6cc6da4714f2b56a9255b373 (patch) | |
tree | e84822ccc1069bde78867b3c9823771d5bfbf525 | |
parent | fcadffeb852bd6419f6fec6a8bbd1041b8475d74 (diff) |
sq: Use NotationData's critical field.nora/767
-rw-r--r-- | sq/src/commands/sign.rs | 22 | ||||
-rw-r--r-- | sq/src/sq.rs | 13 | ||||
-rw-r--r-- | sq/tests/sq-certify.rs | 6 | ||||
-rw-r--r-- | sq/tests/sq-sign.rs | 6 |
4 files changed, 25 insertions, 22 deletions
diff --git a/sq/src/commands/sign.rs b/sq/src/commands/sign.rs index a373910c..646ea36c 100644 --- a/sq/src/commands/sign.rs +++ b/sq/src/commands/sign.rs @@ -28,7 +28,7 @@ pub fn sign(config: Config, output_path: Option<&str>, secrets: Vec<openpgp::Cert>, detached: bool, binary: bool, append: bool, notarize: bool, time: Option<SystemTime>, - notations: &[(bool, NotationData)]) + notations: &[NotationData]) -> Result<()> { match (detached, append|notarize) { (_, false) | (true, true) => @@ -44,7 +44,7 @@ fn sign_data(config: Config, input: &mut dyn io::Read, output_path: Option<&str>, secrets: Vec<openpgp::Cert>, detached: bool, binary: bool, append: bool, time: Option<SystemTime>, - notations: &[(bool, NotationData)]) + notations: &[NotationData]) -> Result<()> { let (mut output, prepend_sigs, tmp_path): (Box<dyn io::Write + Sync + Send>, Vec<Signature>, Option<PathBuf>) = @@ -105,12 +105,12 @@ fn sign_data(config: Config, } let mut builder = SignatureBuilder::new(SignatureType::Binary); - for (critical, n) in notations.iter() { + for n in notations.iter() { builder = builder.add_notation( n.name(), n.value(), Some(n.flags().clone()), - *critical)?; + n.critical())?; } let mut signer = Signer::with_template( @@ -156,7 +156,7 @@ fn sign_message(config: Config, output_path: Option<&str>, secrets: Vec<openpgp::Cert>, binary: bool, notarize: bool, time: Option<SystemTime>, - notations: &[(bool, NotationData)]) + notations: &[NotationData]) -> Result<()> { let mut output = config.create_or_stdout_pgp(output_path, @@ -172,7 +172,7 @@ fn sign_message_(config: Config, output: &mut (dyn io::Write + Sync + Send), secrets: Vec<openpgp::Cert>, notarize: bool, time: Option<SystemTime>, - notations: &[(bool, NotationData)]) + notations: &[NotationData]) -> Result<()> { let mut keypairs = super::get_signing_keys(&secrets, &config.policy, time)?; @@ -245,12 +245,12 @@ fn sign_message_(config: Config, // After the first signature group, we push the signer // onto the writer stack. let mut builder = SignatureBuilder::new(SignatureType::Binary); - for (critical, n) in notations.iter() { + for n in notations { builder = builder.add_notation( n.name(), n.value(), Some(n.flags().clone()), - *critical)?; + n.critical())?; } let mut signer = Signer::with_template( @@ -377,7 +377,7 @@ pub fn clearsign(config: Config, mut output: impl io::Write + Sync + Send, secrets: Vec<openpgp::Cert>, time: Option<SystemTime>, - notations: &[(bool, NotationData)]) + notations: &[NotationData]) -> Result<()> { let mut keypairs = super::get_signing_keys(&secrets, &config.policy, time)?; @@ -387,12 +387,12 @@ pub fn clearsign(config: Config, // Prepare a signature template. let mut builder = SignatureBuilder::new(SignatureType::Text); - for (critical, n) in notations.iter() { + for n in notations.iter() { builder = builder.add_notation( n.name(), n.value(), Some(n.flags().clone()), - *critical)?; + n.critical())?; } let message = Message::new(&mut output); diff --git a/sq/src/sq.rs b/sq/src/sq.rs index d9a22b74..d7a952a5 100644 --- a/sq/src/sq.rs +++ b/sq/src/sq.rs @@ -496,7 +496,7 @@ fn main() -> Result<()> { }; // Each --notation takes two values. The iterator // returns them one at a time, however. - let mut notations: Vec<(bool, NotationData)> = Vec::new(); + let mut notations: Vec<NotationData> = Vec::new(); if let Some(mut n) = m.values_of("notation") { while let Some(name) = n.next() { let value = n.next().unwrap(); @@ -510,10 +510,13 @@ fn main() -> Result<()> { }; notations.push( - (critical, - NotationData::new( - name, value, - NotationDataFlags::empty().set_human_readable()))); + NotationData::new( + name, + value, + NotationDataFlags::empty().set_human_readable(), + critical, + ), + ); } } diff --git a/sq/tests/sq-certify.rs b/sq/tests/sq-certify.rs index 128b4ed8..b95187e7 100644 --- a/sq/tests/sq-certify.rs +++ b/sq/tests/sq-certify.rs @@ -211,9 +211,9 @@ fn sq_certify() -> Result<()> { let hr = NotationDataFlags::empty().set_human_readable(); let notations = &mut [ - (NotationData::new("foo", "bar", hr.clone()), false), - (NotationData::new("foo", "xyzzy", hr.clone()), false), - (NotationData::new("hello@example.org", "1234567890", hr), false) + (NotationData::new("foo", "bar", hr.clone(), false), false), + (NotationData::new("foo", "xyzzy", hr.clone(), false), false), + (NotationData::new("hello@example.org", "1234567890", hr, false), false) ]; for n in c.notation_data() { diff --git a/sq/tests/sq-sign.rs b/sq/tests/sq-sign.rs index 4836e2fe..aac7e2d6 100644 --- a/sq/tests/sq-sign.rs +++ b/sq/tests/sq-sign.rs @@ -109,9 +109,9 @@ fn sq_sign_with_notations() { let hr = NotationDataFlags::empty().set_human_readable(); let notations = &mut [ - (NotationData::new("foo", "bar", hr.clone()), false), - (NotationData::new("foo", "xyzzy", hr.clone()), false), - (NotationData::new("hello@example.org", "1234567890", hr), false) + (NotationData::new("foo", "bar", hr.clone(), false), false), + (NotationData::new("foo", "xyzzy", hr.clone(), false), false), + (NotationData::new("hello@example.org", "1234567890", hr, false), false) ]; for n in sig.notation_data() { |