summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-10-17 23:06:51 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-10-17 23:06:51 +0700
commit4e7e7f5cbee2917b79559f02df64da2d2cb83222 (patch)
tree965791012aef5aaf19a4502f5a6bc45bd602be83 /crypto/test
parentFix tls test files (diff)
downloadBouncyCastle.NET-ed25519-4e7e7f5cbee2917b79559f02df64da2d2cb83222.tar.xz
.NET 1.1 fixes
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/crypto/io/test/PemReaderTest.cs170
-rw-r--r--crypto/test/src/pkcs/test/PKCS10Test.cs2
-rw-r--r--crypto/test/src/test/SP80038GTest.cs4
3 files changed, 87 insertions, 89 deletions
diff --git a/crypto/test/src/crypto/io/test/PemReaderTest.cs b/crypto/test/src/crypto/io/test/PemReaderTest.cs
index 27b7a1f69..c2d4dfb98 100644
--- a/crypto/test/src/crypto/io/test/PemReaderTest.cs
+++ b/crypto/test/src/crypto/io/test/PemReaderTest.cs
@@ -1,10 +1,12 @@
-using NUnit.Framework;
+using System;
+using System.IO;
+
+using NUnit.Framework;
+
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Pkcs;
 using Org.BouncyCastle.Utilities.IO.Pem;
-using System;
-using System.IO;
 
 namespace Org.BouncyCastle.Crypto.IO.Tests
 {
@@ -18,103 +20,98 @@ namespace Org.BouncyCastle.Crypto.IO.Tests
             string raw = "-----BEGIN CERTIFICATE REQUEST----- MIIBkTCB+wIBADAUMRIwEAYDVQQDDAlUZXN0MlNBTnMwgZ8wDQYJKoZIhvcNAQEB BQADgY0AMIGJAoGBAPPPH7W8LqBMCwSu/MsmCeSCfBzMEp4k+aZmeKw8EQD1R3FK WtPy/LcaUyQhyIeNPFAH8JEz0dJRJjleFL8G5pv7c2YXjBmIfbF/W2eETBIohMDP pWOqKYiT1mqzw25rP1VuXGXaSfN22RReomUd9O2GuEkaqz5x5iTRD6aLmDoJAgMB AAGgPjA8BgkqhkiG9w0BCQ4xLzAtMCsGA1UdEQQkMCKCD3NhbjEudGVzdC5sb2Nh bIIPc2FuMi50ZXN0LmxvY2FsMA0GCSqGSIb3DQEBCwUAA4GBAOacp+9s7/jpmSTA ORvx4nsDwBsY4VLeuPUc2gYmHqfVgrCCSHKPQtQge0P5atudbo+q8Fn+/5JnJR6/ JaooICY3M+/QVrvzvV30i5W8aEIERfXsEIcFyVxv24p6SbrGAcSjwpqvgAf0z82F D3f1qdFATb9HAFsuD/J0HexTFDvB -----END CERTIFICATE REQUEST-----";
 
             PemReader pemReader = new PemReader(new StringReader(raw));
-            var item = pemReader.ReadPemObject();
+            PemObject item = pemReader.ReadPemObject();
 
-            var pkcs10 = Pkcs10CertificationRequest.GetInstance(Asn1Sequence.GetInstance(item.Content));
-            var subject = pkcs10.GetCertificationRequestInfo().Subject.ToString();
+            Asn1.Pkcs.CertificationRequest pkcs10 = Pkcs10CertificationRequest.GetInstance(Asn1Sequence.GetInstance(item.Content));
+            string subject = pkcs10.GetCertificationRequestInfo().Subject.ToString();
 
             Assert.AreEqual("CERTIFICATE REQUEST", item.Type);
             Assert.AreEqual("CN=Test2SANs", subject);
         }
 
-
-
         [Test]
         public void TestSaneInput()
         {
-
-            String test = "Certificate:\n" +
-         "    Data:\n" +
-         "        Version: 3 (0x2)\n" +
-         "        Serial Number: 865 (0x361)\n" +
-         "    Signature Algorithm: ecdsa-with-SHA1\n" +
-         "        Issuer: CN=estExampleCA\n" +
-         "        Validity\n" +
-         "            Not Before: Sep 29 12:41:31 2014 GMT\n" +
-         "            Not After : Dec 16 12:41:31 2022 GMT\n" +
-         "        Subject: CN=*.cisco.com\n" +
-         "        Subject Public Key Info:\n" +
-         "            Public Key Algorithm: rsaEncryption\n" +
-         "                Public-Key: (1024 bit)\n" +
-         "                Modulus:\n" +
-         "                    00:b7:08:e6:18:f2:32:d7:07:44:4b:f3:b1:83:01:\n" +
-         "                    59:f8:bc:ec:26:71:92:9a:53:70:f2:c0:be:2a:d6:\n" +
-         "                    26:6f:45:11:86:d7:ee:37:9d:d3:2f:22:b2:8b:9b:\n" +
-         "                    c5:96:00:36:73:97:c3:4c:f2:7a:0b:2c:e0:cc:d9:\n" +
-         "                    f0:ec:ba:1b:75:8c:66:b1:86:10:fd:be:df:6b:67:\n" +
-         "                    9c:0e:6b:2a:0e:d0:80:a8:dc:7a:d4:df:6e:79:28:\n" +
-         "                    a7:60:1a:11:b7:ae:40:94:bb:b4:11:ed:1b:6f:a7:\n" +
-         "                    91:ae:33:ec:bf:9c:30:f3:dc:91:2c:b4:3e:8c:c9:\n" +
-         "                    bd:f1:d1:aa:f6:c2:1d:6a:cd\n" +
-         "                Exponent: 65537 (0x10001)\n" +
-         "        X509v3 extensions:\n" +
-         "            X509v3 Basic Constraints: \n" +
-         "                CA:FALSE\n" +
-         "            X509v3 Key Usage: \n" +
-         "                Digital Signature, Non Repudiation, Key Encipherment\n" +
-         "    Signature Algorithm: ecdsa-with-SHA1\n" +
-         "         30:44:02:20:76:4f:3a:6c:b4:99:cb:1e:37:f4:0d:6e:e1:74:\n" +
-         "         4b:99:bb:f5:c4:b6:3d:c1:61:df:8c:d7:1f:9f:e7:d3:64:d6:\n" +
-         "         02:20:64:38:8f:6f:32:37:2b:7d:cf:28:93:e5:e6:e7:70:c5:\n" +
-         "         a9:12:04:b0:4b:a5:29:7b:23:df:85:f2:18:44:8b:d2\n" +
-         "-----BEGIN CERTIFICATE-----\n" +
-         "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt\n" +
-         "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD\n" +
-         "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy\n" +
-         "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6\n" +
-         "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b\n" +
-         "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL\n" +
-         "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE\n" +
-         "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=\n" +
-         "-----END CERTIFICATE-----\n";
+            string test = "Certificate:\n" +
+                "    Data:\n" +
+                "        Version: 3 (0x2)\n" +
+                "        Serial Number: 865 (0x361)\n" +
+                "    Signature Algorithm: ecdsa-with-SHA1\n" +
+                "        Issuer: CN=estExampleCA\n" +
+                "        Validity\n" +
+                "            Not Before: Sep 29 12:41:31 2014 GMT\n" +
+                "            Not After : Dec 16 12:41:31 2022 GMT\n" +
+                "        Subject: CN=*.cisco.com\n" +
+                "        Subject Public Key Info:\n" +
+                "            Public Key Algorithm: rsaEncryption\n" +
+                "                Public-Key: (1024 bit)\n" +
+                "                Modulus:\n" +
+                "                    00:b7:08:e6:18:f2:32:d7:07:44:4b:f3:b1:83:01:\n" +
+                "                    59:f8:bc:ec:26:71:92:9a:53:70:f2:c0:be:2a:d6:\n" +
+                "                    26:6f:45:11:86:d7:ee:37:9d:d3:2f:22:b2:8b:9b:\n" +
+                "                    c5:96:00:36:73:97:c3:4c:f2:7a:0b:2c:e0:cc:d9:\n" +
+                "                    f0:ec:ba:1b:75:8c:66:b1:86:10:fd:be:df:6b:67:\n" +
+                "                    9c:0e:6b:2a:0e:d0:80:a8:dc:7a:d4:df:6e:79:28:\n" +
+                "                    a7:60:1a:11:b7:ae:40:94:bb:b4:11:ed:1b:6f:a7:\n" +
+                "                    91:ae:33:ec:bf:9c:30:f3:dc:91:2c:b4:3e:8c:c9:\n" +
+                "                    bd:f1:d1:aa:f6:c2:1d:6a:cd\n" +
+                "                Exponent: 65537 (0x10001)\n" +
+                "        X509v3 extensions:\n" +
+                "            X509v3 Basic Constraints: \n" +
+                "                CA:FALSE\n" +
+                "            X509v3 Key Usage: \n" +
+                "                Digital Signature, Non Repudiation, Key Encipherment\n" +
+                "    Signature Algorithm: ecdsa-with-SHA1\n" +
+                "         30:44:02:20:76:4f:3a:6c:b4:99:cb:1e:37:f4:0d:6e:e1:74:\n" +
+                "         4b:99:bb:f5:c4:b6:3d:c1:61:df:8c:d7:1f:9f:e7:d3:64:d6:\n" +
+                "         02:20:64:38:8f:6f:32:37:2b:7d:cf:28:93:e5:e6:e7:70:c5:\n" +
+                "         a9:12:04:b0:4b:a5:29:7b:23:df:85:f2:18:44:8b:d2\n" +
+                "-----BEGIN CERTIFICATE-----\n" +
+                "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt\n" +
+                "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD\n" +
+                "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy\n" +
+                "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6\n" +
+                "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b\n" +
+                "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL\n" +
+                "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE\n" +
+                "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=\n" +
+                "-----END CERTIFICATE-----\n";
 
             PemReader pemReader = new PemReader(new StringReader(test));
-            var item = pemReader.ReadPemObject();
+            PemObject item = pemReader.ReadPemObject();
             Assert.AreEqual("CERTIFICATE", item.Type);
             X509CertificateStructure cert = X509CertificateStructure.GetInstance(Asn1Sequence.GetInstance(item.Content));
             Assert.AreEqual("CN=estExampleCA", cert.Issuer.ToString());
         }
 
