From da114373112e44ec4aea97d510b40cb6b74b00f7 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 27 Sep 2021 14:02:40 +0200
Subject: [PATCH] avoid using deprecated method when computing xml hash

---
 VectoCommon/VectoHashing/Impl/XmlHashProvider.cs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs
index b8dac3e01d..ac6e4d93f3 100644
--- a/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs
+++ b/VectoCommon/VectoHashing/Impl/XmlHashProvider.cs
@@ -93,6 +93,8 @@ namespace TUGraz.VectoHashing.Impl
 				throw new Exception($"CanonicalizationMethod(s) {string.Join(", ", unsupported)} not supported!");
 			}
 
+			// load any HMAC algorithm so that the key is also available. the HVAC algorithm used is the one set in the Reference object below
+			var hmac = HMAC.Create("HMACSHA256"); 
 			var signedXml = new SignedXml(doc);
 			var reference = new Reference("#" + elementId) {
 				DigestMethod = digestMethod
@@ -102,7 +104,7 @@ namespace TUGraz.VectoHashing.Impl
 			}
 
 			signedXml.AddReference(reference);
-			signedXml.ComputeSignature(HMAC.Create());
+			signedXml.ComputeSignature(hmac);
 			var xmlDigitalSignature = reference.GetXml();
 
 			var sigdoc = new XmlDocument();
-- 
GitLab