Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
getrandom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
felixmoebius
getrandom
Commits
70f6ff70
Unverified
Commit
70f6ff70
authored
5 years ago
by
Artyom Pavlov
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Prepare v0.1.4 release (#42)
parent
ea999a6d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+27
-0
27 additions, 0 deletions
CHANGELOG.md
Cargo.toml
+2
-2
2 additions, 2 deletions
Cargo.toml
src/rdrand.rs
+15
-12
15 additions, 12 deletions
src/rdrand.rs
with
44 additions
and
14 deletions
CHANGELOG.md
+
27
−
0
View file @
70f6ff70
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
2
−
2
View file @
70f6ff70
[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]
...
...
This diff is collapsed.
Click to expand it.
src/rdrand.rs
+
15
−
12
View file @
70f6ff70
...
...
@@ -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
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment