diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-05-19 02:44:44 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-05-19 02:44:44 +0700 |
commit | 26e0d33badb193fc7a14b61f652865a83ad61a0f (patch) | |
tree | 03f5e45a1e4d2b3a557342830953535bd3759c44 /crypto | |
parent | Fix spelling (diff) | |
download | BouncyCastle.NET-ed25519-26e0d33badb193fc7a14b61f652865a83ad61a0f.tar.xz |
ByteQueue improvements
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]; |