@@ -10,8 +10,6 @@ pub mod errno;
10
10
pub mod tcplistener;
11
11
pub mod tcpstream;
12
12
13
- use core:: mem:: MaybeUninit ;
14
-
15
13
use core:: ffi:: { c_int, c_void} ;
16
14
17
15
/// A thread handle type
@@ -453,16 +451,6 @@ extern "C" {
453
451
#[ link_name = "sys_network_init" ]
454
452
pub fn network_init ( ) -> i32 ;
455
453
456
- /// The function computes a sequence of pseudo-random integers
457
- /// in the range of 0 to RAND_MAX
458
- #[ link_name = "sys_rand" ]
459
- pub fn rand ( ) -> u32 ;
460
-
461
- /// The function sets its argument as the seed for a new sequence
462
- /// of pseudo-random numbers to be returned by `rand`
463
- #[ link_name = "sys_srand" ]
464
- pub fn srand ( seed : u32 ) ;
465
-
466
454
/// Add current task to the queue of blocked tasks. After calling `block_current_task`,
467
455
/// call `yield_now` to switch to another task.
468
456
#[ link_name = "sys_block_current_task" ]
@@ -497,6 +485,14 @@ extern "C" {
497
485
#[ link_name = "sys_read" ]
498
486
pub fn read ( fd : i32 , buf : * mut u8 , len : usize ) -> isize ;
499
487
488
+ /// Fill `len` bytes in `buf` with cryptographically secure random data.
489
+ ///
490
+ /// Returns either the number of bytes written to buf (a positive value) or
491
+ /// * `-EINVAL` if `flags` contains unknown flags.
492
+ /// * `-ENOSYS` if the system does not support random data generation.
493
+ #[ link_name = "sys_read_entropy" ]
494
+ pub fn read_entropy ( buf : * mut u8 , len : usize , flags : u32 ) -> isize ;
495
+
500
496
/// receive() a message from a socket
501
497
#[ link_name = "sys_recv" ]
502
498
pub fn recv ( socket : i32 , buf : * mut u8 , len : usize , flags : i32 ) -> isize ;
@@ -599,32 +595,10 @@ extern "C" {
599
595
res : * mut * mut addrinfo ,
600
596
) -> i32 ;
601
597
602
- fn sys_secure_rand32 ( value : * mut u32 ) -> i32 ;
603
- fn sys_secure_rand64 ( value : * mut u64 ) -> i32 ;
604
598
fn sys_get_priority ( ) -> u8 ;
605
599
fn sys_set_priority ( tid : Tid , prio : u8 ) ;
606
600
}
607
601
608
- /// Create a cryptographicly secure 32bit random number with the support of
609
- /// the underlying hardware. If the required hardware isn't available,
610
- /// the function returns `None`.
611
- #[ inline( always) ]
612
- pub unsafe fn secure_rand32 ( ) -> Option < u32 > {
613
- let mut rand = MaybeUninit :: uninit ( ) ;
614
- let res = sys_secure_rand32 ( rand. as_mut_ptr ( ) ) ;
615
- ( res == 0 ) . then ( || rand. assume_init ( ) )
616
- }
617
-
618
- /// Create a cryptographicly secure 64bit random number with the support of
619
- /// the underlying hardware. If the required hardware isn't available,
620
- /// the function returns `None`.
621
- #[ inline( always) ]
622
- pub unsafe fn secure_rand64 ( ) -> Option < u64 > {
623
- let mut rand = MaybeUninit :: uninit ( ) ;
624
- let res = sys_secure_rand64 ( rand. as_mut_ptr ( ) ) ;
625
- ( res == 0 ) . then ( || rand. assume_init ( ) )
626
- }
627
-
628
602
/// Determine the priority of the current thread
629
603
#[ inline( always) ]
630
604
pub unsafe fn get_priority ( ) -> Priority {
0 commit comments