base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / li / libtomcrypt / package.nix
blob568d1a22c6a808080ca0fa21cee0a1402a66cc1a
1 { lib, stdenv, fetchurl, fetchpatch, libtool, libtommath }:
3 stdenv.mkDerivation rec {
4   pname = "libtomcrypt";
5   version = "1.18.2";
7   src = fetchurl {
8     url = "https://github.com/libtom/libtomcrypt/releases/download/v${version}/crypt-${version}.tar.xz";
9     sha256 = "113vfrgapyv72lalhd3nkw7jnks8az0gcb5wqn9hj19nhcxlrbcn";
10   };
12   # Fixes a build failure on aarch64-darwin. Define for all Darwin targets for when x86_64-darwin
13   # upgrades to a newer SDK.
14   env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-DTARGET_OS_IPHONE=0";
16   patches = [
17     (fetchpatch {
18       name = "CVE-2019-17362.patch";
19       url = "https://github.com/libtom/libtomcrypt/pull/508/commits/25c26a3b7a9ad8192ccc923e15cf62bf0108ef94.patch";
20       sha256 = "1bwsj0pwffxw648wd713z3xcyrbxc2z646psrzp38ys564fjh5zf";
21     })
22   ];
24   nativeBuildInputs = [ libtool libtommath ];
26   postPatch = ''
27     substituteInPlace makefile.shared --replace "LIBTOOL:=glibtool" "LIBTOOL:=libtool"
28   '';
30   preBuild = ''
31     makeFlagsArray+=(PREFIX=$out \
32       CFLAGS="-DUSE_LTM -DLTM_DESC -DLTC_PTHREAD" \
33       EXTRALIBS=\"-ltommath\" \
34       INSTALL_GROUP=$(id -g) \
35       INSTALL_USER=$(id -u))
36   '';
38   makefile = "makefile.shared";
40   enableParallelBuilding = true;
42   meta = with lib; {
43     description = "Fairly comprehensive, modular and portable cryptographic toolkit";
44     homepage = "https://www.libtom.net/LibTomCrypt/";
45     changelog = "https://github.com/libtom/libtomcrypt/raw/v${version}/changes";
46     license = with licenses; [ publicDomain wtfpl ];
47     maintainers = [ ];
48     platforms = platforms.all;
49   };