@@ -10,8 +10,6 @@ pub mod errno;
1010pub mod tcplistener;
1111pub mod tcpstream;
1212
13- use core:: mem:: MaybeUninit ;
14-
1513use core:: ffi:: { c_int, c_void} ;
1614
1715/// A thread handle type
@@ -453,16 +451,6 @@ extern "C" {
453451 #[ link_name = "sys_network_init" ]
454452 pub fn network_init ( ) -> i32 ;
455453
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-
466454 /// Add current task to the queue of blocked tasks. After calling `block_current_task`,
467455 /// call `yield_now` to switch to another task.
468456 #[ link_name = "sys_block_current_task" ]
@@ -497,6 +485,14 @@ extern "C" {
497485 #[ link_name = "sys_read" ]
498486 pub fn read ( fd : i32 , buf : * mut u8 , len : usize ) -> isize ;
499487
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+
500496 /// receive() a message from a socket
501497 #[ link_name = "sys_recv" ]
502498 pub fn recv ( socket : i32 , buf : * mut u8 , len : usize , flags : i32 ) -> isize ;
@@ -599,32 +595,10 @@ extern "C" {
599595 res : * mut * mut addrinfo ,
600596 ) -> i32 ;
601597
602- fn sys_secure_rand32 ( value : * mut u32 ) -> i32 ;
603- fn sys_secure_rand64 ( value : * mut u64 ) -> i32 ;
604598 fn sys_get_priority ( ) -> u8 ;
605599 fn sys_set_priority ( tid : Tid , prio : u8 ) ;
606600}
607601
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-
628602/// Determine the priority of the current thread
629603#[ inline( always) ]
630604pub unsafe fn get_priority ( ) -> Priority {
0 commit comments