2023-07-15 17:15:38 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, protobufc
|
|
|
|
, pkg-config
|
|
|
|
, fuse3
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, libselinux
|
|
|
|
, jitterentropy
|
2023-10-19 13:55:26 +00:00
|
|
|
, botan3
|
|
|
|
, openssl
|
|
|
|
, libkcapi
|
|
|
|
|
|
|
|
# A more detailed explaination of the following meson build options can be found
|
|
|
|
# in the source code of esdm.
|
|
|
|
# A brief explanation is given.
|
|
|
|
|
|
|
|
# general options
|
2023-07-15 17:15:38 +00:00
|
|
|
, selinux ? false # enable selinux support
|
|
|
|
, drngHashDrbg ? true # set the default drng callback
|
|
|
|
, drngChaCha20 ? false # set the default drng callback
|
|
|
|
, ais2031 ? false # set the seeding strategy to be compliant with AIS 20/31
|
2023-10-19 13:55:26 +00:00
|
|
|
, sp80090c ? false # set compliance with NIST SP800-90C
|
|
|
|
, cryptoBackend ? "botan" # set backend for hash and drbg operations
|
2023-07-15 17:15:38 +00:00
|
|
|
, linuxDevFiles ? true # enable linux /dev/random and /dev/urandom support
|
|
|
|
, linuxGetRandom ? true # enable linux getrandom support
|
2023-10-19 13:55:26 +00:00
|
|
|
, hashSha512 ? false # set the conditioning hash: SHA2-512
|
|
|
|
, hashSha3_512 ? true # set the conditioning hash: SHA3-512
|
|
|
|
, openSSLRandProvider ? true # build ESDM provider for OpenSSL 3.x
|
|
|
|
, botanRng ? true # build ESDM class for Botan 3.x
|
|
|
|
|
|
|
|
# client-related options (handle with care, consult source code and meson options)
|
|
|
|
# leave as is if in doubt
|
|
|
|
, connectTimeoutExponent ? 28 # (1 << EXPONENT nanoseconds)
|
|
|
|
, rxTxTimeoutExponent ? 28 # (1 << EXPONENT nanoseconds)
|
|
|
|
, reconnectAttempts ? 10 # how often to attempt unix socket connection before giving up
|
|
|
|
|
|
|
|
# entropy sources
|
|
|
|
, esJitterRng ? true # enable support for the entropy source: jitter rng (running in user space)
|
|
|
|
, esJitterRngEntropyRate ? 256 # amount of entropy to account for jitter rng source
|
|
|
|
, esJitterRngKernel ? true # enable support for the entropy source: jitter rng (running in kernel space)
|
|
|
|
, esJitterRngKernelEntropyRate ? 256 # amount of entropy to account for kernel jitter rng source
|
2023-07-15 17:15:38 +00:00
|
|
|
, esCPU ? true # enable support for the entropy source: cpu-based entropy
|
2023-10-19 13:55:26 +00:00
|
|
|
, esCPUEntropyRate ? 8 # amount of entropy to account for cpu rng source
|
2023-07-15 17:15:38 +00:00
|
|
|
, esKernel ? true # enable support for the entropy source: kernel-based entropy
|
2023-10-19 13:55:26 +00:00
|
|
|
, esKernelEntropyRate ? 128 # amount of entropy to account for kernel-based source
|
2023-07-15 17:15:38 +00:00
|
|
|
, esIRQ ? false # enable support for the entropy source: interrupt-based entropy
|
2023-10-19 13:55:26 +00:00
|
|
|
, esIRQEntropyRate ? 256 # amount of entropy to account for interrupt-based source (only set irq XOR sched != 0)
|
2023-07-15 17:15:38 +00:00
|
|
|
, esSched ? false # enable support for the entropy source: scheduler-based entropy
|
2023-10-19 13:55:26 +00:00
|
|
|
, esSchedEntropyRate ? 0 # amount of entropy to account for interrupt-based source (only set irq XOR sched != 0)
|
2023-07-15 17:15:38 +00:00
|
|
|
, esHwrand ? true # enable support for the entropy source: /dev/hwrng
|
2023-10-19 13:55:26 +00:00
|
|
|
, esHwrandEntropyRate ? 128 # amount of entropy to account for /dev/hwrng-based sources
|
2023-07-15 17:15:38 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert drngHashDrbg != drngChaCha20;
|
|
|
|
assert hashSha512 != hashSha3_512;
|
2023-10-19 13:55:26 +00:00
|
|
|
assert cryptoBackend == "openssl" || cryptoBackend == "botan" || cryptoBackend == "builtin" "Unsupported ESDM crypto backend";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "esdm";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "1.1.0";
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "smuellerDD";
|
|
|
|
repo = "esdm";
|
|
|
|
rev = "v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
sha256 = "sha256-UH6ws/hfHdcmbLETyZ0b4wDm8nHPdLsot3ZhIljpUlw=";
|
2023-07-15 17:15:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ meson pkg-config ninja ];
|
2023-10-19 13:55:26 +00:00
|
|
|
buildInputs = [ protobufc ]
|
|
|
|
++ lib.optional (cryptoBackend == "botan" || botanRng) botan3
|
|
|
|
++ lib.optional (cryptoBackend == "openssl" || openSSLRandProvider) openssl
|
|
|
|
++ lib.optional selinux libselinux
|
|
|
|
++ lib.optional esJitterRng jitterentropy
|
|
|
|
++ lib.optional linuxDevFiles fuse3
|
|
|
|
++ lib.optional esJitterRngKernel libkcapi;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
mesonFlags = [
|
|
|
|
(lib.mesonBool "b_lto" false)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonBool "fips140" false)
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonBool "ais2031" ais2031)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonBool "sp80090c" sp80090c)
|
|
|
|
(lib.mesonEnable "node" true) # multiple DRNGs
|
|
|
|
(lib.mesonOption "threading_max_threads" (toString 64))
|
|
|
|
(lib.mesonOption "crypto_backend" cryptoBackend)
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "linux-devfiles" linuxDevFiles)
|
|
|
|
(lib.mesonEnable "linux-getrandom" linuxGetRandom)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "client-connect-timeout-exponent" (toString connectTimeoutExponent))
|
|
|
|
(lib.mesonOption "client-rx-tx-timeout-exponent" (toString rxTxTimeoutExponent))
|
|
|
|
(lib.mesonOption "client-reconnect-attempts" (toString reconnectAttempts))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_jent" esJitterRng)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_jent_entropy_rate" (toString esJitterRngEntropyRate))
|
|
|
|
(lib.mesonEnable "es_jent_kernel" esJitterRngKernel)
|
|
|
|
(lib.mesonOption "es_jent_kernel_entropy_rate" (toString esJitterRngKernelEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_cpu" esCPU)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_cpu_entropy_rate" (toString esCPUEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_kernel" esKernel)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_kernel_entropy_rate" (toString esKernelEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_irq" esIRQ)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_irq_entropy_rate" (toString esIRQEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_sched" esSched)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_sched_entropy_rate" (toString esSchedEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "es_hwrand" esHwrand)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonOption "es_hwrand_entropy_rate" (toString esHwrandEntropyRate))
|
2023-07-15 17:15:38 +00:00
|
|
|
(lib.mesonEnable "hash_sha512" hashSha512)
|
|
|
|
(lib.mesonEnable "hash_sha3_512" hashSha3_512)
|
|
|
|
(lib.mesonEnable "selinux" selinux)
|
|
|
|
(lib.mesonEnable "drng_hash_drbg" drngHashDrbg)
|
|
|
|
(lib.mesonEnable "drng_chacha20" drngChaCha20)
|
2023-10-19 13:55:26 +00:00
|
|
|
(lib.mesonEnable "openssl-rand-provider" openSSLRandProvider)
|
|
|
|
(lib.mesonEnable "botan-rng" botanRng)
|
2023-07-15 17:15:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
mesonBuildType = "release";
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://www.chronox.de/esdm.html";
|
|
|
|
description = "Entropy Source and DRNG Manager in user space";
|
|
|
|
license = with lib.licenses; [ gpl2Only bsd3 ];
|
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
maintainers = with lib.maintainers; [ orichter thillux ];
|
|
|
|
};
|
|
|
|
}
|