Commit a9fb6ab5 authored by Justus Winter's avatar Justus Winter

Port to Sequoia 0.13.

parent 288a049f
......@@ -149,7 +149,7 @@ dependencies = [
[[package]]
name = "buffered-reader"
version = "0.12.0"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1301,7 +1301,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket_contrib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sequoia-openpgp 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sequoia-openpgp 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1310,11 +1310,11 @@ dependencies = [
[[package]]
name = "sequoia-openpgp"
version = "0.12.0"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"buffered-reader 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"buffered-reader 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1327,6 +1327,7 @@ dependencies = [
"quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -1761,7 +1762,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0"
"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
"checksum buffered-reader 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "926c9f1c816da9ee57eec1e951483e5d1b1617b4f5131e48902e7ae63154826c"
"checksum buffered-reader 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be74401b94b816fb7995f12ca903a248363523099f40d993b7070aa8a8cacdf"
"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
"checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b"
......@@ -1896,7 +1897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
"checksum safemem 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
"checksum sequoia-openpgp 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "33554f73114b96e1275ebec51131010c15e6c91f18a8d29a7d234112f9be43c5"
"checksum sequoia-openpgp 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b1acca7ce28b65b47bac59da9bf39636427c54445dc4740aed0c093ff7bc9a8"
"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0"
"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8"
"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
......
......@@ -11,7 +11,7 @@ vergen = "3"
chrono = "0.4"
lazy_static = "1.4"
rocket = "0.4"
sequoia-openpgp = { version = "0.12" }
sequoia-openpgp = { version = "0.13" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
......
use std::io::{self, Read};
extern crate sequoia_openpgp as openpgp;
use self::openpgp::types::SymmetricAlgorithm;
use self::openpgp::conversions::hex;
use self::openpgp::types::{Duration, Timestamp, SymmetricAlgorithm};
use self::openpgp::fmt::hex;
use self::openpgp::crypto::mpis;
use self::openpgp::{Packet, Result};
use self::openpgp::packet::prelude::*;
......@@ -18,7 +18,7 @@ pub enum Kind {
encrypted: bool,
},
Keyring,
TPK,
Cert,
Unknown,
}
......@@ -34,12 +34,24 @@ impl Convert<chrono::Duration> for std::time::Duration {
}
}
impl Convert<chrono::Duration> for Duration {
fn convert(self) -> chrono::Duration {
chrono::Duration::seconds(self.as_secs() as i64)
}
}
impl Convert<chrono::DateTime<chrono::offset::Utc>> for std::time::SystemTime {
fn convert(self) -> chrono::DateTime<chrono::offset::Utc> {
chrono::DateTime::<chrono::offset::Utc>::from(self)
}
}
impl Convert<chrono::DateTime<chrono::offset::Utc>> for Timestamp {
fn convert(self) -> chrono::DateTime<chrono::offset::Utc> {
std::time::SystemTime::from(self).convert()
}
}
pub fn dump<P, S, W>(input: &mut dyn io::Read, output: &mut dyn io::Write,
mpis: bool, hex: bool, mut sk: Option<SessionKey>,
decrypt_pkesk: P, decrypt_skesk: S,
......@@ -155,8 +167,8 @@ pub fn dump<P, S, W>(input: &mut dyn io::Read, output: &mut dyn io::Write,
Kind::Message {
encrypted: message_encrypted,
}
} else if eof.is_tpk().is_ok() {
Kind::TPK
} else if eof.is_cert().is_ok() {
Kind::Cert
} else if eof.is_keyring().is_ok() {
Kind::Keyring
} else {
......@@ -439,18 +451,18 @@ impl PacketDumper {
writeln!(output, "{} Hash algo: {}", i, s.hash_algo())?;
if s.hashed_area().iter().count() > 0 {
writeln!(output, "{} Hashed area:", i)?;
for (_, _, pkt) in s.hashed_area().iter() {
for pkt in s.hashed_area().iter() {
self.dump_subpacket(output, i, pkt, s)?;
}
}
if s.unhashed_area().iter().count() > 0 {
writeln!(output, "{} Unhashed area:", i)?;
for (_, _, pkt) in s.unhashed_area().iter() {
for pkt in s.unhashed_area().iter() {
self.dump_subpacket(output, i, pkt, s)?;
}
}
writeln!(output, "{} Hash prefix: {}", i,
hex::encode(s.hash_prefix()))?;
writeln!(output, "{} Digest prefix: {}", i,
hex::encode(s.digest_prefix()))?;
write!(output, "{} Level: {} ", i, s.level())?;
match s.level() {
0 => writeln!(output, "(signature over data)")?,
......@@ -650,10 +662,10 @@ impl PacketDumper {
},
MDC(ref m) => {
writeln!(output, "{} Hash: {}",
i, hex::encode(m.hash()))?;
writeln!(output, "{} Computed hash: {}",
i, hex::encode(m.computed_hash()))?;
writeln!(output, "{} Digest: {}",
i, hex::encode(m.digest()))?;
writeln!(output, "{} Computed digest: {}",
i, hex::encode(m.computed_digest()))?;
},
AED(ref a) => {
......@@ -712,7 +724,7 @@ impl PacketDumper {
}
fn dump_subpacket(&self, output: &mut dyn io::Write, i: &str,
s: Subpacket, sig: &Signature)
s: &Subpacket, sig: &Signature)
-> Result<()> {
use self::SubpacketValue::*;
......@@ -729,11 +741,6 @@ impl PacketDumper {
if s.critical() { " (critical)" } else { "" })?;
hexdump_unknown(output, b)?;
},
Invalid(ref b) => {
writeln!(output, "{} {:?}{}:", i, s.tag(),
if s.critical() { " (critical)" } else { "" })?;
hexdump_unknown(output, b)?;
},
SignatureCreationTime(t) =>
write!(output, "{} Signature creation time: {}", i,
(*t).convert())?,
......@@ -741,7 +748,7 @@ impl PacketDumper {
write!(output, "{} Signature expiration time: {} ({})",
i, t.convert(),
if let Some(creation) = sig.signature_creation_time() {
(creation + *t).convert().to_string()
(creation + t.clone().into()).convert().to_string()
} else {
" (no Signature Creation Time subpacket)".into()
})?,
......@@ -817,7 +824,7 @@ impl PacketDumper {
}
match s.value() {
Unknown(_) | Invalid(_) => (),
Unknown(_) => (),
EmbeddedSignature(ref sig) => {
if s.critical() {
write!(output, " (critical)")?;
......@@ -825,7 +832,8 @@ impl PacketDumper {
writeln!(output)?;
let indent = format!("{} ", i);
write!(output, "{}", indent)?;
self.dump_packet(output, &indent, None, sig, None, None)?;
self.dump_packet(output, &indent, None, &sig.clone().into(),
None, None)?;
},
_ => {
if s.critical() {
......
......@@ -5,9 +5,9 @@ pub fn decrypt_pkesk(pkesk: &openpgp::packet::PKESK)
-> Option<openpgp::crypto::SessionKey>
{
lazy_static::lazy_static! {
pub static ref TPKS: Vec<openpgp::TPK> = {
pub static ref CERTS: Vec<openpgp::Cert> = {
vec![
openpgp::TPK::from_bytes("
openpgp::Cert::from_bytes("
-----BEGIN PGP PRIVATE KEY BLOCK-----
Comment: Alice's OpenPGP Transferable Secret Key
......@@ -25,7 +25,7 @@ Pnn+We1aTBhaGa86AQ==
=n8OM
-----END PGP PRIVATE KEY BLOCK-----
").unwrap(),
openpgp::TPK::from_bytes("
openpgp::Cert::from_bytes("
-----BEGIN PGP PRIVATE KEY BLOCK-----
Comment: Bob's OpenPGP Transferable Secret Key
......@@ -113,13 +113,12 @@ xqAY9Bwizt4FWgXuLm1a4+So4V9j1TRCXd12Uc2l2RNmgDE=
};
}
let mode = openpgp::types::KeyFlags::default()
.set_encrypt_at_rest(true).set_encrypt_for_transport(true);
for tpk in TPKS.iter() {
for (_, _, key) in tpk.keys_all().secret().key_flags(mode.clone()) {
for tpk in CERTS.iter() {
for ka in tpk.keys().secret()
.for_transport_encryption().for_storage_encryption()
{
let mut keypair =
key.clone().into_keypair().unwrap();
ka.key().clone().into_keypair().unwrap();
if let Ok((_, sk)) = pkesk.decrypt(&mut keypair) {
return Some(sk);
}
......
......@@ -13,7 +13,7 @@ use rocket_contrib::templates::Template;
extern crate serde_json;
extern crate sequoia_openpgp as openpgp;
use openpgp::conversions::hex;
use openpgp::fmt::hex;
use openpgp::crypto::SessionKey;
mod known_keys;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment