Skip to content

Commit 3ed794a

Browse files
committed
botan3: make policy more flexible and easier to maintain
1 parent 6278c39 commit 3ed794a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pkgs/development/libraries/botan/default.nix

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
with_esdm ? false,
1818
# useful, but have to disable tests for now, as /dev/tpmrm0 is not accessible
1919
with_tpm2 ? false,
20-
# only allow BSI approved algorithms, FFI and SHAKE for XMSS
21-
with_bsi_policy ? false,
22-
# only allow NIST approved algorithms
23-
with_fips140_policy ? false,
20+
policy ? null,
2421
}:
2522

26-
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+
];
2731

2832
let
2933
common =
@@ -106,13 +110,12 @@ let
106110
++ lib.optionals (lib.versionAtLeast version "3.7.0" && with_esdm) [
107111
"--enable-modules=esdm_rng"
108112
]
109-
++ lib.optionals (lib.versionAtLeast version "3.8.0" && with_bsi_policy) [
110-
"--module-policy=bsi"
113+
++ lib.optionals (lib.versionAtLeast version "3.8.0" && policy != null) [
114+
"--module-policy=${policy}"
115+
]
116+
++ lib.optionals (lib.versionAtLeast version "3.8.0" && policy == "bsi") [
111117
"--enable-module=ffi"
112118
"--enable-module=shake"
113-
]
114-
++ lib.optionals (lib.versionAtLeast version "3.8.0" && with_fips140_policy) [
115-
"--module-policy=fips140"
116119
];
117120

118121
configurePhase = ''

0 commit comments

Comments
 (0)