summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-03-17 01:36:02 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-03-17 01:36:02 +0700
commitf9f4d1a20f8658b9145662f16b0b18c69f673837 (patch)
tree1863dfcca423a39237b8025001d864e5051a1c18
parentFix return type (diff)
downloadBouncyCastle.NET-ed25519-f9f4d1a20f8658b9145662f16b0b18c69f673837.tar.xz
Refactoring
-rw-r--r--crypto/src/tls/DeferredHash.cs20
-rw-r--r--crypto/src/tls/DigestInputBuffer.cs2
-rw-r--r--crypto/src/tls/TlsUtilities.cs2
3 files changed, 13 insertions, 11 deletions
diff --git a/crypto/src/tls/DeferredHash.cs b/crypto/src/tls/DeferredHash.cs
index f97e9c088..ac66c8f0c 100644
--- a/crypto/src/tls/DeferredHash.cs
+++ b/crypto/src/tls/DeferredHash.cs
@@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Tls
                 throw new InvalidOperationException("Not buffering");
             }
 
-            m_buf.CopyTo(output);
+            m_buf.CopyInputTo(output);
         }
 
         public void ForceBuffering()
@@ -97,8 +97,8 @@ namespace Org.BouncyCastle.Tls
             case PrfAlgorithm.ssl_prf_legacy:
             case PrfAlgorithm.tls_prf_legacy:
             {
-                CloneHash(newHashes, HashAlgorithm.md5);
-                CloneHash(newHashes, HashAlgorithm.sha1);
+                CloneHash(newHashes, CryptoHashAlgorithm.md5);
+                CloneHash(newHashes, CryptoHashAlgorithm.sha1);
                 break;
             }
             default:
@@ -126,7 +126,9 @@ namespace Org.BouncyCastle.Tls
             case PrfAlgorithm.ssl_prf_legacy:
             case PrfAlgorithm.tls_prf_legacy:
             {
-                prfHash = new CombinedHash(m_context, CloneHash(HashAlgorithm.md5), CloneHash(HashAlgorithm.sha1));
+                TlsHash md5Hash = CloneHash(CryptoHashAlgorithm.md5);
+                TlsHash sha1Hash = CloneHash(CryptoHashAlgorithm.sha1);
+                prfHash = new CombinedHash(m_context, md5Hash, sha1Hash);
                 break;
             }
             default:
@@ -146,20 +148,20 @@ namespace Org.BouncyCastle.Tls
 
         public byte[] GetFinalHash(int cryptoHashAlgorithm)
         {
-            TlsHash d = (TlsHash)m_hashes[cryptoHashAlgorithm];
-            if (d == null)
+            TlsHash hash = (TlsHash)m_hashes[cryptoHashAlgorithm];
+            if (hash == null)
                 throw new InvalidOperationException("CryptoHashAlgorithm." + cryptoHashAlgorithm
                     + " is not being tracked");
 
             CheckStopBuffering();
 
-            d = d.CloneHash();
+            hash = hash.CloneHash();
             if (m_buf != null)
             {
-                m_buf.UpdateDigest(d);
+                m_buf.UpdateDigest(hash);
             }
 
-            return d.CalculateHash();
+            return hash.CalculateHash();
         }
 
         public void Update(byte[] input, int inOff, int len)
diff --git a/crypto/src/tls/DigestInputBuffer.cs b/crypto/src/tls/DigestInputBuffer.cs
index 7dd525f88..9b4ea4b06 100644
--- a/crypto/src/tls/DigestInputBuffer.cs
+++ b/crypto/src/tls/DigestInputBuffer.cs
@@ -15,7 +15,7 @@ namespace Org.BouncyCastle.Tls
         }
 
         /// <exception cref="IOException"/>
-        internal void CopyTo(Stream output)
+        internal void CopyInputTo(Stream output)
         {
             // TODO[tls-port]
             // NOTE: Copy data since the output here may be under control of external code.
diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs
index f48c7e731..1d9759bca 100644
--- a/crypto/src/tls/TlsUtilities.cs
+++ b/crypto/src/tls/TlsUtilities.cs
@@ -2118,7 +2118,7 @@ namespace Org.BouncyCastle.Tls
                 output.Write(extraSignatureInput, 0, extraSignatureInput.Length);
             }
 
-            buf.CopyTo(output);
+            buf.CopyInputTo(output);
 
             Platform.Dispose(output);
         }