Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2004-05-11 15:30:24 +0400
committerSebastien Pouliot <sebastien@ximian.com>2004-05-11 15:30:24 +0400
commit32fa6d4398606b1b80a7803efa19d90270cfb91d (patch)
tree62237370dc20a8126e131c2cbc95d9bff6d0afa8 /mcs/class/Mono.Security
parentb3dd432929cc6e365eb51f7ba490c4796f29679e (diff)
2004-05-11 Sebastien Pouliot <sebastien@ximian.com>
* ARC4ManagedTest.cs: Added missing unit tests for complete coverage. Completed convertion to NUnit 2. * CryptoConvertTest.cs: Added/modified unit tests for better coverage. * MD2ManagedTest.cs: Added unit tests for better coverage. * MD2Test.cs: Added unit tests for better coverage. * MD4ManagedTest.cs: Added unit tests for better coverage. * MD4Test.cs: Added unit tests for better coverage. * PKCS8.cs: Added unit tests for better coverage. svn path=/trunk/mcs/; revision=27087
Diffstat (limited to 'mcs/class/Mono.Security')
-rw-r--r--mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs42
-rw-r--r--mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog11
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs23
-rw-r--r--mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs15
-rw-r--r--mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs14
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs13
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs19
-rwxr-xr-xmcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs83
8 files changed, 201 insertions, 19 deletions
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs
index f388eeebefa..c5793332438 100644
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs
@@ -50,7 +50,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// from ref. a
- public void TestVector0 ()
+ [Test]
+ public void Vector0 ()
{
byte[] key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
byte[] input = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
@@ -63,7 +64,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// from ref. a
- public void TestVector1 ()
+ [Test]
+ public void Vector1 ()
{
byte[] key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
byte[] input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -76,7 +78,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// from ref. a
- public void TestVector2 ()
+ [Test]
+ public void Vector2 ()
{
byte[] key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
byte[] input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -89,7 +92,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// from ref. a
- public void TestVector3 ()
+ [Test]
+ public void Vector3 ()
{
byte[] key = { 0xef, 0x01, 0x23, 0x45 };
byte[] input = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -102,7 +106,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// from ref. a
- public void TestVector4 ()
+ [Test]
+ public void Vector4 ()
{
byte[] key = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
byte[] input = new byte [512];
@@ -171,7 +176,8 @@ namespace MonoTests.Mono.Security.Cryptography {
static byte[] serverWriteKey = { 0xed, 0x0e, 0x56, 0xc8, 0x95, 0x12, 0x37, 0xb6, 0x21, 0x17, 0x1c, 0x72, 0x79, 0x91, 0x12, 0x1e };
// SSL3 Client's Finished Handshake (from ref. b)
- public void TestSSLClient ()
+ [Test]
+ public void SSLClient ()
{
byte[] data = { 0x14, 0x00, 0x00, 0x24, 0xf2, 0x40, 0x10, 0x3f, 0x74, 0x63, 0xea, 0xe8, 0x7a, 0x27, 0x23, 0x56, 0x5f, 0x59, 0x07, 0xd2, 0xa3, 0x79, 0x5d, 0xb7, 0x8b, 0x94, 0xdb, 0xcf, 0xfa, 0xf5, 0x18, 0x22, 0x15, 0x7b, 0xf2, 0x4a, 0x96, 0x52, 0x9a, 0x0e, 0xd3, 0x09, 0xde, 0x28, 0x84, 0xa7, 0x07, 0x5c, 0x7c, 0x0c, 0x08, 0x85, 0x6b, 0x4f, 0x63, 0x04 };
ARC4Managed rc4 = new ARC4Managed ();
@@ -183,7 +189,8 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// SSL3 Server Finished Handshake (from ref. b)
- public void TestSSLServer ()
+ [Test]
+ public void SSLServer ()
{
byte[] encryptedData = { 0x54, 0x3c, 0xe1, 0xe7, 0x4d, 0x77, 0x76, 0x62, 0x86, 0xfa, 0x4e, 0x0a, 0x6f, 0x5f, 0x6a, 0x3d, 0x43, 0x26, 0xf4, 0xad, 0x8d, 0x3e, 0x09, 0x0b, 0x2b, 0xf7, 0x9f, 0x49, 0x44, 0x92, 0xfb, 0xa9, 0xa4, 0xb0, 0x5a, 0xd8, 0x72, 0x77, 0x6e, 0x8b, 0xb3, 0x78, 0xfb, 0xda, 0xe0, 0x25, 0xef, 0xb3, 0xf5, 0xa7, 0x90, 0x08, 0x6d, 0x60, 0xd5, 0x4e };
ARC4Managed rc4 = new ARC4Managed ();
@@ -193,5 +200,26 @@ namespace MonoTests.Mono.Security.Cryptography {
byte[] expectedData = { 0x14, 0x00, 0x00, 0x24, 0xb7, 0xcc, 0xd6, 0x05, 0x6b, 0xfc, 0xfa, 0x6d, 0xfa, 0xdd, 0x76, 0x81, 0x45, 0x36, 0xe4, 0xf4, 0x26, 0x35, 0x72, 0x2c, 0xec, 0x87, 0x62, 0x1f, 0x55, 0x08, 0x05, 0x4f, 0xc8, 0xf5, 0x7c, 0x49, 0xe2, 0xee, 0xc5, 0xba, 0xbd, 0x69, 0x27, 0x3b, 0xd0, 0x13, 0x23, 0x52, 0xed, 0xec, 0x11, 0x55, 0xd8, 0xb9, 0x90, 0x8c };
AssertEquals ("RC4 - Server's Finished Handshake", expectedData, encryptedData);
}
+
+ [Test]
+ public void DefaultProperties ()
+ {
+ ARC4Managed rc4 = new ARC4Managed ();
+ Assert ("CanReuseTransform", !rc4.CanReuseTransform);
+ Assert ("CanTransformMultipleBlocks", rc4.CanTransformMultipleBlocks);
+ AssertEquals ("InputBlockSize", 1, rc4.InputBlockSize);
+ AssertEquals ("OutputBlockSize", 1, rc4.OutputBlockSize);
+ }
+
+ [Test]
+ public void DefaultSizes ()
+ {
+ ARC4Managed rc4 = new ARC4Managed ();
+ rc4.GenerateKey ();
+ rc4.GenerateIV ();
+ AssertEquals ("Key.Length", 16, rc4.Key.Length);
+ AssertEquals ("KeySize", 128, rc4.KeySize);
+ AssertEquals ("IV.Length", 0, rc4.IV.Length);
+ }
}
}
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
index cda87ac5e8c..ca6ee681e87 100644
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
@@ -1,3 +1,14 @@
+2004-05-11 Sebastien Pouliot <sebastien@ximian.com>
+
+ * ARC4ManagedTest.cs: Added missing unit tests for complete coverage.
+ Completed convertion to NUnit 2.
+ * CryptoConvertTest.cs: Added/modified unit tests for better coverage.
+ * MD2ManagedTest.cs: Added unit tests for better coverage.
+ * MD2Test.cs: Added unit tests for better coverage.
+ * MD4ManagedTest.cs: Added unit tests for better coverage.
+ * MD4Test.cs: Added unit tests for better coverage.
+ * PKCS8.cs: Added unit tests for better coverage.
+
2004-05-01 Sebastien Pouliot <sebastien@ximian.com>
* CryptoConvertTest.cs: Added test case where a strongname key pair
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs
index eac11613622..f75a5b9e191 100755
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs
@@ -254,7 +254,24 @@ namespace MonoTests.Mono.Security.Cryptography {
}
[Test]
- public void ToCapiKeyBlob ()
+ public void ToCapiKeyBlob_AsymmetricAlgorithm ()
+ {
+ AsymmetricAlgorithm rsa = RSA.Create ();
+ rsa.FromXmlString (strongNameString);
+ byte[] keypair = CryptoConvert.ToCapiKeyBlob (rsa, true);
+ AssertEquals ("RSA-KeyPair", strongName, keypair);
+
+ byte[] publicKey = CryptoConvert.ToCapiKeyBlob (rsa, false);
+ AssertEquals ("RSA-PublicKey", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey));
+
+ // TODO dsa (not implemented yet)
+ AsymmetricAlgorithm dsa = DSA.Create ();
+ AssertNull ("DSA-KeyPair", CryptoConvert.ToCapiKeyBlob (dsa, true));
+ AssertNull ("DSA-PublicKey", CryptoConvert.ToCapiKeyBlob (dsa, false));
+ }
+
+ [Test]
+ public void ToCapiKeyBlob_RSA ()
{
RSA rsa = RSA.Create ();
rsa.FromXmlString (strongNameString);
@@ -317,7 +334,7 @@ namespace MonoTests.Mono.Security.Cryptography {
public void FromHex ()
{
AssertNull ("FromHex(null)", CryptoConvert.FromHex (null));
- string result = BitConverter.ToString (CryptoConvert.FromHex ("0123456789abcdef"));
+ string result = BitConverter.ToString (CryptoConvert.FromHex ("0123456789aBcDeF"));
AssertEquals ("0123456789abcdef", "01-23-45-67-89-AB-CD-EF", result);
}
@@ -342,7 +359,7 @@ namespace MonoTests.Mono.Security.Cryptography {
byte[] data = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef };
AssertEquals ("0123456789abcdef", "0123456789ABCDEF", CryptoConvert.ToHex (data));
}
-
+
[Test]
public void NUnitKey_Broken ()
{
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs
index 4df76f98864..4292350a174 100644
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs
@@ -2,12 +2,14 @@
// MD2ManagedTest.cs - NUnit Test Cases for MD2 (RFC1319)
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot (sebastien@ximian.com)
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004 Novell (http://www.novell.com)
//
using System;
+using System.Security.Cryptography;
using Mono.Security.Cryptography;
using NUnit.Framework;
@@ -24,6 +26,13 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// this will run ALL tests defined in MD2Test.cs with the MD2Managed implementation
-}
-
+
+ [Test]
+ public override void Create ()
+ {
+ // try creating ourselve using Create
+ HashAlgorithm h = MD2.Create ("MD2Managed");
+ Assert ("MD2Managed", (h is MD2Managed));
+ }
+ }
} \ No newline at end of file
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs
index ada9865a1b0..03eab010cee 100644
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs
@@ -2,13 +2,15 @@
// MD2Test.cs - NUnit Test Cases for MD2 (RFC1319)
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot (sebastien@ximian.com)
//
// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004 Novell (http://www.novell.com)
//
using System;
using System.IO;
+using System.Security.Cryptography;
using System.Text;
using Mono.Security.Cryptography;
@@ -216,6 +218,7 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// none of those values changes for any implementation of MD2
+ [Test]
public virtual void StaticInfo ()
{
string className = hash.ToString ();
@@ -223,5 +226,14 @@ namespace MonoTests.Mono.Security.Cryptography {
AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize);
AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize);
}
+
+ [Test]
+ public virtual void Create ()
+ {
+ // create the default implementation
+ HashAlgorithm h = MD2.Create ();
+ Assert ("MD2Managed", (h is MD2Managed));
+ // Note: will fail is default is changed in machine.config
+ }
}
}
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs
index 0eb34b5c841..148af999ec2 100755
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs
@@ -2,12 +2,15 @@
// MD4ManagedTest.cs - NUnit Test Cases for MD4 (RFC1320)
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot (sebastien@ximian.com)
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004 Novell (http://www.novell.com)
//
using System;
+using System.Security.Cryptography;
+
using NUnit.Framework;
using Mono.Security.Cryptography;
@@ -23,5 +26,13 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// this will run ALL tests defined in MD4Test.cs with the MD4Managed implementation
+
+ [Test]
+ public override void Create ()
+ {
+ // try creating ourselve using Create
+ HashAlgorithm h = MD4.Create ("MD4Managed");
+ Assert ("MD4Managed", (h is MD4Managed));
+ }
}
} \ No newline at end of file
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs
index 4db2eb8d660..fe18e10ed52 100755
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs
@@ -2,17 +2,20 @@
// MD4Test.cs - NUnit Test Cases for MD4 (RFC1320)
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot (sebastien@ximian.com)
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004 Novell (http://www.novell.com)
//
-using NUnit.Framework;
using System;
using System.IO;
-using Mono.Security.Cryptography;
+using System.Security.Cryptography;
using System.Text;
+using Mono.Security.Cryptography;
+using NUnit.Framework;
+
namespace MonoTests.Mono.Security.Cryptography {
// References:
@@ -215,6 +218,7 @@ namespace MonoTests.Mono.Security.Cryptography {
}
// none of those values changes for any implementation of MD4
+ [Test]
public virtual void StaticInfo ()
{
string className = hash.ToString ();
@@ -222,5 +226,14 @@ namespace MonoTests.Mono.Security.Cryptography {
TestCase.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize);
TestCase.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize);
}
+
+ [Test]
+ public virtual void Create ()
+ {
+ // create the default implementation
+ HashAlgorithm h = MD4.Create ();
+ Assert ("MD4Managed", (h is MD4Managed));
+ // Note: will fail is default is changed in machine.config
+ }
}
}
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs
index dd204519d67..42f7584e1c9 100755
--- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs
+++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs
@@ -12,6 +12,7 @@ using System.IO;
using System.Security.Cryptography;
using System.Text;
+using Mono.Security;
using Mono.Security.Cryptography;
using NUnit.Framework;
@@ -47,6 +48,14 @@ namespace MonoTests.Mono.Security.Cryptography {
0x0B, 0xCF, 0x0A, 0x0C, 0xCB, 0xAA, 0xE3, 0x36, 0xD3, 0xE3, 0xA1, 0xA9, 0x19, 0x26, 0xD4, 0x12, 0x88, 0xDC, 0x3B, 0xC4, 0x12, 0x27, 0x80, 0x07, 0xFC, 0x4C, 0x3D, 0xBB, 0x3A, 0x3D, 0xBE, 0x84, 0x7D, 0xB9, 0x2F, 0x02, 0x41, 0x00, 0xD3, 0x5F, 0xFE, 0xD4, 0x72, 0x83, 0x71, 0x05, 0x5D, 0x49, 0x27, 0x43, 0x3F, 0x23, 0x3D, 0x36, 0x4D, 0xCF, 0x23, 0x1F, 0x0C, 0xB6, 0x19, 0xE6, 0x25, 0x16, 0xDA, 0x0F, 0x07, 0x84, 0x5B, 0x1E, 0x72, 0xE3, 0x5F, 0x0D, 0x09, 0x48, 0x7C, 0x9D, 0x89, 0x1D, 0xFF, 0xD1, 0x2F, 0x47, 0x3D, 0x64, 0xDD, 0x2E, 0x79, 0x7F, 0x76, 0x87, 0x00, 0xC1, 0x05, 0x7C, 0x21, 0xC3, 0xC8, 0xDB,
0xAC, 0xD1, 0x02, 0x40, 0x0B, 0xCD, 0x46, 0x69, 0x9B, 0x05, 0xF9, 0x7E, 0x8D, 0x90, 0xE3, 0xB2, 0xD5, 0xB1, 0x22, 0x57, 0xD6, 0x42, 0xEA, 0x97, 0x6C, 0xE2, 0x68, 0xBC, 0xB7, 0xB5, 0x42, 0x95, 0x7A, 0x9A, 0xD8, 0x00, 0xA0, 0x00, 0xE8, 0x77, 0xC4, 0x25, 0x80, 0xAD, 0x6C, 0x70, 0x2F, 0xFB, 0x17, 0x9D, 0x3E, 0x65, 0xC9, 0x8F, 0xC9, 0x05, 0xA7, 0x73, 0x20, 0x8E, 0x05, 0x21, 0xCB, 0xC4, 0x15, 0xCF, 0xD7, 0xC1, 0x02, 0x41, 0x00, 0xDE, 0x50, 0xE1, 0x6D, 0xF6, 0x32, 0x35, 0x5C, 0xCA, 0x5F, 0xB1, 0x9D, 0x84, 0x25, 0x17, 0x9E, 0x72, 0xBE, 0x00, 0xCE, 0x59, 0xD5, 0x53, 0xAE, 0xCC, 0x94, 0x89, 0x5C, 0xA1,
0x8A, 0x29, 0x37, 0x2D, 0x47, 0xB6, 0x30, 0xE4, 0x04, 0x65, 0x51, 0xD5, 0xB1, 0x63, 0x85, 0x3B, 0x73, 0xD2, 0xF7, 0xA3, 0x2B, 0x19, 0x8F, 0xB2, 0xBC, 0x08, 0xFB, 0xE3, 0x0F, 0xDC, 0xDD, 0x6B, 0x44, 0x95, 0x84 };
+
+ static public byte[] End_Certificate_CP_01_01_pki = { 0x30, 0x82, 0x02, 0x5E, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xC6, 0x34, 0xEC, 0x6F, 0x0C, 0xE0, 0x59, 0x0E, 0xBC, 0x5F, 0xBA, 0x2E, 0x93, 0xBB, 0x04, 0xA7, 0x03, 0xB9, 0x70, 0x8A, 0xB9, 0xD7, 0xE5, 0xD7, 0xE6, 0xCA, 0x4A, 0x8C, 0x23, 0xD8, 0x60, 0xB3, 0x6B, 0xCB, 0x88, 0x88, 0xC7, 0xD8, 0x48, 0x7E, 0x64, 0xF9, 0xF6, 0x1B, 0xE3, 0x79, 0x46, 0x41, 0xE4, 0x61, 0xF7, 0x25, 0x47, 0x71, 0xF3, 0x50, 0x94, 0x4E, 0xF2, 0x7C, 0x6A, 0x37, 0xB6, 0x0C, 0x46, 0xBF, 0x9C, 0x96, 0xA5, 0xE2, 0xAF, 0x0C, 0xCA, 0x8B, 0xF0, 0x8C, 0xBA, 0x43, 0x4A, 0x08, 0x8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D1, 0x2F, 0x47, 0x3D, 0x64, 0xDD, 0x2E, 0x79, 0x7F, 0x76, 0x87, 0x00, 0xC1, 0x05, 0x7C, 0x21, 0xC3, 0xC8, 0xDB, 0xAC, 0xD1, 0x02, 0x40, 0x0B, 0xCD, 0x46, 0x69, 0x9B, 0x05, 0xF9, 0x7E, 0x8D, 0x90, 0xE3, 0xB2, 0xD5, 0xB1, 0x22, 0x57, 0xD6, 0x42, 0xEA, 0x97, 0x6C, 0xE2, 0x68, 0xBC, 0xB7,
+ 0xB5, 0x42, 0x95, 0x7A, 0x9A, 0xD8, 0x00, 0xA0, 0x00, 0xE8, 0x77, 0xC4, 0x25, 0x80, 0xAD, 0x6C, 0x70, 0x2F, 0xFB, 0x17, 0x9D, 0x3E, 0x65, 0xC9, 0x8F, 0xC9, 0x05, 0xA7, 0x73, 0x20, 0x8E, 0x05, 0x21, 0xCB, 0xC4, 0x15, 0xCF, 0xD7, 0xC1, 0x02, 0x41, 0x00, 0xDE, 0x50, 0xE1, 0x6D, 0xF6, 0x32, 0x35, 0x5C, 0xCA, 0x5F, 0xB1, 0x9D, 0x84, 0x25, 0x17, 0x9E, 0x72, 0xBE, 0x00, 0xCE, 0x59, 0xD5, 0x53, 0xAE, 0xCC, 0x94, 0x89, 0x5C, 0xA1, 0x8A, 0x29, 0x37, 0x2D, 0x47, 0xB6, 0x30, 0xE4, 0x04, 0x65, 0x51, 0xD5, 0xB1, 0x63, 0x85, 0x3B, 0x73, 0xD2, 0xF7, 0xA3, 0x2B, 0x19, 0x8F, 0xB2, 0xBC, 0x08, 0xFB, 0xE3, 0x0F,
+ 0xDC, 0xDD, 0x6B, 0x44, 0x95, 0x84 };
static public byte[] End_Certificate_CP_01_02_crtx = { 0x30, 0x82, 0x02, 0x75, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, 0x02, 0x5F, 0x30, 0x82, 0x02, 0x5B, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xD6, 0x39, 0x9E, 0x21, 0x93, 0xE2, 0xBA, 0x35, 0x7F, 0xE5, 0xF8, 0xE8, 0x87, 0x0B, 0x8A, 0x5F, 0x28, 0x25, 0x85, 0xB7, 0xE5, 0xCC, 0xDA, 0x7F, 0xD3, 0xC7, 0x09, 0x2A, 0x63, 0xE9, 0xAD, 0x8F, 0xD0, 0xA8, 0xEF, 0xBA, 0xCF, 0x3C, 0xFB, 0x55, 0x03, 0xB9, 0x83, 0x29, 0x4E, 0x0E, 0x89, 0x84, 0xFB, 0xE2, 0x62, 0x16, 0x1F, 0x9D, 0x87, 0x40, 0x16, 0x6B, 0xF8, 0xF4, 0x66, 0x38, 0x58, 0x74,
0x67, 0xD4, 0xB5, 0xA1, 0x3A, 0x4B, 0x6F, 0x13, 0x4B, 0x08, 0x37, 0x3A, 0x3A, 0x64, 0x0A, 0x06, 0x8E, 0xA2, 0x7B, 0x14, 0x88, 0xB7, 0xF8, 0xCE, 0x6A, 0xD1, 0x45, 0x9B, 0x39, 0x93, 0x67, 0xBF, 0x0A, 0xAB, 0xDB, 0x37, 0x9D, 0xFA, 0xCE, 0x54, 0x0F, 0x37, 0x82, 0x09, 0x8F, 0x0D, 0x33, 0xE4, 0xB8, 0x6E, 0x46, 0xC1, 0xCC, 0x4F, 0x80, 0x5A, 0xB4, 0xBD, 0x19, 0x80, 0x27, 0x40, 0x84, 0x49, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x81, 0x80, 0x14, 0x95, 0x5A, 0xAD, 0x4D, 0x41, 0x56, 0xB4, 0xF7, 0x42, 0x08, 0x85, 0x87, 0x1C, 0x43, 0xC2, 0x5A, 0xE0, 0x28, 0x16, 0x00, 0x5D, 0x8B, 0x8D, 0x06, 0xB3, 0x34, 0x1D,
@@ -63,7 +72,7 @@ namespace MonoTests.Mono.Security.Cryptography {
PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_01_crtx);
AssertEquals ("Algorithm", "1.2.840.113549.1.1.1", p8.Algorithm);
AssertEquals ("Attributes", 0, p8.Attributes.Count);
- AssertEquals ("PrivateKey", "30-82-02-5E-02-01-00-02-81-81-00-C6-34-EC-6F-0C-E0-59-0E-BC-5F-BA-2E-93-BB-04-A7-03-B9-70-8A-B9-D7-E5-D7-E6-CA-4A-8C-23-D8-60-B3-6B-CB-88-88-C7-D8-48-7E-64-F9-F6-1B-E3-79-46-41-E4-61-F7-25-47-71-F3-50-94-4E-F2-7C-6A-37-B6-0C-46-BF-9C-96-A5-E2-AF-0C-CA-8B-F0-8C-BA-43-4A-08-8E-6A-87-F3-46-4E-CF-6D-5D-52-47-AB-99-C7-24-CD-31-0E-7D-EF-D1-D9-F3-69-24-FB-FC-33-6E-29-AB-6F-52-75-80-2A-BB-E0-A9-2C-31-C5-B7-0B-3D-3B-EA-B5-02-03-01-00-01-02-81-81-00-BC-98-69-0C-75-AD-17-30-6D-4F-8C-E1-7A-D2-2D-E8-19-24-1F-10-F1-2A-9C-59-E6-11-40-03-BE-AB-C9-BF-8F-67-38-40-26-20-07-42-B5-24-1E-E8-84-76-C5-C2-36-E4-7C-7C-AD-51-A0-DA-60-74-0A-49-15-EC-72-BB-E5-E3-E0-3B-F5-51-3B-5D-A4-AD-C6-5D-9F-27-69-EA-97-29-7E-9C-FC-4F-2D-AF-C5-DC-FC-F4-A5-4A-12-18-49-28-5F-7F-58-7A-C6-3E-79-DF-BA-06-AE-6D-CC-B4-71-07-D8-18-FB-1E-6D-8D-72-85-F7-BD-97-A3-85-F5-02-41-00-FE-03-77-1A-1B-13-48-07-E0-D2-EB-84-41-39-06-B1-13-D0-E9-A5-B8-AC-53-33-41-5D-B0-F0-CC-61-59-A7-10-91-CA-60-40-17-75-FB-98-7B-84-4B-C7-2F-1D-15-DE-37-C2-A0-E0-BF-A1-67-56-8B-F5-08-B9-82-99-5B-02-41-00-C7-C1-BB-B1-D0-5E-72-8C-1A-68-CF-95-C7-23-70-B9-B1-5F-43-54-10-84-9A-63-77-AA-FE-98-25-0B-CF-0A-0C-CB-AA-E3-36-D3-E3-A1-A9-19-26-D4-12-88-DC-3B-C4-12-27-80-07-FC-4C-3D-BB-3A-3D-BE-84-7D-B9-2F-02-41-00-D3-5F-FE-D4-72-83-71-05-5D-49-27-43-3F-23-3D-36-4D-CF-23-1F-0C-B6-19-E6-25-16-DA-0F-07-84-5B-1E-72-E3-5F-0D-09-48-7C-9D-89-1D-FF-D1-2F-47-3D-64-DD-2E-79-7F-76-87-00-C1-05-7C-21-C3-C8-DB-AC-D1-02-40-0B-CD-46-69-9B-05-F9-7E-8D-90-E3-B2-D5-B1-22-57-D6-42-EA-97-6C-E2-68-BC-B7-B5-42-95-7A-9A-D8-00-A0-00-E8-77-C4-25-80-AD-6C-70-2F-FB-17-9D-3E-65-C9-8F-C9-05-A7-73-20-8E-05-21-CB-C4-15-CF-D7-C1-02-41-00-DE-50-E1-6D-F6-32-35-5C-CA-5F-B1-9D-84-25-17-9E-72-BE-00-CE-59-D5-53-AE-CC-94-89-5C-A1-8A-29-37-2D-47-B6-30-E4-04-65-51-D5-B1-63-85-3B-73-D2-F7-A3-2B-19-8F-B2-BC-08-FB-E3-0F-DC-DD-6B-44-95-84", BitConverter.ToString (p8.PrivateKey));
+ AssertEquals ("PrivateKey", BitConverter.ToString (End_Certificate_CP_01_01_pki), BitConverter.ToString (p8.PrivateKey));
AssertEquals ("Version", 0, p8.Version);
}
@@ -88,5 +97,77 @@ namespace MonoTests.Mono.Security.Cryptography {
DSAParameters p = new DSAParameters ();
DSA dsa = PKCS8.PrivateKeyInfo.DecodeDSA (p8.PrivateKey, p);
}
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void GetType_Null ()
+ {
+ PKCS8.GetType (null);
+ }
+
+ [Test]
+ public void PrivateKeyInfo ()
+ {
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo ();
+ AssertNull ("Default-Algorithm", p8.Algorithm);
+ AssertEquals ("Default-Attributes", 0, p8.Attributes.Count);
+ AssertNull ("Default-PrivateKey", p8.PrivateKey);
+ AssertEquals ("Default-Version", 0, p8.Version);
+
+ byte[] key = new byte [8];
+ p8.Algorithm = "1.2.3.4.5";
+ p8.Attributes.Add (new ASN1 (0x05)); // NULL
+ p8.PrivateKey = key;
+ p8.Version = 1;
+ AssertEquals ("Algorithm", "1.2.3.4.5", p8.Algorithm);
+ AssertEquals ("Attributes", 1, p8.Attributes.Count);
+ AssertEquals ("PrivateKey", 8, p8.PrivateKey.Length);
+ AssertEquals ("Version", 1, p8.Version);
+
+ key [0] = 1;
+ AssertEquals ("PrivateKey not directly accessible", 0, p8.PrivateKey [0]);
+
+ byte[] p8pki = p8.GetBytes ();
+
+ PKCS8.PrivateKeyInfo decoded = new PKCS8.PrivateKeyInfo (p8pki);
+ AssertEquals ("Decoded-Algorithm", "1.2.3.4.5", decoded.Algorithm);
+ AssertEquals ("Decoded-Attributes", 1, decoded.Attributes.Count);
+ AssertEquals ("Decoded-PrivateKey", 8, decoded.PrivateKey.Length);
+ AssertEquals ("Decoded-Version", 1, decoded.Version);
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void NegativeVersion ()
+ {
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo ();
+ p8.Version = -1;
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void NullPrivateKey ()
+ {
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo ();
+ p8.PrivateKey = null;
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void PrivateKeyInfo_BadData ()
+ {
+ byte[] bad = (byte[]) End_Certificate_CP_01_01_pki.Clone ();
+ bad [0] = 0x31; // SET (no SEQUENCE)
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (bad);
+ }
+
+ [Test]
+ [ExpectedException (typeof (CryptographicException))]
+ public void PrivateKeyInfo_BadVersion ()
+ {
+ byte[] bad = (byte[]) End_Certificate_CP_01_01_pki.Clone ();
+ bad [4] = 0x30; // SEQUENCE (not INTEGER)
+ PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (bad);
+ }
}
}