@@ -1020,8 +1020,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
10201020 #[ cfg( unix) ]
10211021 fn create_test_cert ( ca_key : & PrivateKey , user_key : & PrivateKey ) -> ssh_key:: Certificate {
10221022 use ssh_key:: certificate;
1023- use ssh_key:: rand_core:: OsRng ;
1024- use std:: time:: { SystemTime , UNIX_EPOCH } ;
1023+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
10251024
10261025 let now = SystemTime :: now ( )
10271026 . duration_since ( UNIX_EPOCH )
@@ -1031,7 +1030,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
10311030 let valid_before = now + 86400 * 365 ; // 1 year from now
10321031
10331032 let mut builder = certificate:: Builder :: new_with_random_nonce (
1034- & mut OsRng ,
1033+ & mut rand :: rng ( ) ,
10351034 user_key. public_key ( ) ,
10361035 valid_after,
10371036 valid_before,
@@ -1049,18 +1048,17 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
10491048 #[ cfg( unix) ]
10501049 async fn test_request_identities_full_with_keys_and_certs ( ) {
10511050 use crate :: keys:: agent:: { AgentIdentity , client:: AgentClient } ;
1052- use ssh_key:: rand_core:: OsRng ;
1053- use std:: io:: Write ;
1051+ use std:: io:: Write ;
10541052 use std:: process:: Stdio ;
10551053
10561054 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
10571055
10581056 let ( mut agent, agent_path, dir) = spawn_agent ( ) . await . unwrap ( ) ;
10591057
10601058 // Create a CA key and user key
1061- let ca_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1062- let user_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1063- let plain_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1059+ let ca_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1060+ let user_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1061+ let plain_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
10641062
10651063 // Create a certificate
10661064 let cert = create_test_cert ( & ca_key, & user_key) ;
@@ -1176,17 +1174,16 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
11761174 #[ cfg( unix) ]
11771175 async fn test_sign_request_cert ( ) {
11781176 use crate :: keys:: agent:: client:: AgentClient ;
1179- use ssh_key:: rand_core:: OsRng ;
1180- use std:: io:: Write ;
1177+ use std:: io:: Write ;
11811178 use std:: process:: Stdio ;
11821179
11831180 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
11841181
11851182 let ( mut agent, agent_path, dir) = spawn_agent ( ) . await . unwrap ( ) ;
11861183
11871184 // Create a CA key and user key
1188- let ca_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1189- let user_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1185+ let ca_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1186+ let user_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
11901187
11911188 // Create a certificate
11921189 let cert = create_test_cert ( & ca_key, & user_key) ;
@@ -1254,15 +1251,14 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
12541251 #[ cfg( unix) ]
12551252 async fn test_sign_request_cert_missing_key_returns_agent_failure ( ) {
12561253 use crate :: keys:: agent:: client:: AgentClient ;
1257- use ssh_key:: rand_core:: OsRng ;
1258-
1254+
12591255 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
12601256
12611257 let ( mut agent, agent_path, _dir) = spawn_agent ( ) . await . unwrap ( ) ;
12621258
12631259 // Create a CA key and user key, but DON'T add them to the agent
1264- let ca_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1265- let user_key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1260+ let ca_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1261+ let user_key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
12661262
12671263 // Create a certificate
12681264 let cert = create_test_cert ( & ca_key, & user_key) ;
@@ -1307,14 +1303,13 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13071303 #[ cfg( unix) ]
13081304 async fn test_sign_request_missing_key_returns_agent_failure ( ) {
13091305 use crate :: keys:: agent:: client:: AgentClient ;
1310- use ssh_key:: rand_core:: OsRng ;
1311-
1306+
13121307 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
13131308
13141309 let ( mut agent, agent_path, _dir) = spawn_agent ( ) . await . unwrap ( ) ;
13151310
13161311 // Create a key but DON'T add it to the agent
1317- let key = PrivateKey :: random ( & mut OsRng , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
1312+ let key = PrivateKey :: random ( & mut rand :: rng ( ) , ssh_key:: Algorithm :: Ed25519 ) . unwrap ( ) ;
13181313
13191314 // Connect to agent WITHOUT adding any keys
13201315 let stream = tokio:: net:: UnixStream :: connect ( & agent_path) . await . unwrap ( ) ;
@@ -1358,8 +1353,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13581353 #[ cfg( all( unix, feature = "rsa" ) ) ]
13591354 fn create_test_rsa_cert ( ca_key : & PrivateKey , user_key : & PrivateKey ) -> ssh_key:: Certificate {
13601355 use ssh_key:: certificate;
1361- use ssh_key:: rand_core:: OsRng ;
1362- use std:: time:: { SystemTime , UNIX_EPOCH } ;
1356+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
13631357
13641358 let now = SystemTime :: now ( )
13651359 . duration_since ( UNIX_EPOCH )
@@ -1369,7 +1363,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13691363 let valid_before = now + 86400 * 365 ; // 1 year from now
13701364
13711365 let mut builder = certificate:: Builder :: new_with_random_nonce (
1372- & mut OsRng ,
1366+ & mut rand :: rng ( ) ,
13731367 user_key. public_key ( ) ,
13741368 valid_after,
13751369 valid_before,
@@ -1387,8 +1381,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13871381 #[ cfg( all( unix, feature = "rsa" ) ) ]
13881382 async fn test_sign_request_cert_rsa ( ) {
13891383 use crate :: keys:: agent:: client:: AgentClient ;
1390- use ssh_key:: rand_core:: OsRng ;
1391- use std:: io:: Write ;
1384+ use std:: io:: Write ;
13921385 use std:: process:: Stdio ;
13931386
13941387 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
@@ -1397,14 +1390,14 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
13971390
13981391 // Create RSA CA key and user key
13991392 let ca_key = PrivateKey :: random (
1400- & mut OsRng ,
1393+ & mut rand :: rng ( ) ,
14011394 ssh_key:: Algorithm :: Rsa {
14021395 hash : Some ( HashAlg :: Sha256 ) ,
14031396 } ,
14041397 )
14051398 . unwrap ( ) ;
14061399 let user_key = PrivateKey :: random (
1407- & mut OsRng ,
1400+ & mut rand :: rng ( ) ,
14081401 ssh_key:: Algorithm :: Rsa {
14091402 hash : Some ( HashAlg :: Sha256 ) ,
14101403 } ,
@@ -1482,8 +1475,7 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
14821475 #[ cfg( all( unix, feature = "rsa" ) ) ]
14831476 async fn test_sign_request_cert_rsa_sha512 ( ) {
14841477 use crate :: keys:: agent:: client:: AgentClient ;
1485- use ssh_key:: rand_core:: OsRng ;
1486- use std:: io:: Write ;
1478+ use std:: io:: Write ;
14871479 use std:: process:: Stdio ;
14881480
14891481 env_logger:: try_init ( ) . unwrap_or ( ( ) ) ;
@@ -1492,14 +1484,14 @@ Cog3JMeTrb3LiPHgN6gU2P30MRp6L1j1J/MtlOAr5rux
14921484
14931485 // Create RSA CA key and user key
14941486 let ca_key = PrivateKey :: random (
1495- & mut OsRng ,
1487+ & mut rand :: rng ( ) ,
14961488 ssh_key:: Algorithm :: Rsa {
14971489 hash : Some ( HashAlg :: Sha512 ) ,
14981490 } ,
14991491 )
15001492 . unwrap ( ) ;
15011493 let user_key = PrivateKey :: random (
1502- & mut OsRng ,
1494+ & mut rand :: rng ( ) ,
15031495 ssh_key:: Algorithm :: Rsa {
15041496 hash : Some ( HashAlg :: Sha512 ) ,
15051497 } ,
0 commit comments