Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ name = "ring"

[dependencies]
cfg-if = { version = "1.0.0", default-features = false }
getrandom = { version = "0.2.10" }
getrandom = { version = "0.2.16" }
untrusted = { version = "0.9" }

[target.'cfg(all(any(all(target_arch = "aarch64", target_endian = "little"), all(target_arch = "arm", target_endian = "little")), any(target_os = "android", target_os = "linux")))'.dependencies]
Expand Down
24 changes: 21 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod env {
define_env! { pub CARGO_PKG_VERSION_PATCH: SetByCargo }
define_env! { pub CARGO_PKG_VERSION_PRE: SetByCargo }
define_env! { pub DEBUG: SetByCargo }
define_env! { pub HOST: SetByCargo }
define_env! { pub OUT_DIR: SetByCargo }
define_env! { pub PERL_EXECUTABLE: RerunIfChanged }
define_env! { pub RING_PREGENERATE_ASM: RerunIfChanged }
Expand Down Expand Up @@ -246,7 +247,7 @@ const ASM_TARGETS: &[AsmTarget] = &[
perlasm_format: WIN32N,
},
AsmTarget {
oss: &[WINDOWS],
oss: &[WINDOWS, CYGWIN],
arch: X86_64,
perlasm_format: NASM,
},
Expand Down Expand Up @@ -297,6 +298,7 @@ const NASM: &str = "nasm";
const APPLE_ABI: &[&str] = &["ios", "macos", "tvos", "visionos", "watchos"];

const WINDOWS: &str = "windows";
const CYGWIN: &str = "cygwin";

fn main() {
// Avoid assuming the working directory is the same is the $CARGO_MANIFEST_DIR so that toolchains
Expand Down Expand Up @@ -651,7 +653,11 @@ fn nasm(file: &Path, arch: &str, include_dir: &Path, out_dir: &Path, c_root_dir:
let mut include_dir = include_dir.as_os_str().to_os_string();
include_dir.push(OsString::from(String::from(std::path::MAIN_SEPARATOR)));

let mut c = Command::new("./target/tools/windows/nasm/nasm");
let mut c = Command::new(if env::var(&env::HOST).unwrap().contains("cygwin") {
"nasm"
} else {
"./target/tools/windows/nasm/nasm"
});
let _ = c
.arg("-o")
.arg(out_file.to_str().expect("Invalid path"))
Expand Down Expand Up @@ -763,7 +769,19 @@ fn perlasm(
}

fn join_components_with_forward_slashes(path: &Path) -> OsString {
let parts = path.components().map(|c| c.as_os_str()).collect::<Vec<_>>();
let mut parts = path.components().map(|c| c.as_os_str()).collect::<Vec<_>>();
if env::var(&env::HOST).unwrap().contains("cygwin") {
// Most platforms treat `//foo` the same as `/foo`, but POSIX allows `//`
// specifically to have an implementation-defined behavior. Most platforms
// treat them equal, but Cygwin is not one of them.
//
// - POSIX.1-2024: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap04.html#tag_04_16
// - gnulib notes: https://cgit.git.savannah.gnu.org/cgit/gnulib.git/plain/m4/double-slash-root.m4?id=f4038dcb346fccb58d910e2f0a62c0f45022d2a8

if parts[0] == OsStr::new("/") {
parts[0] = OsStr::new("");
}
}
parts.join(OsStr::new("/"))
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// undesirable, so all assembly-referenced symbols should be hidden. CPU
// capabilities are the only such symbols defined in C. Explicitly hide them,
// rather than rely on being built with -fvisibility=hidden.
#if defined(OPENSSL_WINDOWS)
#if defined(OPENSSL_WINDOWS) || defined(__CYGWIN__)
#define HIDDEN
#else
#define HIDDEN __attribute__((visibility("hidden")))
Expand Down
1 change: 1 addition & 0 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl SystemRandom {
all(feature = "less-safe-getrandom-espidf", target_os = "espidf"),
target_os = "aix",
target_os = "android",
target_os = "cygwin",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
Expand Down
4 changes: 3 additions & 1 deletion third_party/fiat/asm/fiat_curve25519_adx_mul.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ring-core/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
(defined(__APPLE__) || defined(__ELF__))
(defined(__APPLE__) || defined(__ELF__) || defined(__CYGWIN__))

.intel_syntax noprefix
.text
Expand All @@ -10,8 +10,10 @@
.global _fiat_curve25519_adx_mul
_fiat_curve25519_adx_mul:
#else
#if defined(__ELF__)
.type fiat_curve25519_adx_mul, @function
.hidden fiat_curve25519_adx_mul
#endif
.global fiat_curve25519_adx_mul
fiat_curve25519_adx_mul:
#endif
Expand Down
4 changes: 3 additions & 1 deletion third_party/fiat/asm/fiat_curve25519_adx_square.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ring-core/asm_base.h>

#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \
(defined(__APPLE__) || defined(__ELF__))
(defined(__APPLE__) || defined(__ELF__) || defined(__CYGWIN__))

.intel_syntax noprefix
.text
Expand All @@ -10,8 +10,10 @@
.global _fiat_curve25519_adx_square
_fiat_curve25519_adx_square:
#else
#if defined (__ELF__)
.type fiat_curve25519_adx_square, @function
.hidden fiat_curve25519_adx_square
#endif
.global fiat_curve25519_adx_square
fiat_curve25519_adx_square:
#endif
Expand Down