You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing with rustls I noticed that sec1-der and pem exported ec private keys would fail to decode. The following is a minimal reproducer. I will say, this could be my fault for mishandling the API somehow, but after a lot of testing and verification I think there may be a fault in the way that sec1 is encoded.
Any advice would be welcome.
#[cfg(test)]
mod tests {
use p384::ecdsa::SigningKey;
use p384::pkcs8::DecodePrivateKey;
use p384::pkcs8::EncodePrivateKey;
use p384::SecretKey;
use sec1::DecodeEcPrivateKey;
#[test]
fn sec1_pem() {
let mut rng = rand::thread_rng();
let signing_key = SigningKey::random(&mut rng);
let server_private_key_pem = SecretKey::from(&signing_key)
.to_sec1_pem(Default::default())
.unwrap();
let _ = SigningKey::from_sec1_pem(server_private_key_pem.as_str()).unwrap();
}
#[test]
fn sec1_der() {
let mut rng = rand::thread_rng();
let signing_key = SigningKey::random(&mut rng);
let server_private_key_pem = SecretKey::from(&signing_key).to_sec1_der().unwrap();
let _ = SigningKey::from_sec1_der(server_private_key_pem.as_slice()).unwrap();
}
}
thread 'tests::sec1_pem' panicked at src/lib.rs:19:76:
called `Result::unwrap()` on an `Err` value: Pkcs8(PublicKey(AlgorithmParametersMissing))
thread 'tests::sec1_der' panicked at src/lib.rs:30:78:
called `Result::unwrap()` on an `Err` value: Pkcs8(PublicKey(AlgorithmParametersMissing))
[package]
name = "rustcrypto-sec1"
version = "0.1.0"
edition = "2021"
[dependencies]
p384 = "0.13"
sec1 = "0.7"
rand = "0.8"
The text was updated successfully, but these errors were encountered:
While testing with rustls I noticed that sec1-der and pem exported ec private keys would fail to decode. The following is a minimal reproducer. I will say, this could be my fault for mishandling the API somehow, but after a lot of testing and verification I think there may be a fault in the way that sec1 is encoded.
Any advice would be welcome.
The text was updated successfully, but these errors were encountered: