summary refs log tree commit diff
path: root/crypto/src/tls/HandshakeMessageOutput.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-30 11:15:39 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-30 11:15:39 +0700
commit633b1a5da2e9ad5323397616dbee05b3d7de5739 (patch)
tree5048f252d70c5fceea0ffbde04afbd3ad9ec7539 /crypto/src/tls/HandshakeMessageOutput.cs
parentNull tmpBuffers when disposing (diff)
downloadBouncyCastle.NET-ed25519-633b1a5da2e9ad5323397616dbee05b3d7de5739.tar.xz
Refactoring around MemoryStream
Diffstat (limited to 'crypto/src/tls/HandshakeMessageOutput.cs')
-rw-r--r--crypto/src/tls/HandshakeMessageOutput.cs28
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) {