-
         [Test]
         public void TestWithHeaders()
         {
-            String hdr = "Proc-Type: 4,CRL\n";
-            String hdr2 = "CRL: CRL Header\n";
-            String hdr3 = "Originator-Certificate: originator certificate\n";
-            String hdr4 = "CRL: crl header\n";
-            String hdr5 = "Originator-Certificate: next originator certificate\n";
-
-            String test = "-----BEGIN CERTIFICATE-----\n" + hdr + hdr2 + "    \t\r\0" + hdr3 + hdr4 + hdr5 +
-         "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt\n" +
-         "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD\n" +
-         "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy\n" +
-         "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6\n" +
-         "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b\n" +
-         "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL\n" +
-         "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE\n" +
-         "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=\n" +
-         "-----END CERTIFICATE-----\n";
+            string hdr = "Proc-Type: 4,CRL\n";
+            string hdr2 = "CRL: CRL Header\n";
+            string hdr3 = "Originator-Certificate: originator certificate\n";
+            string hdr4 = "CRL: crl header\n";
+            string hdr5 = "Originator-Certificate: next originator certificate\n";
+
+            string test = "-----BEGIN CERTIFICATE-----\n" + hdr + hdr2 + "    \t\r\0" + hdr3 + hdr4 + hdr5 +
+                "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt\n" +
+                "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD\n" +
+                "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy\n" +
+                "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6\n" +
+                "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b\n" +
+                "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL\n" +
+                "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE\n" +
+                "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=\n" +
+                "-----END CERTIFICATE-----\n";
 
             PemReader pemReader = new PemReader(new StringReader(test));
-            var item = pemReader.ReadPemObject();
+            PemObject item = pemReader.ReadPemObject();
             Assert.AreEqual("CERTIFICATE", item.Type);
             X509CertificateStructure cert = X509CertificateStructure.GetInstance(Asn1Sequence.GetInstance(item.Content));
             Assert.AreEqual("CN=estExampleCA", cert.Issuer.ToString());
 
-
             int t = 0;
-            foreach(string[] items in new String[][] { 
+            foreach(string[] items in new string[][] { 
                 new string[] { "Proc-Type", "4,CRL" },
                 new string[] { "CRL", "CRL Header" },
                 new string[] { "Originator-Certificate", "originator certificate" },
@@ -133,25 +130,22 @@ namespace Org.BouncyCastle.Crypto.IO.Tests
         [Test]
         public void TestNoWhiteSpace()
         {
-           
-
-            String test = "-----BEGIN CERTIFICATE-----"+ 
-         "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt" +
-         "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD" +
-         "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy" +
-         "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6" +
-         "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b" +
-         "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL" +
-         "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE" +
-         "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=" +
-         "-----END CERTIFICATE-----";
+            string test = "-----BEGIN CERTIFICATE-----" + 
+                "MIIBezCCASOgAwIBAgICA2EwCQYHKoZIzj0EATAXMRUwEwYDVQQDEwxlc3RFeGFt" +
+                "cGxlQ0EwHhcNMTQwOTI5MTI0MTMxWhcNMjIxMjE2MTI0MTMxWjAWMRQwEgYDVQQD" +
+                "DAsqLmNpc2NvLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtwjmGPIy" +
+                "1wdES/OxgwFZ+LzsJnGSmlNw8sC+KtYmb0URhtfuN53TLyKyi5vFlgA2c5fDTPJ6" +
+                "CyzgzNnw7LobdYxmsYYQ/b7fa2ecDmsqDtCAqNx61N9ueSinYBoRt65AlLu0Ee0b" +
+                "b6eRrjPsv5ww89yRLLQ+jMm98dGq9sIdas0CAwEAAaMaMBgwCQYDVR0TBAIwADAL" +
+                "BgNVHQ8EBAMCBeAwCQYHKoZIzj0EAQNHADBEAiB2TzpstJnLHjf0DW7hdEuZu/XE" +
+                "tj3BYd+M1x+f59Nk1gIgZDiPbzI3K33PKJPl5udwxakSBLBLpSl7I9+F8hhEi9I=" +
+                "-----END CERTIFICATE-----";
 
             PemReader pemReader = new PemReader(new StringReader(test));
-            var item = pemReader.ReadPemObject();
+            PemObject item = pemReader.ReadPemObject();
             Assert.AreEqual("CERTIFICATE", item.Type);
             X509CertificateStructure cert = X509CertificateStructure.GetInstance(Asn1Sequence.GetInstance(item.Content));
             Assert.AreEqual("CN=estExampleCA", cert.Issuer.ToString());
         }
-  
     }
 }
diff --git a/crypto/test/src/pkcs/test/PKCS10Test.cs b/crypto/test/src/pkcs/test/PKCS10Test.cs
index 3a17b53a9..45d59ed49 100644
--- a/crypto/test/src/pkcs/test/PKCS10Test.cs
+++ b/crypto/test/src/pkcs/test/PKCS10Test.cs
@@ -113,7 +113,7 @@ namespace Org.BouncyCastle.Pkcs.Tests
             // Disassemble the attributes with the duplicate extensions.
             //
 
-            var extensions = req2.GetRequestedExtensions();
+            X509Extensions extensions = req2.GetRequestedExtensions();
 
             X509Extension returnedExtension = extensions.GetExtension(X509Extensions.SubjectAlternativeName);
             Asn1Sequence seq = Asn1Sequence.GetInstance(returnedExtension.GetParsedValue());
diff --git a/crypto/test/src/test/SP80038GTest.cs b/crypto/test/src/test/SP80038GTest.cs
index 7f9e4d3d4..05dc7dded 100644
--- a/crypto/test/src/test/SP80038GTest.cs
+++ b/crypto/test/src/test/SP80038GTest.cs
@@ -272,6 +272,9 @@ namespace Org.BouncyCastle.Tests
 
     private void testDisable()
     {
+#if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || (PORTABLE && !DOTNET) || NET_1_1
+            // Can't SetEnvironmentVariable !
+#else
         Environment.SetEnvironmentVariable("org.bouncycastle.fpe.disable", "true");
         try
         {
@@ -307,6 +310,7 @@ namespace Org.BouncyCastle.Tests
 
         testFF3_1();
         Environment.SetEnvironmentVariable("org.bouncycastle.fpe.disable_ff1", "false");
+#endif
     }
 
     private void testFF3_1_255()