177 Commits

Author SHA1 Message Date
Joe Richey
10df5588c2 AppVeyor: Run CI on 0.2 branch
Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-25 12:13:57 -07:00
Joe Richey
7631f75292 ci: Pin the Cross binary to avoid breaking the CI
Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-25 03:00:58 -07:00
Diggory Hardy
8191d7f26b
Merge pull request from josephlr/fixing-webpack-warning
Apply  to 0.2 branch
2020-04-28 08:45:26 +01:00
Pauan
ec4a3e1f03 Fixing Webpack require warning 2020-04-27 15:57:14 -07:00
zer0x64
7bfdabf358 wasm-bindgen: Added support for Internet Explorer 11 2020-04-27 06:22:44 -07:00
Diggory Hardy
717b5cc654
Merge pull request from josephlr/nightly
travis: Allow nightly builds to fail
2020-04-27 09:38:01 +01:00
Joe Richey
c7862af490 travis: Allow nightly builds to fail 2020-04-27 00:51:12 -07:00
Joe Richey
74eca5e871 fmt: Use consistent include style 2020-04-27 00:14:53 -07:00
Joe Richey
138d903318 ios: Don't use SecRandom type
The type of the `rnd` parameter is SecRandomRef which is an alias for an
"Opaque Pointer". This is better represented in Rust as a c_void pointer.

We also know that kSecRandomDefault is NULL, so we can simplify the code.

https://developer.apple.com/documentation/security/1399291-secrandomcopybytes
https://developer.apple.com/documentation/security/secrandomref
https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/using_imported_c_functions_in_swift
2020-04-27 00:14:53 -07:00
Joe Richey
afcfcd1525 build: Remove getrandom_uwp cfg
As our minimum rust version is 1.33, we can just use `target_vendor`.
2020-04-27 00:14:53 -07:00
Joe Richey
b3d3fbcb10 assert: Make use of asserts consistent
- Use debug asserts in code
- Use normal asserts in tests
- Use *assert_eq! methods when possible
- Remove unnecessary asserts
2020-04-27 00:14:53 -07:00
Joe Richey
d1a84dbd0d error: Make internal_error! a function
Also make Error::code a const fn. These increase the Min Rust version to 1.33
2020-04-27 00:14:53 -07:00
Diggory Hardy
3d17318c59
Merge pull request from josephlr/travis
travis: Fix wasm32 CI
2020-04-26 14:47:36 +01:00
Joe Richey
c25d0a81eb
travis: Fix wasm32 CI
Split emscripten stuff into its own target and stop relying on cargo web
to download/manage then emscripten toolchain. We can just get it
ourselves. We also now run the emscripten tests.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-04-25 02:44:08 -07:00
Joe Richey
2e39004c4b rdrand: Add 32-bit x86 support
Also add tests for 32-bit x86
2020-02-20 15:24:57 -08:00
Joe Richey
52e7e9fe23 tests: Test CPU-based RNG on all x86 targets
This allows us to verify the RDRAND implementation on Linux.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey
1375181832 tests: Improve testing infrastructure
- Cleanup .travis.yml
  - Loops over std/no_std targets
  - Remove deprecated/useless keys
  - No more `cd`, we just use `--package`.
- Improve tests
  - Main `getrandom` tests are now unit test modules instead of
    integration tests, making the code cleaner.
  - The custom RNG crates now use this common module as part of their
    integration tests.
  - No more weird test-only features needed to get the crate to build.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey
ff6299dd77 cpu: Add support for CPU-based randomness
This allows freestanding targets to use getrandom.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey
cd84484205 target: Drop support for some x86_64 targets
We will use a more generic "cpu" mechanism to support these.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey
4263ac6bc4 custom: Allow no_std custom RNG handlers
Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey
8365277450 custom: Add Custom RNG for wasm-bindgen 2020-01-10 09:16:20 +00:00
Joe Richey
7d558f1cc3 custom: Add custom RNG for stdweb 2020-01-10 09:16:20 +00:00
Joe Richey
3d7a7b5f06 Remove built-in support for wasm32-unknown-unknown 2020-01-10 09:16:20 +00:00
Joe Richey
448bcac6b1 custom: Add support for Custom RNGs 2020-01-10 09:16:20 +00:00
Joseph Richey
d6b75d1c05
log: Remove optional log dependancy ()
This feature isn't enabled by rand/rand_core and provides very little
error information that isn't already conveyed through our Error values.

This also simplifies the supported configuration space for getrandom.
We update the docs and CI to match this change.
2020-01-09 13:27:09 -08:00
Joe Richey
0f14f2a186 Merge branch 'master' into 0.2
Signed-off-by: Joe Richey <joerichey@google.com>
2020-01-08 11:11:08 -08:00
Artyom Pavlov
33b859bae1
Prepare release v0.1.14 () 2020-01-07 12:05:23 +00:00
Joe Richey
c5e2025d2c util: Remove unused spin-lock interfaces
We no longer use spin-locks anywhere in getrandom, so remove any
interfaces which spin.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-01-07 11:06:56 +00:00
Joe Richey
46963aac74 use_file: Remove use of spin-locks
Don't spin when polling /dev/random. We also remove the use of spin
locks when opening the persistent fd for platforms that require it.

