From 9d0c005b35c502824c675034823a024cb3b8ab58 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 21 Feb 2020 11:58:08 +0100 Subject: [PATCH] SEBWIN-309, SEBWIN-358: Fixed crash happening when a configuration does not contain a salt value for the browser exam key. --- SafeExamBrowser.Browser/Handlers/ResourceHandler.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs b/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs index d2a5ae6b..c16d22a6 100644 --- a/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/ResourceHandler.cs @@ -130,7 +130,15 @@ namespace SafeExamBrowser.Browser.Handlers private string ComputeBrowserExamKey() { - using (var algorithm = new HMACSHA256(settings.ExamKeySalt)) + var salt = settings.ExamKeySalt; + + if (salt == default(byte[])) + { + salt = new byte[0]; + logger.Warn("The current configuration does not contain a salt value for the browser exam key!"); + } + + using (var algorithm = new HMACSHA256(salt)) { var hash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(appConfig.CodeSignatureHash + appConfig.ProgramBuildVersion + settings.ConfigurationKey)); var key = BitConverter.ToString(hash).ToLower().Replace("-", string.Empty);