|
2 | 2 | lib, |
3 | 3 | stdenv, |
4 | 4 | fetchurl, |
| 5 | + pkgsStatic, |
5 | 6 | python3, |
6 | 7 | docutils, |
7 | 8 | bzip2, |
|
13 | 14 | static ? stdenv.hostPlatform.isStatic, # generates static libraries *only* |
14 | 15 |
|
15 | 16 | # build ESDM RNG plugin |
16 | | - with_esdm ? false, |
| 17 | + withEsdm ? false, |
17 | 18 | # 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, |
23 | 21 | }: |
24 | 22 |
|
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 | +]; |
26 | 33 |
|
27 | 34 | let |
28 | 35 | common = |
|
64 | 71 | bzip2 |
65 | 72 | zlib |
66 | 73 | ] |
67 | | - ++ lib.optionals (stdenv.hostPlatform.isLinux && with_tpm2) [ |
| 74 | + ++ lib.optionals (stdenv.hostPlatform.isLinux && withTpm2) [ |
68 | 75 | tpm2-tss |
69 | 76 | ] |
70 | 77 | ++ lib.optionals (lib.versionAtLeast version "3.6.0") [ |
71 | 78 | jitterentropy |
72 | 79 | ] |
73 | | - ++ lib.optionals (lib.versionAtLeast version "3.7.0" && with_esdm) [ |
| 80 | + ++ lib.optionals (lib.versionAtLeast version "3.7.0" && withEsdm) [ |
74 | 81 | esdm |
75 | 82 | ]; |
76 | 83 |
|
77 | 84 | buildTargets = |
78 | | - lib.optionals finalAttrs.finalPackage.doCheck [ "tests" ] |
| 85 | + [ "cli" ] |
| 86 | + ++ lib.optionals finalAttrs.finalPackage.doCheck [ "tests" ] |
79 | 87 | ++ lib.optionals static [ "static" ] |
80 | | - ++ lib.optionals (!static) [ |
81 | | - "cli" |
82 | | - "shared" |
83 | | - ]; |
| 88 | + ++ lib.optionals (!static) [ "shared" ]; |
84 | 89 |
|
85 | 90 | botanConfigureFlags = |
86 | 91 | [ |
|
98 | 103 | ++ lib.optionals stdenv.cc.isClang [ |
99 | 104 | "--cc=clang" |
100 | 105 | ] |
101 | | - ++ lib.optionals (stdenv.hostPlatform.isLinux && with_tpm2) [ |
| 106 | + ++ lib.optionals (stdenv.hostPlatform.isLinux && withTpm2) [ |
102 | 107 | "--with-tpm2" |
103 | 108 | ] |
104 | 109 | ++ lib.optionals (lib.versionAtLeast version "3.6.0") [ |
105 | 110 | "--enable-modules=jitter_rng" |
106 | 111 | ] |
107 | | - ++ lib.optionals (lib.versionAtLeast version "3.7.0" && with_esdm) [ |
| 112 | + ++ lib.optionals (lib.versionAtLeast version "3.7.0" && withEsdm) [ |
108 | 113 | "--enable-modules=esdm_rng" |
109 | 114 | ] |
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") [ |
112 | 119 | "--enable-module=ffi" |
113 | 120 | "--enable-module=shake" |
114 | | - ] |
115 | | - ++ lib.optionals (lib.versionAtLeast version "3.8.0" && with_fips140_policy) [ |
116 | | - "--module-policy=fips140" |
117 | 121 | ]; |
118 | 122 |
|
119 | 123 | configurePhase = '' |
|
133 | 137 | ln -s botan-*.pc botan.pc || true |
134 | 138 | ''; |
135 | 139 |
|
136 | | - doCheck = !static; |
| 140 | + doCheck = true; |
| 141 | + |
| 142 | + passthru.tests = lib.optionalAttrs (lib.versionAtLeast version "3") { |
| 143 | + static = pkgsStatic.botan3; |
| 144 | + }; |
137 | 145 |
|
138 | 146 | meta = with lib; { |
139 | 147 | description = "Cryptographic algorithms library"; |
|
142 | 150 | maintainers = with maintainers; [ |
143 | 151 | raskin |
144 | 152 | thillux |
| 153 | + nikstur |
145 | 154 | ]; |
146 | 155 | platforms = platforms.unix; |
147 | 156 | license = licenses.bsd2; |
|
0 commit comments