Skip to content

Commit

Permalink
Merge pull request #7 from dkg/ffi-soname
Browse files Browse the repository at this point in the history
Set FFI SONAME to fips203-ffi crate major version
  • Loading branch information
integritychain committed May 1, 2024
2 parents 9d7830d + e0a61d7 commit 4242795
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ non-goals are:
- better internal error handling
- testing!
- reduce symbol visibility in shared object
- SONAME (bound to major version?)

# Paths considered but discarded

Expand All @@ -48,4 +47,4 @@ $ python3
>>> (ciphertext, shared_secret_1) = encapsulation_key.encaps()
>>> shared_secret_2 = decapsulation_key.decaps(ciphertext)
>>> assert(shared_secret_1 == shared_secret_2)
~~~
~~~
4 changes: 4 additions & 0 deletions ffi/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libfips203.so.{}",
std::env::var("CARGO_PKG_VERSION_MAJOR").unwrap());
}
7 changes: 6 additions & 1 deletion ffi/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
SO_LOCATION = ../../target/debug
SIZES = 512 768 1024
FRAMES = encaps_key decaps_key ciphertext encaps decaps keygen
# should derive SONAME somehow, e.g. from CARGO_PKG_VERSION_MAJOR
SONAME = 0

BASELINES=$(foreach sz, $(SIZES), baseline-$(sz))
CHECKS=$(foreach sz, $(SIZES), runtest-$(sz))

check: $(CHECKS)

runtest-%: baseline-%
$(SO_LOCATION)/libfips203.so.$(SONAME): $(SO_LOCATION)/libfips203.so
ln -s $< $@

runtest-%: baseline-% $(SO_LOCATION)/libfips203.so.$(SONAME)
LD_LIBRARY_PATH=$(SO_LOCATION) ./$<

baseline-%: baseline.c ../fips203.h
Expand Down

0 comments on commit 4242795

Please sign in to comment.