diff options
Diffstat (limited to 'Emby.Server.Implementations/Cryptography')
| -rw-r--r-- | Emby.Server.Implementations/Cryptography/CryptographyProvider.cs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs b/Emby.Server.Implementations/Cryptography/CryptographyProvider.cs index 23b77e2687..776074b728 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>() @@ -30,6 +33,9 @@ namespace Emby.Server.Implementations.Cryptography private bool _disposed = false; + /// <summary> + /// Initializes a new instance of the <see cref="CryptographyProvider"/> class. + /// </summary> public CryptographyProvider() { // FIXME: When we get DotNet Standard 2.1 we need to revisit how we do the crypto @@ -39,8 +45,10 @@ namespace Emby.Server.Implementations.Cryptography _randomNumberGenerator = RandomNumberGenerator.Create(); } + /// <inheritdoc /> public string DefaultHashMethod => "PBKDF2"; + /// <inheritdoc /> public IEnumerable<string> GetSupportedHashMethods() => _supportedHashMethods; @@ -59,12 +67,7 @@ namespace Emby.Server.Implementations.Cryptography throw new CryptographicException($"Cannot currently use PBKDF2 with requested hash method: {method}"); } - public byte[] ComputeHash(string hashMethod, byte[] bytes) - => ComputeHash(hashMethod, bytes, Array.Empty<byte>()); - - public byte[] ComputeHashWithDefaultMethod(byte[] bytes) - => ComputeHash(DefaultHashMethod, bytes); - + /// <inheritdoc /> public byte[] ComputeHash(string hashMethod, byte[] bytes, byte[] salt) { if (hashMethod == DefaultHashMethod) @@ -90,15 +93,17 @@ 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]; @@ -113,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) |
