From 095a665b1c049aa2f757ce62ae411eadde4a67fc Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 14 May 2019 15:29:27 +0700 Subject: Refactor to not need pending_buf_size --- crypto/src/util/zlib/Deflate.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crypto/src/util/zlib/Deflate.cs b/crypto/src/util/zlib/Deflate.cs index 99878c01d..90f8eb09c 100644 --- a/crypto/src/util/zlib/Deflate.cs +++ b/crypto/src/util/zlib/Deflate.cs @@ -174,7 +174,6 @@ namespace Org.BouncyCastle.Utilities.Zlib { internal ZStream strm; // pointer back to this zlib stream internal int status; // as the name implies internal byte[] pending_buf; // output still pending - internal int pending_buf_size; // size of pending_buf internal int pending_out; // next pending byte to output to the stream internal int pending; // nb of bytes in the pending buffer internal int noheader; // suppress zlib header and adler32 @@ -802,13 +801,9 @@ namespace Org.BouncyCastle.Utilities.Zlib { // Stored blocks are limited to 0xffff bytes, pending_buf is limited // to pending_buf_size, and each stored block has a 5 byte header: - int max_block_size = 0xffff; + int max_block_size = System.Math.Min(0xffff, pending_buf.Length - 5); int max_start; - if(max_block_size > pending_buf_size - 5) { - max_block_size = pending_buf_size - 5; - } - // Copy as much as possible from input to output: while(true){ // Fill the window as much as possible: @@ -1382,7 +1377,6 @@ namespace Org.BouncyCastle.Utilities.Zlib { // We overlay pending_buf and d_buf+l_buf. This works since the average // output size for (length,distance) codes is <= 24 bits. pending_buf = new byte[lit_bufsize*4]; - pending_buf_size = lit_bufsize*4; d_buf = lit_bufsize; l_buf = (1+2)*lit_bufsize; -- cgit 1.4.1 From a94b4d6ecffc5cc6ce42caa480a9c6910152bc6e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 14 May 2019 15:29:57 +0700 Subject: Increase zlib default buffer size --- crypto/src/util/zlib/ZInputStream.cs | 2 +- crypto/src/util/zlib/ZOutputStream.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/src/util/zlib/ZInputStream.cs b/crypto/src/util/zlib/ZInputStream.cs index 434fe95c8..ea803fa4f 100644 --- a/crypto/src/util/zlib/ZInputStream.cs +++ b/crypto/src/util/zlib/ZInputStream.cs @@ -49,7 +49,7 @@ namespace Org.BouncyCastle.Utilities.Zlib return z; } - private const int BufferSize = 512; + private const int BufferSize = 4096; protected ZStream z; protected int flushLevel = JZlib.Z_NO_FLUSH; diff --git a/crypto/src/util/zlib/ZOutputStream.cs b/crypto/src/util/zlib/ZOutputStream.cs index 1633b2d8f..a1482a07f 100644 --- a/crypto/src/util/zlib/ZOutputStream.cs +++ b/crypto/src/util/zlib/ZOutputStream.cs @@ -49,7 +49,7 @@ namespace Org.BouncyCastle.Utilities.Zlib return z; } - private const int BufferSize = 512; + private const int BufferSize = 4096; protected ZStream z; protected int flushLevel = JZlib.Z_NO_FLUSH; -- cgit 1.4.1 From 44a7f530bd7b42449072349e956cfef25f9f3ff6 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 14 May 2019 15:53:44 +0700 Subject: Default saltLength to 20 --- crypto/src/crmf/PKMacBuilder.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crypto/src/crmf/PKMacBuilder.cs b/crypto/src/crmf/PKMacBuilder.cs index 6741177da..b74eb6d18 100644 --- a/crypto/src/crmf/PKMacBuilder.cs +++ b/crypto/src/crmf/PKMacBuilder.cs @@ -93,8 +93,7 @@ namespace Org.BouncyCastle.Crmf private SecureRandom random; private PbmParameter parameters; private int iterationCount; - private int saltLength; - private byte[] salt; + private int saltLength = 20; private int maxIterations; /// -- cgit 1.4.1