Refactoring around MemoryStream
1 files changed, 7 insertions, 21 deletions
diff --git a/crypto/src/tls/HandshakeMessageOutput.cs b/crypto/src/tls/HandshakeMessageOutput.cs
index ff45ce6f3..0d8f15018 100644
--- a/crypto/src/tls/HandshakeMessageOutput.cs
+++ b/crypto/src/tls/HandshakeMessageOutput.cs
@@ -41,40 +41,31 @@ namespace Org.BouncyCastle.Tls
internal void Send(TlsProtocol protocol)
{
// Patch actual length back in
- int bodyLength = (int)Length - 4;
+ int bodyLength = Convert.ToInt32(Length) - 4;
TlsUtilities.CheckUint24(bodyLength);
Seek(1L, SeekOrigin.Begin);
TlsUtilities.WriteUint24(bodyLength, this);
-#if PORTABLE
- byte[] buf = ToArray();
- int count = buf.Length;
-#else
byte[] buf = GetBuffer();
- int count = (int)Length;
-#endif
+ int count = Convert.ToInt32(Length);
+
protocol.WriteHandshakeMessage(buf, 0, count);
- Platform.Dispose(this);
+ Dispose();
}
internal void PrepareClientHello(TlsHandshakeHash handshakeHash, int bindersSize)
{
// Patch actual length back in
- int bodyLength = (int)Length - 4 + bindersSize;
+ int bodyLength = Convert.ToInt32(Length) - 4 + bindersSize;
TlsUtilities.CheckUint24(bodyLength);
Seek(1L, SeekOrigin.Begin);
TlsUtilities.WriteUint24(bodyLength, this);
-#if PORTABLE
- byte[] buf = ToArray();
- int count = buf.Length;
-#else
byte[] buf = GetBuffer();
- int count = (int)Length;
-#endif
+ int count = Convert.ToInt32(Length);
handshakeHash.Update(buf, 0, count);
@@ -83,13 +74,8 @@ namespace Org.BouncyCastle.Tls
internal void SendClientHello(TlsClientProtocol clientProtocol, TlsHandshakeHash handshakeHash, int bindersSize)
{
-#if PORTABLE
- byte[] buf = ToArray();
- int count = buf.Length;
-#else
byte[] buf = GetBuffer();
- int count = (int)Length;
-#endif
+ int count = Convert.ToInt32(Length);
if (bindersSize > 0)
{
|