File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
sqlx-core/src/mysql/connection Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,29 @@ use crate::mysql::connection::stream::MySqlStream;
1010use crate :: mysql:: protocol:: auth:: AuthPlugin ;
1111use crate :: mysql:: protocol:: Packet ;
1212
13+ struct RandRngAdapter {
14+ rng : rand:: rngs:: ThreadRng ,
15+ }
16+
17+ impl rsa:: rand_core:: RngCore for RandRngAdapter {
18+ fn next_u32 ( & mut self ) -> u32 {
19+ use rand:: RngCore ;
20+ self . rng . next_u32 ( )
21+ }
22+
23+ fn next_u64 ( & mut self ) -> u64 {
24+ use rand:: RngCore ;
25+ self . rng . next_u64 ( )
26+ }
27+
28+ fn fill_bytes ( & mut self , dest : & mut [ u8 ] ) {
29+ use rand:: RngCore ;
30+ self . rng . fill_bytes ( dest)
31+ }
32+ }
33+
34+ impl rsa:: rand_core:: CryptoRng for RandRngAdapter { }
35+
1336impl AuthPlugin {
1437 pub ( super ) async fn scramble (
1538 self ,
@@ -148,8 +171,11 @@ async fn encrypt_rsa<'s>(
148171
149172 // client sends an RSA encrypted password
150173 let pkey = parse_rsa_pub_key ( rsa_pub_key) ?;
151- let padding = Oaep :: new :: < sha1:: Sha1 > ( ) ;
152- pkey. encrypt ( & mut rand:: thread_rng ( ) , padding, & pass[ ..] )
174+ let padding = Oaep :: < sha1:: Sha1 > :: new ( ) ;
175+ let mut rng = RandRngAdapter {
176+ rng : rand:: thread_rng ( ) ,
177+ } ;
178+ pkey. encrypt ( & mut rng, padding, & pass[ ..] )
153179 . map_err ( Error :: protocol)
154180}
155181
You can’t perform that action at this time.
0 commit comments