|
1 | 1 | diff --git a/Cargo.toml b/Cargo.toml
|
2 |
| -index c9daac82e..f9e578e39 100644 |
| 2 | +index 3378dc84b..f65fd70bd 100644 |
3 | 3 | --- a/Cargo.toml
|
4 | 4 | +++ b/Cargo.toml
|
5 |
| -@@ -302,6 +302,7 @@ name = "ring" |
| 5 | +@@ -171,7 +171,7 @@ all-features = true |
| 6 | + name = "ring" |
6 | 7 |
|
7 | 8 | [dependencies]
|
8 |
| - untrusted = { version = "0.7.1" } |
9 |
| -+getrandom = { version = "0.2.8", features = ["rdrand"] } |
| 9 | +-getrandom = { version = "0.2.10" } |
| 10 | ++getrandom = { version = "0.2.10", features = ["rdrand"] } |
| 11 | + untrusted = { version = "0.9" } |
10 | 12 |
|
11 |
| - [target.'cfg(any(target_arch = "x86",target_arch = "x86_64", all(any(target_arch = "aarch64", target_arch = "arm"), any(target_os = "android", target_os = "fuchsia", target_os = "linux"))))'.dependencies] |
12 |
| - spin = { version = "0.5.2", default-features = false } |
13 |
| -@@ -327,7 +328,7 @@ libc = { version = "0.2.80", default-features = false } |
14 |
| - |
15 |
| - # Keep this in sync with `[dependencies]` in pregenerate_asm/Cargo.toml. |
16 |
| - [build-dependencies] |
17 |
| --cc = { version = "1.0.62", default-features = false } |
18 |
| -+cc = { version = "1.0.63", default-features = false } |
19 |
| - |
20 |
| - [features] |
21 |
| - # These features are documented in the top-level module's documentation. |
| 13 | + [target.'cfg(any(target_arch = "x86",target_arch = "x86_64", all(any(target_arch = "aarch64", target_arch = "arm"), any(target_os = "android", target_os = "fuchsia", target_os = "linux", target_os = "windows"))))'.dependencies] |
22 | 14 | diff --git a/build.rs b/build.rs
|
23 |
| -index a5a8e1995..c67e4bfb0 100644 |
| 15 | +index f7b94108b..3bdc8cd29 100644 |
24 | 16 | --- a/build.rs
|
25 | 17 | +++ b/build.rs
|
26 |
| -@@ -580,7 +580,7 @@ fn cc( |
27 |
| - // |
| 18 | +@@ -121,7 +121,9 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { |
| 19 | + "-Wenum-compare", |
| 20 | + "-Wfloat-equal", |
| 21 | + "-Wformat=2", |
| 22 | +- "-Winline", |
| 23 | ++ // Clear the `-Winline` because warnings will be treated as errors |
| 24 | ++ // when `ring` is used as git submodules. |
| 25 | ++ // "-Winline", |
| 26 | + "-Winvalid-pch", |
| 27 | + "-Wmissing-field-initializers", |
| 28 | + "-Wmissing-include-dirs", |
| 29 | +@@ -260,6 +262,8 @@ const LINUX_ABI: &[&str] = &[ |
| 30 | + "linux", |
| 31 | + "redox", |
| 32 | + "solaris", |
| 33 | ++ // For `x86_64-unknown-none` target |
| 34 | ++ "none", |
| 35 | + ]; |
| 36 | + |
| 37 | + /// Operating systems that have the same ABI as macOS on every architecture |
| 38 | +@@ -604,16 +608,29 @@ fn configure_cc(c: &mut cc::Build, target: &Target, include_dir: &Path) { |
28 | 39 | // poly1305_vec.c requires <emmintrin.h> which requires <stdlib.h>.
|
29 |
| - if (target.arch == "wasm32" && target.os == "unknown") |
30 |
| -- || (target.os == "linux" && is_musl && target.arch != "x86_64") |
31 |
| -+ || (target.os == "linux" && is_musl && target.arch != "x86_64" || target.os == "none") |
| 40 | + if (target.arch == "wasm32") |
| 41 | + || (target.os == "linux" && target.is_musl && target.arch != "x86_64") |
| 42 | ++ || (target.os == "none") |
32 | 43 | {
|
33 | 44 | if let Ok(compiler) = c.try_get_compiler() {
|
34 | 45 | // TODO: Expand this to non-clang compilers in 0.17.0 if practical.
|
35 |
| -@@ -589,6 +589,9 @@ fn cc( |
36 |
| - let _ = c.define("GFp_NOSTDLIBINC", "1"); |
| 46 | + if compiler.is_like_clang() { |
| 47 | + let _ = c.flag("-nostdlibinc"); |
| 48 | ++ // Required on windows for cross compilation to `x86_64-unknown-none` |
| 49 | ++ let _ = c.flag("-ffreestanding"); |
| 50 | + let _ = c.define("RING_CORE_NOSTDLIBINC", "1"); |
37 | 51 | }
|
38 | 52 | }
|
39 |
| -+ if target.os == "none" { |
40 |
| -+ let _ = c.flag("-ffreestanding"); |
| 53 | + } |
| 54 | + |
| 55 | ++ // `clang` does not define `__ELF__` for `x86_64-unknown-none` target. |
| 56 | ++ // Manually define it. |
| 57 | ++ if target.os == "none" { |
| 58 | ++ if let Ok(compiler) = c.try_get_compiler() { |
| 59 | ++ if compiler.is_like_clang() { |
| 60 | ++ let _ = c.define("__ELF__", None); |
| 61 | ++ } |
41 | 62 | + }
|
| 63 | ++ } |
| 64 | ++ |
| 65 | + if target.force_warnings_into_errors { |
| 66 | + c.warnings_into_errors(true); |
42 | 67 | }
|
| 68 | +@@ -645,7 +662,7 @@ fn nasm(file: &Path, arch: &str, include_dir: &Path, out_file: &Path) -> Command |
| 69 | + std::path::MAIN_SEPARATOR, |
| 70 | + ))); |
43 | 71 |
|
44 |
| - if warnings_are_errors { |
45 |
| -@@ -626,7 +629,7 @@ fn nasm(file: &Path, arch: &str, out_file: &Path) -> Command { |
46 |
| - "x86" => ("win32"), |
47 |
| - _ => panic!("unsupported arch: {}", arch), |
48 |
| - }; |
49 |
| -- let mut c = Command::new("./target/tools/nasm"); |
| 72 | +- let mut c = Command::new("./target/tools/windows/nasm/nasm"); |
50 | 73 | + let mut c = Command::new("nasm");
|
51 | 74 | let _ = c
|
52 | 75 | .arg("-o")
|
53 | 76 | .arg(out_file.to_str().expect("Invalid path"))
|
54 | 77 | diff --git a/src/rand.rs b/src/rand.rs
|
55 |
| -index 9d1864fa1..6ac5cc727 100644 |
| 78 | +index 78f4bdc3c..2d1028b84 100644 |
56 | 79 | --- a/src/rand.rs
|
57 | 80 | +++ b/src/rand.rs
|
58 |
| -@@ -195,6 +195,9 @@ use self::darwin::fill as fill_impl; |
59 |
| - #[cfg(any(target_os = "fuchsia"))] |
60 |
| - use self::fuchsia::fill as fill_impl; |
| 81 | +@@ -148,6 +148,7 @@ impl crate::sealed::Sealed for SystemRandom {} |
| 82 | + all(target_os = "unknown", feature = "wasm32_unknown_unknown_js") |
| 83 | + ) |
| 84 | + ), |
| 85 | ++ all(target_arch = "x86_64", target_os = "none"), |
| 86 | + ))] |
| 87 | + impl sealed::SecureRandom for SystemRandom { |
| 88 | + #[inline(always)] |
| 89 | +diff --git a/third_party/fiat/curve25519_64_adx.h b/third_party/fiat/curve25519_64_adx.h |
| 90 | +index 9dcbb69fa..0906fda81 100644 |
| 91 | +--- a/third_party/fiat/curve25519_64_adx.h |
| 92 | ++++ b/third_party/fiat/curve25519_64_adx.h |
| 93 | +@@ -1,7 +1,6 @@ |
| 94 | + #include <stdbool.h> |
| 95 | + #include <stdint.h> |
| 96 | + #include <immintrin.h> |
| 97 | +-#include <string.h> |
61 | 98 |
|
62 |
| -+#[cfg(any(target_os = "none"))] |
63 |
| -+use self::no_std::fill as fill_impl; |
64 |
| -+ |
65 |
| - #[cfg(any(target_os = "android", target_os = "linux"))] |
66 |
| - mod sysrand_chunk { |
67 |
| - use crate::{c, error}; |
68 |
| -@@ -431,3 +434,22 @@ mod fuchsia { |
69 |
| - fn zx_cprng_draw(buffer: *mut u8, length: usize); |
70 |
| - } |
71 |
| - } |
72 |
| -+ |
73 |
| -+#[cfg(any(target_os = "none"))] |
74 |
| -+mod no_std { |
75 |
| -+ use crate::error; |
76 |
| -+ |
77 |
| -+ pub fn fill(dest: &mut [u8]) -> Result<(), error::Unspecified> { |
78 |
| -+ fill_impl(dest) |
79 |
| -+ } |
80 |
| -+ |
81 |
| -+ #[cfg(not(any(target_arch = "x86_64")))] |
82 |
| -+ fn fill_impl(dest: &mut [u8]) -> Result<(), error::Unspecified> { |
83 |
| -+ Err(error::Unspecified) |
84 |
| -+ } |
85 |
| -+ |
86 |
| -+ #[cfg(any(target_arch = "x86_64"))] |
87 |
| -+ fn fill_impl(dest: &mut [u8]) -> Result<(), error::Unspecified> { |
88 |
| -+ getrandom::getrandom(dest).map_err(|_| error::Unspecified) |
89 |
| -+ } |
90 |
| -+} |
| 99 | + typedef uint64_t fe4[4]; |
| 100 | + typedef uint8_t fiat_uint1; |
| 101 | +@@ -469,7 +468,7 @@ __attribute__((target("adx,bmi2"))) |
| 102 | + void x25519_scalar_mult_adx(uint8_t out[32], const uint8_t scalar[32], |
| 103 | + const uint8_t point[32]) { |
| 104 | + uint8_t e[32]; |
| 105 | +- memcpy(e, scalar, 32); |
| 106 | ++ OPENSSL_memcpy(e, scalar, 32); |
| 107 | + e[0] &= 248; |
| 108 | + e[31] &= 127; |
| 109 | + e[31] |= 64; |
0 commit comments