Skip to content

Commit c867651

Browse files
committed
Build IPP Crypto from package
1 parent 272a2b4 commit c867651

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
lines changed

flake.lock

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
77
gradle2nix.url = "github:tadfisher/gradle2nix/03c1b713ad139eb6dfc8d463b5bd348368125cf1";
8+
custom-nixpkgs.url = "github:quapka/nixpkgs/add-ipp-crypto"; # custom for of nixpkgs with ipp-crypto packaged
89
# FIXME how to add submodule declaratively?
910
# submodule = {
1011
# url = ./
1112
# };
1213
};
1314

14-
outputs = { self, nixpkgs, flake-utils, gradle2nix, ... }:
15+
outputs = { self, nixpkgs, custom-nixpkgs, flake-utils, gradle2nix, ... }:
1516
flake-utils.lib.eachDefaultSystem (system:
1617
let
1718
patched_boringssl = with pkgs; pkgs.boringssl.overrideAttrs (final: prev: rec {
@@ -79,10 +80,15 @@
7980
libresslShim = import ./nix/libresslshim.nix { pkgs = pkgs; libressl = libressl; };
8081
boringsslShim = import ./nix/boringsslshim.nix { pkgs = pkgs; boringssl = patched_boringssl; };
8182
mbedtlsShim = import ./nix/mbedtlsshim.nix { pkgs = pkgs; };
83+
ippcryptoShim = import ./nix/ippcryptoshim.nix { pkgs = pkgs; ipp-crypto = customPkgs.ipp-crypto; };
84+
8285
overlays = [];
8386
pkgs = import nixpkgs {
8487
inherit system overlays;
8588
};
89+
customPkgs = import custom-nixpkgs {
90+
inherit system overlays;
91+
};
8692
buildECTesterStandalone = { opensslVersion, opensslHash }: (
8793
let
8894
patched_openssl = pkgs.openssl.overrideAttrs (_old: rec {
@@ -283,6 +289,8 @@
283289
nettle
284290
# libressl
285291

292+
customPkgs.ipp-crypto
293+
286294
gmp
287295
libgpg-error
288296
wget
@@ -392,6 +400,9 @@
392400
# ${buildLibreSSL}
393401
# popd
394402
# '';
403+
IPP_CRYPTO_HEADER = "${customPkgs.ipp-crypto.dev}/include";
404+
IPP_CRYPTO_LIB = "${customPkgs.ipp-crypto}/lib/";
405+
395406

396407
};
397408
}

nix/ippcryptoshim.nix

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
pkgs
3+
, ipp-crypto
4+
}:
5+
with pkgs; stdenv.mkDerivation rec {
6+
name = "IppCryptoShim";
7+
src = ../standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni;
8+
9+
buildInputs = [
10+
ipp-crypto
11+
pkg-config
12+
jdk11_headless
13+
];
14+
15+
IPP_CRYPTO_HEADER = "${ipp-crypto.dev}/include";
16+
IPP_CRYPTO_LIB = "${ipp-crypto}/lib/"
17+
18+
buildPhase = ''
19+
make ippcrypto
20+
'';
21+
22+
installPhase = ''
23+
mkdir --parents $out/lib
24+
cp mbedtls_provider.so $out/lib
25+
'';
26+
}

standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/Makefile

+3-6
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,11 @@ mbedtls.o: mbedtls.c
173173
# Intel Performance Primitives crypto shim
174174
ippcp: ippcp_provider.so
175175

176-
lib_ippcp.so:
177-
cp $(PROJECT_ROOT_PATH)/ext/ipp-crypto/build/.build/RELEASE/lib/libippcp.so lib_ippcp.so
178-
179-
ippcp_provider.so: ippcp.o c_utils.o | lib_timing.so lib_csignals.so lib_ippcp.so
180-
$(CC) $(LFLAGS) -o $@ -Wl,-rpath,'$$ORIGIN/lib' $^ -L. lib_ippcp.so -l:lib_timing.so -l:lib_csignals.so
176+
ippcp_provider.so: ippcp.o c_utils.o | lib_timing.so lib_csignals.so
177+
$(CC) $(LFLAGS) -o $@ -Wl,-rpath,'$$ORIGIN/lib' $^ -L$(IPP_CRYPTO_LIB) -Wl,-Bstatic -l:libippcp.a -L. -Wl,-Bdynamic -l:lib_timing.so -l:lib_csignals.so
181178

182179
ippcp.o: ippcp.c
183-
$(CC) -I$(PROJECT_ROOT_PATH)/ext/ipp-crypto/build/.build/RELEASE/include/ $(CFLAGS) -c $<
180+
$(CC) -I$(IPP_CRYPTO_HEADER) $(CFLAGS) -c $<
184181

185182

186183
# Nettle shim

0 commit comments

Comments
 (0)