diff options
author | Vladimir Panteleev <git@cy.md> | 2024-06-29 13:52:24 +0000 |
---|---|---|
committer | Vladimir Panteleev <git@cy.md> | 2024-06-29 18:08:18 +0000 |
commit | eac595161a60da7d695d46469e2e849d82da57d6 (patch) | |
tree | b0ef489d43982f537c6c4c16e13a897602b28e19 /pkgs | |
parent | 650be5155b0ee012cc4584577872da8d57d3b330 (diff) |
john: add OpenCL support
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/tools/security/john/default.nix | 54 | ||||
-rw-r--r-- | pkgs/tools/security/john/opencl.patch | 18 |
2 files changed, 55 insertions, 17 deletions
diff --git a/pkgs/tools/security/john/default.nix b/pkgs/tools/security/john/default.nix index b5c5cbd66245b..aeefcaa0bbefd 100644 --- a/pkgs/tools/security/john/default.nix +++ b/pkgs/tools/security/john/default.nix @@ -14,6 +14,10 @@ python3Packages, perl, perlPackages, + withOpenCL ? true, + opencl-headers, + ocl-icd, + substituteAll, makeWrapper, }: @@ -28,6 +32,13 @@ stdenv.mkDerivation rec { hash = "sha256-zvoN+8Sx6qpVg2JeRLOIH1ehfl3tFTv7r5wQZ44Qsbc="; }; + patches = lib.optionals withOpenCL [ + (substituteAll { + src = ./opencl.patch; + ocl_icd = ocl-icd; + }) + ]; + postPatch = '' sed -ri -e ' s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/! @@ -39,28 +50,37 @@ stdenv.mkDerivation rec { }' run/*.conf ''; - preConfigure = '' - cd src - # Makefile.in depends on AS and LD being set to CC, which is set by default in configure.ac. - # This ensures we override the environment variables set in cc-wrapper/setup-hook.sh - export AS=$CC - export LD=$CC - ''; + preConfigure = + '' + cd src + # Makefile.in depends on AS and LD being set to CC, which is set by default in configure.ac. + # This ensures we override the environment variables set in cc-wrapper/setup-hook.sh + export AS=$CC + export LD=$CC + '' + + lib.optionalString withOpenCL '' + python ./opencl_generate_dynamic_loader.py # Update opencl_dynamic_loader.c + ''; configureFlags = [ "--disable-native-tests" "--with-systemwide" ]; - buildInputs = [ - openssl - nss - nspr - libkrb5 - gmp - zlib - libpcap - re2 - ]; + buildInputs = + [ + openssl + nss + nspr + libkrb5 + gmp + zlib + libpcap + re2 + ] + ++ lib.optionals withOpenCL [ + opencl-headers + ocl-icd + ]; nativeBuildInputs = [ gcc python3Packages.wrapPython diff --git a/pkgs/tools/security/john/opencl.patch b/pkgs/tools/security/john/opencl.patch new file mode 100644 index 0000000000000..575bfa82638ba --- /dev/null +++ b/pkgs/tools/security/john/opencl.patch @@ -0,0 +1,18 @@ +diff --git a/src/opencl_generate_dynamic_loader.py b/src/opencl_generate_dynamic_loader.py +index 790705330..2acedbc56 100755 +--- a/src/opencl_generate_dynamic_loader.py ++++ b/src/opencl_generate_dynamic_loader.py +@@ -134,12 +134,7 @@ static void load_opencl_dll(void) + + /* Names to try to load */ + const char * const opencl_names[] = { +- "libOpenCL.so", /* Linux/others, hack via "development" sub-package's symlink */ +- "OpenCL", /* _WIN */ +- "/System/Library/Frameworks/OpenCL.framework/OpenCL", /* __APPLE__ */ +- "opencl.dll", /* __CYGWIN__ */ +- "cygOpenCL-1.dll", /* __CYGWIN__ */ +- "libOpenCL.so.1" /* Linux/others, no "development" sub-package installed */ ++ "@ocl_icd@/lib/libOpenCL.so" /* NixOS */ + }; + + for (i = 0; i < sizeof(opencl_names)/sizeof(opencl_names[0]); i++) { |