Repository navigation
Commit d31317c
Make libsodium optional
Summary:
Fizz uses libsodium only for `X25519` and random bytes, which the OpenSSL it already requires provides (`EVP_PKEY_X25519` and `RAND_bytes`), yet every project that uses Fizz has to supply a second crypto library. Fizz's package config looks up Sodium without installing `FindSodium.cmake`, so Thrift installs one just for Fizz; Thrift's build compiles libsodium from source when it isn't installed but can't on Windows, where users have to install it separately; and the Fizz and Thrift getdeps workflows fetch and build it.
Make libsodium optional:
- `openssl::X25519KeyExchange` implements `X25519` with `EVP_PKEY_X25519`. `MultiBackendFactory` is the only place that picks the `X25519` implementation: libsodium's when Fizz is built with it, OpenSSL's otherwise. It uses it for `NamedGroup::x25519` and the hybrid post-quantum groups, and `MultiBackendFactory::makeX25519KeyExchange()` creates it from a private key for `FizzUtil`'s ECH keys and key pair generation. The tool's built-in ECH key and tests use `openssl::X25519KeyExchange`.
- `fizz::random()` in `fizz/crypto/Random.h` fills a buffer with random bytes from libsodium, or from `RAND_bytes` in builds without it. `MultiBackendFactory::makeRandomBytes` and `RandomGenerator` use it, so neither depends on libsodium headers. `useMockRandom()` replaces its source through the test-only `detail::setRandomForTesting()` instead of libsodium's hook.
- CMake builds Fizz with libsodium if it finds it, and only then compiles the libsodium backend, links libsodium, installs its headers and looks it up in the package config. `FindSodium` no longer defines a `sodium` target when it finds nothing, and on a platform or MSVC architecture it doesn't support, such as ARM64, it reports Sodium as not found instead of failing.
Internal builds still take `X25519` in `MultiBackendFactory` and `FizzUtil`, and all random bytes, from libsodium.
Reviewed By: mingtaoy
Differential Revision: D129117795
fbshipit-source-id: 301002f13112f0791ae8873b29f2f5e99ce13e391 parent 96fbbc4 commit d31317c
1 file changed
Lines changed: 12 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
120 | 121 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 122 | + | |
124 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
165 | | - | |
| 167 | + | |
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
| |||
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
199 | | - | |
200 | | - | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | 203 | | |
209 | 204 | | |
210 | 205 | | |
| |||
248 | 243 | | |
249 | 244 | | |
250 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
251 | 250 | | |
252 | 251 | | |
253 | 252 | | |
| |||
0 commit comments