-
Notifications
You must be signed in to change notification settings - Fork 710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Xtensa, RISC-V and ESP-IDF #1506
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,7 +167,7 @@ untrusted = { version = "0.9" } | |
[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] | ||
spin = { version = "0.9.2", default-features = false, features = ["once"] } | ||
|
||
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies] | ||
[target.'cfg(any(target_os = "android", target_os = "linux", target_os = "espidf"))'.dependencies] | ||
libc = { version = "0.2.100", default-features = false } | ||
once_cell = { version = "1.8.0", default-features = false, features=["std"], optional = true } | ||
|
||
|
@@ -201,6 +201,7 @@ slow_tests = [] | |
std = ["alloc"] | ||
test_logging = [] | ||
wasm32_unknown_unknown_js = ["web-sys"] | ||
size_optimized = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather not control this with a feature flag. Perhaps you can work around this with |
||
|
||
# XXX: debug = false because of https://github.com/rust-lang/rust/issues/34122 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,11 +41,11 @@ const RING_SRCS: &[(&[&str], &str)] = &[ | |
(&[], "crypto/mem.c"), | ||
(&[], "crypto/poly1305/poly1305.c"), | ||
|
||
(&[AARCH64, ARM, X86_64, X86], "crypto/crypto.c"), | ||
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/ecp_nistz.c"), | ||
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p256.c"), | ||
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/gfp_p384.c"), | ||
(&[AARCH64, ARM, X86_64, X86], "crypto/fipsmodule/ec/p256.c"), | ||
(&[], "crypto/crypto.c"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think a change for crypto.c is needed. |
||
(&[], "crypto/fipsmodule/ec/ecp_nistz.c"), | ||
(&[], "crypto/fipsmodule/ec/gfp_p256.c"), | ||
(&[], "crypto/fipsmodule/ec/gfp_p384.c"), | ||
(&[], "crypto/fipsmodule/ec/p256.c"), | ||
|
||
(&[X86_64, X86], "crypto/cpu-intel.c"), | ||
|
||
|
@@ -126,6 +126,7 @@ fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { | |
"-Wenum-compare", | ||
"-Wfloat-equal", | ||
"-Wformat=2", | ||
#[cfg(not(feature = "size_optimized"))] | ||
"-Winline", | ||
"-Winvalid-pch", | ||
"-Wmissing-field-initializers", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,3 +156,17 @@ int bn_from_montgomery_in_place(BN_ULONG r[], size_t num_r, BN_ULONG a[], | |
} | ||
return 1; | ||
} | ||
|
||
#if !defined(OPENSSL_X86) && !defined(OPENSSL_X86_64) && \ | ||
!defined(OPENSSL_ARM) && !defined(OPENSSL_AARCH64) | ||
void bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's solve this in a PR that isn't specific to any OS/architecture. I will contact the original author of this code to get it submitted so there's no IPR concerns. |
||
const BN_ULONG *np, const BN_ULONG *n0, size_t num) { | ||
Limb tmp[2 * num]; | ||
for (size_t i = 0; i < num; i++) | ||
tmp[i] = 0; | ||
for (size_t i = 0; i < num; i++) | ||
tmp[num + i] = limbs_mul_add_limb(tmp + i, ap, bp[i], num); | ||
|
||
bn_from_montgomery_in_place(rp, num, tmp, 2 * num, np, num, n0); | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,12 @@ | |
#define OPENSSL_MIPS64 | ||
#elif defined(__wasm__) | ||
#define OPENSSL_32_BIT | ||
#elif defined(__xtensa__) | ||
#define OPENSSL_32_BIT | ||
#elif defined(__riscv) && __riscv_xlen == 64 | ||
#define OPENSSL_64_BIT | ||
#elif defined(__riscv) && __riscv_xlen == 32 | ||
#define OPENSSL_32_BIT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reconsider this in light of the approach I suggest in #1455. |
||
#else | ||
// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, | ||
// little-endian architectures. Functions will not produce the correct answer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,7 @@ impl crate::sealed::Sealed for SystemRandom {} | |
not(feature = "dev_urandom_fallback") | ||
), | ||
target_arch = "wasm32", | ||
target_os = "espidf", | ||
windows | ||
))] | ||
use self::sysrand::fill as fill_impl; | ||
|
@@ -229,6 +230,21 @@ mod sysrand_chunk { | |
} | ||
} | ||
|
||
#[cfg(target_os = "espidf")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part should be updated to just add |
||
mod sysrand_chunk { | ||
use crate::{c, error}; | ||
|
||
#[inline] | ||
pub fn chunk(dest: &mut [u8]) -> Result<usize, error::Unspecified> { | ||
let chunk_len: c::size_t = dest.len(); | ||
let r = unsafe { libc::getrandom(dest.as_mut_ptr() as *mut libc::c_void, chunk_len, 0) }; | ||
if r < 0 { | ||
return Err(error::Unspecified); | ||
} | ||
Ok(r as usize) | ||
} | ||
} | ||
|
||
#[cfg(all( | ||
feature = "wasm32_unknown_unknown_js", | ||
target_arch = "wasm32", | ||
|
@@ -286,6 +302,7 @@ mod sysrand_chunk { | |
target_os = "android", | ||
target_os = "linux", | ||
target_arch = "wasm32", | ||
target_os = "espidf", | ||
windows | ||
))] | ||
mod sysrand { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change will be needed once you update the
rand.rs
changes.