diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-03-02 11:27:44 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-03-02 11:54:11 +0100 |
commit | 43eab70f6a22b62ce0577e929e09f1d68cea80a8 (patch) | |
tree | cf3c1dc1a6e59f7b5c2531b8b7786181574738b5 | |
parent | 18038d05d207ded98620d7ee0f7f3ca968642072 (diff) |
openpgp: Drop spaces from default string representation.
- Spaces in key ids and fingerprints make them awkward to copy and
pass as command line arguments. Change the default representation.
For the rare occasions that we expect users to manually verify
fingerprints, the previously introduced *::to_hex_pretty functions
can be used.
- Fixes #422.
-rw-r--r-- | ffi/lang/python/tests/test_fingerprint.py | 4 | ||||
-rw-r--r-- | ffi/lang/python/tests/test_keyid.py | 4 | ||||
-rw-r--r-- | openpgp-ffi/src/fingerprint.rs | 2 | ||||
-rw-r--r-- | openpgp-ffi/src/keyid.rs | 4 | ||||
-rw-r--r-- | openpgp-ffi/src/lib.rs | 2 | ||||
-rw-r--r-- | openpgp/src/fingerprint.rs | 2 | ||||
-rw-r--r-- | openpgp/src/keyid.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize/cert_armored.rs | 2 |
8 files changed, 11 insertions, 11 deletions
diff --git a/ffi/lang/python/tests/test_fingerprint.py b/ffi/lang/python/tests/test_fingerprint.py index a5470f29..85a505d0 100644 --- a/ffi/lang/python/tests/test_fingerprint.py +++ b/ffi/lang/python/tests/test_fingerprint.py @@ -6,12 +6,12 @@ pretty = "7DCA 58B5 4EB1 4316 9DDE E15F 247F 6DAB C849 14FE" def test_from_bytes(): f = Fingerprint.from_bytes(binary) - assert str(f) == pretty + assert str(f) == hexy assert f.hex() == hexy def test_from_hex(): f = Fingerprint.from_hex(hexy) - assert str(f) == pretty + assert str(f) == hexy assert f.hex() == hexy def test_to_keyid(): diff --git a/ffi/lang/python/tests/test_keyid.py b/ffi/lang/python/tests/test_keyid.py index 6cc95f9e..40c4ad8c 100644 --- a/ffi/lang/python/tests/test_keyid.py +++ b/ffi/lang/python/tests/test_keyid.py @@ -6,12 +6,12 @@ pretty = "247F 6DAB C849 14FE" def test_from_bytes(): k = KeyID.from_bytes(binary) - assert str(k) == pretty + assert str(k) == hexy assert k.hex() == hexy def test_from_hex(): k = KeyID.from_hex(hexy) - assert str(k) == pretty + assert str(k) == hexy assert k.hex() == hexy fp_hexy = "7DCA58B54EB143169DDEE15F247F6DABC84914FE" diff --git a/openpgp-ffi/src/fingerprint.rs b/openpgp-ffi/src/fingerprint.rs index 716d2d23..5d81b56c 100644 --- a/openpgp-ffi/src/fingerprint.rs +++ b/openpgp-ffi/src/fingerprint.rs @@ -61,7 +61,7 @@ fn pgp_fingerprint_from_bytes(buf: *const u8, /// /// char *pretty = pgp_fingerprint_to_string (fp); /// assert (strcmp (pretty, -/// "D2F2 C5D4 5BE9 FDE6 A4EE 0AAF 3185 5247 6038 31FD") == 0); +/// "D2F2C5D45BE9FDE6A4EE0AAF31855247603831FD") == 0); /// /// free (pretty); /// pgp_fingerprint_free (fp); diff --git a/openpgp-ffi/src/keyid.rs b/openpgp-ffi/src/keyid.rs index c5ed5dbe..1ad11207 100644 --- a/openpgp-ffi/src/keyid.rs +++ b/openpgp-ffi/src/keyid.rs @@ -48,7 +48,7 @@ pub struct KeyID(openpgp::KeyID); /// pgp_keyid_from_bytes ((uint8_t *) "\xbb\xbb\xbb\xbb\xbb\xbb\xbb\xbb"); /// /// char *mr_b_as_string = pgp_keyid_to_string (mr_b); -/// assert (strcmp (mr_b_as_string, "BBBB BBBB BBBB BBBB") == 0); +/// assert (strcmp (mr_b_as_string, "BBBBBBBBBBBBBBBB") == 0); /// /// pgp_keyid_free (mr_b); /// free (mr_b_as_string); @@ -73,7 +73,7 @@ fn pgp_keyid_from_bytes(id: *const u8) -> *mut KeyID { /// pgp_keyid_t mr_b = pgp_keyid_from_hex ("bbbbbbbbbbbbbbbb"); /// /// char *mr_b_as_string = pgp_keyid_to_string (mr_b); -/// assert (strcmp (mr_b_as_string, "BBBB BBBB BBBB BBBB") == 0); +/// assert (strcmp (mr_b_as_string, "BBBBBBBBBBBBBBBB") == 0); /// /// free (mr_b_as_string); /// pgp_keyid_free (mr_b); diff --git a/openpgp-ffi/src/lib.rs b/openpgp-ffi/src/lib.rs index e7957745..9072c636 100644 --- a/openpgp-ffi/src/lib.rs +++ b/openpgp-ffi/src/lib.rs @@ -187,7 +187,7 @@ //! //! char *pretty = pgp_fingerprint_to_string (fp); //! assert (strcmp (pretty, -//! "D2F2 C5D4 5BE9 FDE6 A4EE 0AAF 3185 5247 6038 31FD") == 0); +//! "D2F2C5D45BE9FDE6A4EE0AAF31855247603831FD") == 0); //! //! free (pretty); //! pgp_fingerprint_free (fp); diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs index 00802093..cccae03e 100644 --- a/openpgp/src/fingerprint.rs +++ b/openpgp/src/fingerprint.rs @@ -57,7 +57,7 @@ assert_send_and_sync!(Fingerprint); impl fmt::Display for Fingerprint { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.convert_to_string(true)) + write!(f, "{:X}", self) } } diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs index 4e40b914..9c2e4842 100644 --- a/openpgp/src/keyid.rs +++ b/openpgp/src/keyid.rs @@ -69,7 +69,7 @@ assert_send_and_sync!(KeyID); impl fmt::Display for KeyID { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.convert_to_string(true)) + write!(f, "{:X}", self) } } diff --git a/openpgp/src/serialize/cert_armored.rs b/openpgp/src/serialize/cert_armored.rs index ca39b39a..ab22ec51 100644 --- a/openpgp/src/serialize/cert_armored.rs +++ b/openpgp/src/serialize/cert_armored.rs @@ -56,7 +56,7 @@ impl Cert { }).collect(); // Add the fingerprint to the front. - headers.insert(0, self.fingerprint().to_string()); + headers.insert(0, self.fingerprint().to_spaced_hex()); headers } |