summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/backend
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2022-05-11 13:29:08 +0200
committerJustus Winter <justus@sequoia-pgp.org>2022-05-11 15:55:59 +0200
commit119b59a2c8403ee69f788106f8192949e3b40c34 (patch)
tree4c583be724a5e61b60c2199c7e5acc4584c56e53 /openpgp/src/crypto/backend
parent523cfd7845fd8141293b5dbe63e630428e9ac90d (diff)
openpgp: Add crypto::backend that identifies the backend.
- This returns a short, human-readable description of the cryptographic backend for use in version strings to improve bug reports. - Fixes #818.
Diffstat (limited to 'openpgp/src/crypto/backend')
-rw-r--r--openpgp/src/crypto/backend/cng.rs6
-rw-r--r--openpgp/src/crypto/backend/nettle.rs7
-rw-r--r--openpgp/src/crypto/backend/rust.rs6
3 files changed, 19 insertions, 0 deletions
diff --git a/openpgp/src/crypto/backend/cng.rs b/openpgp/src/crypto/backend/cng.rs
index f964756a..89f56e31 100644
--- a/openpgp/src/crypto/backend/cng.rs
+++ b/openpgp/src/crypto/backend/cng.rs
@@ -10,6 +10,12 @@ pub mod ecdh;
pub mod hash;
pub mod symmetric;
+/// Returns a short, human-readable description of the backend.
+pub fn backend() -> String {
+ // XXX: can we include features and the version?
+ "Windows CNG".to_string()
+}
+
/// Fills the given buffer with random data.
pub fn random(buf: &mut [u8]) {
RandomNumberGenerator::system_preferred()
diff --git a/openpgp/src/crypto/backend/nettle.rs b/openpgp/src/crypto/backend/nettle.rs
index 79497a66..3de8a6a9 100644
--- a/openpgp/src/crypto/backend/nettle.rs
+++ b/openpgp/src/crypto/backend/nettle.rs
@@ -10,6 +10,13 @@ pub mod ecdh;
pub mod hash;
pub mod symmetric;
+/// Returns a short, human-readable description of the backend.
+pub fn backend() -> String {
+ // XXX: Once we depend on nettle-rs 7.1, add cv448 feature
+ // XXX: Once we depend on nettle-rs 7.2, add nettle::version
+ "Nettle".to_string()
+}
+
/// Fills the given buffer with random data.
pub fn random(buf: &mut [u8]) {
Yarrow::default().random(buf);
diff --git a/openpgp/src/crypto/backend/rust.rs b/openpgp/src/crypto/backend/rust.rs
index 06b1da03..dc4773ed 100644
--- a/openpgp/src/crypto/backend/rust.rs
+++ b/openpgp/src/crypto/backend/rust.rs
@@ -9,6 +9,12 @@ pub mod ecdh;
pub mod hash;
pub mod symmetric;
+/// Returns a short, human-readable description of the backend.
+pub fn backend() -> String {
+ // XXX: can we include features and the version?
+ "RustCrypto".to_string()
+}
+
/// Fills the given buffer with random data.
pub fn random(buf: &mut [u8]) {
use rand07::rngs::OsRng;