From 4198486935e8b5b7f83734ea9347cb6fc00a9802 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 8 Nov 2015 17:21:22 +0700 Subject: Some more PORTABLE updates --- crypto/src/crypto/tls/DtlsReliableHandshake.cs | 10 +++++++++- crypto/src/crypto/tls/HeartbeatMessage.cs | 9 ++++++++- crypto/src/crypto/tls/TlsProtocol.cs | 11 ++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'crypto') diff --git a/crypto/src/crypto/tls/DtlsReliableHandshake.cs b/crypto/src/crypto/tls/DtlsReliableHandshake.cs index 7f3f832a1..18a41769a 100644 --- a/crypto/src/crypto/tls/DtlsReliableHandshake.cs +++ b/crypto/src/crypto/tls/DtlsReliableHandshake.cs @@ -419,7 +419,15 @@ namespace Org.BouncyCastle.Crypto.Tls internal void SendToRecordLayer(DtlsRecordLayer recordLayer) { - recordLayer.Send(GetBuffer(), 0, (int)Length); +#if PORTABLE + byte[] buf = ToArray(); + int bufLen = buf.Length; +#else + byte[] buf = GetBuffer(); + int bufLen = (int)Length; +#endif + + recordLayer.Send(buf, 0, bufLen); Platform.Dispose(this); } } diff --git a/crypto/src/crypto/tls/HeartbeatMessage.cs b/crypto/src/crypto/tls/HeartbeatMessage.cs index f64a7baa4..3f22f7e1d 100644 --- a/crypto/src/crypto/tls/HeartbeatMessage.cs +++ b/crypto/src/crypto/tls/HeartbeatMessage.cs @@ -95,7 +95,14 @@ namespace Org.BouncyCastle.Crypto.Tls int minimumCount = payloadLength + 16; if (Length < minimumCount) return null; - return Arrays.CopyOf(GetBuffer(), payloadLength); + +#if PORTABLE + byte[] buf = ToArray(); +#else + byte[] buf = GetBuffer(); +#endif + + return Arrays.CopyOf(buf, payloadLength); } } } diff --git a/crypto/src/crypto/tls/TlsProtocol.cs b/crypto/src/crypto/tls/TlsProtocol.cs index 51178a473..99168b883 100644 --- a/crypto/src/crypto/tls/TlsProtocol.cs +++ b/crypto/src/crypto/tls/TlsProtocol.cs @@ -1310,7 +1310,16 @@ namespace Org.BouncyCastle.Crypto.Tls TlsUtilities.CheckUint24(length); this.Position = 1; TlsUtilities.WriteUint24((int)length, this); - protocol.WriteHandshakeMessage(GetBuffer(), 0, (int)Length); + +#if PORTABLE + byte[] buf = ToArray(); + int bufLen = buf.Length; +#else + byte[] buf = GetBuffer(); + int bufLen = (int)Length; +#endif + + protocol.WriteHandshakeMessage(buf, 0, bufLen); Platform.Dispose(this); } } -- cgit 1.4.1