nixpkgs/pkgs/tools/security/rng-tools/default.nix

67 lines
2.0 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, libtool, autoreconfHook, pkgconfig
2018-10-22 22:48:25 +01:00
, sysfsutils
# WARNING: DO NOT USE BEACON GENERATED VALUES AS SECRET CRYPTOGRAPHIC KEYS
# https://www.nist.gov/programs-projects/nist-randomness-beacon
, curl ? null, libxml2 ? null, openssl ? null, withNistBeacon ? false
# Systems that support RDRAND but not AES-NI require libgcrypt to use RDRAND as an entropy source
, libgcrypt ? null, withGcrypt ? true
2018-10-23 22:36:57 +01:00
# Not sure if jitterentropy is safe to use for cryptography
# and thus a default entropy source
, jitterentropy ? null, withJitterEntropy ? false
, libp11 ? null, opensc ? null, withPkcs11 ? true
2018-10-22 22:48:25 +01:00
}:
2018-10-22 22:48:25 +01:00
with stdenv.lib;
2012-11-22 06:05:45 +00:00
stdenv.mkDerivation rec {
pname = "rng-tools";
version = "6.7";
2018-10-22 22:48:25 +01:00
src = fetchFromGitHub {
owner = "nhorman";
repo = "rng-tools";
rev = "v${version}";
sha256 = "19f75m6mzg8h7b4snzg7d6ypvkz6nq32lrpi9ja95gqz4wsd18a5";
2018-10-22 22:48:25 +01:00
};
2012-11-22 06:05:45 +00:00
postPatch = ''
cp README.md README
${optionalString withPkcs11 ''
substituteInPlace rngd.c \
--replace /usr/lib64/opensc-pkcs11.so ${opensc}/lib/opensc-pkcs11.so
''}
'';
2012-11-22 06:05:45 +00:00
nativeBuildInputs = [ autoreconfHook libtool pkgconfig ];
2018-10-22 22:48:25 +01:00
configureFlags = [
(withFeature withGcrypt "libgcrypt")
(enableFeature withJitterEntropy "jitterentropy")
(withFeature withNistBeacon "nistbeacon")
(withFeature withPkcs11 "pkcs11")
];
2018-10-22 22:48:25 +01:00
buildInputs = [ sysfsutils ]
++ optionals withGcrypt [ libgcrypt ]
++ optionals withJitterEntropy [ jitterentropy ]
++ optionals withNistBeacon [ curl libxml2 openssl ]
++ optionals withPkcs11 [ libp11 openssl ];
# This shouldn't be necessary but is as of 6.7
NIX_LDFLAGS = optionalString withPkcs11 "-lcrypto";
2018-10-22 22:48:25 +01:00
enableParallelBuilding = true;
2012-11-22 06:05:45 +00:00
2018-02-26 23:17:23 +00:00
# For cross-compilation
makeFlags = [ "AR:=$(AR)" ];
2012-11-22 06:05:45 +00:00
meta = {
description = "A random number generator daemon";
2018-10-22 22:48:25 +01:00
homepage = https://github.com/nhorman/rng-tools;
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ johnazoidberg ];
2012-11-22 06:05:45 +00:00
};
}