summary refs log tree commit diff
path: root/crypto/test/src/openpgp
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-07-16 01:13:26 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-07-16 01:13:26 +0700
commitbb8fafb833412453d062abbba6f22b22426286d6 (patch)
tree50c2c2cd8908033c076348efce57ca7ee7ad6e45 /crypto/test/src/openpgp
parentFix bzip2 compression for empty contents (diff)
downloadBouncyCastle.NET-ed25519-bb8fafb833412453d062abbba6f22b22426286d6.tar.xz
bzip2 perf. opts.
Diffstat (limited to 'crypto/test/src/openpgp')
-rw-r--r--crypto/test/src/openpgp/test/PGPCompressionTest.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/test/src/openpgp/test/PGPCompressionTest.cs b/crypto/test/src/openpgp/test/PGPCompressionTest.cs
index f42ccfb88..4a8df30e1 100644
--- a/crypto/test/src/openpgp/test/PGPCompressionTest.cs
+++ b/crypto/test/src/openpgp/test/PGPCompressionTest.cs
@@ -4,6 +4,7 @@ using System.Text;
 
 using NUnit.Framework;
 
+using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.IO;
 using Org.BouncyCastle.Utilities.Test;
 
@@ -13,6 +14,8 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 	public class PgpCompressionTest
 		: SimpleTest
 	{
+        private static readonly SecureRandom Random = new SecureRandom();
+
         private static readonly byte[] Data1 = new byte[0];
         private static readonly byte[] Data2 = Encoding.ASCII.GetBytes("hello world! !dlrow olleh");
 
@@ -21,6 +24,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
         {
             DoTestCompression(Data1, CompressionAlgorithmTag.BZip2);
             DoTestCompression(Data2, CompressionAlgorithmTag.BZip2);
+            DoTestCompression(RandomData(1000000), CompressionAlgorithmTag.BZip2);
         }
 
         [Test]
@@ -28,6 +32,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 		{
 			DoTestCompression(Data1, CompressionAlgorithmTag.Uncompressed);
             DoTestCompression(Data2, CompressionAlgorithmTag.Uncompressed);
+            DoTestCompression(RandomData(1000000), CompressionAlgorithmTag.Uncompressed);
         }
 
         [Test]
@@ -35,6 +40,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 		{
 			DoTestCompression(Data1, CompressionAlgorithmTag.Zip);
             DoTestCompression(Data2, CompressionAlgorithmTag.Zip);
+            DoTestCompression(RandomData(1000000), CompressionAlgorithmTag.Zip);
         }
 
         [Test]
@@ -42,6 +48,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 		{
 			DoTestCompression(Data1, CompressionAlgorithmTag.ZLib);
             DoTestCompression(Data2, CompressionAlgorithmTag.ZLib);
+            DoTestCompression(RandomData(1000000), CompressionAlgorithmTag.ZLib);
         }
 
         public override void PerformTest()
@@ -87,6 +94,11 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 			}
 		}
 
+        private byte[] RandomData(int length)
+        {
+            return SecureRandom.GetNextBytes(Random, length);
+        }
+
 		private void ValidateData(byte[] data, byte[] compressed)
 		{
 			PgpObjectFactory pgpFact = new PgpObjectFactory(compressed);