+2005-04-23 Sebastien Pouliot <sebastien@ximian.com>
+
+ * CmsRecipientTest.cs, CmsSignerTest.cs, EnvelopedCmsTest.cs,
+ Pkcs9AttributeTest.cs, Pkcs9DocumentDescriptionTest.cs,
+ Pkcs9DocumentNameTest.cs, Pkcs9SigningTimeTest.cs, SignedCmsTest.cs:
+ Adapted for class name changes in beta2 and re-activated some tests on
+ Windows that were fixed in beta2.
+
2005-01-17 Sebastien Pouliot <sebastien@ximian.com>
* Pkcs9ContentTypeTest.cs: New. Unit tests for ContentType attribute.
0x0F, 0xCE, 0x10, 0x28, 0x3D, 0x2A, 0x45, 0x64, 0x60, 0xE3, 0xB7, 0xE1, 0x76, 0x90, 0xEC, 0x5B, 0xC6, 0xA1, 0xF0, 0xC4, 0xE8, 0x12, 0xD9, 0xC6, 0x22, 0x80, 0xB5, 0x30, 0xE5, 0x17, 0xAE, 0x05, 0x96, 0xBB, 0x4E, 0xBB, 0x33, 0xBB, 0xB0, 0x63, 0x29, 0x74, 0x11, 0x06, 0x23, 0x36, 0xB4, 0xA1, 0x25, 0xD5, 0x2A, 0xF3, 0x90, 0x38, 0x18, 0x02, 0x62, 0x30, 0x3B, 0x30, 0x1F, 0x30, 0x07, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x04, 0x14, 0xDC, 0x3A, 0xAB, 0x36, 0xD7, 0x3E, 0xF4, 0x6C, 0x52, 0xC9, 0x89, 0x37, 0xFE, 0x71, 0x71, 0x83, 0xC6, 0x09, 0x88, 0xDD, 0x04, 0x14, 0xF5, 0x76, 0xC2, 0xCC, 0xB9, 0xE5,
0xF5, 0x28, 0xA3, 0x2D, 0x55, 0xDC, 0xDE, 0x3B, 0xCF, 0x53, 0xEE, 0x4B, 0x8F, 0x6F, 0x02, 0x02, 0x07, 0xD0 };
- private X509CertificateEx GetCertificate (bool includePrivateKey)
+ private X509Certificate2 GetCertificate (bool includePrivateKey)
{
- return new X509CertificateEx (farscape_p12_pfx, "farscape");
+ return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
[Test]
public void IssuerAndSerialNumber ()
{
- X509CertificateEx x509 = GetCertificate (true);
+ X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType);
AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);
[Test]
public void SubjectKeyIdentifier ()
{
- X509CertificateEx x509 = GetCertificate (true);
+ X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.SubjectKeyIdentifier, p7r.RecipientIdentifierType);
AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);
[Test]
public void Unknown ()
{
- X509CertificateEx x509 = GetCertificate (true);
+ X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
AssertEquals ("RecipientIdentifierType", SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType);
AssertEquals ("Certificate", x509.Thumbprint, p7r.Certificate.Thumbprint);
}
// TODO: return valid x509 certifiate with private key
- private X509CertificateEx GetValidCertificateWithPrivateKey ()
+ private X509Certificate2 GetValidCertificateWithPrivateKey ()
{
- X509CertificateEx x509 = new X509CertificateEx ();
+ X509Certificate2 x509 = new X509Certificate2 ();
return x509;
}
[Test]
public void ConstructorX509CertificateEx ()
{
- X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+ X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
[Test]
public void ConstructorX509CertificateExEmpty ()
{
- X509CertificateEx x509 = new X509CertificateEx (); // empty
+ X509Certificate2 x509 = new X509Certificate2 (); // empty
CmsSigner ps = new CmsSigner (x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void ConstructorX509CertificateExNull ()
{
- X509CertificateEx x509 = null;
+ X509Certificate2 x509 = null;
CmsSigner ps = new CmsSigner (x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
[Test]
public void ConstructorIssuerAndSerialNumberX509CertificateEx ()
{
- X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+ X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
[Test]
public void ConstructorSubjectKeyIdentifierX509CertificateEx ()
{
- X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+ X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
[Test]
public void ConstructorUnknownX509CertificateEx ()
{
- X509CertificateEx x509 = GetValidCertificateWithPrivateKey ();
+ X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.Unknown, x509);
// default properties
AssertEquals ("SignedAttributes", 0, ps.SignedAttributes.Count);
AssertEquals ("Version", version, ep.Version);
}
- private X509CertificateEx GetCertificate (bool includePrivateKey)
+ private X509Certificate2 GetCertificate (bool includePrivateKey)
{
- return new X509CertificateEx (farscape_p12_pfx, "farscape");
+ return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
[Test]
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
- X509CertificateEx x509 = GetCertificate (true);
- X509CertificateExCollection xc = new X509CertificateExCollection ();
+ X509Certificate2 x509 = GetCertificate (true);
+ X509Certificate2Collection xc = new X509Certificate2Collection ();
xc.Add (x509);
ep.Decrypt (xc);
// properties
public void DecryptX509CertificateExCollectionNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
- X509CertificateExCollection xec = null; // do not confuse compiler
+ X509Certificate2Collection xec = null; // do not confuse compiler
ep.Decrypt (xec);
}
public void DecryptRecipientInfoX509CertificateExCollectionNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
- X509CertificateExCollection xec = new X509CertificateExCollection ();
+ X509Certificate2Collection xec = new X509Certificate2Collection ();
ep.Decrypt (null, xec);
}
private void RoundTrip (byte[] encoded)
{
- X509CertificateExCollection xc = new X509CertificateExCollection ();
+ X509Certificate2Collection xc = new X509Certificate2Collection ();
xc.Add (GetCertificate (true));
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
- X509CertificateEx x509 = GetCertificate (false);
+ X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
- X509CertificateEx x509 = GetCertificate (false);
+ X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
- X509CertificateEx x509 = GetCertificate (false);
+ X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
- public class Pkcs9AttributeTest {
+ public class Pkcs9AttributeObjectTest {
static string defaultOid = "1.2.840.113549.1.7.1";
static string defaultName = "PKCS 7 Data";
[Test]
public void ConstructorEmpty ()
{
- Pkcs9Attribute a = new Pkcs9Attribute ();
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
Assert.IsNull (a.Oid, "Oid");
Assert.IsNull (a.RawData, "RawData");
}
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorAsnEncodedDataNull ()
{
- Pkcs9Attribute a = new Pkcs9Attribute (null);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (null);
}
[Test]
public void ConstructorOidArray ()
{
Oid o = new Oid (defaultOid);
- Pkcs9Attribute a = new Pkcs9Attribute (o, new byte [0]);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
Assert.AreEqual (defaultName, a.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (defaultOid, a.Oid.Value, "Oid.Value");
Assert.AreEqual (0, a.RawData.Length, "RawData");
public void ConstructorOidNullArray ()
{
Oid o = null;
- Pkcs9Attribute a = new Pkcs9Attribute (o, new byte [0]);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
}
[Test]
public void ConstructorOidArrayNull ()
{
Oid o = new Oid (defaultOid);
- Pkcs9Attribute a = new Pkcs9Attribute (o, null);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, null);
}
[Test]
public void ConstructorStringArray ()
{
- Pkcs9Attribute a = new Pkcs9Attribute (defaultOid, new byte [0]);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (defaultOid, new byte[0]);
Assert.AreEqual (defaultName, a.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (defaultOid, a.Oid.Value, "Oid.Value");
Assert.AreEqual (0, a.RawData.Length, "RawData");
public void ConstructorStringNullArray ()
{
string s = null;
- Pkcs9Attribute a = new Pkcs9Attribute (s, new byte [0]);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (s, new byte[0]);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorStringArrayNull ()
{
- Pkcs9Attribute a = new Pkcs9Attribute (defaultOid, null);
+ Pkcs9AttributeObject a = new Pkcs9AttributeObject (defaultOid, null);
}
}
}
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
}
[Test]
- [ExpectedException (typeof (NullReferenceException))]
- // MSBUG [ExpectedException (typeof (ArgumentNullException))]
- // reported as
+ [ExpectedException (typeof (ArgumentNullException))]
public void Constructor_StringNull ()
{
string desc = null;
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
}
[Test]
- [ExpectedException (typeof (NullReferenceException))]
- // MSBUG [ExpectedException (typeof (ArgumentNullException))]
- // reported as
+ [ExpectedException (typeof (ArgumentNullException))]
public void Constructor_StringNull ()
{
string name = null;
}
[Test]
- [Ignore ("MS returns bad results (original time) - Mono needs to override CopyFrom to fix")]
+// [Ignore ("MS returns bad results (original time) - Mono needs to override CopyFrom to fix")]
// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=66943396-ad73-497f-82ae-090b87ffcb4e
public void CopyFrom ()
{
}
[Test]
- [Ignore ("MS doesn't throw but returns bad results - Mono needs to override CopyFrom to fix")]
+// [Ignore ("MS doesn't throw but returns bad results - Mono needs to override CopyFrom to fix")]
// http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=66943396-ad73-497f-82ae-090b87ffcb4e
[ExpectedException (typeof (CryptographicException))]
public void CopyFrom_Bad ()
AssertEquals ("Version", version, sp.Version);
}
- private X509CertificateEx GetCertificate (bool includePrivateKey)
+ private X509Certificate2 GetCertificate (bool includePrivateKey)
{
- return new X509CertificateEx (farscape_p12_pfx, "farscape");
+ return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
- private void AddChain (X509CertificateExCollection coll)
+ private void AddChain (X509Certificate2Collection coll)
{
- coll.Add (new X509CertificateEx (intca_cer));
- coll.Add (new X509CertificateEx (root_cer));
+ coll.Add (new X509Certificate2 (intca_cer));
+ coll.Add (new X509Certificate2 (root_cer));
}
[Test]
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, GetCertificate (true));
- signer.Certificates.Add (new X509CertificateEx (intca_cer));
- signer.Certificates.Add (new X509CertificateEx (root_cer));
+ signer.Certificates.Add (new X509Certificate2 (intca_cer));
+ signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, GetCertificate (true));
- signer.Certificates.Add (new X509CertificateEx (intca_cer));
- signer.Certificates.Add (new X509CertificateEx (root_cer));
+ signer.Certificates.Add (new X509Certificate2 (intca_cer));
+ signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.Unknown, GetCertificate (true));
- signer.Certificates.Add (new X509CertificateEx (intca_cer));
- signer.Certificates.Add (new X509CertificateEx (root_cer));
+ signer.Certificates.Add (new X509Certificate2 (intca_cer));
+ signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();