Restore SEBPatch
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the cryptographic parameters used to encrypt configuration data.
|
||||
/// </summary>
|
||||
public abstract class EncryptionParameters
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality related to certificates installed on the computer.
|
||||
/// </summary>
|
||||
public interface ICertificateStore
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to retrieve the certificate which matches the specified public key hash value.
|
||||
/// Returns <c>true</c> if the certificate was found, otherwise <c>false</c>.
|
||||
/// </summary>
|
||||
bool TryGetCertificateWith(byte[] keyHash, out X509Certificate2 certificate);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all identity certificates from the given configuration data and installs them on the computer.
|
||||
/// </summary>
|
||||
void ExtractAndImportIdentities(IDictionary<string, object> data);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality to calculate hash codes of different objects.
|
||||
/// </summary>
|
||||
public interface IHashAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Computes a hash code for the given password.
|
||||
/// </summary>
|
||||
string GenerateHashFor(string password);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides funcionality to calculate keys for integrity checks.
|
||||
/// </summary>
|
||||
public interface IKeyGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the encrypted value of the app signature key.
|
||||
/// </summary>
|
||||
string CalculateAppSignatureKey(string connectionToken, string salt);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the hash value of the browser exam key (BEK) for the given URL.
|
||||
/// </summary>
|
||||
string CalculateBrowserExamKeyHash(string configurationKey, byte[] salt, string url);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the hash value of the configuration key (CK) for the given URL.
|
||||
/// </summary>
|
||||
string CalculateConfigurationKeyHash(string configurationKey, string url);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that a custom browser exam key (BEK) should be used.
|
||||
/// </summary>
|
||||
void UseCustomBrowserExamKey(string browserExamKey);
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Encrypts and decrypts data with a password.
|
||||
/// </summary>
|
||||
public interface IPasswordEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to decrypt the given data. The decrypted data stream can only be considered valid if <see cref="LoadStatus.Success"/>
|
||||
/// is returned!
|
||||
/// </summary>
|
||||
LoadStatus Decrypt(Stream data, string password, out Stream decrypted);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to encrypt the given data. The encrypted data stream can only be considered valid if <see cref="SaveStatus.Success"/>
|
||||
/// is returned.
|
||||
/// </summary>
|
||||
SaveStatus Encrypt(Stream data, string password, out Stream encrypted);
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Encrypts and decrypts data with a certificate.
|
||||
/// </summary>
|
||||
public interface IPublicKeyEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// Attempts to decrypt the given data. The decrypted data stream and the certificate can only be considered valid if
|
||||
/// <see cref="LoadStatus.Success"/> is returned!
|
||||
/// </summary>
|
||||
LoadStatus Decrypt(Stream data, out Stream decrypted, out X509Certificate2 certificate);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to encrypt the given data. The encrypted data stream can only be considered valid if <see cref="SaveStatus.Success"/>
|
||||
/// is returned.
|
||||
/// </summary>
|
||||
SaveStatus Encrypt(Stream data, X509Certificate2 certificate, out Stream encrypted);
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds all parameters for data encryption by password.
|
||||
/// </summary>
|
||||
public class PasswordParameters : EncryptionParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// The password in plain text.
|
||||
/// </summary>
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the password is a hash code.
|
||||
/// </summary>
|
||||
public bool IsHash { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Contracts.Cryptography
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds all parameters for data encryption by certificate.
|
||||
/// </summary>
|
||||
public class PublicKeyParameters : EncryptionParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// The certificate holding the public key used for encryption.
|
||||
/// </summary>
|
||||
public X509Certificate2 Certificate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The encryption parameters of the inner data, if available.
|
||||
/// </summary>
|
||||
public PasswordParameters InnerEncryption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines the usage of symmetric vs. asymmetric encryption.
|
||||
/// </summary>
|
||||
public bool SymmetricEncryption { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user