@@ -453,16 +453,6 @@ extern "C" {
453453 #[ link_name = "sys_network_init" ]
454454 pub fn network_init ( ) -> i32 ;
455455
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-
466456 /// Add current task to the queue of blocked tasks. After calling `block_current_task`,
467457 /// call `yield_now` to switch to another task.
468458 #[ link_name = "sys_block_current_task" ]
@@ -497,6 +487,14 @@ extern "C" {
497487 #[ link_name = "sys_read" ]
498488 pub fn read ( fd : i32 , buf : * mut u8 , len : usize ) -> isize ;
499489
490+ /// Fill `len` bytes in `buf` with cryptographically secure random data.
491+ ///
492+ /// Returns either the number of bytes written to buf (a positive value) or
493+ /// * `-EINVAL` if `flags` contains unknown flags.
494+ /// * `-ENOSYS` if the system does not support random data generation.
495+ #[ link_name = "sys_read_entropy" ]
496+ pub fn read_entropy ( buf : * mut u8 , len : usize , flags : u32 ) -> isize ;
497+
500498 /// receive() a message from a socket
501499 #[ link_name = "sys_recv" ]
502500 pub fn recv ( socket : i32 , buf : * mut u8 , len : usize , flags : i32 ) -> isize ;
@@ -599,32 +597,10 @@ extern "C" {
599597 res : * mut * mut addrinfo ,
600598 ) -> i32 ;
601599
602- fn sys_secure_rand32 ( value : * mut u32 ) -> i32 ;
603- fn sys_secure_rand64 ( value : * mut u64 ) -> i32 ;
604600 fn sys_get_priority ( ) -> u8 ;
605601 fn sys_set_priority ( tid : Tid , prio : u8 ) ;
606602}
607603
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-
628604/// Determine the priority of the current thread
629605#[ inline( always) ]
630606pub unsafe fn get_priority ( ) -> Priority {
0 commit comments