Skip to content
Snippets Groups Projects
Unverified Commit 70f6ff70 authored by Artyom Pavlov's avatar Artyom Pavlov Committed by GitHub
Browse files

Prepare v0.1.4 release (#42)

parent ea999a6d
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.3] - 2019-06-28
### Added
- Add support for `x86_64-unknown-uefi` target by using RDRAND with CPUID
feature detection. [#30]
### Fixed
- Fix long buffer issues on Windows and Linux. [#31] [#32]
- Check `EPERM` in addition to `ENOSYS` on Linux. [#37]
### Changed
- Improve efficiency by sharing file descriptor across threads. [#13]
- Remove `cloudabi`, `winapi`, and `fuchsia-cprng` dependencies. [#40]
- Improve RDRAND implementation. [#24]
- Don't block during syscall detection on Linux. [#26]
- Increase consistency with libc implementation on FreeBSD. [#36]
- Apply `rustfmt`. [#39]
[#30]: https://github.com/rust-random/getrandom/pull/30
[#13]: https://github.com/rust-random/getrandom/issues/13
[#40]: https://github.com/rust-random/getrandom/pull/40
[#26]: https://github.com/rust-random/getrandom/pull/26
[#24]: https://github.com/rust-random/getrandom/pull/24
[#39]: https://github.com/rust-random/getrandom/pull/39
[#36]: https://github.com/rust-random/getrandom/pull/36
[#31]: https://github.com/rust-random/getrandom/issues/31
[#32]: https://github.com/rust-random/getrandom/issues/32
[#37]: https://github.com/rust-random/getrandom/issues/37
## [0.1.3] - 2019-05-15
- Update for `wasm32-unknown-wasi` being renamed to `wasm32-wasi`, and for
......
[package]
name = "getrandom"
version = "0.1.3"
version = "0.1.4"
edition = "2018"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
......@@ -28,7 +28,7 @@ libc = "0.2.54"
lazy_static = "1.3.0"
# For caching result of CPUID check for RDRAND
[target.'cfg(any(target_env = "sgx", target_os = "uefi"))'.dependencies]
[target.'cfg(target_os = "uefi")'.dependencies]
lazy_static = { version = "1.3.0", features = ["spin_no_std"] }
[target.wasm32-unknown-unknown.dependencies]
......
......@@ -8,10 +8,9 @@
//! Implementation for SGX using RDRAND instruction
use crate::Error;
use core::arch::x86_64::{__cpuid, _rdrand64_step};
use core::arch::x86_64::_rdrand64_step;
use core::mem;
use core::num::NonZeroU32;
use lazy_static::lazy_static;
// Recommendation from "Intel® Digital Random Number Generator (DRNG) Software
// Implementation Guide" - Section 5.2.1 and "Intel® 64 and IA-32 Architectures
......@@ -37,19 +36,23 @@ compile_error!(
"SGX targets require 'rdrand' target feature. Enable by using -C target-feature=+rdrnd."
);
#[cfg(any(target_env = "sgx", target_feature = "rdrand"))]
fn is_rdrand_supported() -> bool {
true
}
// TODO use is_x86_feature_detected!("rdrand") when that works in core. See:
// https://github.com/rust-lang-nursery/stdsimd/issues/464
// https://github.com/rust-lang-nursery/stdsimd/issues/464
#[cfg(not(any(target_env = "sgx", target_feature = "rdrand")))]
fn is_rdrand_supported() -> bool {
if cfg!(target_feature = "rdrand") {
true
} else {
// SAFETY: All x86_64 CPUs support CPUID leaf 1
const FLAG: u32 = 1 << 30;
lazy_static! {
static ref HAS_RDRAND: bool = unsafe { __cpuid(1).ecx & FLAG != 0 };
}
*HAS_RDRAND
use core::arch::x86_64::__cpuid;
use lazy_static::lazy_static;
// SAFETY: All x86_64 CPUs support CPUID leaf 1
const FLAG: u32 = 1 << 30;
lazy_static! {
static ref HAS_RDRAND: bool = unsafe { __cpuid(1).ecx & FLAG != 0 };
}
*HAS_RDRAND
}
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment