html-to-markdown 2.27.1 → 2.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/ext/html-to-markdown-rb/native/Cargo.toml +1 -1
- data/lib/html_to_markdown/version.rb +1 -1
- data/rust-vendor/getrandom/.cargo-checksum.json +1 -1
- data/rust-vendor/getrandom/.cargo_vcs_info.json +1 -1
- data/rust-vendor/getrandom/CHANGELOG.md +62 -43
- data/rust-vendor/getrandom/Cargo.lock +49 -56
- data/rust-vendor/getrandom/Cargo.toml +2 -2
- data/rust-vendor/getrandom/Cargo.toml.orig +2 -2
- data/rust-vendor/getrandom/src/backends/efi_rng.rs +8 -10
- data/rust-vendor/getrandom/src/backends/getentropy.rs +13 -4
- data/rust-vendor/getrandom/src/backends/linux_android_with_fallback.rs +10 -25
- data/rust-vendor/getrandom/src/backends/netbsd.rs +17 -25
- data/rust-vendor/getrandom/src/backends/rdrand.rs +15 -9
- data/rust-vendor/getrandom/src/backends/rndr.rs +2 -1
- data/rust-vendor/getrandom/src/backends/vxworks.rs +7 -3
- data/rust-vendor/getrandom/src/backends/windows.rs +21 -5
- data/rust-vendor/getrandom/src/utils/lazy_bool.rs +39 -0
- data/rust-vendor/getrandom/src/utils/lazy_ptr.rs +57 -0
- data/rust-vendor/html-to-markdown-rs/Cargo.toml +2 -2
- data/rust-vendor/html-to-markdown-rs/src/converter/plain_text.rs +64 -9
- data/rust-vendor/html-to-markdown-rs/src/converter/text_node.rs +2 -1
- data/rust-vendor/html-to-markdown-rs/tests/issue_216_217_regressions.rs +82 -0
- data/rust-vendor/html-to-markdown-rs/tests/plain_output_test.rs +59 -6
- data/rust-vendor/quote/.cargo-checksum.json +1 -1
- data/rust-vendor/quote/.cargo_vcs_info.json +1 -1
- data/rust-vendor/quote/.github/workflows/ci.yml +2 -2
- data/rust-vendor/quote/Cargo.lock +21 -21
- data/rust-vendor/quote/Cargo.toml +2 -2
- data/rust-vendor/quote/Cargo.toml.orig +2 -2
- data/rust-vendor/quote/README.md +0 -1
- data/rust-vendor/quote/src/lib.rs +1 -1
- data/rust-vendor/quote/src/to_tokens.rs +7 -0
- data/rust-vendor/quote/tests/ui/not-quotable.stderr +1 -1
- data/rust-vendor/quote/tests/ui/not-repeatable.stderr +3 -11
- data/rust-vendor/r-efi/.cargo-checksum.json +1 -1
- data/rust-vendor/r-efi/.cargo_vcs_info.json +1 -1
- data/rust-vendor/r-efi/AUTHORS +1 -0
- data/rust-vendor/r-efi/Cargo.lock +1 -1
- data/rust-vendor/r-efi/Cargo.toml +1 -3
- data/rust-vendor/r-efi/Cargo.toml.orig +1 -5
- data/rust-vendor/r-efi/NEWS.md +16 -0
- data/rust-vendor/r-efi/src/base.rs +1 -1
- data/rust-vendor/r-efi/src/lib.rs +27 -12
- data/rust-vendor/r-efi/src/protocols/absolute_pointer.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/block_io.rs +8 -8
- data/rust-vendor/r-efi/src/protocols/bus_specific_driver_override.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/debug_support.rs +10 -10
- data/rust-vendor/r-efi/src/protocols/debugport.rs +8 -8
- data/rust-vendor/r-efi/src/protocols/decompress.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/device_path_from_text.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/device_path_to_text.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/device_path_utilities.rs +16 -16
- data/rust-vendor/r-efi/src/protocols/disk_io.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/disk_io2.rs +8 -8
- data/rust-vendor/r-efi/src/protocols/driver_binding.rs +6 -6
- data/rust-vendor/r-efi/src/protocols/driver_diagnostics2.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/driver_family_override.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/file.rs +28 -28
- data/rust-vendor/r-efi/src/protocols/graphics_output.rs +6 -6
- data/rust-vendor/r-efi/src/protocols/hii_database.rs +24 -24
- data/rust-vendor/r-efi/src/protocols/hii_font.rs +8 -8
- data/rust-vendor/r-efi/src/protocols/hii_font_ex.rs +10 -10
- data/rust-vendor/r-efi/src/protocols/hii_string.rs +10 -10
- data/rust-vendor/r-efi/src/protocols/ip4.rs +16 -16
- data/rust-vendor/r-efi/src/protocols/ip6.rs +18 -18
- data/rust-vendor/r-efi/src/protocols/load_file.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/loaded_image.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/managed_network.rs +16 -16
- data/rust-vendor/r-efi/src/protocols/memory_attribute.rs +6 -6
- data/rust-vendor/r-efi/src/protocols/mp_services.rs +15 -15
- data/rust-vendor/r-efi/src/protocols/pci_io.rs +26 -26
- data/rust-vendor/r-efi/src/protocols/platform_driver_override.rs +6 -6
- data/rust-vendor/r-efi/src/protocols/rng.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/service_binding.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/shell.rs +81 -81
- data/rust-vendor/r-efi/src/protocols/shell_dynamic_command.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/simple_file_system.rs +2 -2
- data/rust-vendor/r-efi/src/protocols/simple_network.rs +26 -26
- data/rust-vendor/r-efi/src/protocols/simple_text_input.rs +4 -4
- data/rust-vendor/r-efi/src/protocols/simple_text_input_ex.rs +11 -11
- data/rust-vendor/r-efi/src/protocols/simple_text_output.rs +18 -18
- data/rust-vendor/r-efi/src/protocols/tcp4.rs +20 -20
- data/rust-vendor/r-efi/src/protocols/tcp6.rs +18 -18
- data/rust-vendor/r-efi/src/protocols/timestamp.rs +3 -3
- data/rust-vendor/r-efi/src/protocols/udp4.rs +16 -16
- data/rust-vendor/r-efi/src/protocols/udp6.rs +14 -14
- data/rust-vendor/r-efi/src/system.rs +115 -115
- data/rust-vendor/r-efi/src/vendor/intel/console_control.rs +6 -6
- data/rust-vendor/r-efi-5.3.0/.cargo-checksum.json +1 -0
- data/rust-vendor/r-efi-5.3.0/.cargo_vcs_info.json +6 -0
- data/rust-vendor/r-efi-5.3.0/.github/workflows/publish.yml +39 -0
- data/rust-vendor/r-efi-5.3.0/.github/workflows/rust-tests.yml +125 -0
- data/rust-vendor/r-efi-5.3.0/AUTHORS +74 -0
- data/rust-vendor/r-efi-5.3.0/Cargo.lock +16 -0
- data/rust-vendor/r-efi-5.3.0/Cargo.toml +70 -0
- data/rust-vendor/r-efi-5.3.0/Cargo.toml.orig +51 -0
- data/rust-vendor/r-efi-5.3.0/Makefile +85 -0
- data/rust-vendor/r-efi-5.3.0/NEWS.md +301 -0
- data/rust-vendor/r-efi-5.3.0/README.md +99 -0
- data/rust-vendor/r-efi-5.3.0/examples/freestanding.rs +34 -0
- data/rust-vendor/r-efi-5.3.0/examples/gop-query.rs +188 -0
- data/rust-vendor/r-efi-5.3.0/examples/hello-world.rs +55 -0
- data/rust-vendor/r-efi-5.3.0/src/base.rs +993 -0
- data/rust-vendor/r-efi-5.3.0/src/hii.rs +1300 -0
- data/rust-vendor/r-efi-5.3.0/src/lib.rs +182 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/absolute_pointer.rs +69 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/block_io.rs +70 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/bus_specific_driver_override.rs +32 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/debug_support.rs +835 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/debugport.rs +42 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/decompress.rs +37 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/device_path.rs +82 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/device_path_from_text.rs +26 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/device_path_to_text.rs +30 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/device_path_utilities.rs +63 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/disk_io.rs +40 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/disk_io2.rs +58 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/driver_binding.rs +42 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/driver_diagnostics2.rs +38 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/driver_family_override.rs +23 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/file.rs +183 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/graphics_output.rs +103 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/hii_database.rs +299 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/hii_font.rs +87 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/hii_font_ex.rs +107 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/hii_package_list.rs +14 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/hii_string.rs +71 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/ip4.rs +202 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/ip6.rs +264 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/load_file.rs +26 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/load_file2.rs +15 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/loaded_image.rs +39 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/loaded_image_device_path.rs +13 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/managed_network.rs +147 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/memory_attribute.rs +40 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/mp_services.rs +121 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/pci_io.rs +203 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/platform_driver_override.rs +46 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/rng.rs +83 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/service_binding.rs +20 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/shell.rs +295 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/shell_dynamic_command.rs +33 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/shell_parameters.rs +23 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/simple_file_system.rs +26 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/simple_network.rs +196 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/simple_text_input.rs +38 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/simple_text_input_ex.rs +85 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/simple_text_output.rs +86 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/tcp4.rs +224 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/tcp6.rs +202 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/timestamp.rs +32 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/udp4.rs +151 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols/udp6.rs +137 -0
- data/rust-vendor/r-efi-5.3.0/src/protocols.rs +54 -0
- data/rust-vendor/r-efi-5.3.0/src/system.rs +1130 -0
- data/rust-vendor/r-efi-5.3.0/src/vendor/intel/console_control.rs +37 -0
- data/rust-vendor/r-efi-5.3.0/src/vendor.rs +10 -0
- data/rust-vendor/tokio/.cargo-checksum.json +1 -1
- data/rust-vendor/tokio/.cargo_vcs_info.json +1 -1
- data/rust-vendor/tokio/CHANGELOG.md +94 -0
- data/rust-vendor/tokio/Cargo.lock +1549 -0
- data/rust-vendor/tokio/Cargo.toml +96 -83
- data/rust-vendor/tokio/Cargo.toml.orig +7 -7
- data/rust-vendor/tokio/README.md +1 -1
- data/rust-vendor/tokio/src/fs/open_options.rs +4 -1
- data/rust-vendor/tokio/src/fs/read.rs +4 -1
- data/rust-vendor/tokio/src/fs/write.rs +4 -1
- data/rust-vendor/tokio/src/io/async_write.rs +3 -4
- data/rust-vendor/tokio/src/io/poll_evented.rs +23 -1
- data/rust-vendor/tokio/src/io/stderr.rs +15 -1
- data/rust-vendor/tokio/src/io/stdout.rs +14 -0
- data/rust-vendor/tokio/src/io/util/async_write_ext.rs +2 -2
- data/rust-vendor/tokio/src/io/util/write_buf.rs +11 -2
- data/rust-vendor/tokio/src/lib.rs +12 -28
- data/rust-vendor/tokio/src/macros/select.rs +6 -8
- data/rust-vendor/tokio/src/net/tcp/socket.rs +25 -1
- data/rust-vendor/tokio/src/net/tcp/stream.rs +40 -1
- data/rust-vendor/tokio/src/process/unix/pidfd_reaper.rs +1 -41
- data/rust-vendor/tokio/src/runtime/blocking/pool.rs +18 -14
- data/rust-vendor/tokio/src/runtime/builder.rs +10 -4
- data/rust-vendor/tokio/src/runtime/handle.rs +3 -2
- data/rust-vendor/tokio/src/runtime/io/driver/uring.rs +49 -61
- data/rust-vendor/tokio/src/runtime/io/driver.rs +6 -5
- data/rust-vendor/tokio/src/runtime/mod.rs +20 -1
- data/rust-vendor/tokio/src/runtime/runtime.rs +71 -1
- data/rust-vendor/tokio/src/runtime/scheduler/current_thread/mod.rs +24 -8
- data/rust-vendor/tokio/src/runtime/scheduler/multi_thread/worker.rs +5 -0
- data/rust-vendor/tokio/src/runtime/task/core.rs +1 -0
- data/rust-vendor/tokio/src/runtime/task/join.rs +7 -3
- data/rust-vendor/tokio/src/runtime/task/list.rs +5 -3
- data/rust-vendor/tokio/src/runtime/task/mod.rs +0 -5
- data/rust-vendor/tokio/src/runtime/tests/loom_blocking.rs +39 -1
- data/rust-vendor/tokio/src/signal/mod.rs +6 -17
- data/rust-vendor/tokio/src/signal/registry.rs +1 -1
- data/rust-vendor/tokio/src/signal/unix.rs +24 -44
- data/rust-vendor/tokio/src/signal/windows/sys.rs +52 -64
- data/rust-vendor/tokio/src/signal/windows.rs +35 -23
- data/rust-vendor/tokio/src/sync/mpsc/mod.rs +3 -1
- data/rust-vendor/tokio/src/sync/oneshot.rs +13 -0
- data/rust-vendor/tokio/src/sync/rwlock.rs +4 -5
- data/rust-vendor/tokio/src/sync/tests/loom_oneshot.rs +27 -1
- data/rust-vendor/tokio/src/task/blocking.rs +16 -1
- data/rust-vendor/tokio/src/task/builder.rs +2 -2
- data/rust-vendor/tokio/src/task/mod.rs +1 -1
- data/rust-vendor/tokio/src/task/spawn.rs +8 -3
- data/rust-vendor/tokio/src/task/yield_now.rs +13 -23
- data/rust-vendor/tokio/src/time/clock.rs +62 -0
- data/rust-vendor/tokio/src/util/memchr.rs +32 -4
- data/rust-vendor/tokio/src/util/sharded_list.rs +6 -4
- data/rust-vendor/tokio/tests/fs_link.rs +54 -0
- data/rust-vendor/tokio/tests/io_async_fd_memory_leak.rs +209 -0
- data/rust-vendor/tokio/tests/io_write_buf.rs +56 -0
- data/rust-vendor/tokio/tests/process_issue_7144.rs +8 -0
- data/rust-vendor/tokio/tests/rt_basic.rs +41 -0
- data/rust-vendor/tokio/tests/rt_common_before_park.rs +92 -0
- data/rust-vendor/tokio/tests/rt_metrics.rs +1 -1
- data/rust-vendor/tokio/tests/rt_panic.rs +12 -0
- data/rust-vendor/tokio/tests/rt_shutdown_err.rs +82 -0
- data/rust-vendor/tokio/tests/rt_threaded.rs +49 -1
- data/rust-vendor/tokio/tests/rt_unstable_metrics.rs +32 -0
- data/rust-vendor/tokio/tests/tcp_connect.rs +2 -3
- data/rust-vendor/tokio/tests/tcp_shutdown.rs +1 -3
- data/rust-vendor/tokio/tests/tcp_socket.rs +3 -4
- data/rust-vendor/tokio/tests/tcp_stream.rs +3 -0
- metadata +78 -3
- data/rust-vendor/getrandom/src/utils/lazy.rs +0 -64
|
@@ -4,9 +4,9 @@ version = 4
|
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "anyhow"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.102"
|
|
8
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
-
checksum = "
|
|
9
|
+
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
|
10
10
|
|
|
11
11
|
[[package]]
|
|
12
12
|
name = "async-trait"
|
|
@@ -27,15 +27,15 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
|
27
27
|
|
|
28
28
|
[[package]]
|
|
29
29
|
name = "bitflags"
|
|
30
|
-
version = "2.
|
|
30
|
+
version = "2.11.0"
|
|
31
31
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
32
|
-
checksum = "
|
|
32
|
+
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
|
|
33
33
|
|
|
34
34
|
[[package]]
|
|
35
35
|
name = "bumpalo"
|
|
36
|
-
version = "3.
|
|
36
|
+
version = "3.20.2"
|
|
37
37
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
38
|
-
checksum = "
|
|
38
|
+
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
|
39
39
|
|
|
40
40
|
[[package]]
|
|
41
41
|
name = "cast"
|
|
@@ -45,9 +45,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
|
|
45
45
|
|
|
46
46
|
[[package]]
|
|
47
47
|
name = "cc"
|
|
48
|
-
version = "1.2.
|
|
48
|
+
version = "1.2.56"
|
|
49
49
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
50
|
-
checksum = "
|
|
50
|
+
checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
|
|
51
51
|
dependencies = [
|
|
52
52
|
"find-msvc-tools",
|
|
53
53
|
"shlex",
|
|
@@ -79,32 +79,31 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|
|
79
79
|
|
|
80
80
|
[[package]]
|
|
81
81
|
name = "futures-core"
|
|
82
|
-
version = "0.3.
|
|
82
|
+
version = "0.3.32"
|
|
83
83
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
-
checksum = "
|
|
84
|
+
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
|
|
85
85
|
|
|
86
86
|
[[package]]
|
|
87
87
|
name = "futures-task"
|
|
88
|
-
version = "0.3.
|
|
88
|
+
version = "0.3.32"
|
|
89
89
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
-
checksum = "
|
|
90
|
+
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
|
|
91
91
|
|
|
92
92
|
[[package]]
|
|
93
93
|
name = "futures-util"
|
|
94
|
-
version = "0.3.
|
|
94
|
+
version = "0.3.32"
|
|
95
95
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
96
|
-
checksum = "
|
|
96
|
+
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
|
|
97
97
|
dependencies = [
|
|
98
98
|
"futures-core",
|
|
99
99
|
"futures-task",
|
|
100
100
|
"pin-project-lite",
|
|
101
|
-
"pin-utils",
|
|
102
101
|
"slab",
|
|
103
102
|
]
|
|
104
103
|
|
|
105
104
|
[[package]]
|
|
106
105
|
name = "getrandom"
|
|
107
|
-
version = "0.4.
|
|
106
|
+
version = "0.4.2"
|
|
108
107
|
dependencies = [
|
|
109
108
|
"cfg-if",
|
|
110
109
|
"js-sys",
|
|
@@ -164,9 +163,9 @@ checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
|
|
164
163
|
|
|
165
164
|
[[package]]
|
|
166
165
|
name = "js-sys"
|
|
167
|
-
version = "0.3.
|
|
166
|
+
version = "0.3.91"
|
|
168
167
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
169
|
-
checksum = "
|
|
168
|
+
checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
|
|
170
169
|
dependencies = [
|
|
171
170
|
"once_cell",
|
|
172
171
|
"wasm-bindgen",
|
|
@@ -180,9 +179,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
|
|
180
179
|
|
|
181
180
|
[[package]]
|
|
182
181
|
name = "libc"
|
|
183
|
-
version = "0.2.
|
|
182
|
+
version = "0.2.182"
|
|
184
183
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
185
|
-
checksum = "
|
|
184
|
+
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
|
|
186
185
|
|
|
187
186
|
[[package]]
|
|
188
187
|
name = "libm"
|
|
@@ -198,9 +197,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
|
|
198
197
|
|
|
199
198
|
[[package]]
|
|
200
199
|
name = "memchr"
|
|
201
|
-
version = "2.
|
|
200
|
+
version = "2.8.0"
|
|
202
201
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
203
|
-
checksum = "
|
|
202
|
+
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
|
204
203
|
|
|
205
204
|
[[package]]
|
|
206
205
|
name = "minicov"
|
|
@@ -245,15 +244,9 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
|
|
|
245
244
|
|
|
246
245
|
[[package]]
|
|
247
246
|
name = "pin-project-lite"
|
|
248
|
-
version = "0.2.
|
|
249
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
250
|
-
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
|
251
|
-
|
|
252
|
-
[[package]]
|
|
253
|
-
name = "pin-utils"
|
|
254
|
-
version = "0.1.0"
|
|
247
|
+
version = "0.2.17"
|
|
255
248
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
256
|
-
checksum = "
|
|
249
|
+
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
|
257
250
|
|
|
258
251
|
[[package]]
|
|
259
252
|
name = "prettyplease"
|
|
@@ -285,9 +278,9 @@ dependencies = [
|
|
|
285
278
|
|
|
286
279
|
[[package]]
|
|
287
280
|
name = "r-efi"
|
|
288
|
-
version = "
|
|
281
|
+
version = "6.0.0"
|
|
289
282
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
290
|
-
checksum = "
|
|
283
|
+
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
|
291
284
|
|
|
292
285
|
[[package]]
|
|
293
286
|
name = "rand_core"
|
|
@@ -373,9 +366,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
|
|
373
366
|
|
|
374
367
|
[[package]]
|
|
375
368
|
name = "syn"
|
|
376
|
-
version = "2.0.
|
|
369
|
+
version = "2.0.117"
|
|
377
370
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
378
|
-
checksum = "
|
|
371
|
+
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
379
372
|
dependencies = [
|
|
380
373
|
"proc-macro2",
|
|
381
374
|
"quote",
|
|
@@ -384,9 +377,9 @@ dependencies = [
|
|
|
384
377
|
|
|
385
378
|
[[package]]
|
|
386
379
|
name = "unicode-ident"
|
|
387
|
-
version = "1.0.
|
|
380
|
+
version = "1.0.24"
|
|
388
381
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
389
|
-
checksum = "
|
|
382
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
390
383
|
|
|
391
384
|
[[package]]
|
|
392
385
|
name = "unicode-xid"
|
|
@@ -424,9 +417,9 @@ dependencies = [
|
|
|
424
417
|
|
|
425
418
|
[[package]]
|
|
426
419
|
name = "wasm-bindgen"
|
|
427
|
-
version = "0.2.
|
|
420
|
+
version = "0.2.114"
|
|
428
421
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
429
|
-
checksum = "
|
|
422
|
+
checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
|
|
430
423
|
dependencies = [
|
|
431
424
|
"cfg-if",
|
|
432
425
|
"once_cell",
|
|
@@ -437,9 +430,9 @@ dependencies = [
|
|
|
437
430
|
|
|
438
431
|
[[package]]
|
|
439
432
|
name = "wasm-bindgen-futures"
|
|
440
|
-
version = "0.4.
|
|
433
|
+
version = "0.4.64"
|
|
441
434
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
442
|
-
checksum = "
|
|
435
|
+
checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8"
|
|
443
436
|
dependencies = [
|
|
444
437
|
"cfg-if",
|
|
445
438
|
"futures-util",
|
|
@@ -451,9 +444,9 @@ dependencies = [
|
|
|
451
444
|
|
|
452
445
|
[[package]]
|
|
453
446
|
name = "wasm-bindgen-macro"
|
|
454
|
-
version = "0.2.
|
|
447
|
+
version = "0.2.114"
|
|
455
448
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
456
|
-
checksum = "
|
|
449
|
+
checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
|
|
457
450
|
dependencies = [
|
|
458
451
|
"quote",
|
|
459
452
|
"wasm-bindgen-macro-support",
|
|
@@ -461,9 +454,9 @@ dependencies = [
|
|
|
461
454
|
|
|
462
455
|
[[package]]
|
|
463
456
|
name = "wasm-bindgen-macro-support"
|
|
464
|
-
version = "0.2.
|
|
457
|
+
version = "0.2.114"
|
|
465
458
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
466
|
-
checksum = "
|
|
459
|
+
checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
|
|
467
460
|
dependencies = [
|
|
468
461
|
"bumpalo",
|
|
469
462
|
"proc-macro2",
|
|
@@ -474,18 +467,18 @@ dependencies = [
|
|
|
474
467
|
|
|
475
468
|
[[package]]
|
|
476
469
|
name = "wasm-bindgen-shared"
|
|
477
|
-
version = "0.2.
|
|
470
|
+
version = "0.2.114"
|
|
478
471
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
479
|
-
checksum = "
|
|
472
|
+
checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
|
|
480
473
|
dependencies = [
|
|
481
474
|
"unicode-ident",
|
|
482
475
|
]
|
|
483
476
|
|
|
484
477
|
[[package]]
|
|
485
478
|
name = "wasm-bindgen-test"
|
|
486
|
-
version = "0.3.
|
|
479
|
+
version = "0.3.64"
|
|
487
480
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
488
|
-
checksum = "
|
|
481
|
+
checksum = "6311c867385cc7d5602463b31825d454d0837a3aba7cdb5e56d5201792a3f7fe"
|
|
489
482
|
dependencies = [
|
|
490
483
|
"async-trait",
|
|
491
484
|
"cast",
|
|
@@ -505,9 +498,9 @@ dependencies = [
|
|
|
505
498
|
|
|
506
499
|
[[package]]
|
|
507
500
|
name = "wasm-bindgen-test-macro"
|
|
508
|
-
version = "0.3.
|
|
501
|
+
version = "0.3.64"
|
|
509
502
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
510
|
-
checksum = "
|
|
503
|
+
checksum = "67008cdde4769831958536b0f11b3bdd0380bde882be17fff9c2f34bb4549abd"
|
|
511
504
|
dependencies = [
|
|
512
505
|
"proc-macro2",
|
|
513
506
|
"quote",
|
|
@@ -516,9 +509,9 @@ dependencies = [
|
|
|
516
509
|
|
|
517
510
|
[[package]]
|
|
518
511
|
name = "wasm-bindgen-test-shared"
|
|
519
|
-
version = "0.2.
|
|
512
|
+
version = "0.2.114"
|
|
520
513
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
521
|
-
checksum = "
|
|
514
|
+
checksum = "cfe29135b180b72b04c74aa97b2b4a2ef275161eff9a6c7955ea9eaedc7e1d4e"
|
|
522
515
|
|
|
523
516
|
[[package]]
|
|
524
517
|
name = "wasm-encoder"
|
|
@@ -556,9 +549,9 @@ dependencies = [
|
|
|
556
549
|
|
|
557
550
|
[[package]]
|
|
558
551
|
name = "web-sys"
|
|
559
|
-
version = "0.3.
|
|
552
|
+
version = "0.3.91"
|
|
560
553
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
561
|
-
checksum = "
|
|
554
|
+
checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9"
|
|
562
555
|
dependencies = [
|
|
563
556
|
"js-sys",
|
|
564
557
|
"wasm-bindgen",
|
|
@@ -678,6 +671,6 @@ dependencies = [
|
|
|
678
671
|
|
|
679
672
|
[[package]]
|
|
680
673
|
name = "zmij"
|
|
681
|
-
version = "1.0.
|
|
674
|
+
version = "1.0.21"
|
|
682
675
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
683
|
-
checksum = "
|
|
676
|
+
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
edition = "2024"
|
|
14
14
|
rust-version = "1.85"
|
|
15
15
|
name = "getrandom"
|
|
16
|
-
version = "0.4.
|
|
16
|
+
version = "0.4.2"
|
|
17
17
|
authors = ["The Rand Project Developers"]
|
|
18
18
|
build = "build.rs"
|
|
19
19
|
exclude = [".*"]
|
|
@@ -108,7 +108,7 @@ default-features = false
|
|
|
108
108
|
version = "0.4"
|
|
109
109
|
|
|
110
110
|
[target.'cfg(all(target_os = "uefi", getrandom_backend = "efi_rng"))'.dependencies.r-efi]
|
|
111
|
-
version = "
|
|
111
|
+
version = "6"
|
|
112
112
|
default-features = false
|
|
113
113
|
|
|
114
114
|
[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "hurd", target_os = "illumos", target_os = "cygwin", all(target_os = "horizon", target_arch = "arm")))'.dependencies.libc]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "getrandom"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85" # Sync tests.yml and README.md.
|
|
6
6
|
authors = ["The Rand Project Developers"]
|
|
@@ -50,7 +50,7 @@ libc = { version = "0.2.154", default-features = false }
|
|
|
50
50
|
|
|
51
51
|
# efi_rng
|
|
52
52
|
[target.'cfg(all(target_os = "uefi", getrandom_backend = "efi_rng"))'.dependencies]
|
|
53
|
-
r-efi = { version = "
|
|
53
|
+
r-efi = { version = "6", default-features = false }
|
|
54
54
|
|
|
55
55
|
# getentropy
|
|
56
56
|
[target.'cfg(any(target_os = "macos", target_os = "openbsd", target_os = "vita", target_os = "emscripten"))'.dependencies]
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
use crate::Error;
|
|
3
3
|
use core::{
|
|
4
4
|
mem::MaybeUninit,
|
|
5
|
-
ptr::{self, NonNull
|
|
6
|
-
sync::atomic::{AtomicPtr, Ordering::Relaxed},
|
|
5
|
+
ptr::{self, NonNull},
|
|
7
6
|
};
|
|
8
7
|
use r_efi::{
|
|
9
8
|
efi::{BootServices, Handle},
|
|
@@ -17,8 +16,6 @@ pub use crate::util::{inner_u32, inner_u64};
|
|
|
17
16
|
#[cfg(not(target_os = "uefi"))]
|
|
18
17
|
compile_error!("`efi_rng` backend can be enabled only for UEFI targets!");
|
|
19
18
|
|
|
20
|
-
static RNG_PROTOCOL: AtomicPtr<rng::Protocol> = AtomicPtr::new(null_mut());
|
|
21
|
-
|
|
22
19
|
#[cold]
|
|
23
20
|
#[inline(never)]
|
|
24
21
|
fn init() -> Result<NonNull<rng::Protocol>, Error> {
|
|
@@ -36,7 +33,7 @@ fn init() -> Result<NonNull<rng::Protocol>, Error> {
|
|
|
36
33
|
((*boot_services.as_ptr()).locate_handle)(
|
|
37
34
|
r_efi::efi::BY_PROTOCOL,
|
|
38
35
|
&mut guid,
|
|
39
|
-
null_mut(),
|
|
36
|
+
ptr::null_mut(),
|
|
40
37
|
&mut buf_size,
|
|
41
38
|
handles.as_mut_ptr(),
|
|
42
39
|
)
|
|
@@ -88,7 +85,6 @@ fn init() -> Result<NonNull<rng::Protocol>, Error> {
|
|
|
88
85
|
continue;
|
|
89
86
|
}
|
|
90
87
|
|
|
91
|
-
RNG_PROTOCOL.store(protocol.as_ptr(), Relaxed);
|
|
92
88
|
return Ok(protocol);
|
|
93
89
|
}
|
|
94
90
|
Err(Error::NO_RNG_HANDLE)
|
|
@@ -96,10 +92,12 @@ fn init() -> Result<NonNull<rng::Protocol>, Error> {
|
|
|
96
92
|
|
|
97
93
|
#[inline]
|
|
98
94
|
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
#[path = "../utils/lazy_ptr.rs"]
|
|
96
|
+
mod lazy;
|
|
97
|
+
|
|
98
|
+
static RNG_PROTOCOL: lazy::LazyPtr<rng::Protocol> = lazy::LazyPtr::new();
|
|
99
|
+
|
|
100
|
+
let protocol = RNG_PROTOCOL.try_unsync_init(init)?;
|
|
103
101
|
|
|
104
102
|
let mut alg_guid = rng::ALGORITHM_RAW;
|
|
105
103
|
let ret = unsafe {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
//! Implementation using getentropy(2)
|
|
2
2
|
//!
|
|
3
|
+
//! When porting to a new target, ensure that its implementation follows the
|
|
4
|
+
//! POSIX conventions from
|
|
5
|
+
//! <https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html>.
|
|
6
|
+
//!
|
|
3
7
|
//! Available since:
|
|
4
8
|
//! - macOS 10.12
|
|
5
9
|
//! - OpenBSD 5.6
|
|
@@ -17,11 +21,16 @@ mod utils;
|
|
|
17
21
|
|
|
18
22
|
#[inline]
|
|
19
23
|
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
20
|
-
|
|
24
|
+
// https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html
|
|
25
|
+
// says `GETENTROPY_MAX` is at least 256.
|
|
26
|
+
const GETENTROPY_MAX: usize = 256;
|
|
27
|
+
|
|
28
|
+
for chunk in dest.chunks_mut(GETENTROPY_MAX) {
|
|
21
29
|
let ret = unsafe { libc::getentropy(chunk.as_mut_ptr().cast::<c_void>(), chunk.len()) };
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return Err(Error::from_errno(
|
|
30
|
+
match ret {
|
|
31
|
+
0 => continue,
|
|
32
|
+
-1 => return Err(Error::from_errno(utils::get_errno())),
|
|
33
|
+
_ => return Err(Error::UNEXPECTED),
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
Ok(())
|
|
@@ -4,8 +4,7 @@ use crate::Error;
|
|
|
4
4
|
use core::{
|
|
5
5
|
ffi::c_void,
|
|
6
6
|
mem::{MaybeUninit, transmute},
|
|
7
|
-
ptr::NonNull,
|
|
8
|
-
sync::atomic::{AtomicPtr, Ordering},
|
|
7
|
+
ptr::{self, NonNull},
|
|
9
8
|
};
|
|
10
9
|
use use_file::utils;
|
|
11
10
|
|
|
@@ -17,18 +16,12 @@ type GetRandomFn = unsafe extern "C" fn(*mut c_void, libc::size_t, libc::c_uint)
|
|
|
17
16
|
/// or not supported by kernel.
|
|
18
17
|
const NOT_AVAILABLE: NonNull<c_void> = unsafe { NonNull::new_unchecked(usize::MAX as *mut c_void) };
|
|
19
18
|
|
|
20
|
-
static GETRANDOM_FN: AtomicPtr<c_void> = AtomicPtr::new(core::ptr::null_mut());
|
|
21
|
-
|
|
22
19
|
#[cold]
|
|
23
20
|
#[inline(never)]
|
|
24
21
|
fn init() -> NonNull<c_void> {
|
|
25
22
|
// Use static linking to `libc::getrandom` on MUSL targets and `dlsym` everywhere else
|
|
26
23
|
#[cfg(not(target_env = "musl"))]
|
|
27
|
-
let raw_ptr = {
|
|
28
|
-
static NAME: &[u8] = b"getrandom\0";
|
|
29
|
-
let name_ptr = NAME.as_ptr().cast::<libc::c_char>();
|
|
30
|
-
unsafe { libc::dlsym(libc::RTLD_DEFAULT, name_ptr) }
|
|
31
|
-
};
|
|
24
|
+
let raw_ptr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, c"getrandom".as_ptr()) };
|
|
32
25
|
#[cfg(target_env = "musl")]
|
|
33
26
|
let raw_ptr = {
|
|
34
27
|
let fptr: GetRandomFn = libc::getrandom;
|
|
@@ -37,10 +30,9 @@ fn init() -> NonNull<c_void> {
|
|
|
37
30
|
|
|
38
31
|
let res_ptr = match NonNull::new(raw_ptr) {
|
|
39
32
|
Some(fptr) => {
|
|
40
|
-
let getrandom_fn = unsafe { transmute
|
|
41
|
-
let dangling_ptr = NonNull::dangling().as_ptr();
|
|
33
|
+
let getrandom_fn = unsafe { transmute::<*mut c_void, GetRandomFn>(fptr.as_ptr()) };
|
|
42
34
|
// Check that `getrandom` syscall is supported by kernel
|
|
43
|
-
let res = unsafe { getrandom_fn(
|
|
35
|
+
let res = unsafe { getrandom_fn(ptr::dangling_mut(), 0, 0) };
|
|
44
36
|
if cfg!(getrandom_test_linux_fallback) {
|
|
45
37
|
NOT_AVAILABLE
|
|
46
38
|
} else if res.is_negative() {
|
|
@@ -65,7 +57,6 @@ fn init() -> NonNull<c_void> {
|
|
|
65
57
|
panic!("Fallback is triggered with enabled `getrandom_test_linux_without_fallback`")
|
|
66
58
|
}
|
|
67
59
|
|
|
68
|
-
GETRANDOM_FN.store(res_ptr.as_ptr(), Ordering::Release);
|
|
69
60
|
res_ptr
|
|
70
61
|
}
|
|
71
62
|
|
|
@@ -77,23 +68,17 @@ fn use_file_fallback(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
|
77
68
|
|
|
78
69
|
#[inline]
|
|
79
70
|
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// probably unnecessary.
|
|
86
|
-
let raw_ptr = GETRANDOM_FN.load(Ordering::Acquire);
|
|
87
|
-
let fptr = match NonNull::new(raw_ptr) {
|
|
88
|
-
Some(p) => p,
|
|
89
|
-
None => init(),
|
|
90
|
-
};
|
|
71
|
+
#[path = "../utils/lazy_ptr.rs"]
|
|
72
|
+
mod lazy;
|
|
73
|
+
|
|
74
|
+
static GETRANDOM_FN: lazy::LazyPtr<c_void> = lazy::LazyPtr::new();
|
|
75
|
+
let fptr = GETRANDOM_FN.unsync_init(init);
|
|
91
76
|
|
|
92
77
|
if fptr == NOT_AVAILABLE {
|
|
93
78
|
use_file_fallback(dest)
|
|
94
79
|
} else {
|
|
95
80
|
// note: `transmute` is currently the only way to convert a pointer into a function reference
|
|
96
|
-
let getrandom_fn = unsafe { transmute
|
|
81
|
+
let getrandom_fn = unsafe { transmute::<*mut c_void, GetRandomFn>(fptr.as_ptr()) };
|
|
97
82
|
utils::sys_fill_exact(dest, |buf| unsafe {
|
|
98
83
|
getrandom_fn(buf.as_mut_ptr().cast(), buf.len(), 0)
|
|
99
84
|
})
|
|
@@ -8,8 +8,7 @@ use core::{
|
|
|
8
8
|
cmp,
|
|
9
9
|
ffi::c_void,
|
|
10
10
|
mem::{self, MaybeUninit},
|
|
11
|
-
ptr,
|
|
12
|
-
sync::atomic::{AtomicPtr, Ordering},
|
|
11
|
+
ptr::{self, NonNull},
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
pub use crate::util::{inner_u32, inner_u64};
|
|
@@ -42,36 +41,29 @@ unsafe extern "C" fn polyfill_using_kern_arand(
|
|
|
42
41
|
|
|
43
42
|
type GetRandomFn = unsafe extern "C" fn(*mut c_void, libc::size_t, libc::c_uint) -> libc::ssize_t;
|
|
44
43
|
|
|
45
|
-
static GETRANDOM: AtomicPtr<c_void> = AtomicPtr::new(ptr::null_mut());
|
|
46
|
-
|
|
47
44
|
#[cold]
|
|
48
45
|
#[inline(never)]
|
|
49
|
-
fn init() ->
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const POLYFILL: GetRandomFn = polyfill_using_kern_arand;
|
|
56
|
-
ptr = POLYFILL as *mut c_void;
|
|
46
|
+
fn init() -> NonNull<c_void> {
|
|
47
|
+
let ptr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, c"getrandom".as_ptr()) };
|
|
48
|
+
if !cfg!(getrandom_test_netbsd_fallback) {
|
|
49
|
+
if let Some(ptr) = NonNull::new(ptr) {
|
|
50
|
+
return ptr;
|
|
51
|
+
}
|
|
57
52
|
}
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
// Verify `polyfill_using_kern_arand` has the right signature.
|
|
54
|
+
const POLYFILL: GetRandomFn = polyfill_using_kern_arand;
|
|
55
|
+
unsafe { NonNull::new_unchecked(POLYFILL as *mut c_void) }
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
#[inline]
|
|
63
59
|
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let
|
|
71
|
-
if fptr.is_null() {
|
|
72
|
-
fptr = init();
|
|
73
|
-
}
|
|
74
|
-
let fptr = unsafe { mem::transmute::<*mut c_void, GetRandomFn>(fptr) };
|
|
60
|
+
#[path = "../utils/lazy_ptr.rs"]
|
|
61
|
+
mod lazy;
|
|
62
|
+
|
|
63
|
+
static GETRANDOM_FN: lazy::LazyPtr<c_void> = lazy::LazyPtr::new();
|
|
64
|
+
|
|
65
|
+
let fptr = GETRANDOM_FN.unsync_init(init);
|
|
66
|
+
let fptr = unsafe { mem::transmute::<*mut c_void, GetRandomFn>(fptr.as_ptr()) };
|
|
75
67
|
utils::sys_fill_exact(dest, |buf| unsafe {
|
|
76
68
|
fptr(buf.as_mut_ptr().cast::<c_void>(), buf.len(), 0)
|
|
77
69
|
})
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
use crate::{Error, util::slice_as_uninit};
|
|
3
3
|
use core::mem::{MaybeUninit, size_of};
|
|
4
4
|
|
|
5
|
-
#[path = "../utils/lazy.rs"]
|
|
6
|
-
mod lazy;
|
|
7
|
-
|
|
8
5
|
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
|
|
9
6
|
compile_error!("`rdrand` backend can be enabled only for x86 and x86-64 targets!");
|
|
10
7
|
|
|
@@ -20,8 +17,6 @@ cfg_if! {
|
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
static RDRAND_GOOD: lazy::LazyBool = lazy::LazyBool::new();
|
|
24
|
-
|
|
25
20
|
// Recommendation from "Intel® Digital Random Number Generator (DRNG) Software
|
|
26
21
|
// Implementation Guide" - Section 5.2.1 and "Intel® 64 and IA-32 Architectures
|
|
27
22
|
// Software Developer’s Manual" - Volume 1 - Section 7.3.17.1.
|
|
@@ -72,7 +67,9 @@ fn self_test() -> bool {
|
|
|
72
67
|
fails <= 2
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
#[cold]
|
|
71
|
+
#[inline(never)]
|
|
72
|
+
fn init() -> bool {
|
|
76
73
|
#[cfg(not(target_feature = "rdrand"))]
|
|
77
74
|
{
|
|
78
75
|
// SAFETY: All Rust x86 targets are new enough to have CPUID, and we
|
|
@@ -115,6 +112,15 @@ fn is_rdrand_good() -> bool {
|
|
|
115
112
|
unsafe { self_test() }
|
|
116
113
|
}
|
|
117
114
|
|
|
115
|
+
fn is_rdrand_good() -> bool {
|
|
116
|
+
#[path = "../utils/lazy_bool.rs"]
|
|
117
|
+
mod lazy;
|
|
118
|
+
|
|
119
|
+
static RDRAND_GOOD: lazy::LazyBool = lazy::LazyBool::new();
|
|
120
|
+
|
|
121
|
+
RDRAND_GOOD.unsync_init(init)
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
#[target_feature(enable = "rdrand")]
|
|
119
125
|
fn rdrand_exact(dest: &mut [MaybeUninit<u8>]) -> Option<()> {
|
|
120
126
|
// We use chunks_exact_mut instead of chunks_mut as it allows almost all
|
|
@@ -162,7 +168,7 @@ fn rdrand_u64() -> Option<u64> {
|
|
|
162
168
|
|
|
163
169
|
#[inline]
|
|
164
170
|
pub fn inner_u32() -> Result<u32, Error> {
|
|
165
|
-
if !
|
|
171
|
+
if !is_rdrand_good() {
|
|
166
172
|
return Err(Error::NO_RDRAND);
|
|
167
173
|
}
|
|
168
174
|
// SAFETY: After this point, we know rdrand is supported.
|
|
@@ -171,7 +177,7 @@ pub fn inner_u32() -> Result<u32, Error> {
|
|
|
171
177
|
|
|
172
178
|
#[inline]
|
|
173
179
|
pub fn inner_u64() -> Result<u64, Error> {
|
|
174
|
-
if !
|
|
180
|
+
if !is_rdrand_good() {
|
|
175
181
|
return Err(Error::NO_RDRAND);
|
|
176
182
|
}
|
|
177
183
|
// SAFETY: After this point, we know rdrand is supported.
|
|
@@ -180,7 +186,7 @@ pub fn inner_u64() -> Result<u64, Error> {
|
|
|
180
186
|
|
|
181
187
|
#[inline]
|
|
182
188
|
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
183
|
-
if !
|
|
189
|
+
if !is_rdrand_good() {
|
|
184
190
|
return Err(Error::NO_RDRAND);
|
|
185
191
|
}
|
|
186
192
|
// SAFETY: After this point, we know rdrand is supported.
|
|
@@ -69,8 +69,9 @@ fn is_rndr_available() -> bool {
|
|
|
69
69
|
|
|
70
70
|
#[cfg(not(target_feature = "rand"))]
|
|
71
71
|
fn is_rndr_available() -> bool {
|
|
72
|
-
#[path = "../utils/
|
|
72
|
+
#[path = "../utils/lazy_bool.rs"]
|
|
73
73
|
mod lazy;
|
|
74
|
+
|
|
74
75
|
static RNDR_GOOD: lazy::LazyBool = lazy::LazyBool::new();
|
|
75
76
|
|
|
76
77
|
cfg_if::cfg_if! {
|
|
@@ -38,9 +38,13 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
|
|
38
38
|
.expect("chunk size is bounded by i32::MAX");
|
|
39
39
|
let p: *mut libc::c_uchar = chunk.as_mut_ptr().cast();
|
|
40
40
|
let ret = unsafe { libc::randABytes(p, chunk_len) };
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
match ret {
|
|
42
|
+
0 => continue,
|
|
43
|
+
-1 => {
|
|
44
|
+
let errno = unsafe { libc::errnoGet() };
|
|
45
|
+
return Err(Error::from_errno(errno));
|
|
46
|
+
}
|
|
47
|
+
_ => return Err(Error::UNEXPECTED),
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
Ok(())
|