File tree 1 file changed +4
-9
lines changed
1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change 8
8
9
9
//! Implementation for iOS
10
10
use crate :: Error ;
11
-
12
- // TODO: Make extern once extern_types feature is stabilized. See:
13
- // https://github.com/rust-lang/rust/issues/43467
14
- #[ repr( C ) ]
15
- struct SecRandom ( [ u8 ; 0 ] ) ;
11
+ use core:: { ffi:: c_void, ptr:: null} ;
16
12
17
13
#[ link( name = "Security" , kind = "framework" ) ]
18
14
extern "C" {
19
- static kSecRandomDefault: * const SecRandom ;
20
-
21
- fn SecRandomCopyBytes ( rnd : * const SecRandom , count : usize , bytes : * mut u8 ) -> i32 ;
15
+ fn SecRandomCopyBytes ( rnd : * const c_void , count : usize , bytes : * mut u8 ) -> i32 ;
22
16
}
23
17
24
18
pub fn getrandom_inner ( dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
25
- let ret = unsafe { SecRandomCopyBytes ( kSecRandomDefault, dest. len ( ) , dest. as_mut_ptr ( ) ) } ;
19
+ // Apple's documentation guarantees kSecRandomDefault is a synonym for NULL.
20
+ let ret = unsafe { SecRandomCopyBytes ( null ( ) , dest. len ( ) , dest. as_mut_ptr ( ) ) } ;
26
21
if ret == -1 {
27
22
Err ( Error :: IOS_SEC_RANDOM )
28
23
} else {
You can’t perform that action at this time.
0 commit comments