summary refs log tree commit diff
path: root/crypto/src/tls/DtlsTransport.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-26 00:22:51 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-04-13 17:16:20 +0700
commita575400e49d34228b3fed4f365a01b1ad03c3e1c (patch)
treee321e65398e4eb219b048b0e301ac8631e096108 /crypto/src/tls/DtlsTransport.cs
parentRFC 9146: TODOs for API changes when possible (diff)
downloadBouncyCastle.NET-ed25519-a575400e49d34228b3fed4f365a01b1ad03c3e1c.tar.xz
RFC 9146: Add simple record callback for testing purposes
Diffstat (limited to '')
-rw-r--r--crypto/src/tls/DtlsTransport.cs28
1 files changed, 20 insertions, 8 deletions
diff --git a/crypto/src/tls/DtlsTransport.cs b/crypto/src/tls/DtlsTransport.cs
index 30cd364d2..b452b8c89 100644
--- a/crypto/src/tls/DtlsTransport.cs
+++ b/crypto/src/tls/DtlsTransport.cs
@@ -31,6 +31,12 @@ namespace Org.BouncyCastle.Tls
         /// <exception cref="IOException"/>
         public virtual int Receive(byte[] buf, int off, int len, int waitMillis)
         {
+            return Receive(buf, off, len, waitMillis, null);
+        }
+
+        /// <exception cref="IOException"/>
+        public virtual int Receive(byte[] buf, int off, int len, int waitMillis, Action recordCallback)
+        {
             if (null == buf)
                 throw new ArgumentNullException("buf");
             if (off < 0 || off >= buf.Length)
@@ -39,14 +45,14 @@ namespace Org.BouncyCastle.Tls
                 throw new ArgumentException("invalid length: " + len, "len");
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-            return Receive(buf.AsSpan(off, len), waitMillis);
+            return Receive(buf.AsSpan(off, len), waitMillis, recordCallback);
 #else
             if (waitMillis < 0)
                 throw new ArgumentException("cannot be negative", "waitMillis");
 
             try
             {
-                return m_recordLayer.Receive(buf, off, len, waitMillis);
+                return m_recordLayer.Receive(buf, off, len, waitMillis, recordCallback);
             }
             catch (TlsFatalAlert fatalAlert)
             {
@@ -87,7 +93,7 @@ namespace Org.BouncyCastle.Tls
         }
 
         /// <exception cref="IOException"/>
-        public virtual int ReceivePending(byte[] buf, int off, int len)
+        public virtual int ReceivePending(byte[] buf, int off, int len, Action recordCallback = null)
         {
             if (null == buf)
                 throw new ArgumentNullException("buf");
@@ -97,11 +103,11 @@ namespace Org.BouncyCastle.Tls
                 throw new ArgumentException("invalid length: " + len, "len");
 
 #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
-            return ReceivePending(buf.AsSpan(off, len));
+            return ReceivePending(buf.AsSpan(off, len), recordCallback);
 #else
             try
             {
-                return m_recordLayer.ReceivePending(buf, off, len);
+                return m_recordLayer.ReceivePending(buf, off, len, recordCallback);
             }
             catch (TlsFatalAlert fatalAlert)
             {
@@ -145,12 +151,18 @@ namespace Org.BouncyCastle.Tls
         /// <exception cref="IOException"/>
         public virtual int Receive(Span<byte> buffer, int waitMillis)
         {
+            return Receive(buffer, waitMillis, null);
+        }
+
+        /// <exception cref="IOException"/>
+        public virtual int Receive(Span<byte> buffer, int waitMillis, Action recordCallback)
+        {
             if (waitMillis < 0)
                 throw new ArgumentException("cannot be negative", nameof(waitMillis));
 
             try
             {
-                return m_recordLayer.Receive(buffer, waitMillis);
+                return m_recordLayer.Receive(buffer, waitMillis, recordCallback);
             }
             catch (TlsFatalAlert fatalAlert)
             {
@@ -190,11 +202,11 @@ namespace Org.BouncyCastle.Tls
         }
 
         /// <exception cref="IOException"/>
-        public virtual int ReceivePending(Span<byte> buffer)
+        public virtual int ReceivePending(Span<byte> buffer, Action recordCallback = null)
         {
             try
             {
-                return m_recordLayer.ReceivePending(buffer);
+                return m_recordLayer.ReceivePending(buffer, recordCallback);
             }
             catch (TlsFatalAlert fatalAlert)
             {