aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquapka2024-07-25 14:22:14 +0200
committerquapka2024-07-25 14:22:14 +0200
commitb29f697ad640653c976f9f25c97358aa96a509a9 (patch)
tree0ac3c71cd7d62c1cff0eadf12056e0c2a0c4160b
parent2c484515b9f2d9584e4954ca06ffe6c173db0a7b (diff)
downloadECTester-b29f697ad640653c976f9f25c97358aa96a509a9.tar.gz
ECTester-b29f697ad640653c976f9f25c97358aa96a509a9.tar.zst
ECTester-b29f697ad640653c976f9f25c97358aa96a509a9.zip
Link TomCrypt statically and build the shim with Nix
-rw-r--r--flake.nix13
-rw-r--r--standalone/src/main/java/cz/crcs/ectester/standalone/libs/TomcryptLib.java2
-rw-r--r--standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile2
3 files changed, 14 insertions, 3 deletions
diff --git a/flake.nix b/flake.nix
index bd93f5e..c841ce4 100644
--- a/flake.nix
+++ b/flake.nix
@@ -64,9 +64,17 @@
libgpg-error = pkgs.libgpg-error.overrideAttrs (final: prev: {
configureFlags = ( prev.configureFlags or [] ) ++ [ "--enable-static" ];
});
- libtomcrypt = pkgs.libtomcrypt.overrideAttrs (final: prev: {
+ libtomcrypt = (pkgs.libtomcrypt.override { libtommath = libtommath; }).overrideAttrs (final: prev: {
makefile = "makefile.unix";
});
+ libtommath = pkgs.libtommath.overrideAttrs (final: prev: rec {
+ makefile = "makefile.unix";
+ version = "1.3.0";
+ src = pkgs.fetchurl {
+ url = "https://github.com/libtom/libtommath/releases/download/v${version}/ltm-${version}.tar.xz";
+ sha256 = "sha256-KWJy2TQ1mRMI63NgdgDANLVYgHoH6CnnURQuZcz6nQg=";
+ };
+ });
nettle = pkgs.nettle.overrideAttrs (final: prev: {
configureFlags = ( prev.configureFlags or [] ) ++ [ "--enable-static" ];
});
@@ -109,6 +117,8 @@
});
libresslShim = import ./nix/libresslshim.nix { pkgs = pkgs; libressl = libressl; };
boringsslShim = import ./nix/boringsslshim.nix { pkgs = pkgs; boringssl = patched_boringssl; };
+ # Current list of targets: tomcrypt botan cryptopp openssl boringssl gcrypt mbedtls ippcp nettle libressl
+ tomcryptShim = import ./nix/tomcryptshim.nix { inherit pkgs libtomcrypt libtommath; };
botanShim = import ./nix/botanshim.nix { inherit pkgs; };
mbedtlsShim = import ./nix/mbedtlsshim.nix { pkgs = pkgs; };
ippcryptoShim = import ./nix/ippcryptoshim.nix { pkgs = pkgs; ipp-crypto = customPkgs.ipp-crypto; };
@@ -146,6 +156,7 @@
pushd standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/
make lib_timing.so lib_csignals.so lib_cppsignals.so
popd
+ cp ${tomcryptShim.out}/lib/tomcrypt_provider.so ${jniLibsPath}
cp ${botanShim.out}/lib/botan_provider.so ${jniLibsPath}
cp ${commonLibs}/lib/* ${jniLibsPath}
'';
diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/libs/TomcryptLib.java b/standalone/src/main/java/cz/crcs/ectester/standalone/libs/TomcryptLib.java
index 8c000a2..9339986 100644
--- a/standalone/src/main/java/cz/crcs/ectester/standalone/libs/TomcryptLib.java
+++ b/standalone/src/main/java/cz/crcs/ectester/standalone/libs/TomcryptLib.java
@@ -9,7 +9,7 @@ import java.util.Set;
public class TomcryptLib extends NativeECLibrary {
public TomcryptLib() {
- super("tomcrypt","tomcrypt_provider", "tommath", "tomcrypt");
+ super("tomcrypt","tomcrypt_provider");
}
@Override
diff --git a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile
index 8ea1f8d..1e98956 100644
--- a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile
+++ b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile
@@ -117,7 +117,7 @@ gcrypt.o: gcrypt.c
tomcrypt: tomcrypt_provider.so
tomcrypt_provider.so: tomcrypt.o c_utils.o | lib_timing.so lib_csignals.so
- $(CC) $(LFLAGS) -o $@ -Wl,-rpath,'$$ORIGIN/lib' $^ -L. -ltommath -Wl,-Bstatic $(shell pkg-config --libs libtomcrypt) -Wl,-Bdynamic -l:lib_timing.so -l:lib_csignals.so
+ $(CC) $(LFLAGS) -o $@ -Wl,-rpath,'$$ORIGIN/lib' $^ -L. -Wl,-Bstatic $(shell pkg-config --libs libtomcrypt libtommath) -Wl,-Bdynamic -l:lib_timing.so -l:lib_csignals.so
tomcrypt.o: tomcrypt.c
$(CC) -DLTM_DESC $(shell pkg-config --cflags libtomcrypt) $(CFLAGS) -c $<