diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-12-03 13:58:24 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-03 13:58:24 +0100 |
commit | bd153237fc6eb0a841f4d8b8d79f3383b7115b00 (patch) | |
tree | 07b7e8ad7b12d68da2b86729b68a219cff3cf6e0 | |
parent | 88442e46a8f5639c4493713baeb5b90f7cf6a84b (diff) |
openpgp: Rename openpgp::conversions to openpgp::fmt.
-rw-r--r-- | ipc/src/gnupg.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/aead.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/ecdh.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/keygrip.rs | 6 | ||||
-rw-r--r-- | openpgp/src/crypto/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/mpis.rs | 4 | ||||
-rw-r--r-- | openpgp/src/crypto/s2k.rs | 2 | ||||
-rw-r--r-- | openpgp/src/fingerprint.rs | 2 | ||||
-rw-r--r-- | openpgp/src/fmt.rs (renamed from openpgp/src/conversions.rs) | 4 | ||||
-rw-r--r-- | openpgp/src/keyid.rs | 2 | ||||
-rw-r--r-- | openpgp/src/lib.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 6 | ||||
-rw-r--r-- | openpgp/src/packet/trust.rs | 2 | ||||
-rw-r--r-- | openpgp/src/parse/hashed_reader.rs | 6 | ||||
-rw-r--r-- | openpgp/src/parse/parse.rs | 16 | ||||
-rw-r--r-- | openpgp/src/types/key_flags.rs | 2 | ||||
-rw-r--r-- | tool/src/commands/decrypt.rs | 2 | ||||
-rw-r--r-- | tool/src/commands/dump.rs | 2 | ||||
-rw-r--r-- | tool/src/sq.rs | 2 |
19 files changed, 34 insertions, 34 deletions
diff --git a/ipc/src/gnupg.rs b/ipc/src/gnupg.rs index 1a274278..d2f28f4d 100644 --- a/ipc/src/gnupg.rs +++ b/ipc/src/gnupg.rs @@ -13,7 +13,7 @@ extern crate libc; extern crate tempfile; use crate::openpgp::types::HashAlgorithm; -use crate::openpgp::conversions::hex; +use crate::openpgp::fmt::hex; use crate::openpgp::crypto; use crate::openpgp::crypto::sexp::Sexp; use crate::openpgp::packet::prelude::*; diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs index 50255d2f..4e16c888 100644 --- a/openpgp/src/crypto/aead.rs +++ b/openpgp/src/crypto/aead.rs @@ -9,7 +9,7 @@ use crate::types::{ AEADAlgorithm, SymmetricAlgorithm, }; -use crate::conversions::{ +use crate::fmt::{ write_be_u64, }; use crate::Error; diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 9f281865..d6c21897 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -13,7 +13,7 @@ use crate::types::{ SymmetricAlgorithm, PublicKeyAlgorithm, }; -use crate::conversions::{ +use crate::fmt::{ write_be_u64, read_be_u64, }; diff --git a/openpgp/src/crypto/keygrip.rs b/openpgp/src/crypto/keygrip.rs index 5e79247b..adb05ed0 100644 --- a/openpgp/src/crypto/keygrip.rs +++ b/openpgp/src/crypto/keygrip.rs @@ -40,7 +40,7 @@ impl std::str::FromStr for Keygrip { impl Keygrip { /// Parses a keygrip. pub fn from_hex(hex: &str) -> Result<Self> { - let bytes = crate::conversions::from_hex(hex, true)?; + let bytes = crate::fmt::from_hex(hex, true)?; if bytes.len() != 20 { return Err(Error::InvalidArgument( format!("Expected 20 bytes, got {}", bytes.len())).into()); @@ -212,13 +212,13 @@ fn ecc_param(curve: &Curve, i: usize) -> MPI { (_, _) => unreachable!(), }; - crate::conversions::from_hex(hex, true).unwrap().into() + crate::fmt::from_hex(hex, true).unwrap().into() } #[cfg(test)] mod tests { use super::*; - use crate::conversions::from_hex; + use crate::fmt::from_hex; /// Test vectors from libgcrypt/tests/basic.c. #[test] diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index fd43481c..667f2d82 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -217,6 +217,6 @@ fn hash_file_test() { hash.digest(&mut digest); assert_eq!(*expected.get(&algo).unwrap(), - &crate::conversions::to_hex(&digest[..], false)); + &crate::fmt::to_hex(&digest[..], false)); } } diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpis.rs index f3113f63..7dd731f5 100644 --- a/openpgp/src/crypto/mpis.rs +++ b/openpgp/src/crypto/mpis.rs @@ -170,7 +170,7 @@ impl fmt::Debug for MPI { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_fmt(format_args!( "{} bits: {}", self.bits(), - crate::conversions::to_hex(&*self.value, true))) + crate::fmt::to_hex(&*self.value, true))) } } @@ -264,7 +264,7 @@ impl fmt::Debug for ProtectedMPI { if cfg!(debug_assertions) { f.write_fmt(format_args!( "{} bits: {}", self.bits(), - crate::conversions::to_hex(&*self.value, true))) + crate::fmt::to_hex(&*self.value, true))) } else { f.write_str("<Redacted>") } diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index 2a819c47..f0614ab0 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -286,7 +286,7 @@ impl Arbitrary for S2K { mod tests { use super::*; - use crate::conversions::to_hex; + use crate::fmt::to_hex; use crate::SymmetricAlgorithm; use crate::Packet; use crate::parse::{Parse, PacketParser}; diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs index ab662ed1..1e9779f2 100644 --- a/openpgp/src/fingerprint.rs +++ b/openpgp/src/fingerprint.rs @@ -52,7 +52,7 @@ impl Fingerprint { /// assert_eq!(fp.unwrap().to_hex(), hex); /// ``` pub fn from_hex(hex: &str) -> Result<Fingerprint> { - Ok(Fingerprint::from_bytes(&crate::conversions::from_hex(hex, true)?[..])) + Ok(Fingerprint::from_bytes(&crate::fmt::from_hex(hex, true)?[..])) } /// Returns a reference to the raw Fingerprint. diff --git a/openpgp/src/conversions.rs b/openpgp/src/fmt.rs index 4b631d55..845b5af1 100644 --- a/openpgp/src/conversions.rs +++ b/openpgp/src/fmt.rs @@ -1,4 +1,4 @@ -//! Conversions for primitive OpenPGP types. +//! Utilities for formatting, printing, and user communication. use crate::Error; use crate::Result; @@ -32,7 +32,7 @@ pub mod hex { /// # Example /// /// ```rust - /// use sequoia_openpgp::conversions::hex; + /// use sequoia_openpgp::fmt::hex; /// /// let mut dumper = hex::Dumper::new(Vec::new(), ""); /// dumper.write(&[0x89, 0x01, 0x33], "frame").unwrap(); diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 5cda407b..fac2b4c0 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -116,7 +116,7 @@ impl KeyID { /// Reads a hex-encoded Key ID. pub fn from_hex(hex: &str) -> Result<KeyID> { - let bytes = crate::conversions::from_hex(hex, true)?; + let bytes = crate::fmt::from_hex(hex, true)?; // A KeyID is exactly 8 bytes long. if bytes.len() == 8 { diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index 505c9b32..05830cc2 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -120,7 +120,7 @@ macro_rules! assert_match { #[macro_use] pub mod armor; pub mod autocrypt; -pub mod conversions; +pub mod fmt; pub mod crypto; pub mod packet; diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 8219e6ba..8853c7e1 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -350,10 +350,10 @@ impl fmt::Debug for Signature4 { .field("hashed_area", self.hashed_area()) .field("unhashed_area", self.unhashed_area()) .field("hash_prefix", - &crate::conversions::to_hex(&self.hash_prefix, false)) + &crate::fmt::to_hex(&self.hash_prefix, false)) .field("computed_hash", &if let Some((algo, ref hash)) = self.computed_hash { - Some((algo, crate::conversions::to_hex(&hash[..], false))) + Some((algo, crate::fmt::to_hex(&hash[..], false))) } else { None }) @@ -1470,7 +1470,7 @@ mod test { "contrib/gnupg/timestamp-signature-by-alice.asc")).unwrap(); if let Packet::Signature(sig) = p { let digest = Signature::standalone_hash(&sig).unwrap(); - eprintln!("{}", crate::conversions::hex::encode(&digest)); + eprintln!("{}", crate::fmt::hex::encode(&digest)); assert!(sig.verify_timestamp(alpha.primary()).unwrap()); } else { panic!("expected a signature packet"); diff --git a/openpgp/src/packet/trust.rs b/openpgp/src/packet/trust.rs index fbf03569..5005153a 100644 --- a/openpgp/src/packet/trust.rs +++ b/openpgp/src/packet/trust.rs @@ -34,7 +34,7 @@ impl fmt::Display for Trust { impl fmt::Debug for Trust { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Trust") - .field("value", &crate::conversions::hex::encode(&self.value)) + .field("value", &crate::fmt::hex::encode(&self.value)) .finish() } } diff --git a/openpgp/src/parse/hashed_reader.rs b/openpgp/src/parse/hashed_reader.rs index 120cf222..a8ec36cf 100644 --- a/openpgp/src/parse/hashed_reader.rs +++ b/openpgp/src/parse/hashed_reader.rs @@ -88,7 +88,7 @@ impl Cookie { if self.hashing == Hashing::Disabled { t!(" hash_update: NOT hashing {} bytes: {}.", - data.len(), crate::conversions::to_hex(data, true)); + data.len(), crate::fmt::to_hex(data, true)); return; } @@ -96,7 +96,7 @@ impl Cookie { for (i, sig_group) in self.sig_groups.iter_mut().enumerate() { if topmost_group(i) && self.hashing != Hashing::Enabled { t!("topmost group {} NOT hashing {} bytes: {}.", - i, data.len(), crate::conversions::to_hex(data, true)); + i, data.len(), crate::fmt::to_hex(data, true)); return; } @@ -280,7 +280,7 @@ mod test { hash.digest(&mut digest); assert_eq!(digest, - &crate::conversions::from_hex(test.expected.get(algo) + &crate::fmt::from_hex(test.expected.get(algo) .unwrap(), true) .unwrap()[..], "Algo: {:?}", algo); diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index a06a710c..79d09137 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -1385,10 +1385,10 @@ fn one_pass_sig_test () { } else if let Packet::Signature(ref sig) = pp.packet { eprintln!(" {}:\n prefix: expected: {}, in sig: {}", test.filename, - crate::conversions::to_hex(&test.hash_prefix[sigs][..], false), - crate::conversions::to_hex(sig.hash_prefix(), false)); + crate::fmt::to_hex(&test.hash_prefix[sigs][..], false), + crate::fmt::to_hex(sig.hash_prefix(), false)); eprintln!(" computed hash: {}", - crate::conversions::to_hex(&sig.computed_hash().unwrap().1, + crate::fmt::to_hex(&sig.computed_hash().unwrap().1, false)); assert_eq!(&test.hash_prefix[sigs], sig.hash_prefix()); @@ -1987,7 +1987,7 @@ fn skesk_parser_test() { match skesk.decrypt(&test.password) { Ok((_sym_algo, key)) => { - let key = crate::conversions::to_hex(&key[..], false); + let key = crate::fmt::to_hex(&key[..], false); assert_eq!(&key[..], &test.key_hex[..]); } Err(e) => { @@ -3574,7 +3574,7 @@ impl<'a> PacketParser<'a> { return Err(Error::InvalidSessionKey( format!( "Last two 16-bit quantities don't match: {}", - crate::conversions::to_hex(&header[..], false))) + crate::fmt::to_hex(&header[..], false))) .into()); } } @@ -3903,7 +3903,7 @@ mod test { ppr, false, &[ Tag::SEIP, Tag::AED ][..], &[ Tag::SKESK, Tag::PKESK ][..] ); if let PacketParserResult::Some(ref mut pp) = ppr { - let key = crate::conversions::from_hex(test.key_hex, false) + let key = crate::fmt::from_hex(test.key_hex, false) .unwrap().into(); pp.decrypt(test.algo, &key).unwrap(); @@ -3972,7 +3972,7 @@ mod test { match pp.packet { Packet::SEIP(_) | Packet::AED(_) => { - let key = crate::conversions::from_hex(test.key_hex, false) + let key = crate::fmt::from_hex(test.key_hex, false) .unwrap().into(); pp.decrypt(test.algo, &key).unwrap(); }, @@ -4109,7 +4109,7 @@ mod test { match pp.packet { Packet::SEIP(_) | Packet::AED(_) => { - let key = crate::conversions::from_hex(test.key_hex, false) + let key = crate::fmt::from_hex(test.key_hex, false) .unwrap().into(); pp.decrypt(test.algo, &key).unwrap(); diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs index 9d6123f8..af766b31 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -48,7 +48,7 @@ impl fmt::Debug for KeyFlags { if self.unknown.len() > 0 { f.write_str("+0x")?; f.write_str( - &crate::conversions::hex::encode_pretty(&self.unknown))?; + &crate::fmt::hex::encode_pretty(&self.unknown))?; } Ok(()) diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs index a30d6d6f..775ab386 100644 --- a/tool/src/commands/decrypt.rs +++ b/tool/src/commands/decrypt.rs @@ -7,7 +7,7 @@ extern crate termsize; extern crate sequoia_openpgp as openpgp; use sequoia_core::Context; use crate::openpgp::types::SymmetricAlgorithm; -use crate::openpgp::conversions::hex; +use crate::openpgp::fmt::hex; use crate::openpgp::crypto::{self, SessionKey}; use crate::openpgp::{Fingerprint, Cert, KeyID, Result}; use crate::openpgp::packet::prelude::*; diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 6b696ff3..2b117585 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -2,7 +2,7 @@ use std::io::{self, Read}; extern crate sequoia_openpgp as openpgp; use self::openpgp::types::{Duration, Timestamp, SymmetricAlgorithm}; -use self::openpgp::conversions::hex; +use self::openpgp::fmt::hex; use self::openpgp::crypto::mpis; use self::openpgp::{Packet, Result}; use self::openpgp::packet::prelude::*; diff --git a/tool/src/sq.rs b/tool/src/sq.rs index e82f3097..c928a325 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -24,7 +24,7 @@ extern crate sequoia_net; extern crate sequoia_store as store; use crate::openpgp::{armor, autocrypt, Fingerprint, Cert}; -use crate::openpgp::conversions::hex; +use crate::openpgp::fmt::hex; use crate::openpgp::types::KeyFlags; use crate::openpgp::parse::Parse; use crate::openpgp::serialize::Serialize; |