Skip to content

Commit

Permalink
Use ALGORITHM_RAW
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Dec 18, 2024
1 parent 871e40e commit 9829eba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ of randomness based on their specific needs:
| `linux_rustix` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses [`rustix`] instead of `libc`.
| `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction
| `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register
| `efi_rng` | UEFI | `*-unknown‑uefi` | [`EFI_RNG_PROTOCOL`] (requires `std` and Nigthly compiler)
| `efi_rng` | UEFI | `*-unknown‑uefi` | [`EFI_RNG_PROTOCOL`] with `EFI_RNG_ALGORITHM_RAW` (requires `std` and Nigthly compiler)
| `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration!
| `wasm_js` | Web Browser, Node.js | `wasm32‑unknown‑unknown`, `wasm32v1-none` | [`Crypto.getRandomValues`]
| `custom` | All targets | `*` | User-provided custom implementation (see [custom backend])
Expand Down
6 changes: 4 additions & 2 deletions src/backends/efi_rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ fn init() -> Result<NonNull<rng::Protocol>, Error> {

// Try to use the acquired protocol handle
let mut buf = [0u8; 8];
let mut alg_guid = rng::ALGORITHM_RAW;
let ret = unsafe {
((*protocol.as_ptr()).get_rng)(
protocol.as_ptr(),
ptr::null_mut(),
&mut alg_guid,
buf.len(),
buf.as_mut_ptr(),
)
Expand All @@ -97,10 +98,11 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
None => init()?,
};

let mut alg_guid = rng::ALGORITHM_RAW;
let ret = unsafe {
((*protocol.as_ptr()).get_rng)(
protocol.as_ptr(),
ptr::null_mut(),
&mut alg_guid,
dest.len(),
dest.as_mut_ptr().cast::<u8>(),
)
Expand Down

0 comments on commit 9829eba

Please sign in to comment.