diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-09-09 17:16:52 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-09-30 13:49:17 +0200 |
commit | aa21e2404d9502eeea84ff39da03a85c971ea2d3 (patch) | |
tree | ea723d20c230e45899b4268f40bf89e7ff765808 /openpgp/build.rs | |
parent | c422b1b317fb760bc6b43cb8055fe0a1305ba3a5 (diff) |
openpgp: Add features to opt-in to experimental crypto backends.
Diffstat (limited to 'openpgp/build.rs')
-rw-r--r-- | openpgp/build.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/openpgp/build.rs b/openpgp/build.rs index bc0f09a7..210483e5 100644 --- a/openpgp/build.rs +++ b/openpgp/build.rs @@ -96,4 +96,46 @@ See https://crates.io/crates/sequoia-openpgp#crypto-backends", exit(1); }, } + + // We now have exactly one backend. + assert_eq!(backends.len(), 1); + let backend = &backends[0]; + + // Check its properties. + if ! (backend.production_ready + || cfg!(feature = "allow-experimental-crypto")) + { + eprintln!(" +The cryptographic backend {} is not considered production ready. + +If you know what you are doing, you can opt-in to using experimental +cryptographic backends using the feature flag + + allow-experimental-crypto + +See https://crates.io/crates/sequoia-openpgp#crypto-backends", + backend.name); + exit(1); + } + + if ! (backend.constant_time + || cfg!(feature = "allow-variable-time-crypto")) + { + eprintln!(" +The cryptographic backend {} does not provide constant-time +operations. This has the potential of leaking cryptographic secrets, +enable attackers to forge signatures, or cause other mayhem. + +If you are not using Sequoia in an interactive setting, using +variable-time cryptographic operations is probably safe. + +If you know what you are doing, you can opt-in to using variable-time +cryptographic operations using the feature flag + + allow-variable-time-crypto + +See https://crates.io/crates/sequoia-openpgp#crypto-backends", + backend.name); + exit(1); + } } |