1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 libtool,
7 libtommath,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "libtomcrypt";
12 version = "1.18.2";
13
14 src = fetchurl {
15 url = "https://github.com/libtom/libtomcrypt/releases/download/v${version}/crypt-${version}.tar.xz";
16 sha256 = "113vfrgapyv72lalhd3nkw7jnks8az0gcb5wqn9hj19nhcxlrbcn";
17 };
18
19 patches = [
20 (fetchpatch {
21 name = "CVE-2019-17362.patch";
22 url = "https://github.com/libtom/libtomcrypt/pull/508/commits/25c26a3b7a9ad8192ccc923e15cf62bf0108ef94.patch";
23 sha256 = "1bwsj0pwffxw648wd713z3xcyrbxc2z646psrzp38ys564fjh5zf";
24 })
25 ];
26
27 buildInputs = [
28 libtommath
29 ];
30
31 postPatch = ''
32 substituteInPlace makefile.shared \
33 --replace-fail "LIBTOOL:=glibtool" "LIBTOOL:=libtool" \
34 --replace-fail libtool "${lib.getExe libtool}"
35 '';
36
37 preBuild = ''
38 makeFlagsArray+=(PREFIX=$out \
39 CFLAGS="-DUSE_LTM -DLTM_DESC -DLTC_PTHREAD" \
40 EXTRALIBS=\"-ltommath\" \
41 INSTALL_GROUP=$(id -g) \
42 INSTALL_USER=$(id -u))
43 '';
44
45 makefile = "makefile.shared";
46
47 enableParallelBuilding = true;
48
49 meta = {
50 description = "Fairly comprehensive, modular and portable cryptographic toolkit";
51 homepage = "https://www.libtom.net/LibTomCrypt/";
52 changelog = "https://github.com/libtom/libtomcrypt/raw/v${version}/changes";
53 license = with lib.licenses; [
54 publicDomain
55 wtfpl
56 ];
57 maintainers = with lib.maintainers; [ ];
58 platforms = lib.platforms.all;
59 };
60}