File tree 4 files changed +39
-1
lines changed
4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ jobs:
314
314
run : cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc
315
315
- name : VxWorks
316
316
run : cargo build -Z build-std=core --target=x86_64-wrs-vxworks
317
+ - name : SOLID
318
+ run : cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3
317
319
318
320
clippy-fmt :
319
321
name : Clippy + rustfmt
Original file line number Diff line number Diff line change @@ -73,7 +73,14 @@ impl Error {
73
73
#[ inline]
74
74
pub fn raw_os_error ( self ) -> Option < i32 > {
75
75
if self . 0 . get ( ) < Self :: INTERNAL_START {
76
- Some ( self . 0 . get ( ) as i32 )
76
+ match ( ) {
77
+ #[ cfg( target_os = "solid_asp3" ) ]
78
+ // On SOLID, negate the error code again to obtain the original
79
+ // error code.
80
+ ( ) => Some ( -( self . 0 . get ( ) as i32 ) ) ,
81
+ #[ cfg( not( target_os = "solid_asp3" ) ) ]
82
+ ( ) => Some ( self . 0 . get ( ) as i32 ) ,
83
+ }
77
84
} else {
78
85
None
79
86
}
Original file line number Diff line number Diff line change 30
30
//! | WASI | `wasm32‑wasi` | [`random_get`][17]
31
31
//! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues()`][14], see [WebAssembly support][16]
32
32
//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`][15], see [WebAssembly support][16]
33
+ //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
33
34
//!
34
35
//! There is no blanket implementation on `unix` targets that reads from
35
36
//! `/dev/urandom`. This ensures all supported targets are using the recommended
@@ -203,6 +204,8 @@ cfg_if! {
203
204
} else if #[ cfg( target_os = "vxworks" ) ] {
204
205
mod util_libc;
205
206
#[ path = "vxworks.rs" ] mod imp;
207
+ } else if #[ cfg( target_os = "solid_asp3" ) ] {
208
+ #[ path = "solid.rs" ] mod imp;
206
209
} else if #[ cfg( windows) ] {
207
210
#[ path = "windows.rs" ] mod imp;
208
211
} else if #[ cfg( all( target_arch = "x86_64" , target_env = "sgx" ) ) ] {
Original file line number Diff line number Diff line change
1
+ // Copyright 2021 Developers of the Rand project.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4
+ // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5
+ // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6
+ // option. This file may not be copied, modified, or distributed
7
+ // except according to those terms.
8
+
9
+ //! Implementation for SOLID
10
+ use crate :: Error ;
11
+ use core:: num:: NonZeroU32 ;
12
+
13
+ extern "C" {
14
+ pub fn SOLID_RNG_SampleRandomBytes ( buffer : * mut u8 , length : usize ) -> i32 ;
15
+ }
16
+
17
+ pub fn getrandom_inner ( dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
18
+ let ret = unsafe { SOLID_RNG_SampleRandomBytes ( dest. as_mut_ptr ( ) , dest. len ( ) ) } ;
19
+ if ret >= 0 {
20
+ Ok ( ( ) )
21
+ } else {
22
+ // ITRON error numbers are always negative, so we negate it so that it
23
+ // falls in the dedicated OS error range (1..INTERNAL_START).
24
+ Err ( NonZeroU32 :: new ( ( -ret) as u32 ) . unwrap ( ) . into ( ) )
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments