summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@gmail.com>2022-06-22 01:40:55 +0700
committerPeter Dettman <peter.dettman@gmail.com>2022-06-22 01:40:55 +0700
commit892dbe845c98ff3fad3d682aaed3cd40b3161d4f (patch)
tree785ea8dc92cde60b6c06d5f56f6c3f0cda69bb2c /crypto/test/src
parentCleanup old build systems (diff)
downloadBouncyCastle.NET-ed25519-892dbe845c98ff3fad3d682aaed3cd40b3161d4f.tar.xz
ObsoleteAttribute cleanup
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/asn1/test/SignerLocationUnitTest.cs8
-rw-r--r--crypto/test/src/crypto/test/AESFastTest.cs168
-rw-r--r--crypto/test/src/crypto/test/RegressionTest.cs1
-rw-r--r--crypto/test/src/openpgp/test/PgpKeyRingTest.cs10
-rw-r--r--crypto/test/src/security/test/SecureRandomTest.cs7
5 files changed, 8 insertions, 186 deletions
diff --git a/crypto/test/src/asn1/test/SignerLocationUnitTest.cs b/crypto/test/src/asn1/test/SignerLocationUnitTest.cs
index 650e2fcfd..5ce1bbe6c 100644
--- a/crypto/test/src/asn1/test/SignerLocationUnitTest.cs
+++ b/crypto/test/src/asn1/test/SignerLocationUnitTest.cs
@@ -143,24 +143,24 @@ namespace Org.BouncyCastle.Asn1.Tests
         {
             if (countryName != null)
             {
-                if (!countryName.Equals(sl.CountryName))
+                if (!countryName.Equals(sl.Country))
                 {
                     Fail("countryNames don't match.");
                 }
             }
-            else if (sl.CountryName != null)
+            else if (sl.Country != null)
             {
                 Fail("countryName found when none expected.");
             }
 
             if (localityName != null)
             {
-                if (!localityName.Equals(sl.LocalityName))
+                if (!localityName.Equals(sl.Locality))
                 {
                     Fail("localityNames don't match.");
                 }
             }
-            else if (sl.LocalityName != null)
+            else if (sl.Locality != null)
             {
                 Fail("localityName found when none expected.");
             }
diff --git a/crypto/test/src/crypto/test/AESFastTest.cs b/crypto/test/src/crypto/test/AESFastTest.cs
deleted file mode 100644
index 5513a0e78..000000000
--- a/crypto/test/src/crypto/test/AESFastTest.cs
+++ /dev/null
@@ -1,168 +0,0 @@
-using System;
-
-using NUnit.Framework;
-
-using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Engines;
-using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Utilities.Encoders;
-using Org.BouncyCastle.Utilities.Test;
-
-namespace Org.BouncyCastle.Crypto.Tests
-{
-	/**
-	* Test vectors from the NIST standard tests and Brian Gladman's vector set
-	* <a href="http://fp.gladman.plus.com/cryptography_technology/rijndael/">
-	* http://fp.gladman.plus.com/cryptography_technology/rijndael/</a>
-	*/
-	[TestFixture]
-	public class AesFastTest
-		: CipherTest
-	{
-		static SimpleTest[]  tests =
-		{
-			new BlockCipherVectorTest(0, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("80000000000000000000000000000000")),
-					"00000000000000000000000000000000", "0EDD33D3C621E546455BD8BA1418BEC8"),
-			new BlockCipherVectorTest(1, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000080")),
-					"00000000000000000000000000000000", "172AEAB3D507678ECAF455C12587ADB7"),
-			new BlockCipherMonteCarloTest(2, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000000")),
-					"00000000000000000000000000000000", "C34C052CC0DA8D73451AFE5F03BE297F"),
-			new BlockCipherMonteCarloTest(3, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("5F060D3716B345C253F6749ABAC10917")),
-					"355F697E8B868B65B25A04E18D782AFA", "ACC863637868E3E068D2FD6E3508454A"),
-			new BlockCipherVectorTest(4, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "6CD02513E8D4DC986B4AFE087A60BD0C"),
-			new BlockCipherMonteCarloTest(5, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("AAFE47EE82411A2BF3F6752AE8D7831138F041560631B114")),
-					"F3F6752AE8D7831138F041560631B114", "77BA00ED5412DFF27C8ED91F3C376172"),
-			new BlockCipherVectorTest(6, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("0000000000000000000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "DDC6BF790C15760D8D9AEB6F9A75FD4E"),
-			new BlockCipherMonteCarloTest(7, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("28E79E2AFC5F7745FCCABE2F6257C2EF4C4EDFB37324814ED4137C288711A386")),
-					"C737317FE0846F132B23C8C2A672CE22", "E58B82BFBA53C0040DC610C642121168"),
-			new BlockCipherVectorTest(8, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("80000000000000000000000000000000")),
-					"00000000000000000000000000000000", "0EDD33D3C621E546455BD8BA1418BEC8"),
-			new BlockCipherVectorTest(9, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000080")),
-					"00000000000000000000000000000000", "172AEAB3D507678ECAF455C12587ADB7"),
-			new BlockCipherMonteCarloTest(10, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000000")),
-					"00000000000000000000000000000000", "C34C052CC0DA8D73451AFE5F03BE297F"),
-			new BlockCipherMonteCarloTest(11, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("5F060D3716B345C253F6749ABAC10917")),
-					"355F697E8B868B65B25A04E18D782AFA", "ACC863637868E3E068D2FD6E3508454A"),
-			new BlockCipherVectorTest(12, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "6CD02513E8D4DC986B4AFE087A60BD0C"),
-			new BlockCipherMonteCarloTest(13, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("AAFE47EE82411A2BF3F6752AE8D7831138F041560631B114")),
-					"F3F6752AE8D7831138F041560631B114", "77BA00ED5412DFF27C8ED91F3C376172"),
-			new BlockCipherVectorTest(14, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("0000000000000000000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "DDC6BF790C15760D8D9AEB6F9A75FD4E"),
-			new BlockCipherMonteCarloTest(15, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("28E79E2AFC5F7745FCCABE2F6257C2EF4C4EDFB37324814ED4137C288711A386")),
-					"C737317FE0846F132B23C8C2A672CE22", "E58B82BFBA53C0040DC610C642121168"),
-			new BlockCipherVectorTest(16, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("80000000000000000000000000000000")),
-					"00000000000000000000000000000000", "0EDD33D3C621E546455BD8BA1418BEC8"),
-			new BlockCipherVectorTest(17, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000080")),
-					"00000000000000000000000000000000", "172AEAB3D507678ECAF455C12587ADB7"),
-			new BlockCipherMonteCarloTest(18, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("00000000000000000000000000000000")),
-					"00000000000000000000000000000000", "C34C052CC0DA8D73451AFE5F03BE297F"),
-			new BlockCipherMonteCarloTest(19, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("5F060D3716B345C253F6749ABAC10917")),
-					"355F697E8B868B65B25A04E18D782AFA", "ACC863637868E3E068D2FD6E3508454A"),
-			new BlockCipherVectorTest(20, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "6CD02513E8D4DC986B4AFE087A60BD0C"),
-			new BlockCipherMonteCarloTest(21, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("AAFE47EE82411A2BF3F6752AE8D7831138F041560631B114")),
-					"F3F6752AE8D7831138F041560631B114", "77BA00ED5412DFF27C8ED91F3C376172"),
-			new BlockCipherVectorTest(22, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("0000000000000000000000000000000000000000000000000000000000000000")),
-					"80000000000000000000000000000000", "DDC6BF790C15760D8D9AEB6F9A75FD4E"),
-			new BlockCipherMonteCarloTest(23, 10000, new AesFastEngine(),
-					new KeyParameter(Hex.Decode("28E79E2AFC5F7745FCCABE2F6257C2EF4C4EDFB37324814ED4137C288711A386")),
-					"C737317FE0846F132B23C8C2A672CE22", "E58B82BFBA53C0040DC610C642121168")
-		};
-
-		private IBlockCipher _engine = new AesFastEngine();
-
-		public AesFastTest()
-			: base(tests, new AesFastEngine(), new KeyParameter(new byte[16]))
-		{
-		}
-
-		public override string Name
-		{
-			get
-			{
-				return "AESFast";
-			}
-		}
-
-		public override void PerformTest()
-		{
-			base.PerformTest();
-
-			byte[] keyBytes = new byte[16];
-
-			_engine.Init(true, new KeyParameter(keyBytes));
-
-			//
-			// init tests
-			//
-			try
-			{
-				byte[] dudKey = new byte[6];
-
-				_engine.Init(true, new KeyParameter(dudKey));
-
-				Fail("failed key length check");
-			}
-			catch (ArgumentException)
-			{
-				// expected
-			}
-
-			try
-			{
-				byte[] iv = new byte[16];
-
-				_engine.Init(true, new ParametersWithIV(null, iv));
-
-				Fail("failed parameter check");
-			}
-			catch (ArgumentException)
-			{
-				// expected
-			}
-		}
-
-		public static void Main(
-			string[] args)
-		{
-			AesFastTest test = new AesFastTest();
-			ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-		}
-
-		[Test]
-		public void TestFunction()
-		{
-			string resultText = Perform().ToString();
-
-			Assert.AreEqual(Name + ": Okay", resultText);
-		}
-	}
-}
diff --git a/crypto/test/src/crypto/test/RegressionTest.cs b/crypto/test/src/crypto/test/RegressionTest.cs
index edb50da40..2827821be 100644
--- a/crypto/test/src/crypto/test/RegressionTest.cs
+++ b/crypto/test/src/crypto/test/RegressionTest.cs
@@ -11,7 +11,6 @@ namespace Org.BouncyCastle.Crypto.Tests
         {
             new AesTest(),
             new AesLightTest(),
-            new AesFastTest(),
             new AesWrapTest(),
             new AriaTest(),
             new DesTest(),
diff --git a/crypto/test/src/openpgp/test/PgpKeyRingTest.cs b/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
index f8eaa648d..765b54392 100644
--- a/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
+++ b/crypto/test/src/openpgp/test/PgpKeyRingTest.cs
@@ -2091,11 +2091,6 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
             {
                 PgpPublicKey pubKey = secretKey.PublicKey;
 
-                if (pubKey.ValidDays != 28)
-                {
-                    Fail("days wrong on secret key ring");
-                }
-
                 if (pubKey.GetValidSeconds() != 28 * 24 * 60 * 60)
                 {
                     Fail("seconds wrong on secret key ring");
@@ -2106,11 +2101,6 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp.Tests
 
             foreach (PgpPublicKey pubKey in publicRing.GetPublicKeys())
             {
-                if (pubKey.ValidDays != 28)
-                {
-                    Fail("days wrong on public key ring");
-                }
-
                 if (pubKey.GetValidSeconds() != 28 * 24 * 60 * 60)
                 {
                     Fail("seconds wrong on public key ring");
diff --git a/crypto/test/src/security/test/SecureRandomTest.cs b/crypto/test/src/security/test/SecureRandomTest.cs
index 8aac422fd..d7e186ab3 100644
--- a/crypto/test/src/security/test/SecureRandomTest.cs
+++ b/crypto/test/src/security/test/SecureRandomTest.cs
@@ -55,11 +55,12 @@ namespace Org.BouncyCastle.Security.Tests
         }
 
         [Test]
-        public void TestSha1PrngBackward()
+        public void TestSha1PrngReplicable()
         {
-            byte[] seed = Encoding.ASCII.GetBytes("backward compatible");
+            SecureRandom random = new SecureRandom();
+            byte[] seed = SecureRandom.GetNextBytes(random, 16);
 
-            SecureRandom sx = new SecureRandom(seed);
+            SecureRandom sx = SecureRandom.GetInstance("SHA1PRNG", false); sx.SetSeed(seed);
             SecureRandom sy = SecureRandom.GetInstance("SHA1PRNG", false); sy.SetSeed(seed);
 
             byte[] bx = new byte[128]; sx.NextBytes(bx);