keyfork-derive-openpgp: make clippy happy
This commit is contained in:
parent
dc1e192b67
commit
2aba00c457
|
@ -45,7 +45,7 @@ pub enum Error {
|
||||||
|
|
||||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
pub fn derive(data: DerivationResponse, keys: &[KeyFlags], userid: UserID) -> Result<Cert> {
|
pub fn derive(data: DerivationResponse, keys: &[KeyFlags], userid: &UserID) -> Result<Cert> {
|
||||||
let primary_key_flags = match keys.get(0) {
|
let primary_key_flags = match keys.get(0) {
|
||||||
Some(kf) if kf.for_certification() => kf,
|
Some(kf) if kf.for_certification() => kf,
|
||||||
_ => return Err(Error::NotCert),
|
_ => return Err(Error::NotCert),
|
||||||
|
@ -96,16 +96,14 @@ pub fn derive(data: DerivationResponse, keys: &[KeyFlags], userid: UserID) -> Re
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
epoch,
|
epoch,
|
||||||
)
|
)?
|
||||||
.expect("keyforkd gave invalid cv25519 key"),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Key::from(
|
Key::from(
|
||||||
Key4::<_, SubordinateRole>::import_secret_ed25519(
|
Key4::<_, SubordinateRole>::import_secret_ed25519(
|
||||||
&PrivateKey::to_bytes(derived_key.private_key()),
|
&PrivateKey::to_bytes(derived_key.private_key()),
|
||||||
epoch,
|
epoch,
|
||||||
)
|
)?
|
||||||
.expect("keyforkd gave invalid ed25519 key"),
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use keyfork_derive_util::{
|
||||||
DerivationIndex, DerivationPath,
|
DerivationIndex, DerivationPath,
|
||||||
};
|
};
|
||||||
use keyforkd_client::Client;
|
use keyforkd_client::Client;
|
||||||
use sequoia_openpgp::{packet::UserID, types::KeyFlags};
|
use sequoia_openpgp::{packet::UserID, types::KeyFlags, armor::{Kind, Writer}, serialize::Marshal};
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum Error {
|
enum Error {
|
||||||
|
@ -15,41 +15,41 @@ enum Error {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct KeyType {
|
struct KeyType {
|
||||||
_inner: KeyFlags,
|
inner: KeyFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for KeyType {
|
impl Default for KeyType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
_inner: KeyFlags::empty(),
|
inner: KeyFlags::empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeyType {
|
impl KeyType {
|
||||||
fn certify(mut self) -> Self {
|
fn certify(mut self) -> Self {
|
||||||
self._inner = self._inner.set_certification();
|
self.inner = self.inner.set_certification();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sign(mut self) -> Self {
|
fn sign(mut self) -> Self {
|
||||||
self._inner = self._inner.set_signing();
|
self.inner = self.inner.set_signing();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encrypt(mut self) -> Self {
|
fn encrypt(mut self) -> Self {
|
||||||
self._inner = self._inner.set_transport_encryption();
|
self.inner = self.inner.set_transport_encryption();
|
||||||
self._inner = self._inner.set_storage_encryption();
|
self.inner = self.inner.set_storage_encryption();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn authenticate(mut self) -> Self {
|
fn authenticate(mut self) -> Self {
|
||||||
self._inner = self._inner.set_authentication();
|
self.inner = self.inner.set_authentication();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inner(&self) -> &KeyFlags {
|
fn inner(&self) -> &KeyFlags {
|
||||||
&self._inner
|
&self.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,12 +115,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
.map(|kt| kt.inner().clone())
|
.map(|kt| kt.inner().clone())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let cert = keyfork_derive_openpgp::derive(derived_data, subkeys.as_slice(), default_userid)?;
|
let cert = keyfork_derive_openpgp::derive(derived_data, subkeys.as_slice(), &default_userid)?;
|
||||||
|
|
||||||
use sequoia_openpgp::{
|
|
||||||
armor::{Kind, Writer},
|
|
||||||
serialize::Marshal,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut w = Writer::new(std::io::stdout(), Kind::SecretKey)?;
|
let mut w = Writer::new(std::io::stdout(), Kind::SecretKey)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue