[pbs-devel] [PATCH proxmox-backup 1/7] crypt config: add fingerprint mechanism
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Nov 17 18:57:19 CET 2020
by computing the ID digest of a hash of a static string.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Notes:
obviously the input could be whatever, but
sizeof(input) >= sizeof(output)
seemed like a good idea and we use the same scheme for the magic
header strings..
src/backup/crypt_config.rs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/backup/crypt_config.rs b/src/backup/crypt_config.rs
index 4be728d9..01ab0942 100644
--- a/src/backup/crypt_config.rs
+++ b/src/backup/crypt_config.rs
@@ -17,6 +17,11 @@ use serde::{Deserialize, Serialize};
use proxmox::api::api;
+// openssl::sha::sha256(b"Proxmox Backup Encryption Key Fingerprint")
+const FINGERPRINT_INPUT: [u8; 32] = [ 110, 208, 239, 119, 71, 31, 255, 77,
+ 85, 199, 168, 254, 74, 157, 182, 33,
+ 97, 64, 127, 19, 76, 114, 93, 223,
+ 48, 153, 45, 37, 236, 69, 237, 38, ];
#[api(default: "encrypt")]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
@@ -101,6 +106,10 @@ impl CryptConfig {
tag
}
+ pub fn fingerprint(&self) -> [u8; 32] {
+ self.compute_digest(&FINGERPRINT_INPUT)
+ }
+
pub fn data_crypter(&self, iv: &[u8; 16], mode: Mode) -> Result<Crypter, Error> {
let mut crypter = openssl::symm::Crypter::new(self.cipher, mode, &self.enc_key, Some(iv))?;
crypter.aad_update(b"")?; //??
--
2.20.1
More information about the pbs-devel
mailing list