[pmg-devel] [PATCH proxmox 2/6] tfa: add WebauthnConfig::digest method
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Nov 26 14:55:20 CET 2021
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
proxmox-tfa/src/api/webauthn.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/proxmox-tfa/src/api/webauthn.rs b/proxmox-tfa/src/api/webauthn.rs
index d4f8acb..6453808 100644
--- a/proxmox-tfa/src/api/webauthn.rs
+++ b/proxmox-tfa/src/api/webauthn.rs
@@ -49,6 +49,18 @@ pub struct WebauthnConfig {
pub id: String,
}
+impl WebauthnConfig {
+ pub fn digest(&self) -> [u8; 32] {
+ let data = format!(
+ "rp={:?}\norigin={:?}\nid={:?}\n",
+ self.rp,
+ self.origin.0.as_str(),
+ self.id,
+ );
+ openssl::sha::sha256(data.as_bytes())
+ }
+}
+
/// For now we just implement this on the configuration this way.
///
/// Note that we may consider changing this so `get_origin` returns the `Host:` header provided by
--
2.30.2
More information about the pmg-devel
mailing list