aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2020-01-10 21:16:46 +0100
committerBond_009 <bond.009@outlook.com>2020-01-10 21:16:46 +0100
commite714b9930ef27e5a1ea870e04e2241eb7cf1fce0 (patch)
tree95503cad3bea14e88c2030e3764fa3910fdd2d67 /Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
parent5cab79c839d2212ae638db403ec4d7ba0699f9a1 (diff)
parent162c1ac7b7fde0e4929cf262b0f275e3eb15524c (diff)
Merge branch 'master' into embytv
Diffstat (limited to 'Emby.Server.Implementations/Cryptography/CryptographyProvider.cs')
-rw-r--r--Emby.Server.Implementations/Cryptography/CryptographyProvider.cs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
index fec7d161e..776074b72 100644
--- a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
+++ b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs
@@ -6,6 +6,9 @@ using static MediaBrowser.Common.Cryptography.Constants;
namespace Emby.Server.Implementations.Cryptography
{
+ /// <summary>
+ /// Class providing abstractions over cryptographic functions.
+ /// </summary>
public class CryptographyProvider : ICryptoProvider, IDisposable
{
private static readonly HashSet<string> _supportedHashMethods = new HashSet<string>()
@@ -42,8 +45,10 @@ namespace Emby.Server.Implementations.Cryptography
_randomNumberGenerator = RandomNumberGenerator.Create();
}
+ /// <inheritdoc />
public string DefaultHashMethod => "PBKDF2";
+ /// <inheritdoc />
public IEnumerable<string> GetSupportedHashMethods()
=> _supportedHashMethods;
@@ -62,6 +67,7 @@ namespace Emby.Server.Implementations.Cryptography
throw new CryptographicException($"Cannot currently use PBKDF2 with requested hash method: {method}");
}
+ /// <inheritdoc />
public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt)
{
if (hashMethod == DefaultHashMethod)
@@ -89,12 +95,15 @@ namespace Emby.Server.Implementations.Cryptography
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
}
+ /// <inheritdoc />
public byte[] ComputeHashWithDefaultMethod(byte[] bytes, byte[] salt)
=> PBKDF2(DefaultHashMethod, bytes, salt, DefaultIterations);
+ /// <inheritdoc />
public byte[] GenerateSalt()
=> GenerateSalt(DefaultSaltLength);
+ /// <inheritdoc />
public byte[] GenerateSalt(int length)
{
byte[] salt = new byte[length];
@@ -109,6 +118,10 @@ namespace Emby.Server.Implementations.Cryptography
GC.SuppressFinalize(this);
}
+ /// <summary>
+ /// Releases unmanaged and - optionally - managed resources.
+ /// </summary>
+ /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)