Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
b13f30ab2d | ||
|
35f144a7af |
2 changed files with 7 additions and 6 deletions
|
@ -9,6 +9,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using SafeExamBrowser.Configuration.Contracts;
|
using SafeExamBrowser.Configuration.Contracts;
|
||||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||||
using SafeExamBrowser.Configuration.Contracts.Integrity;
|
using SafeExamBrowser.Configuration.Contracts.Integrity;
|
||||||
|
@ -20,7 +21,7 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
{
|
{
|
||||||
private readonly object @lock = new object();
|
private readonly object @lock = new object();
|
||||||
|
|
||||||
private readonly SHA256Managed algorithm;
|
private readonly ThreadLocal<SHA256Managed> algorithm;
|
||||||
private readonly AppConfig appConfig;
|
private readonly AppConfig appConfig;
|
||||||
private readonly IIntegrityModule integrityModule;
|
private readonly IIntegrityModule integrityModule;
|
||||||
private readonly ILogger logger;
|
private readonly ILogger logger;
|
||||||
|
@ -29,7 +30,7 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
|
|
||||||
public KeyGenerator(AppConfig appConfig, IIntegrityModule integrityModule, ILogger logger)
|
public KeyGenerator(AppConfig appConfig, IIntegrityModule integrityModule, ILogger logger)
|
||||||
{
|
{
|
||||||
this.algorithm = new SHA256Managed();
|
this.algorithm = new ThreadLocal<SHA256Managed>(() => new SHA256Managed());
|
||||||
this.appConfig = appConfig;
|
this.appConfig = appConfig;
|
||||||
this.integrityModule = integrityModule;
|
this.integrityModule = integrityModule;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
@ -52,7 +53,7 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
public string CalculateBrowserExamKeyHash(string configurationKey, byte[] salt, string url)
|
public string CalculateBrowserExamKeyHash(string configurationKey, byte[] salt, string url)
|
||||||
{
|
{
|
||||||
var urlWithoutFragment = url.Split('#')[0];
|
var urlWithoutFragment = url.Split('#')[0];
|
||||||
var hash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(urlWithoutFragment + (browserExamKey ?? ComputeBrowserExamKey(configurationKey, salt))));
|
var hash = algorithm.Value.ComputeHash(Encoding.UTF8.GetBytes(urlWithoutFragment + (browserExamKey ?? ComputeBrowserExamKey(configurationKey, salt))));
|
||||||
var key = ToString(hash);
|
var key = ToString(hash);
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
|
@ -61,7 +62,7 @@ namespace SafeExamBrowser.Configuration.Cryptography
|
||||||
public string CalculateConfigurationKeyHash(string configurationKey, string url)
|
public string CalculateConfigurationKeyHash(string configurationKey, string url)
|
||||||
{
|
{
|
||||||
var urlWithoutFragment = url.Split('#')[0];
|
var urlWithoutFragment = url.Split('#')[0];
|
||||||
var hash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(urlWithoutFragment + configurationKey));
|
var hash = algorithm.Value.ComputeHash(Encoding.UTF8.GetBytes(urlWithoutFragment + configurationKey));
|
||||||
var key = ToString(hash);
|
var key = ToString(hash);
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version: '3.7.0.{build}'
|
version: '3.7.1.{build}'
|
||||||
image: Windows
|
image: Windows
|
||||||
configuration: Release
|
configuration: Release
|
||||||
platform:
|
platform:
|
||||||
|
@ -12,7 +12,7 @@ assembly_info:
|
||||||
file: AssemblyInfo.*
|
file: AssemblyInfo.*
|
||||||
assembly_version: '{version}'
|
assembly_version: '{version}'
|
||||||
assembly_file_version: '{version}'
|
assembly_file_version: '{version}'
|
||||||
assembly_informational_version: '3.7.0 ($(platform))'
|
assembly_informational_version: '3.7.1 ($(platform))'
|
||||||
install:
|
install:
|
||||||
- appveyor DownloadFile "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
- appveyor DownloadFile "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||||
build_script:
|
build_script:
|
||||||
|
|
Loading…
Reference in a new issue