Skip to content

Commit 8de7d70

Browse files
authored
botan: various improvements (#408391)
2 parents 3510020 + f44dc95 commit 8de7d70

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

pkgs/development/libraries/botan/default.nix

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
lib,
33
stdenv,
44
fetchurl,
5+
pkgsStatic,
56
python3,
67
docutils,
78
bzip2,
@@ -13,16 +14,22 @@
1314
static ? stdenv.hostPlatform.isStatic, # generates static libraries *only*
1415

1516
# build ESDM RNG plugin
16-
with_esdm ? false,
17+
withEsdm ? false,
1718
# useful, but have to disable tests for now, as /dev/tpmrm0 is not accessible
18-
with_tpm2 ? false,
19-
# only allow BSI approved algorithms, FFI and SHAKE for XMSS
20-
with_bsi_policy ? false,
21-
# only allow NIST approved algorithms
22-
with_fips140_policy ? false,
19+
withTpm2 ? false,
20+
policy ? null,
2321
}:
2422

25-
assert (!with_bsi_policy && !with_fips140_policy) || (with_bsi_policy != with_fips140_policy);
23+
assert lib.assertOneOf "policy" policy [
24+
# no explicit policy is given. The defaults by the library are used
25+
null
26+
# only allow BSI approved algorithms, FFI and SHAKE for XMSS
27+
"bsi"
28+
# only allow NIST approved algorithms in FIPS 140
29+
"fips140"
30+
# only allow "modern" algorithms
31+
"modern"
32+
];
2633

2734
let
2835
common =
@@ -64,23 +71,21 @@ let
6471
bzip2
6572
zlib
6673
]
67-
++ lib.optionals (stdenv.hostPlatform.isLinux && with_tpm2) [
74+
++ lib.optionals (stdenv.hostPlatform.isLinux && withTpm2) [
6875
tpm2-tss
6976
]
7077
++ lib.optionals (lib.versionAtLeast version "3.6.0") [
7178
jitterentropy
7279
]
73-
++ lib.optionals (lib.versionAtLeast version "3.7.0" && with_esdm) [
80+
++ lib.optionals (lib.versionAtLeast version "3.7.0" && withEsdm) [
7481
esdm
7582
];
7683

7784
buildTargets =
78-
lib.optionals finalAttrs.finalPackage.doCheck [ "tests" ]
85+
[ "cli" ]
86+
++ lib.optionals finalAttrs.finalPackage.doCheck [ "tests" ]
7987
++ lib.optionals static [ "static" ]
80-
++ lib.optionals (!static) [
81-
"cli"
82-
"shared"
83-
];
88+
++ lib.optionals (!static) [ "shared" ];
8489

8590
botanConfigureFlags =
8691
[
@@ -98,22 +103,21 @@ let
98103
++ lib.optionals stdenv.cc.isClang [
99104
"--cc=clang"
100105
]
101-
++ lib.optionals (stdenv.hostPlatform.isLinux && with_tpm2) [
106+
++ lib.optionals (stdenv.hostPlatform.isLinux && withTpm2) [
102107
"--with-tpm2"
103108
]
104109
++ lib.optionals (lib.versionAtLeast version "3.6.0") [
105110
"--enable-modules=jitter_rng"
106111
]
107-
++ lib.optionals (lib.versionAtLeast version "3.7.0" && with_esdm) [
112+
++ lib.optionals (lib.versionAtLeast version "3.7.0" && withEsdm) [
108113
"--enable-modules=esdm_rng"
109114
]
110-
++ lib.optionals (lib.versionAtLeast version "3.8.0" && with_bsi_policy) [
111-
"--module-policy=bsi"
115+
++ lib.optionals (lib.versionAtLeast version "3.8.0" && policy != null) [
116+
"--module-policy=${policy}"
117+
]
118+
++ lib.optionals (lib.versionAtLeast version "3.8.0" && policy == "bsi") [
112119
"--enable-module=ffi"
113120
"--enable-module=shake"
114-
]
115-
++ lib.optionals (lib.versionAtLeast version "3.8.0" && with_fips140_policy) [
116-
"--module-policy=fips140"
117121
];
118122

119123
configurePhase = ''
@@ -133,7 +137,11 @@ let
133137
ln -s botan-*.pc botan.pc || true
134138
'';
135139

136-
doCheck = !static;
140+
doCheck = true;
141+
142+
passthru.tests = lib.optionalAttrs (lib.versionAtLeast version "3") {
143+
static = pkgsStatic.botan3;
144+
};
137145

138146
meta = with lib; {
139147
description = "Cryptographic algorithms library";
@@ -142,6 +150,7 @@ let
142150
maintainers = with maintainers; [
143151
raskin
144152
thillux
153+
nikstur
145154
];
146155
platforms = platforms.unix;
147156
license = licenses.bsd2;

pkgs/top-level/all-packages.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7839,7 +7839,11 @@ with pkgs;
78397839

78407840
boost = boost187;
78417841

7842-
inherit (callPackages ../development/libraries/botan { })
7842+
inherit
7843+
(callPackages ../development/libraries/botan {
7844+
# botan3 only sensibly works with libcxxStdenv when building static binaries
7845+
stdenv = if stdenv.hostPlatform.isStatic then buildPackages.libcxxStdenv else stdenv;
7846+
})
78437847
botan2
78447848
botan3
78457849
;

0 commit comments

Comments
 (0)