For both these cases, we can just use the pthread lock/unlock methods
in libc. This includes adding Mutex and DropGuard abstractions.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-01-07 11:06:56 +00:00
Joe Richey
245b5b2121 util_libc: open_readonly shoud return a Result
Signed-off-by: Joe Richey <joerichey@google.com>
2020-01-07 11:06:56 +00:00
Joseph Richey
a913c9c673 dragonfly: Don't try to read errno value () 2020-01-07 03:54:43 +00:00
Joseph Richey
48781cd9ec wasi: Update and Fix Travis failures () 2020-01-05 20:59:50 +00:00
Joseph Richey
8096bac100 0.2: Error and Testing improvements () 2019-10-28 08:06:05 +00:00
Joseph Richey
cf2d81bfff Improve src/lib.rs cfgs ()
Right now for each of `util_libc` and `use_file` we have a list of
`target_os` configs to determine if we build the module.

This PR moves these mod declarations into the main `cfg_if` statement
(the one that selects which implementation we use). This way, the mod
statements are kept in-sync with the implementations that use them.

Also, I merged together `target_os` cfgs that have the same
implementation. The downside to this is that the targets are no longer
in alphabetical order.

Also, this is only being applied to `0.2` as the `0.1` cfgs still have
to keep `std` around.
2019-10-25 12:55:12 +00:00
Artyom Pavlov
d661aa7e1b
Prepare release v0.1.13 () 2019-10-25 12:25:33 +00:00
Joe Richey
1f1f964e4a Merge branch 'master' into 0.2 2019-10-24 02:10:00 -07:00
Joseph Richey
81bd43e5d6
Fix typos and bad doc links. () 2019-10-24 02:06:53 -07:00
Artyom Pavlov
9a385f1923
Add VxWorks support () 2019-10-23 09:35:50 +00:00
nia
2fa1bbac80 Switch to using the arandom sysctl on NetBSD (same as FreeBSD). ()
Rename it from freebsd.rs to sysctl_arandom.rs.

NetBSD has been patching rustc for some time to use the FreeBSD
implementation because every single invocation of the compiler
may drain from the entropy pool and cause the next to block.

This can massively inflate build times for rust software, or cause
it to fail entirely, especially in VMs (for example, our Xen package
building cluster).
2019-10-23 09:03:44 +00:00
Joseph Richey
add45a3899 Remove dummy implementation ()
Removes the “dummy” feature and “wasm32-unknown-unknown” dummy impl
2019-10-15 23:40:05 -07:00
Joseph Richey
605736748a Only impl std traits if feature is specified ()
* Fix CI to allow for PRs against 0.2 to be run

* Only impl std traits if feature is specified

* Fix l4re
2019-10-15 23:40:05 -07:00
Diggory Hardy
6b4925a76d
Merge pull request from dekellum/min-cfg-if
cfg-if 0.1.2 is minimal version of dependency
2019-10-01 08:43:28 +01:00
Diggory Hardy
7f013b15d8
Merge pull request from josephlr/ci
Fix and Improve WASM CI
2019-10-01 08:39:45 +01:00
Joe Richey
04f65172f5 Remove jq dep 2019-09-30 16:20:13 -07:00
Joe Richey
93312bdca7 Fix CI
- Use latest Firefox
- Explicitly pin wasmtime and cargo-web
- Make sure our `wasm-bindgen-test-runner` and `wasm-bindgen` versions match
2019-09-30 15:45:23 -07:00
David Kellum
2052159fd1 cfg-if 0.1.2 needed as minimal version of dep 2019-09-30 14:06:16 -07:00
Diggory Hardy
6bd6e048ca
Merge pull request from josephlr/fmt
Run Rustfmt
2019-09-23 20:48:10 +01:00
Joe Richey
3b6c90ca24 Run Rustfmt and make formatting error fail the CI 2019-09-23 10:21:23 -07:00
Joseph Richey
fa6f929aed
Improve CI for web targets ()
* Simplify CI process for WASM

Run WASI tests, and run both stdweb/wasm-bindgen on both node and in browsers

These changes also remove the need for a separate tests/wasm_bindgen

* Use all pre-built binaries in the CI

* Fix Cargo.toml typo

Co-Authored-By: Artyom Pavlov <newpavlov@gmail.com>

* Fix install location

* Debug CI
2019-09-21 01:46:26 -07:00
Elichai Turkel
ccc47748d0 Handle zero-length slices ()
Ensure and document that we do nothing when an empty slice is passed.

Note that this changes are for consistency, not to prevent UB.
2019-09-19 16:41:20 -07:00