summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-05-10 17:14:40 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-05-10 17:14:40 +0700
commit156f94cb0a16ec24feaf4ecf6f409dc670dcf55c (patch)
tree8feb7276ca69578ac82d218b92cc0fa00ab09e09
parentUpdate KDF test project files and .NET 1.1 compat. (diff)
parentCleanup around OfferInput methods (diff)
downloadBouncyCastle.NET-ed25519-156f94cb0a16ec24feaf4ecf6f409dc670dcf55c.tar.xz
Merge branch 'deniszykov-patch-1'
-rw-r--r--crypto/src/crypto/tls/TlsProtocol.cs20
-rw-r--r--crypto/test/src/crypto/tls/test/TlsProtocolNonBlockingTest.cs2
2 files changed, 16 insertions, 6 deletions
diff --git a/crypto/src/crypto/tls/TlsProtocol.cs b/crypto/src/crypto/tls/TlsProtocol.cs
index 394967c37..388eb629f 100644
--- a/crypto/src/crypto/tls/TlsProtocol.cs
+++ b/crypto/src/crypto/tls/TlsProtocol.cs
@@ -729,11 +729,19 @@ namespace Org.BouncyCastle.Crypto.Tls
         }
 
         /**
+         * Equivalent to <code>OfferInput(input, 0, input.length)</code>
+         * @see TlsProtocol#OfferInput(byte[], int, int)
+         * @param input The input buffer to offer
+         * @throws IOException If an error occurs while decrypting or processing a record
+         */
+        public virtual void OfferInput(byte[] input)
+        {
+            OfferInput(input, 0, input.Length);
+        }
+
+        /**
          * Offer input from an arbitrary source. Only allowed in non-blocking mode.<br/>
          * <br/>
-         * After this method returns, the input buffer is "owned" by this object. Other code
-         * must not attempt to do anything with it.<br/>
-         * <br/>
          * This method will decrypt and process all records that are fully available.
          * If only part of a record is available, the buffer will be retained until the
          * remainder of the record is offered.<br/>
@@ -744,16 +752,18 @@ namespace Org.BouncyCastle.Crypto.Tls
          * You should always check to see if there is any available output after calling
          * this method by calling {@link #getAvailableOutputBytes()}.
          * @param input The input buffer to offer
+         * @param inputOff The offset within the input buffer that input begins
+         * @param inputLen The number of bytes of input being offered
          * @throws IOException If an error occurs while decrypting or processing a record
          */
-        public virtual void OfferInput(byte[] input)
+        public virtual void OfferInput(byte[] input, int inputOff, int inputLen)
         {
             if (mBlocking)
                 throw new InvalidOperationException("Cannot use OfferInput() in blocking mode! Use Stream instead.");
             if (mClosed)
                 throw new IOException("Connection is closed, cannot accept any more input");
 
-            mInputBuffers.Write(input);
+            mInputBuffers.Write(input, inputOff, inputLen);
 
             // loop while there are enough bytes to read the length of the next record
             while (mInputBuffers.Available >= RecordStream.TLS_HEADER_SIZE)
diff --git a/crypto/test/src/crypto/tls/test/TlsProtocolNonBlockingTest.cs b/crypto/test/src/crypto/tls/test/TlsProtocolNonBlockingTest.cs
index 68f2341ee..219a65af7 100644
--- a/crypto/test/src/crypto/tls/test/TlsProtocolNonBlockingTest.cs
+++ b/crypto/test/src/crypto/tls/test/TlsProtocolNonBlockingTest.cs
@@ -79,9 +79,9 @@ namespace Org.BouncyCastle.Crypto.Tls.Tests
 
             if (fragment)
             {
+                byte[] buffer = new byte[1];
                 while (from.GetAvailableOutputBytes() > 0)
                 {
-                    byte[] buffer = new byte[1];
                     from.ReadOutput(buffer, 0, 1);
                     to.OfferInput(buffer);
                 }