diff --git a/openpgp-card-sequoia/Cargo.toml b/openpgp-card-sequoia/Cargo.toml index 6096298..b22d3e5 100644 --- a/openpgp-card-sequoia/Cargo.toml +++ b/openpgp-card-sequoia/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://gitlab.com/hkos/openpgp-card" documentation = "https://docs.rs/crate/openpgp-card-sequoia" [dependencies] -sequoia-openpgp = "1.3" +sequoia-openpgp = "1.4" nettle = "7" openpgp-card = { path = "../openpgp-card", version = "0.0.4" } openpgp-card-pcsc = { path = "../pcsc", version = "0.0.4" } diff --git a/openpgp-card-sequoia/src/privkey.rs b/openpgp-card-sequoia/src/privkey.rs index 1745b4f..fdc92f5 100644 --- a/openpgp-card-sequoia/src/privkey.rs +++ b/openpgp-card-sequoia/src/privkey.rs @@ -225,9 +225,9 @@ impl EccKey for SqEccKey { fn get_private(&self) -> Vec { // FIXME: padding for 25519? match self.curve { - Curve::NistP256 => util::left_zero_pad(self.private.value(), 0x20), - Curve::NistP384 => util::left_zero_pad(self.private.value(), 0x30), - Curve::NistP521 => util::left_zero_pad(self.private.value(), 0x42), + Curve::NistP256 => self.private.value_padded(0x20).to_vec(), + Curve::NistP384 => self.private.value_padded(0x30).to_vec(), + Curve::NistP521 => self.private.value_padded(0x42).to_vec(), _ => self.private.value().to_vec(), } } diff --git a/openpgp-card-sequoia/src/util.rs b/openpgp-card-sequoia/src/util.rs index 9969c54..defa580 100644 --- a/openpgp-card-sequoia/src/util.rs +++ b/openpgp-card-sequoia/src/util.rs @@ -305,16 +305,3 @@ pub fn decrypt( Ok(decrypted) } - -/// This fn prepends zeros to `value` so that the resulting Vec has -/// len `size`. -/// -/// (Leading zero-bytes may be stripped from MPIs, this fn is a helper for -/// re-creating the non-stripped representation of an MPI) -pub(crate) fn left_zero_pad(value: &[u8], size: usize) -> Vec { - let pad = size - value.len(); - let mut res = vec![0; pad]; - res.extend_from_slice(value); - - res -}