summary refs log tree commit diff
path: root/crypto/src/tls/DeferredHash.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/tls/DeferredHash.cs')
-rw-r--r--crypto/src/tls/DeferredHash.cs18
1 files changed, 8 insertions, 10 deletions
diff --git a/crypto/src/tls/DeferredHash.cs b/crypto/src/tls/DeferredHash.cs
index ac66c8f0c..82f7899a5 100644
--- a/crypto/src/tls/DeferredHash.cs
+++ b/crypto/src/tls/DeferredHash.cs
@@ -1,9 +1,8 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Tls.Crypto;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Tls
 {
@@ -16,7 +15,7 @@ namespace Org.BouncyCastle.Tls
         private readonly TlsContext m_context;
 
         private DigestInputBuffer m_buf;
-        private IDictionary m_hashes;
+        private IDictionary<int, TlsHash> m_hashes;
         private bool m_forceBuffering;
         private bool m_sealed;
 
@@ -24,7 +23,7 @@ namespace Org.BouncyCastle.Tls
         {
             this.m_context = context;
             this.m_buf = new DigestInputBuffer();
-            this.m_hashes = Platform.CreateHashtable();
+            this.m_hashes = new Dictionary<int, TlsHash>();
             this.m_forceBuffering = false;
             this.m_sealed = false;
         }
@@ -91,7 +90,7 @@ namespace Org.BouncyCastle.Tls
         {
             SecurityParameters securityParameters = m_context.SecurityParameters;
 
-            IDictionary newHashes = Platform.CreateHashtable();
+            IDictionary<int, TlsHash> newHashes = new Dictionary<int, TlsHash>();
             switch (securityParameters.PrfAlgorithm)
             {
             case PrfAlgorithm.ssl_prf_legacy:
@@ -148,8 +147,7 @@ namespace Org.BouncyCastle.Tls
 
         public byte[] GetFinalHash(int cryptoHashAlgorithm)
         {
-            TlsHash hash = (TlsHash)m_hashes[cryptoHashAlgorithm];
-            if (hash == null)
+            if (!m_hashes.TryGetValue(cryptoHashAlgorithm, out var hash))
                 throw new InvalidOperationException("CryptoHashAlgorithm." + cryptoHashAlgorithm
                     + " is not being tracked");
 
@@ -217,7 +215,7 @@ namespace Org.BouncyCastle.Tls
 
         private void CheckTrackingHash(int cryptoHashAlgorithm)
         {
-            if (!m_hashes.Contains(cryptoHashAlgorithm))
+            if (!m_hashes.ContainsKey(cryptoHashAlgorithm))
             {
                 TlsHash hash = m_context.Crypto.CreateHash(cryptoHashAlgorithm);
                 m_hashes[cryptoHashAlgorithm] = hash;
@@ -226,10 +224,10 @@ namespace Org.BouncyCastle.Tls
 
         private TlsHash CloneHash(int cryptoHashAlgorithm)
         {
-            return ((TlsHash)m_hashes[cryptoHashAlgorithm]).CloneHash();
+            return m_hashes[cryptoHashAlgorithm].CloneHash();
         }
 
-        private void CloneHash(IDictionary newHashes, int cryptoHashAlgorithm)
+        private void CloneHash(IDictionary<int, TlsHash> newHashes, int cryptoHashAlgorithm)
         {
             TlsHash hash = CloneHash(cryptoHashAlgorithm);
             if (m_buf != null)