Skip to content

Commit 5142481

Browse files
committed
Merge remote-tracking branch 'origin/master' and update changelog
2 parents e1e4005 + afc9d9a commit 5142481

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ matrix:
137137
- rustup target add wasm32-unknown-emscripten
138138
- nvm install 9
139139
- ./utils/ci/install_cargo_web.sh
140+
- cargo web prepare-emscripten
140141
- cargo web -V
141142
addons:
142143
chrome: stable
@@ -211,7 +212,11 @@ script:
211212

212213
after_script: set +e
213214

214-
cache: cargo
215+
cache:
216+
cargo: true
217+
directories:
218+
- .local/share/cargo-web
219+
215220
before_cache:
216221
# Travis can't cache files that are not readable by "others"
217222
- chmod -R a+r $HOME/.cargo

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
1010

1111

1212
## [0.6.4] - 2019-01-08
13+
### Additions
14+
- Add support for x86_64-fortanix-unknown-sgx target (#670)
15+
1316
### Fixes
1417
- Move wasm-bindgen shims to correct crate (#686)
1518
- Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686)

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,6 @@ autocfg = "0.1"
7979

8080
[package.metadata.docs.rs]
8181
all-features = true
82+
83+
[patch.crates-io]
84+
rand_core = { path = "rand_core", version = "0.3", default-features = false }

rand_os/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ fuchsia-zircon = "0.3.2"
3333
[target.wasm32-unknown-unknown.dependencies]
3434
wasm-bindgen = { version = "0.2.12", optional = true }
3535
stdweb = { version = "0.4", optional = true }
36+
37+
[target.'cfg(target_env = "sgx")'.dependencies]
38+
rdrand = "0.4.0"

rand_os/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ extern crate wasm_bindgen;
142142
feature = "stdweb"))]
143143
#[macro_use] extern crate stdweb;
144144

145+
#[cfg(target_env = "sgx")]
146+
extern crate rdrand;
145147

146148
#[cfg(not(feature = "log"))]
147149
#[macro_use]
@@ -310,6 +312,7 @@ mod_use!(cfg(target_os = "openbsd"), openbsd_bitrig);
310312
mod_use!(cfg(target_os = "redox"), redox);
311313
mod_use!(cfg(target_os = "solaris"), solaris);
312314
mod_use!(cfg(windows), windows);
315+
mod_use!(cfg(target_env = "sgx"), sgx);
313316

314317
mod_use!(
315318
cfg(all(
@@ -376,6 +379,7 @@ mod imp {
376379
target_os = "solaris",
377380
windows,
378381
target_arch = "wasm32",
382+
target_env = "sgx"
379383
)))]
380384
compile_error!("OS RNG support is not available for this platform");
381385

rand_os/src/sgx.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2018 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+
use super::OsRngImpl;
10+
use Error;
11+
use rdrand::RdRand;
12+
use rand_core::RngCore;
13+
use std::fmt::{Debug, Formatter, Result as FmtResult};
14+
15+
#[derive(Clone)]
16+
pub struct OsRng{
17+
gen: RdRand
18+
}
19+
20+
impl OsRngImpl for OsRng {
21+
fn new() -> Result<OsRng, Error> {
22+
let rng = RdRand::new()?;
23+
Ok(OsRng{ gen: rng })
24+
}
25+
26+
fn fill_chunk(&mut self, dest: &mut [u8]) -> Result<(), Error> {
27+
self.gen.try_fill_bytes(dest)
28+
}
29+
30+
fn method_str(&self) -> &'static str { "RDRAND" }
31+
}
32+
33+
impl Debug for OsRng {
34+
fn fmt(&self, f: &mut Formatter) -> FmtResult {
35+
f.debug_struct("OsRng")
36+
.finish()
37+
}
38+
}

0 commit comments

Comments
 (0)