SEBWIN-309, SEBWIN-358: Fixed crash happening when a configuration does not contain a salt value for the browser exam key.

This commit is contained in:
dbuechel 2020-02-21 11:58:08 +01:00
parent 6865798fb5
commit 9d0c005b35

View file

@ -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);