summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs')
-rw-r--r--src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs b/src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs
new file mode 100644
index 0000000000..b1aa99b579
--- /dev/null
+++ b/src/mscorlib/src/System/Security/Cryptography/MD5CryptoServiceProvider.cs
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System.Diagnostics.Contracts;
+namespace System.Security.Cryptography {
+[System.Runtime.InteropServices.ComVisible(true)]
+ public sealed class MD5CryptoServiceProvider : MD5 {
+ [System.Security.SecurityCritical] // auto-generated
+ private SafeHashHandle _safeHashHandle = null;
+
+ //
+ // public constructors
+ //
+
+ [System.Security.SecuritySafeCritical] // auto-generated
+ public MD5CryptoServiceProvider() {
+ if (CryptoConfig.AllowOnlyFipsAlgorithms)
+ throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
+ Contract.EndContractBlock();
+
+ // _CreateHash will check for failures and throw the appropriate exception
+ _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
+ }
+
+ [System.Security.SecuritySafeCritical] // overrides public transparent member
+ protected override void Dispose(bool disposing)
+ {
+ if (_safeHashHandle != null && !_safeHashHandle.IsClosed)
+ _safeHashHandle.Dispose();
+ base.Dispose(disposing);
+ }
+
+ //
+ // public methods
+ //
+
+ [System.Security.SecuritySafeCritical] // auto-generated
+ public override void Initialize() {
+ if (_safeHashHandle != null && !_safeHashHandle.IsClosed)
+ _safeHashHandle.Dispose();
+
+ // _CreateHash will check for failures and throw the appropriate exception
+ _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_MD5);
+ }
+
+ [System.Security.SecuritySafeCritical] // overrides protected transparent member
+ protected override void HashCore(byte[] rgb, int ibStart, int cbSize)
+ {
+ Utils.HashData(_safeHashHandle, rgb, ibStart, cbSize);
+ }
+
+ [System.Security.SecuritySafeCritical] // overrides protected transparent member
+ protected override byte[] HashFinal() {
+ return Utils.EndHash(_safeHashHandle);
+ }
+ }
+}