Skip to content

Conversation

@lovasoa
Copy link
Collaborator

@lovasoa lovasoa commented Nov 28, 2025

Update crypto-common and related crypto crates to their latest release candidate versions.

This update modernizes the crypto dependency stack, requiring adaptations to API changes in hmac (adding KeyInit trait) and digest output formatting (using .as_slice() for hex conversion).


Open in Cursor Open in Web

Updates several cryptographic dependencies to their latest release candidates. Fixes an issue with MD5 password hashing by correctly formatting the output.

Co-authored-by: contact <[email protected]>
@cursor
Copy link

cursor bot commented Nov 28, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@lovasoa
Copy link
Collaborator Author

lovasoa commented Nov 28, 2025

@cursoragent test locally with all feature combinations

Run cargo clippy --manifest-path sqlx-core/Cargo.toml \
  cargo clippy --manifest-path sqlx-core/Cargo.toml \
    --no-default-features \
    --features offline,all-databases,all-types,migrate,runtime-async-std-native-tls \
    -- -D warnings
    
error[E0107]: associated function takes 0 generic arguments but 1 generic argument was supplied
   --> sqlx-core/src/mysql/connection/auth.rs:151:25
    |
151 |     let padding = Oaep::new::<sha1::Sha1>();
    |                         ^^^-------------- help: remove the unnecessary generics
    |                         |
    |                         expected 0 generic arguments
    |
note: associated function defined here, with 0 generic parameters
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rsa-0.10.0-rc.10/src/oaep.rs:82:12
    |
 82 |     pub fn new() -> Self {
    |            ^^^

error[E0277]: the trait bound `rand::prelude::ThreadRng: rsa::rand_core::CryptoRng` is not satisfied
   --> sqlx-core/src/mysql/connection/auth.rs:152:18
    |
152 |     pkey.encrypt(&mut rand::thread_rng(), padding, &pass[..])
    |          ------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::DerefMut` is not implemented for `rand::prelude::ThreadRng`
    |          |
    |          required by a bound introduced by this call
    |
note: there are multiple different versions of crate `rand_core` in the dependency graph
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.10.0-rc-2/src/lib.rs:165:1
    |
165 | pub trait CryptoRng: RngCore {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
    |
   ::: sqlx-core/src/mysql/connection/auth.rs:4:5
    |
  4 | use rsa::{pkcs8::DecodePublicKey, Oaep, RsaPublicKey};
    |     --- one version of crate `rand_core` used here, as a dependency of crate `crypto_bigint`
    |
   ::: sqlx-core/src/postgres/connection/establish.rs:1:5
    |
  1 | use rand::Rng as _;
    |     ---- one version of crate `rand_core` used here, as a dependency of crate `rand`
    |
   ::: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand-0.8.5/src/rngs/thread.rs:62:1
    |
 62 | pub struct ThreadRng {
    | -------------------- this type doesn't implement the required trait
    |
   ::: /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand_core-0.6.4/src/block.rs:68:1
    |
 68 | pub trait BlockRngCore {
    | ---------------------- this is the found trait
    = help: you can use `cargo tree` to explore your dependency tree
    = note: required for `rand::prelude::ThreadRng` to implement `rsa::rand_core::CryptoRng`
note: required by a bound in `rsa::RsaPublicKey::encrypt`
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rsa-0.10.0-rc.10/src/key.rs:191:23
    |
191 |     pub fn encrypt<R: CryptoRng + ?Sized, P: PaddingScheme>(
    |                       ^^^^^^^^^ required by this bound in `RsaPublicKey::encrypt`

Some errors have detailed explanations: E0107, E0277.
For more information about an error, try `rustc --explain E0107`. 

@cursor
Copy link

cursor bot commented Nov 28, 2025

Compilation succeeded. Summary of fixes:

Summary

Fixed two compilation errors related to the updated RSA crate:

  1. Fixed Oaep::new() API usage: Changed Oaep::new::<sha1::Sha1>() to Oaep::<sha1::Sha1>::new() to match the new API where the hash type is a struct type parameter, not a method generic.

  2. Fixed RNG compatibility issue: Created a RandRngAdapter struct that bridges rand::rngs::ThreadRng (from rand 0.8, which uses rand_core 0.6) to the rsa::rand_core::RngCore trait (from rand_core 0.10) required by the new RSA crate. The adapter implements:

    • rsa::rand_core::RngCore with next_u32(), next_u64(), and fill_bytes()
    • rsa::rand_core::CryptoRng as a marker trait

The code now compiles successfully with all feature combinations. The OpenSSL error seen in CI is an environment issue (missing libssl-dev), not a code problem.


Open in Cursor Open in Web

Learn more about Cursor Agents

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

Successfully merging this pull request may close these issues.

3 participants