openpgp-card-sequoia: fix padding for Curve 25519 private key material.

Importing 25519 keys with leading zero bytes led to failures on at least Gnuk and Nitrokey's opgpcard-rs implementation.

Reported by Wiktor Kwapisiewicz, also see https://codeberg.org/wiktor/broken-nitro
This commit is contained in:
Heiko Schaefer 2023-04-08 13:49:01 +02:00
parent 7a28d36e93
commit 365670041f
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D

View file

@ -234,11 +234,11 @@ impl EccKey for SqEccKey {
}
fn private(&self) -> Vec<u8> {
// FIXME: padding for 25519?
match self.curve {
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(),
Curve::Cv25519 | Curve::Ed25519 => self.private.value_padded(0x20).to_vec(),
_ => self.private.value().to_vec(),
}
}