mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-03-15 15:39:09 +01:00
Provide fallback for crypto's fixed_time_eq on non-x86/arm targets
This commit is contained in:
parent
4d75d4c099
commit
1ec9c3aa4b
5 changed files with 35 additions and 0 deletions
|
@ -8,6 +8,7 @@ description = """
|
|||
A Bitcoin Lightning implementation in Rust.
|
||||
Still super-early code-dump quality and is missing large chunks. See README in git repo for suggested projects if you want to contribute. Don't have to bother telling you not to use this for anything serious, because you'd have to finish building it to even try.
|
||||
"""
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
# Supports tracking channels with a non-bitcoin chain hashes. Currently enables all kinds of fun DoS attacks.
|
||||
|
@ -20,6 +21,9 @@ rust-crypto = "0.2"
|
|||
rand = "0.4"
|
||||
secp256k1 = "0.9"
|
||||
|
||||
[build-dependencies]
|
||||
gcc = "0.3"
|
||||
|
||||
[dev-dependencies.bitcoin]
|
||||
version = "0.13"
|
||||
features = ["bitcoinconsensus"]
|
||||
|
|
10
build.rs
Normal file
10
build.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
extern crate gcc;
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm")))]
|
||||
{
|
||||
let mut cfg = gcc::Build::new();
|
||||
cfg.file("src/util/rust_crypto_nonstd_arch.c");
|
||||
cfg.compile("lib_rust_crypto_nonstd_arch.a");
|
||||
}
|
||||
}
|
|
@ -3,6 +3,10 @@ name = "lightning-fuzz"
|
|||
version = "0.0.1"
|
||||
authors = ["Automatically generated"]
|
||||
publish = false
|
||||
# Because the function is unused it gets dropped before we link lightning, so
|
||||
# we have to duplicate build.rs here. Note that this is only required for
|
||||
# fuzztarget mode.
|
||||
build = "../build.rs"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
@ -19,6 +23,9 @@ rust-crypto = "0.2"
|
|||
honggfuzz = { version = "0.5", optional = true }
|
||||
afl = { version = "0.3", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
gcc = "0.3"
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
|
1
fuzz/src/util/rust_crypto_nonstd_arch.c
Symbolic link
1
fuzz/src/util/rust_crypto_nonstd_arch.c
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../src/util/rust_crypto_nonstd_arch.c
|
13
src/util/rust_crypto_nonstd_arch.c
Normal file
13
src/util/rust_crypto_nonstd_arch.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t rust_crypto_util_fixed_time_eq_asm(uint8_t* lhsp, uint8_t* rhsp, size_t count) {
|
||||
if (count == 0) {
|
||||
return 1;
|
||||
}
|
||||
uint8_t result = 0;
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
result |= (lhsp[i] ^ rhsp[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
Loading…
Add table
Reference in a new issue