diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/tls/ByteQueue.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/crypto/src/tls/ByteQueue.cs b/crypto/src/tls/ByteQueue.cs index b0241972e..e39e797dd 100644 --- a/crypto/src/tls/ByteQueue.cs +++ b/crypto/src/tls/ByteQueue.cs @@ -59,9 +59,18 @@ namespace Org.BouncyCastle.Tls if (m_readOnlyBuf) throw new InvalidOperationException("Cannot add data to read-only buffer"); - if ((m_skipped + m_available + len) > m_databuf.Length) + if (m_available == 0) + { + if (len > m_databuf.Length) + { + int desiredSize = NextTwoPow(len | 256); + m_databuf = new byte[desiredSize]; + } + m_skipped = 0; + } + else if ((m_skipped + m_available + len) > m_databuf.Length) { - int desiredSize = ByteQueue.NextTwoPow(m_available + len); + int desiredSize = NextTwoPow(m_available + len); if (desiredSize > m_databuf.Length) { byte[] tmp = new byte[desiredSize]; @@ -181,7 +190,7 @@ namespace Org.BouncyCastle.Tls } else { - int desiredSize = ByteQueue.NextTwoPow(m_available); + int desiredSize = NextTwoPow(m_available); if (desiredSize < m_databuf.Length) { byte[] tmp = new byte[desiredSize]; |