Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in Provider::load_private_key for RSA key #14

Open
ctz opened this issue Dec 9, 2024 · 2 comments
Open

Panic in Provider::load_private_key for RSA key #14

ctz opened this issue Dec 9, 2024 · 2 comments
Assignees

Comments

@ctz
Copy link

ctz commented Dec 9, 2024

Hello!

When calling Provider::load_private_key with a valid RSA key, a panic occurs as follows:

thread 'main' panicked at /home/jbp/.cargo/git/checkouts/rustls-wolfcrypt-provider-d8a28048c104d2dd/0c7d407/rustls-wolfcrypt-provider/src/sign/ecdsa.rs:49:36:
called `Result::unwrap()` on an `Err` value: Failure
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
   2: core::result::unwrap_failed
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/result.rs:1700:5
   3: core::result::Result<T,E>::unwrap
             at /home/jbp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1104:23
   4: <rustls_wolfcrypt_provider::sign::ecdsa::EcdsaSigningKeyP256Sign as core::convert::TryFrom<&rustls_pki_types::PrivateKeyDer>>::try_from
             at /home/jbp/.cargo/git/checkouts/rustls-wolfcrypt-provider-d8a28048c104d2dd/0c7d407/rustls-wolfcrypt-provider/src/sign/ecdsa.rs:49:17
   5: <rustls_wolfcrypt_provider::Provider as rustls::crypto::KeyProvider>::load_private_key::{{closure}}
             at /home/jbp/.cargo/git/checkouts/rustls-wolfcrypt-provider-d8a28048c104d2dd/0c7d407/rustls-wolfcrypt-provider/src/lib.rs:88:17
   6: <rustls_wolfcrypt_provider::Provider as rustls::crypto::KeyProvider>::load_private_key
             at /home/jbp/.cargo/git/checkouts/rustls-wolfcrypt-provider-d8a28048c104d2dd/0c7d407/rustls-wolfcrypt-provider/src/lib.rs:106:9
   7: rustls::server::builder::<impl rustls::builder::ConfigBuilder<rustls::server::server_conn::ServerConfig,rustls::server::builder::WantsServerCert>>::with_single_cert
             at /home/jbp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.19/src/server/builder.rs:70:27
   8: rustls_bench::Parameters::server_config
             at ./rustls-bench/src/main.rs:801:23
   9: rustls_bench::bench_bulk
             at ./rustls-bench/src/main.rs:523:25
  10: rustls_bench::all_tests
             at ./rustls-bench/src/main.rs:238:9
  11: rustls_bench::main
             at ./rustls-bench/src/main.rs:105:13
  12: core::ops::function::FnOnce::call_once
             at /home/jbp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I think if this error is bubbled up rather than unwrap()ed, this should work.

@gasbytes
Copy link
Contributor

gasbytes commented Dec 9, 2024

Hello @ctz,

Thanks for the report! I'm actually working on #13 that should fix these problems with the signer, the only fallback is p256 right now to load a private key, but I added all the missing ones in the pr with proper testing and some bugs came out during this process.
By end of this week I should finish up the sign/verify tests in the e2e test suite and get it merged.

Thanks again for the report, do you mind me asking what are you working on? From the logs it seems like you are working on benchmarking the provider, is that right?

@ctz
Copy link
Author

ctz commented Dec 9, 2024

Thanks again for the report, do you mind me asking what are you working on? From the logs it seems like you are working on benchmarking the provider, is that right?

Yes, I was doing some comparative benchmarks between all the providers we have linked in the rustls readme. Not planning on publishing the results, mainly done for my own interest at this point.

@gasbytes gasbytes self-assigned this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants