summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/crypto/tls/DtlsReliableHandshake.cs10
-rw-r--r--crypto/src/crypto/tls/HeartbeatMessage.cs9
-rw-r--r--crypto/src/crypto/tls/TlsProtocol.cs11
3 files changed, 27 insertions, 3 deletions
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);
             }
         }