Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,142 @@
//
// AlgorithmIdentifierTest.cs - NUnit tests for AlgorithmIdentifier
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class AlgorithmIdentifierTest {
static string defaultOid = "1.2.840.113549.3.7";
static string defaultName = "3des";
static string validOid = "1.2.840.113549.1.1.1";
[Test]
public void ConstructorEmpty ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
Assert.AreEqual (0, ai.KeyLength, "KeyLength");
Assert.AreEqual (defaultName, ai.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (defaultOid, ai.Oid.Value, "Oid.Value");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
public void ConstructorOid ()
{
Oid o = new Oid (validOid);
AlgorithmIdentifier ai = new AlgorithmIdentifier (o);
Assert.AreEqual (0, ai.KeyLength, "KeyLength");
Assert.AreEqual (validOid, ai.Oid.Value, "Oid");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidNull ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier (null);
Assert.IsNull (ai.Oid, "Oid");
Assert.AreEqual (0, ai.KeyLength, "KeyLength");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
public void ConstructorOidKeyLength ()
{
Oid o = new Oid (validOid);
AlgorithmIdentifier ai = new AlgorithmIdentifier (o, 128);
Assert.AreEqual (128, ai.KeyLength, "KeyLength");
Assert.AreEqual (validOid, ai.Oid.Value, "Oid");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidNullKeyLength ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier (null, 128);
Assert.IsNull (ai.Oid, "Oid");
Assert.AreEqual (128, ai.KeyLength, "KeyLength");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
//BUG [ExpectedException (typeof (ArgumentOutOfRangeException))]
public void ConstructorOidKeyLengthNegative ()
{
Oid o = new Oid (validOid);
AlgorithmIdentifier ai = new AlgorithmIdentifier (o, -1);
Assert.AreEqual (-1, ai.KeyLength, "KeyLength");
Assert.AreEqual (validOid, ai.Oid.Value, "Oid");
Assert.AreEqual (0, ai.Parameters.Length, "Parameters");
}
[Test]
public void KeyLength ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ai.KeyLength = Int32.MaxValue;
Assert.AreEqual (Int32.MaxValue, ai.KeyLength, "KeyLength-Max");
ai.KeyLength = 0;
Assert.AreEqual (0, ai.KeyLength, "KeyLength-Zero");
ai.KeyLength = Int32.MinValue;
Assert.AreEqual (Int32.MinValue, ai.KeyLength, "KeyLength-Min");
}
[Test]
public void Oid ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ai.Oid = new Oid (validOid);
Assert.AreEqual (validOid, ai.Oid.Value, "Oid");
ai.Oid = null;
Assert.IsNull (ai.Oid, "Oid-Null");
}
[Test]
public void Parameters ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ai.Parameters = new byte[2] { 0x05, 0x00 }; // ASN.1 NULL
Assert.AreEqual ("05-00", BitConverter.ToString (ai.Parameters), "Parameters");
ai.Parameters = null;
Assert.IsNull (ai.Parameters, "Parameters-Null");
}
}
}
#endif

View File

@@ -0,0 +1,108 @@
2009-06-26 Robert Jordan <robertj@gmx.net>
* *.cs: Upgrade to new NUnit style.
2008-11-01 Sebastien Pouliot <sebastien@ximian.com>
* CmsRecipientCollectionTest.cs: Verify NRE behavior of ctor.
2006-12-15 Sebastien Pouliot <sebastien@ximian.com>
* PkitsTest.cs: New. Common test code to use the PKITS test data.
* Pkits_4_01_SignatureVerification.cs: New. Test signature on S/MIME
using the PKITS test data (if available).
2005-09-27 Sebastien Pouliot <sebastien@ximian.com>
* Pkcs9AttributeTest.cs: Added new tests case for new overriden
CopyFrom (added in 2.0 RC).
* Pkcs9ContentTypeTest.cs: Fixed tests case for 2.0 RC.
* Pkcs9MessageDigestTest.cs: Fixed tests case for 2.0 RC.
2005-05-03 Sebastien Pouliot <sebastien@ximian.com>
* ContentInfoTest.cs: Addd test cases for data, envelopedData and
other "bad" cases.
* EnvelopedCmsTest.cs: Added [Category ("NotWorking")] to tests for
which Mono isn't complete enough to execute.
* KeyTransRecipientInfoTest.cs: Added test for EncryptedKey (reference
not copy).
* Pkcs9ContentTypeTest.cs: Removed FIXME (fixed in beta2). Added
CopyFrom tests.
* Pkcs9DocumentDescriptionTest.cs: Removed FIXME (fixed in beta2).
* Pkcs9MessageDigestTest.cs: Added CopyFrom tests.
* SignerInfoCollectionTest.cs: New. Tests for SignerInfoCollection.
* SignerInfoTest.cs: Mark some method/data internal so they can be
reused for other tests.
2005-04-26 Sebastien Pouliot <sebastien@ximian.com>
* AlgorithmIdentifierTest.cs: Complete some test cases. Updated to
NUnit 2.2 API.
* SignedCmsTest.cs: Added [Ignore] to 3 tests that now also fails
on beta2.
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.
* Pkcs9DocumentDescriptionTest.cs: Added tests for Format(bool).
* Pkcs9DocumentNameTest.cs: Added tests for Format(bool).
* Pkcs9MessageDigestTest.cs: New. Unit tests for MessageDigest attr.
* Pkcs9SigningTimeTest.cs: Added tests for Format(bool) and tests to
check valid dates - limited to [1950,2049].
2004-07-09 Sebastien Pouliot <sebastien@ximian.com>
* AlgorithmIdentifierTest.cs: Fixed for Fx 2.0 beta1.
* CmsRecipientTest.cs: Replace Pkcs7RecipientTest.cs in Fx 2.0 beta1.
* CmsSignerTest.cs: Replace Pkcs7SignerTest.cs in Fx 2.0 beta1.
* ContentInfoTest.cs: Fixed for Fx 2.0 beta1.
* EnvelopedCmsTest.cs: Replace EnvelopedPkcs7Test.cs in Fx 2.0 beta1.
* KeyTransRecipientInfoTest.cs: Fixed for Fx 2.0 beta1.
* Pkcs9AttributeTest.cs: Fixed for Fx 2.0 beta1.
* Pkcs9DocumentDescriptionTest.cs: Fixed for Fx 2.0 beta1.
* Pkcs9DocumentNameTest.cs: Fixed for Fx 2.0 beta1.
* Pkcs9SigningTimeTest.cs: Fixed for Fx 2.0 beta1.
* SignedCmsTest.cs: Replace SignedPkcs7Test.cs in Fx 2.0 beta1.
* SignerInfoTest.cs: Fixed for Fx 2.0 beta1.
* SubjectIdentifierTest.cs: Fixed for Fx 2.0 beta1.
2004-07-07 Sebastien Pouliot <sebastien@ximian.com>
* ContentInfoTest.cs: Adjusted for changes in Mono.Security.
2003-12-07 Sebastien Pouliot <spouliot@videotron.ca>
* ContentInfoTest.cs: Changed test for GetContentType.
* EnvelopedPkcs7Test.cs: New. Unit tests for EnvelopedPkcs7
(encryption).
* KeyTransRecipientInfoTest.cs: New. Unit tests for
KeyTransRecipientInfo.
* Pkcs7RecipientTest.cs: New. Unit tests for Pkcs7Recipient.
* SignedPkcs7Test.cs: New. Unit tests for SignedPkcs7 (signatures).
* SignedInfoTest.cs: New. Unit tests for SignedInfo.
* SubjectIdentifierTest.cs: New. Unit tests for SubjectIdentifier.
2003-11-08 Sebastien Pouliot <spouliot@videotron.ca>
* ContentInfoTest.cs: New. (Incomplete) Unit tests for ContentInfo.
* Pkcs7SignerTest.cs: New. New. Unit tests for Pkcs7Signer.
* RecipientInfoTest.cs: New. Unit tests for abstract class RecipientInfo.
2003-11-07 Sebastien Pouliot <spouliot@videotron.ca>
* AlgorithmIdentifierTest.cs: New. Unit tests for AlgorithmIdentifier.
* CryptographicAttributeTest.cs: New. Unit tests for CryptographicAttribute.
* Pkcs9AttributeTest.cs: New. Unit tests for Pkcs9Attribute (same as for
CryptographicAttribute).
* Pkcs9DocumentDescriptionTest.cs: New. Unit tests for Pkcs9DocumentDescription.
* Pkcs9DocumentNameTest.cs: New. Unit tests for Pkcs9DocumentName.
* Pkcs9SigningTimeTest.cs: New. Unit tests for Pkcs9SigningTime.

View File

@@ -0,0 +1,50 @@
//
// Unit tests for CmsRecipientCollection
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2008 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class CmsRecipientCollectionTest {
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void Ctor_SubjectIdentifierType_X509Certificate2CollectionNull ()
{
new CmsRecipientCollection (SubjectIdentifierType.NoSignature, null);
}
}
}
#endif

View File

@@ -0,0 +1,108 @@
//
// CmsRecipientTest.cs - NUnit tests for CmsRecipient
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class CmsRecipientTest {
static public byte [] farscape_p12_pfx = {
0x30, 0x82, 0x07, 0x17, 0x02, 0x01, 0x03, 0x30, 0x82, 0x06, 0xD3, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x06, 0xC4, 0x04, 0x82, 0x06, 0xC0, 0x30, 0x82, 0x06, 0xBC, 0x30, 0x82, 0x03, 0xCD, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x03, 0xBE, 0x04, 0x82, 0x03, 0xBA, 0x30, 0x82, 0x03, 0xB6, 0x30, 0x82, 0x03, 0xB2, 0x06, 0x0B, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x02, 0xA0, 0x82, 0x02, 0xB6, 0x30, 0x82, 0x02, 0xB2, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7,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x09, 0x14, 0x31, 0x4A, 0x1E, 0x48, 0x00, 0x64, 0x00, 0x64, 0x00, 0x62, 0x00, 0x30, 0x00, 0x65, 0x00, 0x64, 0x00, 0x31, 0x00, 0x64, 0x00, 0x2D, 0x00, 0x32, 0x00, 0x36, 0x00, 0x30, 0x00, 0x34, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x32, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x31, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x39, 0x00, 0x35, 0x00, 0x61, 0x00, 0x37, 0x00, 0x64, 0x00, 0x65, 0x00, 0x65, 0x00, 0x37, 0x00, 0x61, 0x00,
0x64, 0x00, 0x30, 0x30, 0x69, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01, 0x31, 0x5C, 0x1E, 0x5A, 0x00, 0x4D, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41, 0x00, 0x20, 0x00, 0x53, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79, 0x00, 0x70, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F,
0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x30, 0x82, 0x02, 0xE7, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA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x30, 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 X509Certificate2 GetCertificate (bool includePrivateKey)
{
return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
[Test]
public void IssuerAndSerialNumber ()
{
X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType, "RecipientIdentifierType");
Assert.AreEqual (x509.Thumbprint, p7r.Certificate.Thumbprint, "Certificate");
}
[Test]
public void SubjectKeyIdentifier ()
{
X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, p7r.RecipientIdentifierType, "RecipientIdentifierType");
Assert.AreEqual (x509.Thumbprint, p7r.Certificate.Thumbprint, "Certificate");
}
[Test]
public void Unknown ()
{
X509Certificate2 x509 = GetCertificate (true);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, p7r.RecipientIdentifierType, "RecipientIdentifierType");
Assert.AreEqual (x509.Thumbprint, p7r.Certificate.Thumbprint, "Certificate");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void NullCertificate ()
{
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, null);
}
}
}
#endif

View File

@@ -0,0 +1,296 @@
//
// CmsSignerTest.cs - NUnit tests for CmsSigner
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class CmsSignerTest {
static byte[] asnNull = { 0x05, 0x00 };
static string sha1Oid = "1.3.14.3.2.26";
static string sha1Name = "sha1";
static string rsaOid = "1.2.840.113549.1.1.1";
static string rsaName = "RSA";
[Test]
public void ConstructorEmpty ()
{
CmsSigner ps = new CmsSigner ();
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorIssuerAndSerialNumber ()
{
CmsSigner ps = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorSubjectKeyIdentifier ()
{
CmsSigner ps = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorUnknown ()
{
CmsSigner ps = new CmsSigner (SubjectIdentifierType.Unknown);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
// Unknown is converted to IssuerAndSerialNumber
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
// TODO: return valid x509 certifiate with private key
private X509Certificate2 GetValidCertificateWithPrivateKey ()
{
X509Certificate2 x509 = new X509Certificate2 ();
return x509;
}
[Test]
public void ConstructorX509CertificateEx ()
{
X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorX509CertificateExEmpty ()
{
X509Certificate2 x509 = new X509Certificate2 (); // empty
CmsSigner ps = new CmsSigner (x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void ConstructorX509CertificateExNull ()
{
X509Certificate2 x509 = null;
CmsSigner ps = new CmsSigner (x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorIssuerAndSerialNumberX509CertificateEx ()
{
X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorSubjectKeyIdentifierX509CertificateEx ()
{
X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void ConstructorUnknownX509CertificateEx ()
{
X509Certificate2 x509 = GetValidCertificateWithPrivateKey ();
CmsSigner ps = new CmsSigner (SubjectIdentifierType.Unknown, x509);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
// Unknown is converted to IssuerAndSerialNumber
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
//BUG [ExpectedException (typeof (ArgumentNullException))]
public void ConstructorIssuerAndSerialNumberX509CertificateExNull ()
{
CmsSigner ps = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, null);
// default properties
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes");
Assert.IsNull (ps.Certificate, "Certificate");
Assert.AreEqual (sha1Name, ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "IncludeOption");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "SignerIdentifierType");
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes");
}
[Test]
public void SignedAttributes ()
{
CmsSigner ps = new CmsSigner ();
Assert.AreEqual (0, ps.SignedAttributes.Count, "SignedAttributes=0");
ps.SignedAttributes.Add (new Pkcs9DocumentDescription ("mono"));
Assert.AreEqual (1, ps.SignedAttributes.Count, "SignedAttributes=1");
}
[Test]
public void Certificate ()
{
CmsSigner ps = new CmsSigner ();
Assert.IsNull (ps.Certificate, "Certificate=default(null)");
ps.Certificate = GetValidCertificateWithPrivateKey ();
Assert.IsNotNull (ps.Certificate, "Certificate!=null");
ps.Certificate = null;
Assert.IsNull (ps.Certificate, "Certificate=null");
}
[Test]
public void Digest ()
{
CmsSigner ps = new CmsSigner ();
ps.DigestAlgorithm = new Oid ("1.2.840.113549.2.5");
Assert.AreEqual ("md5", ps.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual ("1.2.840.113549.2.5", ps.DigestAlgorithm.Value, "DigestAlgorithm.Value");
ps.DigestAlgorithm = null;
Assert.IsNull (ps.DigestAlgorithm, "DigestAlgorithm=null");
}
[Test]
public void IncludeOption ()
{
CmsSigner ps = new CmsSigner ();
ps.IncludeOption = X509IncludeOption.EndCertOnly;
Assert.AreEqual (X509IncludeOption.EndCertOnly, ps.IncludeOption, "EndCertOnly");
ps.IncludeOption = X509IncludeOption.ExcludeRoot;
Assert.AreEqual (X509IncludeOption.ExcludeRoot, ps.IncludeOption, "ExcludeRoot");
ps.IncludeOption = X509IncludeOption.None;
Assert.AreEqual (X509IncludeOption.None, ps.IncludeOption, "None");
ps.IncludeOption = X509IncludeOption.WholeChain;
Assert.AreEqual (X509IncludeOption.WholeChain, ps.IncludeOption, "WholeChain");
}
[Test]
public void SubjectIdentifierTypeProperty ()
{
CmsSigner ps = new CmsSigner ();
ps.SignerIdentifierType = SubjectIdentifierType.IssuerAndSerialNumber;
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ps.SignerIdentifierType, "IssuerAndSerialNumber");
ps.SignerIdentifierType = SubjectIdentifierType.SubjectKeyIdentifier;
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, ps.SignerIdentifierType, "SubjectKeyIdentifier");
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void SubjectIdentifierTypeUnknown ()
{
CmsSigner ps = new CmsSigner ();
ps.SignerIdentifierType = SubjectIdentifierType.Unknown;
}
[Test]
public void UnauthenticatedAttributes ()
{
CmsSigner ps = new CmsSigner ();
Assert.AreEqual (0, ps.UnsignedAttributes.Count, "UnsignedAttributes=0");
ps.UnsignedAttributes.Add (new Pkcs9DocumentDescription ("mono"));
Assert.AreEqual (1, ps.UnsignedAttributes.Count, "UnsignedAttributes=1");
}
}
}
#endif

View File

@@ -0,0 +1,241 @@
//
// ContentInfoTest.cs - NUnit tests for ContentInfo
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class ContentInfoTest {
static string defaultOid = "1.2.840.113549.1.7.1";
static string defaultName = "PKCS 7 Data";
static byte[] asnNull = { 0x05, 0x00 };
[Test]
public void ConstructorContent ()
{
ContentInfo ci = new ContentInfo (asnNull);
Assert.AreEqual (asnNull, ci.Content, "Content");
Assert.AreEqual (defaultName, ci.ContentType.FriendlyName, "ContentType.FriendlyName");
Assert.AreEqual (defaultOid, ci.ContentType.Value, "ContentType.Value");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidNull ()
{
ContentInfo ci = new ContentInfo (null);
}
[Test]
public void ConstructorOidContent ()
{
Oid o = new Oid (defaultOid);
ContentInfo ci = new ContentInfo (o, asnNull);
Assert.AreEqual (asnNull, ci.Content, "Content");
Assert.AreEqual (defaultName, ci.ContentType.FriendlyName, "ContentType.FriendlyName");
Assert.AreEqual (defaultOid, ci.ContentType.Value, "ContentType.Value");
}
[Test]
public void ConstructorNonPkcs7Oid ()
{
Oid o = new Oid ("1.2.3.4");
ContentInfo ci = new ContentInfo (o, asnNull);
Assert.AreEqual (asnNull, ci.Content, "Content");
Assert.AreEqual ("1.2.3.4", ci.ContentType.Value, "ContentType.Value");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidNullContent ()
{
ContentInfo ci = new ContentInfo (null, asnNull);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidContentNull ()
{
Oid o = new Oid (defaultOid);
ContentInfo ci = new ContentInfo (o, null);
}
[Test]
public void Oid_ModifyContent ()
{
ContentInfo ci = new ContentInfo (asnNull);
Assert.AreEqual (asnNull, ci.Content, "Content-Before");
ci.Content[0] = 0x04;
Assert.AreEqual (asnNull, ci.Content, "Content-After");
// this means we get a copy (not a reference)
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void GetContentType_invalid ()
{
byte[] invalid = { 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x00, 0xA0, 0x0D, 0x04, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x4D, 0x6F, 0x6E, 0x6F, 0x21 };
Oid o = ContentInfo.GetContentType (invalid);
Assert.AreEqual ("1.2.840.113549.1.7.0", o.Value, "GetContentType");
}
[Test]
public void GetContentType_data ()
{
// ASN1 a0 = new ASN1 (0xA0);
// a0.Add (new ASN1 (0x04, Encoding.ASCII.GetBytes ("Hello Mono!")));
// ASN1 contentInfo = new ASN1 (0x30);
// contentInfo.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.1"));
// contentInfo.Add (a0);
// byte[] data = contentInfo.GetBytes ();
byte[] data = { 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x0D, 0x04, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x4D, 0x6F, 0x6E, 0x6F, 0x21 };
Oid o = ContentInfo.GetContentType (data);
Assert.AreEqual ("1.2.840.113549.1.7.1", o.Value, "GetContentType");
}
[Test]
public void GetContentType_signedData ()
{
byte[] signedData = { 0x30, 0x82, 0x03, 0x4C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x3D, 0x30, 0x82, 0x03, 0x39, 0x02, 0x01, 0x01, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x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 0xE8, 0xC9, 0x49, 0xE0, 0xC6, 0xEA, 0x02, 0x76, 0x01, 0xE0, 0xBB, 0x8A, 0x70, 0xEB, 0x07, 0x86, 0xE8, 0x04, 0xE7, 0x48, 0xE4, 0x6C, 0x90, 0xE6, 0x16, 0x42, 0xB4, 0xBB, 0xC0, 0xC4, 0x82, 0x5F, 0xF8, 0xFB, 0x7E, 0xB2, 0x9E, 0xC2, 0x78, 0x26, 0x86, 0x31, 0x81, 0xE1, 0x30, 0x81, 0xDE, 0x02, 0x01, 0x01, 0x30, 0x3C, 0x30, 0x28,
0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94,
0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC, 0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
Oid o = ContentInfo.GetContentType (signedData);
Assert.AreEqual ("1.2.840.113549.1.7.2", o.Value, "GetContentType");
}
[Test]
public void GetContentType_envelopedData ()
{
byte[] envelopedData = { 0x30, 0x82, 0x01, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x03, 0xA0, 0x82, 0x01, 0x0D, 0x30, 0x82, 0x01, 0x09, 0x02, 0x01, 0x00, 0x31, 0x81, 0xD6, 0x30, 0x81, 0xD3, 0x02, 0x01, 0x00, 0x30, 0x3C, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42,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 0x05, 0x72, 0x80, 0x08, 0x2C, 0xAF, 0x82, 0x91, 0xEC, 0xAD, 0xC5, 0xB5 };
Oid o = ContentInfo.GetContentType (envelopedData);
Assert.AreEqual ("1.2.840.113549.1.7.3", o.Value, "GetContentType");
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void GetContentType_signedAndEnvelopedData ()
{
// Note: signedAndEnvelopedData isn't defined in RFC2630
byte[] signedAndEnvelopedData = { 0x30, 0x82, 0x01, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x04, 0xA0, 0x82, 0x01, 0x0D, 0x30, 0x82, 0x01, 0x09, 0x02, 0x01, 0x00, 0x31, 0x81, 0xD6, 0x30, 0x81, 0xD3, 0x02, 0x01, 0x00, 0x30, 0x3C, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0xCA, 0x4B, 0x97, 0x9C, 0xAB, 0x79, 0xC6, 0xDF, 0x6A, 0x27, 0xC7, 0x24, 0xC4, 0x5E, 0x3B, 0x31, 0xAD, 0xBC, 0x25, 0xE6, 0x38, 0x5E, 0x79, 0x26, 0x0E, 0x68, 0x46, 0x1D, 0x21, 0x81, 0x38, 0x92, 0xEC, 0xCB, 0x7C, 0x91, 0xD6, 0x09, 0x38, 0x91, 0xCE, 0x50, 0x5B, 0x70, 0x31, 0xB0, 0x9F, 0xFC, 0xE2, 0xEE, 0x45, 0xBC, 0x4B, 0xF8, 0x9A, 0xD9, 0xEE, 0xE7, 0x4A, 0x3D, 0xCD, 0x8D, 0xFF, 0x10, 0xAB, 0xC8, 0x19, 0x05, 0x54, 0x5E, 0x40, 0x7A, 0xBE, 0x2B, 0xD7, 0x22, 0x97, 0xF3, 0x23, 0xAF, 0x50, 0xF5, 0xEB, 0x43, 0x06, 0xC3, 0xFB, 0x17, 0xCA, 0xBD, 0xAD, 0x28, 0xD8, 0x10, 0x0F, 0x61, 0xCE, 0xF8, 0x25, 0x70, 0xF6, 0xC8, 0x1E, 0x7F, 0x82, 0xE5, 0x94, 0xEB, 0x11, 0xBF, 0xB8, 0x6F, 0xEE, 0x79, 0xCD, 0x63, 0xDD, 0x59, 0x8D, 0x25, 0x0E, 0x78, 0x55, 0xCE, 0x21, 0xBA, 0x13, 0x6B, 0x30, 0x2B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x14, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x03, 0x07, 0x04, 0x08, 0x8C, 0x5D, 0xC9, 0x87, 0x88, 0x9C, 0x05, 0x72, 0x80, 0x08, 0x2C, 0xAF, 0x82, 0x91, 0xEC, 0xAD, 0xC5, 0xB5 };
Oid o = ContentInfo.GetContentType (signedAndEnvelopedData);
Assert.AreEqual ("1.2.840.113549.1.7.4", o.Value, "GetContentType");
}
[Test]
[Ignore ("need a working sample")]
public void GetContentType_digestedData ()
{
/*ASN1 eci = new ASN1 (0x30);
eci.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.1"));
eci.Add (new ASN1 (0x05));
ASN1 dData = new ASN1 (0x30);
dData.Add (new ASN1 (0x02, new byte[1] { 2 }));
dData.Add (PKCS7.AlgorithmIdentifier (CryptoConfig.MapNameToOID ("SHA1")));
ASN1 a0 = new ASN1 (0xA0);
a0.Add (dData);
ASN1 contentInfo = new ASN1 (0x30);
contentInfo.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.5"));
contentInfo.Add (a0);
byte[] digestedData = contentInfo.GetBytes ();*/
byte[] digestedData = null;
Oid o = ContentInfo.GetContentType (digestedData);
Assert.AreEqual ("1.2.840.113549.1.7.5", o.Value, "GetContentType");
}
[Test]
[Ignore ("need a working sample")]
public void GetContentType_encryptedData ()
{
/* ASN1 eci = new ASN1 (0x30);
eci.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.1"));
eci.Add (PKCS7.AlgorithmIdentifier ("1.2.840.113549.1.1.1"));
ASN1 eData = new ASN1 (0x30);
eData.Add (new ASN1 (0x02, new byte[1] { 2 }));
eData.Add (eci);
ASN1 a0 = new ASN1 (0xA0);
a0.Add (eci);
ASN1 contentInfo = new ASN1 (0x30);
contentInfo.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.6"));
contentInfo.Add (a0);
byte[] encryptedData = contentInfo.GetBytes (); */
byte[] encryptedData = null;
Oid o = ContentInfo.GetContentType (encryptedData);
Assert.AreEqual ("1.2.840.113549.1.7.6", o.Value, "GetContentType");
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void GetContentType_unknown ()
{
byte[] unknown = { 0x30, 0x1A, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x07, 0xA0, 0x0D, 0x04, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x4D, 0x6F, 0x6E, 0x6F, 0x21 };
Oid o = ContentInfo.GetContentType (unknown);
Assert.AreEqual ("1.2.840.113549.1.7.7", o.Value, "GetContentType");
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void GetContentTypeBadASN1 ()
{
// ContentInfo ::= SEQUENCE {
// contentType ContentType, -> ContentType ::= OBJECT IDENTIFIER
// content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
// Generated using Mono.Security.dll and the following code
byte [] badasn = new byte [] { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x05, 0x00 };
// ASN1 contentInfo = new ASN1 (0x30);
// contentInfo.Add (ASN1Convert.FromOid (defaultOid));
// contentInfo.Add (new ASN1 (asnNull));
Oid o = ContentInfo.GetContentType (badasn);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void GetContentTypeNull ()
{
Oid o = ContentInfo.GetContentType (null);
}
}
}
#endif

View File

@@ -0,0 +1,396 @@
//
// EnvelopedCmsTest.cs - NUnit tests for EnvelopedCms
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class EnvelopedCmsTest {
static byte[] asnNull = { 0x05, 0x00 };
static string tdesOid = "1.2.840.113549.3.7";
static string tdesName = "3des";
static string p7DataOid = "1.2.840.113549.1.7.1";
static string p7DataName = "PKCS 7 Data";
static public byte [] farscape_p12_pfx = {
0x30, 0x82, 0x07, 0x17, 0x02, 0x01, 0x03, 0x30, 0x82, 0x06, 0xD3, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x06, 0xC4, 0x04, 0x82, 0x06, 0xC0, 0x30, 0x82, 0x06, 0xBC, 0x30, 0x82, 0x03, 0xCD, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x03, 0xBE, 0x04, 0x82, 0x03, 0xBA, 0x30, 0x82, 0x03, 0xB6, 0x30, 0x82, 0x03, 0xB2, 0x06, 0x0B, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x02, 0xA0, 0x82, 0x02, 0xB6, 0x30, 0x82, 0x02, 0xB2, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30,
0x0E, 0x04, 0x08, 0x86, 0x2A, 0xA9, 0x71, 0x6D, 0xA4, 0xB8, 0x2D, 0x02, 0x02, 0x07, 0xD0, 0x04, 0x82, 0x02, 0x90, 0x90, 0x14, 0xB5, 0xF0, 0xB6, 0x86, 0x56, 0xCB, 0xFA, 0x63, 0xAD, 0x9F, 0x5A, 0x59, 0x6C, 0xAD, 0x00, 0x3C, 0x37, 0x8A, 0xC3, 0x88, 0x58, 0x8B, 0xD7, 0x48, 0x53, 0x7A, 0xC8, 0x5B, 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0x96, 0x43, 0xD8, 0x86, 0x82, 0xBE,
0x37, 0xFF, 0x9B, 0xEB, 0xB7, 0x18, 0xA1, 0x2F, 0xE3, 0x6C, 0x08, 0xE8, 0x11, 0x96, 0x8C, 0x5E, 0x9E, 0x2B, 0xE7, 0xDB, 0x7D, 0x54, 0xE1, 0xDB, 0x1E, 0xD3, 0x8F, 0xB5, 0x19, 0x4B, 0xB2, 0x16, 0xDB, 0xCF, 0xEC, 0x88, 0x0B, 0x6C, 0x3C, 0xE4, 0xF2, 0xC4, 0xFF, 0x4D, 0x3E, 0x53, 0x52, 0x3A, 0x81, 0x0B, 0x6E, 0xAC, 0x95, 0xEA, 0x5A, 0x6E, 0x4D, 0x83, 0x23, 0x82, 0xC9, 0x90, 0x02, 0x74, 0x10, 0x2A, 0x6C, 0xFB, 0x97, 0x4F, 0x5F, 0x70, 0x8E, 0xF0, 0xB9, 0x31, 0x81, 0xE8, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x02, 0x31, 0x00, 0x30, 0x13, 0x06, 0x09, 0x2A, 0x86, 0x48,
0x86, 0xF7, 0x0D, 0x01, 0x09, 0x15, 0x31, 0x06, 0x04, 0x04, 0x01, 0x00, 0x00, 0x00, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x14, 0x31, 0x4A, 0x1E, 0x48, 0x00, 0x64, 0x00, 0x64, 0x00, 0x62, 0x00, 0x30, 0x00, 0x65, 0x00, 0x64, 0x00, 0x31, 0x00, 0x64, 0x00, 0x2D, 0x00, 0x32, 0x00, 0x36, 0x00, 0x30, 0x00, 0x34, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x32, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x31, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x39, 0x00, 0x35, 0x00, 0x61, 0x00, 0x37, 0x00, 0x64, 0x00, 0x65, 0x00, 0x65, 0x00, 0x37, 0x00, 0x61, 0x00,
0x64, 0x00, 0x30, 0x30, 0x69, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01, 0x31, 0x5C, 0x1E, 0x5A, 0x00, 0x4D, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41, 0x00, 0x20, 0x00, 0x53, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79, 0x00, 0x70, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F,
0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x30, 0x82, 0x02, 0xE7, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA0, 0x82, 0x02, 0xD8, 0x30, 0x82, 0x02, 0xD4, 0x02, 0x01, 0x00, 0x30, 0x82, 0x02, 0xCD, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x06, 0x30, 0x0E, 0x04, 0x08, 0x0B, 0x02, 0xBA, 0x83, 0x5D, 0x71, 0x1D, 0xBD, 0x02, 0x02, 0x07, 0xD0, 0x80, 0x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 0x02, 0x02, 0x07, 0xD0 };
private void DefaultProperties (EnvelopedCms ep, int contentLength, int version)
{
Assert.AreEqual (0, ep.Certificates.Count, "Certificates");
Assert.AreEqual (0, ep.ContentEncryptionAlgorithm.KeyLength, "ContentEncryptionAlgorithm.KeyLength");
Assert.AreEqual (tdesName, ep.ContentEncryptionAlgorithm.Oid.FriendlyName, "ContentEncryptionAlgorithm.Oid.FriendlyName");
Assert.AreEqual (tdesOid, ep.ContentEncryptionAlgorithm.Oid.Value, "ContentEncryptionAlgorithm.Oid.Value");
Assert.AreEqual (0, ep.ContentEncryptionAlgorithm.Parameters.Length, "ContentEncryptionAlgorithm.Parameters");
Assert.AreEqual (p7DataName, ep.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (p7DataOid, ep.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (contentLength, ep.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.AreEqual (0, ep.RecipientInfos.Count, "RecipientInfos");
Assert.AreEqual (0, ep.UnprotectedAttributes.Count, "UnprotectedAttributes");
Assert.AreEqual (version, ep.Version, "Version");
}
private X509Certificate2 GetCertificate (bool includePrivateKey)
{
return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
[Test]
public void ConstructorEmpty ()
{
EnvelopedCms ep = new EnvelopedCms ();
DefaultProperties (ep, 0, 0);
}
[Test]
public void ConstructorContentInfo ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (ci);
DefaultProperties (ep, asnNull.Length, 0);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorContentInfoNull ()
{
EnvelopedCms ep = new EnvelopedCms (null);
}
[Test]
public void ConstructorContentInfoAlgorithmIdentifier ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (ci, ai);
DefaultProperties (ep, 2, 0);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorContentInfoNullAlgorithmIdentifier ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
EnvelopedCms ep = new EnvelopedCms (null, ai);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorContentInfoAlgorithmIdentifierNull ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (ci, null);
}
[Test]
public void ConstructorSubjectIdentifierTypeIssuerAndSerialNumberContentInfoAlgorithmIdentifier ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci, ai);
DefaultProperties (ep, 2, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeSubjectKeyIdentifierContentInfoAlgorithmIdentifier ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.SubjectKeyIdentifier, ci, ai);
DefaultProperties (ep, 2, 2);
}
[Test]
public void ConstructorSubjectIdentifierTypeUnknownContentInfoAlgorithmIdentifier ()
{
AlgorithmIdentifier ai = new AlgorithmIdentifier ();
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.Unknown, ci, ai);
DefaultProperties (ep, 2, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeIssuerAndSerialNumberContentInfo ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
DefaultProperties (ep, 2, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeSubjectKeyIdentifierContentInfo ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.SubjectKeyIdentifier, ci);
DefaultProperties (ep, 2, 2);
}
[Test]
public void ConstructorSubjectIdentifierTypeUnknownContentInfo ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.Unknown, ci);
DefaultProperties (ep, 2, 0);
}
[Test]
[Category ("NotWorking")]
public void Decode ()
{
byte[] encoded = { 0x30, 0x82, 0x01, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x03, 0xA0, 0x82, 0x01, 0x0D, 0x30, 0x82, 0x01, 0x09, 0x02, 0x01, 0x00, 0x31, 0x81, 0xD6, 0x30, 0x81, 0xD3, 0x02, 0x01, 0x00, 0x30, 0x3C, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0xCA, 0x4B, 0x97, 0x9C, 0xAB, 0x79, 0xC6, 0xDF, 0x6A, 0x27, 0xC7, 0x24, 0xC4, 0x5E, 0x3B, 0x31, 0xAD, 0xBC, 0x25, 0xE6, 0x38, 0x5E, 0x79, 0x26, 0x0E, 0x68, 0x46, 0x1D, 0x21, 0x81, 0x38, 0x92, 0xEC, 0xCB, 0x7C, 0x91, 0xD6, 0x09, 0x38, 0x91, 0xCE, 0x50, 0x5B, 0x70, 0x31, 0xB0, 0x9F, 0xFC, 0xE2, 0xEE, 0x45, 0xBC, 0x4B, 0xF8, 0x9A, 0xD9, 0xEE, 0xE7, 0x4A, 0x3D, 0xCD, 0x8D, 0xFF, 0x10, 0xAB, 0xC8, 0x19, 0x05, 0x54, 0x5E, 0x40, 0x7A, 0xBE, 0x2B, 0xD7, 0x22, 0x97, 0xF3, 0x23, 0xAF, 0x50, 0xF5, 0xEB, 0x43, 0x06, 0xC3, 0xFB, 0x17, 0xCA, 0xBD, 0xAD, 0x28, 0xD8, 0x10, 0x0F, 0x61, 0xCE, 0xF8, 0x25, 0x70, 0xF6, 0xC8, 0x1E, 0x7F, 0x82, 0xE5, 0x94, 0xEB, 0x11, 0xBF, 0xB8, 0x6F, 0xEE, 0x79, 0xCD, 0x63, 0xDD, 0x59, 0x8D, 0x25, 0x0E, 0x78, 0x55, 0xCE, 0x21, 0xBA, 0x13, 0x6B, 0x30, 0x2B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x14, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x03, 0x07, 0x04, 0x08, 0x8C, 0x5D, 0xC9, 0x87, 0x88, 0x9C, 0x05, 0x72, 0x80, 0x08, 0x2C, 0xAF, 0x82, 0x91, 0xEC, 0xAD, 0xC5, 0xB5 };
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
// properties
Assert.AreEqual (0, ep.Certificates.Count, "Certificates");
Assert.AreEqual (192, ep.ContentEncryptionAlgorithm.KeyLength, "ContentEncryptionAlgorithm.KeyLength");
Assert.AreEqual (tdesName, ep.ContentEncryptionAlgorithm.Oid.FriendlyName, "ContentEncryptionAlgorithm.Oid.FriendlyName");
Assert.AreEqual (tdesOid, ep.ContentEncryptionAlgorithm.Oid.Value, "ContentEncryptionAlgorithm.Oid.Value");
Assert.AreEqual (16, ep.ContentEncryptionAlgorithm.Parameters.Length, "ContentEncryptionAlgorithm.Parameters");
Assert.AreEqual (p7DataName, ep.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (p7DataOid, ep.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (14, ep.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.AreEqual (1, ep.RecipientInfos.Count, "RecipientInfos");
RecipientInfo ri = ep.RecipientInfos [0];
Assert.IsTrue ((ri is KeyTransRecipientInfo), "RecipientInfos is KeyTransRecipientInfo");
Assert.AreEqual (0, ep.UnprotectedAttributes.Count, "UnprotectedAttributes");
Assert.AreEqual (0, ep.Version, "Version");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DecodeNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (null);
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void EncodeEmpty ()
{
EnvelopedCms ep = new EnvelopedCms ();
byte[] encoded = ep.Encode ();
}
[Test]
[Category ("NotWorking")]
public void Decrypt ()
{
byte[] encoded = { 0x30, 0x82, 0x01, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x03, 0xA0, 0x82, 0x01, 0x0D, 0x30, 0x82, 0x01, 0x09, 0x02, 0x01, 0x00, 0x31, 0x81, 0xD6, 0x30, 0x81, 0xD3, 0x02, 0x01, 0x00, 0x30, 0x3C, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0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08, 0x2C, 0xAF, 0x82, 0x91, 0xEC, 0xAD, 0xC5, 0xB5 };
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
X509Certificate2 x509 = GetCertificate (true);
X509Certificate2Collection xc = new X509Certificate2Collection ();
xc.Add (x509);
ep.Decrypt (xc);
// properties
Assert.AreEqual (0, ep.Certificates.Count, "Certificates");
Assert.AreEqual (192, ep.ContentEncryptionAlgorithm.KeyLength, "ContentEncryptionAlgorithm.KeyLength");
Assert.AreEqual (tdesName, ep.ContentEncryptionAlgorithm.Oid.FriendlyName, "ContentEncryptionAlgorithm.Oid.FriendlyName");
Assert.AreEqual (tdesOid, ep.ContentEncryptionAlgorithm.Oid.Value, "ContentEncryptionAlgorithm.Oid.Value");
Assert.AreEqual (16, ep.ContentEncryptionAlgorithm.Parameters.Length, "ContentEncryptionAlgorithm.Parameters");
Assert.AreEqual (p7DataName, ep.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (p7DataOid, ep.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual ("05-00", BitConverter.ToString (ep.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, ep.RecipientInfos.Count, "RecipientInfos");
Assert.AreEqual (0, ep.UnprotectedAttributes.Count, "UnprotectedAttributes");
Assert.AreEqual (0, ep.Version, "Version");
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void DecryptEmpty ()
{
EnvelopedCms ep = new EnvelopedCms ();
ep.Decrypt ();
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DecryptRecipientInfoNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
RecipientInfo ri = null; // do not confuse compiler
ep.Decrypt (ri);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DecryptX509CertificateExCollectionNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
X509Certificate2Collection xec = null; // do not confuse compiler
ep.Decrypt (xec);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DecryptRecipientInfoX509CertificateExCollectionNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
X509Certificate2Collection xec = new X509Certificate2Collection ();
ep.Decrypt (null, xec);
}
/* [Test]
[ExpectedException (typeof (ArgumentNullException))]
public void DecryptX509CertificateExCollectionNull ()
{
EnvelopedPkcs7 ep = new EnvelopedPkcs7 ();
RecipientInfo ri =
ep.Decrypt (ri, null);
}*/
private void RoundTrip (byte[] encoded)
{
X509Certificate2Collection xc = new X509Certificate2Collection ();
xc.Add (GetCertificate (true));
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
ep.Decrypt (xc);
Assert.AreEqual ("05-00", BitConverter.ToString (ep.ContentInfo.Content), "ContentInfo.Content");
}
[Test]
[Category ("NotWorking")]
public void EncryptCmsRecipientIssuerAndSerialNumber ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.IssuerAndSerialNumber, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
#if DEBUG
FileStream fs = File.OpenWrite ("EncryptCmsRecipientIssuerAndSerialNumber.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[Category ("NotWorking")]
public void EncryptCmsRecipientSubjectKeyIdentifier ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.SubjectKeyIdentifier, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
#if DEBUG
FileStream fs = File.OpenWrite ("EncryptCmsRecipientSubjectKeyIdentifier.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[Category ("NotWorking")]
public void EncryptCmsRecipientUnknown ()
{
ContentInfo ci = new ContentInfo (asnNull);
EnvelopedCms ep = new EnvelopedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
X509Certificate2 x509 = GetCertificate (false);
CmsRecipient p7r = new CmsRecipient (SubjectIdentifierType.Unknown, x509);
ep.Encrypt (p7r);
byte[] encoded = ep.Encode ();
#if DEBUG
FileStream fs = File.OpenWrite ("EncryptCmsRecipientUnknown.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (CryptographicException))]
public void EncryptEmpty ()
{
EnvelopedCms ep = new EnvelopedCms ();
ep.Encrypt ();
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void EnvelopedCmsRecipientNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
CmsRecipient p7r = null; // do not confuse compiler
ep.Encrypt (p7r);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void EnvelopedCmsRecipientCollectionNull ()
{
EnvelopedCms ep = new EnvelopedCms ();
CmsRecipientCollection p7rc = null; // do not confuse compiler
ep.Encrypt (p7rc);
}
}
}
#endif

View File

@@ -0,0 +1,101 @@
//
// KeyTransRecipientInfoTest.cs - NUnit tests for KeyTransRecipientInfo
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class KeyTransRecipientInfoTest {
static private byte[] issuerAndSerialNumber = { 0x30, 0x82, 0x01, 0x1C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x03, 0xA0, 0x82, 0x01, 0x0D, 0x30, 0x82, 0x01, 0x09, 0x02, 0x01, 0x00, 0x31, 0x81, 0xD6, 0x30, 0x81, 0xD3, 0x02, 0x01, 0x00, 0x30, 0x3C, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0xCA, 0x4B, 0x97, 0x9C, 0xAB, 0x79, 0xC6, 0xDF, 0x6A, 0x27, 0xC7, 0x24, 0xC4, 0x5E, 0x3B, 0x31, 0xAD, 0xBC, 0x25, 0xE6, 0x38, 0x5E, 0x79, 0x26, 0x0E, 0x68, 0x46, 0x1D, 0x21, 0x81, 0x38, 0x92, 0xEC, 0xCB, 0x7C, 0x91, 0xD6, 0x09, 0x38, 0x91, 0xCE, 0x50, 0x5B, 0x70, 0x31, 0xB0, 0x9F, 0xFC, 0xE2, 0xEE, 0x45, 0xBC, 0x4B, 0xF8, 0x9A, 0xD9, 0xEE, 0xE7, 0x4A, 0x3D, 0xCD, 0x8D, 0xFF, 0x10, 0xAB, 0xC8, 0x19, 0x05, 0x54, 0x5E, 0x40, 0x7A, 0xBE, 0x2B, 0xD7, 0x22, 0x97, 0xF3, 0x23, 0xAF, 0x50, 0xF5, 0xEB, 0x43, 0x06, 0xC3, 0xFB, 0x17, 0xCA, 0xBD, 0xAD, 0x28, 0xD8, 0x10, 0x0F, 0x61, 0xCE, 0xF8, 0x25, 0x70, 0xF6, 0xC8, 0x1E, 0x7F, 0x82, 0xE5, 0x94, 0xEB, 0x11, 0xBF, 0xB8, 0x6F, 0xEE, 0x79, 0xCD, 0x63, 0xDD, 0x59, 0x8D, 0x25, 0x0E, 0x78, 0x55, 0xCE, 0x21, 0xBA, 0x13, 0x6B, 0x30, 0x2B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x14, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x03, 0x07, 0x04, 0x08, 0x8C, 0x5D, 0xC9, 0x87, 0x88, 0x9C, 0x05, 0x72, 0x80, 0x08, 0x2C, 0xAF, 0x82, 0x91, 0xEC, 0xAD, 0xC5, 0xB5 };
static private byte[] subjectKeyIdentifier = { 0x30, 0x81, 0xF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0x5F, 0x4A, 0x5D, 0x32, 0x2E, 0x51, 0xD4, 0xE9, 0xD5, 0x17, 0xC9, 0x30, 0x2B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x14, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x03, 0x07, 0x04, 0x08, 0x55, 0x62, 0xB4, 0x77, 0x9A, 0x99, 0x39, 0xEF, 0x80, 0x08, 0x76, 0x3A, 0x9B, 0x63, 0x46, 0x95, 0xDB, 0xFA };
private KeyTransRecipientInfo GetKeyTransRecipientInfo (byte[] encoded)
{
EnvelopedCms ep = new EnvelopedCms ();
ep.Decode (encoded);
return (KeyTransRecipientInfo) ep.RecipientInfos [0];
}
[Test]
public void IssuerAndSerialNumber ()
{
KeyTransRecipientInfo ktri = GetKeyTransRecipientInfo (issuerAndSerialNumber);
Assert.AreEqual ("CA-4B-97-9C-AB-79-C6-DF-6A-27-C7-24-C4-5E-3B-31-AD-BC-25-E6-38-5E-79-26-0E-68-46-1D-21-81-38-92-EC-CB-7C-91-D6-09-38-91-CE-50-5B-70-31-B0-9F-FC-E2-EE-45-BC-4B-F8-9A-D9-EE-E7-4A-3D-CD-8D-FF-10-AB-C8-19-05-54-5E-40-7A-BE-2B-D7-22-97-F3-23-AF-50-F5-EB-43-06-C3-FB-17-CA-BD-AD-28-D8-10-0F-61-CE-F8-25-70-F6-C8-1E-7F-82-E5-94-EB-11-BF-B8-6F-EE-79-CD-63-DD-59-8D-25-0E-78-55-CE-21-BA-13-6B", BitConverter.ToString (ktri.EncryptedKey), "EncryptedKey");
Assert.AreEqual (0, ktri.KeyEncryptionAlgorithm.KeyLength, "KeyEncryptionAlgorithm.KeyLength");
Assert.AreEqual ("RSA", ktri.KeyEncryptionAlgorithm.Oid.FriendlyName, "KeyEncryptionAlgorithm.Oid.FriendlyName");
Assert.AreEqual ("1.2.840.113549.1.1.1", ktri.KeyEncryptionAlgorithm.Oid.Value, "KeyEncryptionAlgorithm.Oid.Value");
Assert.AreEqual (0, ktri.KeyEncryptionAlgorithm.Parameters.Length, "KeyEncryptionAlgorithm.Parameters");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, ktri.RecipientIdentifier.Type, "RecipientIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) ktri.RecipientIdentifier.Value;
Assert.AreEqual ("CN=Motus Technologies inc.(test)", xis.IssuerName, "RecipientIdentifier.Value.IssuerName");
Assert.AreEqual ("91C44B0DB7D81084422671B397B50097", xis.SerialNumber, "RecipientIdentifier.Value.SerialNumber");
Assert.AreEqual (RecipientInfoType.KeyTransport, ktri.Type, "Type");
Assert.AreEqual (0, ktri.Version, "Version");
}
[Test]
[Category ("NotWorking")]
public void SubjectKeyIdentifier ()
{
KeyTransRecipientInfo ktri = GetKeyTransRecipientInfo (subjectKeyIdentifier);
Assert.AreEqual ("4E-0C-A0-9D-79-D0-31-12-96-32-D5-9B-51-49-DC-C5-C4-FB-FE-E8-33-11-13-BE-48-02-5D-99-9D-B5-AC-52-A3-E3-DE-1B-88-00-7C-3E-D4-FE-93-6A-93-03-04-73-A9-22-3E-D5-2A-EE-D7-FC-FB-B4-FF-D4-9B-32-4F-B3-1E-8E-BA-F7-D3-12-07-19-B8-28-57-C4-54-33-14-83-77-A6-14-00-F2-02-A9-9B-45-F3-AB-41-00-69-E2-B3-D0-B9-A3-2D-9E-29-7F-BC-AE-92-05-11-5A-06-B7-26-83-0A-33-32-6E-5F-4A-5D-32-2E-51-D4-E9-D5-17-C9", BitConverter.ToString (ktri.EncryptedKey), "EncryptedKey");
Assert.AreEqual (0, ktri.KeyEncryptionAlgorithm.KeyLength, "KeyEncryptionAlgorithm.KeyLength");
Assert.AreEqual ("RSA", ktri.KeyEncryptionAlgorithm.Oid.FriendlyName, "KeyEncryptionAlgorithm.Oid.FriendlyName");
Assert.AreEqual ("1.2.840.113549.1.1.1", ktri.KeyEncryptionAlgorithm.Oid.Value, "KeyEncryptionAlgorithm.Oid.Value");
Assert.AreEqual (0, ktri.KeyEncryptionAlgorithm.Parameters.Length, "KeyEncryptionAlgorithm.Parameters");
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, ktri.RecipientIdentifier.Type, "RecipientIdentifier.Type");
Assert.AreEqual ("02E1A73254AEFDC0A43236F6FE236A037228B1F7", (string)ktri.RecipientIdentifier.Value, "RecipientIdentifier.Value");
Assert.AreEqual (RecipientInfoType.KeyTransport, ktri.Type, "Type");
Assert.AreEqual (2, ktri.Version, "Version");
}
[Test]
public void EncryptedKey_ModifyContent ()
{
KeyTransRecipientInfo ktri = GetKeyTransRecipientInfo (issuerAndSerialNumber);
Assert.AreEqual ("CA-4B-97-9C-AB-79-C6-DF-6A-27-C7-24-C4-5E-3B-31-AD-BC-25-E6-38-5E-79-26-0E-68-46-1D-21-81-38-92-EC-CB-7C-91-D6-09-38-91-CE-50-5B-70-31-B0-9F-FC-E2-EE-45-BC-4B-F8-9A-D9-EE-E7-4A-3D-CD-8D-FF-10-AB-C8-19-05-54-5E-40-7A-BE-2B-D7-22-97-F3-23-AF-50-F5-EB-43-06-C3-FB-17-CA-BD-AD-28-D8-10-0F-61-CE-F8-25-70-F6-C8-1E-7F-82-E5-94-EB-11-BF-B8-6F-EE-79-CD-63-DD-59-8D-25-0E-78-55-CE-21-BA-13-6B", BitConverter.ToString (ktri.EncryptedKey), "EncryptedKey");
ktri.EncryptedKey[0] = 0x00;
Assert.AreEqual ("00-4B-97-9C-AB-79-C6-DF-6A-27-C7-24-C4-5E-3B-31-AD-BC-25-E6-38-5E-79-26-0E-68-46-1D-21-81-38-92-EC-CB-7C-91-D6-09-38-91-CE-50-5B-70-31-B0-9F-FC-E2-EE-45-BC-4B-F8-9A-D9-EE-E7-4A-3D-CD-8D-FF-10-AB-C8-19-05-54-5E-40-7A-BE-2B-D7-22-97-F3-23-AF-50-F5-EB-43-06-C3-FB-17-CA-BD-AD-28-D8-10-0F-61-CE-F8-25-70-F6-C8-1E-7F-82-E5-94-EB-11-BF-B8-6F-EE-79-CD-63-DD-59-8D-25-0E-78-55-CE-21-BA-13-6B", BitConverter.ToString (ktri.EncryptedKey), "EncryptedKey");
// this is a reference (not a copy) of the key
}
}
}
#endif

View File

@@ -0,0 +1,147 @@
//
// Pkcs9AttributeTest.cs - NUnit tests for Pkcs9Attribute
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9AttributeObjectTest {
static string defaultOid = "1.2.840.113549.1.7.1";
static string defaultName = "PKCS 7 Data";
[Test]
public void ConstructorEmpty ()
{
Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
Assert.IsNull (a.Oid, "Oid");
Assert.IsNull (a.RawData, "RawData");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorAsnEncodedDataNull ()
{
Pkcs9AttributeObject a = new Pkcs9AttributeObject (null);
}
[Test]
public void ConstructorOidArray ()
{
Oid o = new Oid (defaultOid);
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");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidNullArray ()
{
Oid o = null;
Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, new byte[0]);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorOidArrayNull ()
{
Oid o = new Oid (defaultOid);
Pkcs9AttributeObject a = new Pkcs9AttributeObject (o, null);
}
[Test]
public void ConstructorStringArray ()
{
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");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorStringNullArray ()
{
string s = null;
Pkcs9AttributeObject a = new Pkcs9AttributeObject (s, new byte[0]);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorStringArrayNull ()
{
Pkcs9AttributeObject a = new Pkcs9AttributeObject (defaultOid, null);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9AttributeObject ().CopyFrom (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom_SigningTime_Raw ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.UtcNow);
Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
a.CopyFrom (new AsnEncodedData (st.RawData));
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom_SigningTime_OidRaw ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.UtcNow);
Pkcs9AttributeObject a = new Pkcs9AttributeObject ();
a.CopyFrom (new AsnEncodedData (st.Oid, st.RawData));
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom_Self ()
{
Pkcs9AttributeObject a = new Pkcs9AttributeObject ("1.2.3.4", new byte[2] { 0x05, 0x00 } );
a.CopyFrom (new AsnEncodedData (a.Oid, a.RawData));
}
}
}
#endif

View File

@@ -0,0 +1,94 @@
//
// Pkcs9ContentTypeTest.cs - NUnit tests for Pkcs9ContentType
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using Mono.Security;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9ContentTypeTest {
[Test]
public void Constructor_Empty ()
{
Pkcs9ContentType ct = new Pkcs9ContentType ();
Assert.AreEqual ("1.2.840.113549.1.9.3", ct.Oid.Value, "Oid.Value");
Assert.AreEqual ("Content Type", ct.Oid.FriendlyName, "Oid.FriendlyName");
Assert.IsNull (ct.RawData, "RawData");
Assert.IsNull (ct.ContentType, "ContentType");
Assert.AreEqual (String.Empty, ct.Format (true), "Format(true)");
Assert.AreEqual (String.Empty, ct.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9ContentType ().CopyFrom (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom ()
{
/* byte[] data = ASN1Convert.FromOid ("1.2.840.113549.1.7.1").GetBytes (); */
byte[] data = { 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
AsnEncodedData aed = new AsnEncodedData (data);
Pkcs9ContentType ct = new Pkcs9ContentType ();
ct.CopyFrom (aed);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom_BadData ()
{
/* Note: this is the full structure (but only the OID part is required)
ASN1 set = new ASN1 (0x30);
set.Add (ASN1Convert.FromOid ("1.2.840.113549.1.7.1"));
ASN1 p9 = new ASN1 (0x30);
p9.Add (ASN1Convert.FromOid ("1.2.840.113549.1.9.3"));
p9.Add (set);
byte[] data = p9.GetBytes ();*/
byte[] data = { 0x30, 0x18, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x03, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
AsnEncodedData aed = new AsnEncodedData (data);
Pkcs9ContentType ct = new Pkcs9ContentType ();
ct.CopyFrom (aed);
}
}
}
#endif

View File

@@ -0,0 +1,108 @@
//
// Pkcs9DocumentDescriptionTest.cs - NUnit tests for Pkcs9DocumentDescription
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9DocumentDescriptionTest {
[Test]
public void Constructor_Empty ()
{
Pkcs9DocumentDescription dd = new Pkcs9DocumentDescription ();
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.2", dd.Oid.Value, "Oid.Value");
Assert.IsNull (dd.Oid.FriendlyName, "Oid.FriendlyName");
Assert.IsNull (dd.RawData, "RawData");
Assert.IsNull (dd.DocumentDescription, "DocumentDescription");
Assert.AreEqual (String.Empty, dd.Format (true), "Format(true)");
Assert.AreEqual (String.Empty, dd.Format (false), "Format(false)");
}
[Test]
public void Constructor_String ()
{
Pkcs9DocumentDescription dd = new Pkcs9DocumentDescription ("mono");
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.2", dd.Oid.Value, "Oid.Value");
Assert.IsNull (dd.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual ("mono", dd.DocumentDescription, "DocumentDescription");
Assert.AreEqual (12, dd.RawData.Length, "RawData.Length");
Assert.AreEqual ("04-0A-6D-00-6F-00-6E-00-6F-00-00-00", BitConverter.ToString (dd.RawData), "RawData");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dd.Format (true), "Format(true)");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dd.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_StringNull ()
{
string desc = null;
Pkcs9DocumentDescription dd = new Pkcs9DocumentDescription (desc);
}
[Test]
public void Constructor_Array ()
{
byte[] desc = { 0x04, 0x0A, 0x6D, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x6F, 0x00, 0x00, 0x00 };
Pkcs9DocumentDescription dd = new Pkcs9DocumentDescription (desc);
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.2", dd.Oid.Value, "Oid.Value");
Assert.IsNull (dd.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual ("mono", dd.DocumentDescription, "DocumentDescription");
Assert.AreEqual (12, dd.RawData.Length, "RawData.Length");
Assert.AreEqual ("04-0A-6D-00-6F-00-6E-00-6F-00-00-00", BitConverter.ToString (dd.RawData), "RawData");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dd.Format (true), "Format(true)");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dd.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_ArrayNull ()
{
byte[] desc = null;
Pkcs9DocumentDescription dd = new Pkcs9DocumentDescription (desc);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9DocumentDescription ().CopyFrom (null);
}
}
}
#endif

View File

@@ -0,0 +1,116 @@
//
// Pkcs9DocumentNameTest.cs - NUnit tests for Pkcs9DocumentName
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9DocumentNameTest {
[Test]
public void Constructor_Empty ()
{
Pkcs9DocumentName dn = new Pkcs9DocumentName ();
Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.1", dn.Oid.Value, "Oid.Value");
Assert.IsNull (dn.RawData, "RawData");
Assert.AreEqual (String.Empty, dn.Format (true), "Format(true)");
Assert.AreEqual (String.Empty, dn.Format (false), "Format(false)");
}
[Test]
// FIXME: throws a NullReferenceException in beta 1 - still true in Dec CTP
[Category ("NotDotNet")] // MS throws [ExpectedException (typeof (NullReferenceException))]
public void Constructor_Empty_MessageDigest ()
{
Pkcs9DocumentName dn = new Pkcs9DocumentName ();
Assert.IsNull (dn.DocumentName, "DocumentName");
}
[Test]
public void Constructor_String ()
{
Pkcs9DocumentName dn = new Pkcs9DocumentName ("mono");
Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.1", dn.Oid.Value, "Oid.Value");
Assert.AreEqual ("mono", dn.DocumentName, "DocumentName");
Assert.AreEqual (12, dn.RawData.Length, "RawData.Length");
Assert.AreEqual ("04-0A-6D-00-6F-00-6E-00-6F-00-00-00", BitConverter.ToString (dn.RawData), "RawData");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dn.Format (true), "Format(true)");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dn.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_StringNull ()
{
string name = null;
Pkcs9DocumentName dn = new Pkcs9DocumentName (name);
}
[Test]
public void Constructor_Array ()
{
byte[] name = { 0x04, 0x0A, 0x6D, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x6F, 0x00, 0x00, 0x00 };
Pkcs9DocumentName dn = new Pkcs9DocumentName (name);
Assert.AreEqual ("1.3.6.1.4.1.311.88.2.1", dn.Oid.Value, "Oid.Value");
Assert.IsNull (dn.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual ("mono", dn.DocumentName, "DocumentName");
Assert.AreEqual (12, dn.RawData.Length, "RawData.Length");
Assert.AreEqual ("04-0A-6D-00-6F-00-6E-00-6F-00-00-00", BitConverter.ToString (dn.RawData), "RawData");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dn.Format (true), "Format(true)");
Assert.AreEqual ("04 0a 6d 00 6f 00 6e 00 6f 00 00 00", dn.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_ArrayNull ()
{
byte[] name = null;
Pkcs9DocumentName dn = new Pkcs9DocumentName (name);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9DocumentName ().CopyFrom (null);
}
}
}
#endif

View File

@@ -0,0 +1,84 @@
//
// Pkcs9MessageDigestTest.cs - NUnit tests for Pkcs9MessageDigest
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9MessageDigestTest {
[Test]
public void Constructor_Empty ()
{
Pkcs9MessageDigest md = new Pkcs9MessageDigest ();
Assert.AreEqual ("1.2.840.113549.1.9.4", md.Oid.Value, "Oid.Value");
Assert.AreEqual ("Message Digest", md.Oid.FriendlyName, "Oid.FriendlyName");
Assert.IsNull (md.RawData, "RawData");
Assert.IsNull (md.MessageDigest, "MessageDigest");
Assert.AreEqual (String.Empty, md.Format (true), "Format(true)");
Assert.AreEqual (String.Empty, md.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9MessageDigest ().CopyFrom (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom ()
{
byte[] data = { 0x04, 0x10, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
AsnEncodedData aed = new AsnEncodedData (data);
Pkcs9MessageDigest md = new Pkcs9MessageDigest ();
md.CopyFrom (aed);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void CopyFrom_BadData ()
{
byte[] data = { 0x30, 0x18, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x03, 0x30, 0x0B, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01 };
AsnEncodedData aed = new AsnEncodedData (data);
Pkcs9MessageDigest md = new Pkcs9MessageDigest ();
md.CopyFrom (aed);
}
}
}
#endif

View File

@@ -0,0 +1,230 @@
//
// Pkcs9SigningTimeTest.cs - NUnit tests for Pkcs9SigningTime
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Text;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class Pkcs9SigningTimeTest {
static string signingTimeOid = "1.2.840.113549.1.9.5";
static string signingTimeName = "Signing Time";
static DateTime mono10release = new DateTime (632241648000000000);
[Test]
public void DateTime_Mono10Release ()
{
// some tests fails if the assumption fails
Assert.AreEqual ("040630040000Z", mono10release.ToString ("yyMMddhhmmssZ"), "Z");
}
[Test]
public void Constructor_Empty ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime ();
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (true), "Format(true)");
Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (false), "Format(false)");
}
[Test]
public void Constructor_DateTime_Now ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.UtcNow);
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (true), "Format(true)");
Assert.AreEqual (BitConverter.ToString (st.RawData).ToLower ().Replace ("-", " "), st.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Constructor_DateTime_MinValue ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.MinValue);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Constructor_DateTime_1600 ()
{
DateTime dt = new DateTime (1600, 12, 31, 11, 59, 59);
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void Constructor_DateTime_1601 ()
{
DateTime dt = new DateTime (1601, 01, 01, 00, 00, 00);
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void Constructor_DateTime_MaxValue ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (DateTime.MaxValue);
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void Constructor_DateTime_Before1950 ()
{
DateTime dt = new DateTime (1949, 12, 31, 11, 59, 59);
// UTCTIME (0x17), i.e. 2 digits years, limited to 1950-2050
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
}
[Test]
public void Constructor_DateTime_After1950 ()
{
DateTime dt = new DateTime (1950, 01, 01, 00, 00, 00);
// UTCTIME (0x17), i.e. 2 digits years, limited to 1950-2050
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual ("17-0D-35-30-30-31-30-31-30-30-30-30-30-30-5A", BitConverter.ToString (st.RawData));
Assert.AreEqual (dt, st.SigningTime, "st.SigningTime");
Assert.AreEqual ("17 0d 35 30 30 31 30 31 30 30 30 30 30 30 5a", st.Format (true), "Format(true)");
Assert.AreEqual ("17 0d 35 30 30 31 30 31 30 30 30 30 30 30 5a", st.Format (false), "Format(false)");
}
[Test]
public void Constructor_DateTime_Before2050 ()
{
DateTime dt = new DateTime (2049, 12, 31, 11, 59, 59);
// up to 2050 encoding should stay with UTCTIME (0x17), i.e. 2 digits years
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual ("17-0D-34-39-31-32-33-31-31-31-35-39-35-39-5A", BitConverter.ToString (st.RawData));
Assert.AreEqual (dt, st.SigningTime, "st.SigningTime");
Assert.AreEqual ("17 0d 34 39 31 32 33 31 31 31 35 39 35 39 5a", st.Format (true), "Format(true)");
Assert.AreEqual ("17 0d 34 39 31 32 33 31 31 31 35 39 35 39 5a", st.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void Constructor_DateTime_After2050 ()
{
DateTime dt = new DateTime (2050, 01, 01, 00, 00, 00);
// in 2050 encoding should switch to GENERALIZEDTIME (0x18), i.e. 4 digits years
Pkcs9SigningTime st = new Pkcs9SigningTime (dt);
}
[Test]
public void Constructor_DateTime ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (mono10release);
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual ("17-0D-30-34-30-36-33-30-30-34-30-30-30-30-5A", BitConverter.ToString (st.RawData), "RawData");
Assert.AreEqual (mono10release, st.SigningTime, "st.SigningTime");
Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (true), "Format(true)");
Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (false), "Format(false)");
}
[Test]
public void Constructor_Bytes ()
{
byte[] date = new byte [15] { 0x17, 0x0D, 0x30, 0x34, 0x30, 0x36, 0x33, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x5A };
Pkcs9SigningTime st = new Pkcs9SigningTime (date);
Assert.AreEqual (signingTimeName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (signingTimeOid, st.Oid.Value, "Oid.Value");
Assert.AreEqual (15, st.RawData.Length, "RawData.Length");
Assert.AreEqual ("17-0D-30-34-30-36-33-30-30-34-30-30-30-30-5A", BitConverter.ToString (st.RawData), "RawData");
Assert.AreEqual (mono10release, st.SigningTime, "st.SigningTime");
Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (true), "Format(true)");
Assert.AreEqual ("17 0d 30 34 30 36 33 30 30 34 30 30 30 30 5a", st.Format (false), "Format(false)");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Constructor_Bytes_Null ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (null);
}
[Test]
// [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 ()
{
Pkcs9SigningTime st1 = new Pkcs9SigningTime (mono10release);
Pkcs9SigningTime st2 = new Pkcs9SigningTime (DateTime.UtcNow);
st1.CopyFrom (st2);
Assert.AreEqual (st2.Oid.FriendlyName, st1.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (st2.Oid.Value, st1.Oid.Value, "Oid.Value");
Assert.AreEqual (BitConverter.ToString (st2.RawData), BitConverter.ToString (st1.RawData), "RawData");
// Note: Some timing resolution is lost by goind to ASN.1
Assert.AreEqual (st2.SigningTime.ToString (), st1.SigningTime.ToString (), "SigningTime");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyFrom_Null ()
{
new Pkcs9SigningTime (mono10release).CopyFrom (null);
}
[Test]
// [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 ()
{
Pkcs9SigningTime st = new Pkcs9SigningTime (mono10release);
Pkcs9DocumentName dn = new Pkcs9DocumentName ("Mono");
st.CopyFrom (dn);
Assert.AreEqual (dn.Oid.FriendlyName, st.Oid.FriendlyName, "Oid.FriendlyName");
Assert.AreEqual (dn.Oid.Value, st.Oid.Value, "Oid.Value");
Assert.AreEqual (BitConverter.ToString (dn.RawData), BitConverter.ToString (st.RawData), "RawData");
// wrong ASN.1
Assert.AreEqual (mono10release, st.SigningTime, "SigningTime");
}
}
}
#endif

View File

@@ -0,0 +1,165 @@
//
// PkitsTest.cs - NUnit tests for
// NIST Public Key Interoperability Test Suite (PKITS)
// Certificate Path Validation, Version 1.0, September 2, 2004
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2006 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace MonoTests.System.Security.Cryptography.Pkcs {
/*
* PKITS home page
* http://csrs.nist.gov/pki/testing/x509paths.html
*
* Documentation is available at
* http://csrc.nist.gov/pki/testing/PKITS.pdf
*
* Test data is available at
* http://csrc.nist.gov/pki/testing/PKITS_data.zip
*
* License information are available at
* http://cio.nist.gov/esd/emaildir/lists/pkits/msg00048.html
*/
[Category ("PKITS")]
public class PkitsTest {
private string base_dir;
private string certs_base_dir;
private string smime_base_dir;
private Hashtable cache;
private Oid[] policies;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
// reuse PKITS data installed in System (for X509Chain tests)
base_dir = String.Format ("{0}{1}..{1}System{1}Test{1}System.Security.Cryptography.X509Certificates{1}pkits",
Directory.GetCurrentDirectory (), Path.DirectorySeparatorChar);
if (!Directory.Exists (base_dir))
Assert.Ignore ("PKITS tests data not found under '{0}'.", new object[] { base_dir });
certs_base_dir = Path.Combine (base_dir, "certs");
smime_base_dir = Path.Combine (base_dir, "smime");
cache = new Hashtable ();
policies = new Oid[9];
// any-policies
policies[0] = new Oid ("2.5.29.32.0");
// nist_test_policy_#
for (int i=0; i < 9; i++)
policies[i] = new Oid ("2.16.840.1.101.3.2.1.48." + i.ToString ());
}
[TestFixtureTearDown]
public void FixtureTearDown ()
{
cache.Clear ();
}
public X509Certificate2 GetCertificate (string filename)
{
X509Certificate2 result = (cache[filename] as X509Certificate2);
if (result == null) {
string full_path = Path.Combine (certs_base_dir, filename);
result = new X509Certificate2 (full_path);
cache[filename] = result;
}
return result;
}
public byte[] GetData (string filename)
{
string full_path = Path.Combine (smime_base_dir, filename);
using (StreamReader sr = new StreamReader (full_path)) {
string s = sr.ReadLine ();
while (!sr.EndOfStream) {
if (s.Length == 0)
break;
s = sr.ReadLine ();
}
s = sr.ReadToEnd ();
return Convert.FromBase64String (s);
}
}
public X509Certificate2 TrustAnchorRoot {
get { return GetCertificate ("TrustAnchorRootCertificate.crt"); }
}
public X509Certificate2 GoodCACert {
get { return GetCertificate ("GoodCACert.crt"); }
}
// Sadly both SignedCms.CheckHash and SignedCms.CheckSignature returns void and throw an exception.
// This makes it difficult to use in tests because we want to be sure that the "expected exception"
// is being thrown at the "right" place. The next 2 methods hacks around that limitation.
public bool CheckHash (SignedCms cms)
{
try {
cms.CheckSignature (false);
return true;
}
catch {
}
return false;
}
public bool CheckSignature (SignedCms cms)
{
try {
cms.CheckSignature (false);
return true;
}
catch {
}
return false;
}
public Oid AnyPolicy {
get { return policies [0]; }
}
public Oid NistPolicy (int n)
{
return policies[n];
}
}
}
#endif

View File

@@ -0,0 +1,241 @@
//
// Pkits_4_01_SignatureVerification.cs -
// NUnit tests for Pkits 4.1 : Signature Verification
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2006 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
[Category ("PKITS")]
[Category ("NotWorking")]
public class Pkits_4_01_SignatureVerification: PkitsTest {
public X509Certificate2 BadSignedCACert {
get { return GetCertificate ("BadSignedCACert.crt"); }
}
public X509Certificate2 DSACACert {
get { return GetCertificate ("DSACACert.crt"); }
}
public X509Certificate2 DSAParametersInheritedCACert {
get { return GetCertificate ("DSAParametersInheritedCACert.crt"); }
}
[Test]
public void T1_ValidSignature ()
{
byte[] data = GetData ("SignedValidSignaturesTest1.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsTrue (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("ValidCertificatePathTest1EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (GoodCACert), "GoodCACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-3B-20-63-68-61-72-73-65-74-3D-69-73-6F-2D-38-38-35-39-2D-31-0D-0A-43-6F-6E-74-65-6E-74-2D-54-72-61-6E-73-66-65-72-2D-45-6E-63-6F-64-69-6E-67-3A-20-37-62-69-74-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=Good CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("01", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
[Test]
public void T2_InvalidCASignature ()
{
byte[] data = GetData ("SignedInvalidCASignatureTest2.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsFalse (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("InvalidCASignatureTest2EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (BadSignedCACert), "BadSignedCACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-3B-20-63-68-61-72-73-65-74-3D-69-73-6F-2D-38-38-35-39-2D-31-0D-0A-43-6F-6E-74-65-6E-74-2D-54-72-61-6E-73-66-65-72-2D-45-6E-63-6F-64-69-6E-67-3A-20-37-62-69-74-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=Bad Signed CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("01", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
[Test]
public void T3_InvalidEESignature ()
{
byte[] data = GetData ("SignedInvalidEESignatureTest3.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsFalse (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("InvalidEESignatureTest3EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (GoodCACert), "GoodCACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-3B-20-63-68-61-72-73-65-74-3D-69-73-6F-2D-38-38-35-39-2D-31-0D-0A-43-6F-6E-74-65-6E-74-2D-54-72-61-6E-73-66-65-72-2D-45-6E-63-6F-64-69-6E-67-3A-20-37-62-69-74-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=Good CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("02", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
[Test]
public void T4_ValidDSASignatures ()
{
byte[] data = GetData ("SignedValidDSASignaturesTest4.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsTrue (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("ValidDSASignaturesTest4EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (DSACACert), "DSACACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-0D-0A-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E-0D-0A", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=DSA CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("01", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
[Test]
public void T5_ValidDSAParameterInheritance ()
{
byte[] data = GetData ("SignedValidDSAParameterInheritanceTest5.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsTrue (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("ValidDSAParameterInheritanceTest5EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (DSAParametersInheritedCACert), "DSAParametersInheritedCACert");
Assert.IsTrue (cms.Certificates.Contains (DSACACert), "DSACACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-0D-0A-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E-0D-0A", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=DSA Parameters Inherited CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("01", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
[Test]
public void T6_InvalidDSASignatures ()
{
byte[] data = GetData ("SignedInvalidDSASignatureTest6.eml");
SignedCms cms = new SignedCms ();
cms.Decode (data);
Assert.IsTrue (CheckHash (cms), "CheckHash");
Assert.IsFalse (CheckSignature (cms), "CheckSignature");
X509Certificate2 ee = GetCertificate ("InvalidDSASignatureTest6EE.crt");
// certificates aren't in any particuliar order
Assert.IsTrue (cms.Certificates.Contains (ee), "EE");
Assert.IsTrue (cms.Certificates.Contains (DSACACert), "DSACACert");
Assert.IsFalse (cms.Detached, "Detached");
Assert.AreEqual (1, cms.Version, "Version");
Assert.AreEqual ("1.2.840.113549.1.7.1", cms.ContentInfo.ContentType.Value, "ContentInfo.Oid");
Assert.AreEqual ("43-6F-6E-74-65-6E-74-2D-54-79-70-65-3A-20-74-65-78-74-2F-70-6C-61-69-6E-0D-0A-0D-0A-0D-0A-54-68-69-73-20-69-73-20-61-20-73-61-6D-70-6C-65-20-73-69-67-6E-65-64-20-6D-65-73-73-61-67-65-2E-0D-0A", BitConverter.ToString (cms.ContentInfo.Content), "ContentInfo.Content");
Assert.AreEqual (1, cms.SignerInfos.Count, "SignerInfos.Count");
Assert.AreEqual (ee, cms.SignerInfos[0].Certificate, "SignerInfos[0].Certificate");
Assert.AreEqual (0, cms.SignerInfos[0].CounterSignerInfos.Count, "SignerInfos[0].CounterSignerInfos.Count");
Assert.AreEqual ("1.3.14.3.2.26", cms.SignerInfos[0].DigestAlgorithm.Value, "cms.SignerInfos[0].DigestAlgorithm");
Assert.AreEqual (0, cms.SignerInfos[0].SignedAttributes.Count, "SignerInfos[0].SignedAttributes.Count");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, cms.SignerInfos[0].SignerIdentifier.Type, "SignerInfos[0].SignerIdentifier.Type");
X509IssuerSerial xis = (X509IssuerSerial) cms.SignerInfos[0].SignerIdentifier.Value;
Assert.AreEqual ("CN=DSA CA, O=Test Certificates, C=US", xis.IssuerName, "SignerInfos[0].SignerIdentifier.Value.IssuerName");
Assert.AreEqual ("03", xis.SerialNumber, "SignerInfos[0].SignerIdentifier.Value.SerialNumber");
Assert.AreEqual (0, cms.SignerInfos[0].UnsignedAttributes.Count, "SignerInfos[0].UnsignedAttributes.Count");
Assert.AreEqual (1, cms.SignerInfos[0].Version, "SignerInfos[0].Version");
}
}
}
#endif

View File

@@ -0,0 +1,457 @@
//
// SignedCmsTest.cs - NUnit tests for SignedCms
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class SignedCmsTest {
static byte[] asnNull = { 0x05, 0x00 };
static string pkcs7Oid = "1.2.840.113549.1.7.1";
static string pkcs7Name = "PKCS 7 Data";
static string rsaOid = "1.2.840.113549.1.1.1";
static string rsaName = "RSA";
static public byte[] farscape_p12_pfx = {
0x30, 0x82, 0x07, 0x17, 0x02, 0x01, 0x03, 0x30, 0x82, 0x06, 0xD3, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x06, 0xC4, 0x04, 0x82, 0x06, 0xC0, 0x30, 0x82, 0x06, 0xBC, 0x30, 0x82, 0x03, 0xCD, 0x06, 0x09, 0x2A, 0x86,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, 0x70, 0x8E, 0xF0, 0xB9, 0x31, 0x81, 0xE8, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x02, 0x31, 0x00, 0x30, 0x13, 0x06, 0x09, 0x2A, 0x86, 0x48,
0x86, 0xF7, 0x0D, 0x01, 0x09, 0x15, 0x31, 0x06, 0x04, 0x04, 0x01, 0x00, 0x00, 0x00, 0x30, 0x57, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x14, 0x31, 0x4A, 0x1E, 0x48, 0x00, 0x64, 0x00, 0x64, 0x00, 0x62, 0x00, 0x30, 0x00, 0x65, 0x00, 0x64, 0x00, 0x31, 0x00, 0x64, 0x00, 0x2D, 0x00, 0x32, 0x00, 0x36, 0x00, 0x30, 0x00, 0x34, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x32, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x31, 0x00, 0x35, 0x00, 0x66, 0x00, 0x2D, 0x00, 0x34, 0x00, 0x39, 0x00, 0x35, 0x00, 0x61, 0x00, 0x37, 0x00, 0x64, 0x00, 0x65, 0x00, 0x65, 0x00, 0x37, 0x00, 0x61, 0x00,
0x64, 0x00, 0x30, 0x30, 0x69, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01, 0x31, 0x5C, 0x1E, 0x5A, 0x00, 0x4D, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41, 0x00, 0x20, 0x00, 0x53, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79, 0x00, 0x70, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F,
0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x30, 0x82, 0x02, 0xE7, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA0, 0x82, 0x02, 0xD8, 0x30, 0x82, 0x02, 0xD4, 0x02, 0x01, 0x00, 0x30, 0x82, 0x02, 0xCD, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x06, 0x30, 0x0E, 0x04, 0x08, 0x0B, 0x02, 0xBA, 0x83, 0x5D, 0x71, 0x1D, 0xBD, 0x02, 0x02, 0x07, 0xD0, 0x80, 0x82, 0x02, 0xA0, 0x52, 0xD1, 0x51, 0x2A, 0xD1, 0x6D, 0x7E, 0xB0, 0x0A, 0x62, 0x6C, 0x0B, 0xE6, 0x6C, 0x72,
0x65, 0x3F, 0x89, 0x36, 0x1F, 0x71, 0x85, 0x00, 0x45, 0xC9, 0x56, 0x65, 0xC6, 0x43, 0xF6, 0xC1, 0x56, 0x81, 0xF0, 0xF5, 0x73, 0x57, 0xA5, 0x47, 0x45, 0xB6, 0xBD, 0xC3, 0xEB, 0xE0, 0xE0, 0x0F, 0x23, 0xCE, 0x95, 0xD7, 0x85, 0xCA, 0x73, 0xC0, 0x0E, 0x36, 0x7A, 0xF1, 0x01, 0x3F, 0x0B, 0x1C, 0xC2, 0x6C, 0x09, 0xC2, 0x43, 0x98, 0x14, 0x10, 0x80, 0x35, 0xF0, 0x45, 0x7A,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64, 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 };
static public byte [] intca_cer = { 0x30, 0x82, 0x02, 0x31, 0x30, 0x82, 0x01, 0x9A, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x1B, 0xFC, 0x61, 0x41, 0xD0, 0xCF, 0x41, 0xB9, 0x47, 0xEF, 0x21, 0x7D, 0x6A, 0x53, 0x32, 0x76, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x30, 0x21, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x55, 0x6E, 0x69, 0x74, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x31, 0x31, 0x32, 0x37, 0x30, 0x32, 0x33, 0x32, 0x32, 0x34, 0x5A, 0x17, 0x0D, 0x33,
0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x53, 0x53, 0x4C, 0x20, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x6D, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xB9, 0xA0, 0xA4, 0x9D, 0xC5, 0xF8, 0x60, 0x9E, 0xCB, 0x2C, 0xC5, 0xF0, 0xF7, 0x36, 0x72, 0x1B, 0x2B, 0x6E, 0x28, 0xEA, 0x40, 0x4A,
0x9F, 0xD1, 0x50, 0x8C, 0xB0, 0xD7, 0xAB, 0x44, 0x0C, 0x86, 0x32, 0x6D, 0x79, 0xA9, 0xFB, 0x67, 0x7E, 0x7E, 0x88, 0xE6, 0x58, 0x85, 0x47, 0x54, 0x78, 0xC2, 0xE0, 0x22, 0xA5, 0xB2, 0x83, 0x2C, 0x67, 0xF1, 0x64, 0xAC, 0xA4, 0xE5, 0x14, 0x3E, 0x3A, 0xB5, 0xC1, 0xD6, 0xD3, 0x11, 0xA6, 0x6D, 0x0D, 0x59, 0x4F, 0xE7, 0x93, 0x60, 0x45, 0xE3, 0xD5, 0x73, 0x83, 0xB5, 0xCA, 0x9E, 0xD1, 0x69, 0x12, 0x56, 0x19, 0x49, 0x19, 0xBD, 0x11, 0x91, 0x54, 0x36, 0x31, 0x97, 0x9A, 0x91, 0x4A, 0x66, 0x8C, 0x67, 0x5F, 0xE3, 0x30, 0xBC, 0xDA, 0xE5, 0x41, 0xC9, 0x6B, 0xD5, 0x7B, 0x3F, 0x08, 0x14, 0x59, 0x8C, 0xD5, 0x99,
0x13, 0xE3, 0x02, 0xDE, 0xB0, 0xCD, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x68, 0x30, 0x66, 0x30, 0x10, 0x06, 0x03, 0x55, 0x1D, 0x0A, 0x04, 0x09, 0x30, 0x07, 0x03, 0x02, 0x07, 0x80, 0x02, 0x01, 0x01, 0x30, 0x52, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x4B, 0x30, 0x49, 0x80, 0x10, 0xD5, 0x6B, 0x08, 0x45, 0x51, 0x7C, 0x7E, 0xE7, 0x36, 0x07, 0x6E, 0xF7, 0x07, 0xE5, 0xC3, 0xE0, 0xA1, 0x23, 0x30, 0x21, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x55, 0x6E, 0x69, 0x74, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x82,
0x10, 0xAF, 0x9A, 0xC0, 0xAC, 0xB0, 0x96, 0x43, 0x85, 0x43, 0xF5, 0x85, 0xD0, 0x24, 0xB4, 0x24, 0x9C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x5B, 0xE9, 0x92, 0x57, 0xF1, 0x5F, 0xB6, 0x1D, 0x43, 0x2E, 0xB8, 0xE6, 0xA9, 0x68, 0x76, 0x0D, 0x41, 0xF4, 0x46, 0x0D, 0x32, 0x6A, 0xA1, 0x52, 0x30, 0x31, 0x4F, 0x0E, 0x4B, 0x91, 0x83, 0x6A, 0x18, 0x18, 0x48, 0x9C, 0xBB, 0xDB, 0x1D, 0x8B, 0xB3, 0x2B, 0x7A, 0x34, 0x57, 0xD7, 0x2F, 0xE6, 0x0A, 0xD9, 0x98, 0xAA, 0xD0, 0x2C, 0x5F, 0xBC, 0x36, 0xB6, 0xC4, 0x9B, 0xF1, 0x11, 0x9F, 0x9C,
0xAE, 0x9F, 0x05, 0x40, 0xC5, 0x71, 0xA4, 0x0D, 0xA5, 0x2C, 0x9A, 0x77, 0x5F, 0xD5, 0x04, 0xA4, 0xE7, 0xAB, 0x9C, 0x65, 0xC8, 0x26, 0x4C, 0xF6, 0x0C, 0x0A, 0x6A, 0x50, 0x4E, 0x21, 0x9A, 0x23, 0xD2, 0xDB, 0xDC, 0x0A, 0xC8, 0xFC, 0x6D, 0x9C, 0x24, 0xCB, 0x2F, 0x3B, 0x63, 0xE1, 0x2E, 0xDA, 0xA5, 0x97, 0x90, 0xB8, 0x3E, 0xAE, 0xE2, 0x18, 0x08, 0xB9, 0x19, 0x97, 0xE0, 0x21, 0xA0, 0xFB };
static public byte [] root_cer = { 0x30, 0x82, 0x02, 0x1D, 0x30, 0x82, 0x01, 0x86, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0xAF, 0x9A, 0xC0, 0xAC, 0xB0, 0x96, 0x43, 0x85, 0x43, 0xF5, 0x85, 0xD0, 0x24, 0xB4, 0x24, 0x9C, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x30, 0x21, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x55, 0x6E, 0x69, 0x74, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x31, 0x31, 0x32, 0x37, 0x30, 0x32, 0x32, 0x38, 0x30, 0x36, 0x5A, 0x17, 0x0D, 0x33,
0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x21, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x55, 0x6E, 0x69, 0x74, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xCC, 0x7C, 0x6B, 0xFE, 0xC4, 0x76, 0x23, 0x15, 0xBD, 0x7C, 0xD5, 0x58, 0x47, 0x92, 0x46, 0xA6, 0x8A, 0x7A, 0xA1, 0xEC, 0x8A, 0xB6, 0x35, 0x17,
0x9E, 0x4C, 0xD8, 0x1B, 0xCB, 0x89, 0x6A, 0x55, 0x2E, 0x0B, 0x13, 0x68, 0xCA, 0xBC, 0x33, 0xC2, 0xA9, 0x92, 0x70, 0xDF, 0xFA, 0xD9, 0x1F, 0x10, 0x5F, 0xAE, 0x2B, 0xD4, 0x43, 0x64, 0x44, 0xE3, 0x05, 0xF5, 0x11, 0xFD, 0x17, 0x29, 0x55, 0xF4, 0x60, 0x00, 0x9D, 0x23, 0x27, 0x1E, 0x73, 0x64, 0x97, 0xAB, 0x9A, 0x1B, 0x71, 0x65, 0x48, 0x25, 0x8B, 0x27, 0x3F, 0x02, 0xA1, 0xF1, 0xF0, 0x9A, 0x6A, 0x52, 0x02, 0x19, 0x0B, 0x18, 0xB8, 0xCF, 0x42, 0x2E, 0x8A, 0x8C, 0x83, 0x62, 0x12, 0x5D, 0xBA, 0x1D, 0xC1, 0x54, 0xC6, 0x03, 0x3B, 0x17, 0xD3, 0xB8, 0x78, 0x31, 0xB9, 0x7A, 0xAC, 0x84, 0xE5, 0x51, 0x84, 0xD8,
0x5A, 0x16, 0x40, 0xA1, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x56, 0x30, 0x54, 0x30, 0x52, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x4B, 0x30, 0x49, 0x80, 0x10, 0xD5, 0x6B, 0x08, 0x45, 0x51, 0x7C, 0x7E, 0xE7, 0x36, 0x07, 0x6E, 0xF7, 0x07, 0xE5, 0xC3, 0xE0, 0xA1, 0x23, 0x30, 0x21, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x4D, 0x6F, 0x6E, 0x6F, 0x20, 0x55, 0x6E, 0x69, 0x74, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x82, 0x10, 0xAF, 0x9A, 0xC0, 0xAC, 0xB0, 0x96, 0x43, 0x85, 0x43, 0xF5, 0x85, 0xD0, 0x24, 0xB4, 0x24, 0x9C, 0x30, 0x0D, 0x06,
0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0xA9, 0xE3, 0x44, 0x93, 0x54, 0x8E, 0x50, 0x93, 0xAC, 0xBE, 0x91, 0xA4, 0x99, 0x37, 0x3B, 0xAA, 0xEA, 0x22, 0x13, 0x14, 0xD3, 0x3A, 0xB8, 0xFB, 0xA3, 0x0F, 0x55, 0xB8, 0x83, 0xA1, 0x56, 0xA7, 0x51, 0xE3, 0x22, 0x14, 0x44, 0x41, 0x3E, 0xDC, 0x3B, 0xF3, 0x03, 0x89, 0xF4, 0xF2, 0x55, 0x70, 0x9A, 0x02, 0x48, 0x25, 0x0D, 0x66, 0x40, 0x21, 0x70, 0xF0, 0x0E, 0x79, 0xF5, 0x48, 0xD5, 0x19, 0xB8, 0xCC, 0xBD, 0x5D, 0xAC, 0xA5, 0x33, 0xD5, 0x02, 0x4F, 0x3F, 0x16, 0x42, 0xE6, 0x32, 0xFA, 0xEC, 0xAF, 0xE6, 0x12,
0xD0, 0x75, 0xE7, 0x4F, 0x0D, 0x50, 0xF4, 0xFC, 0x82, 0xD9, 0x82, 0xAF, 0x15, 0xDA, 0x74, 0xB5, 0xBF, 0xA9, 0x7A, 0xE2, 0xD0, 0x60, 0x7F, 0xEF, 0x48, 0x98, 0x03, 0x33, 0xDA, 0xBA, 0x12, 0x5E, 0x2F, 0xD7, 0x7F, 0xB6, 0xD3, 0xDF, 0x11, 0x93, 0xF8, 0x7B, 0xA9, 0xA8 };
private void DefaultProperties (SignedCms sp, int version)
{
// unaffected by constructors
Assert.AreEqual (0, sp.Certificates.Count, "Certificates");
Assert.AreEqual (0, sp.SignerInfos.Count, "SignerInfos");
Assert.AreEqual (version, sp.Version, "Version");
}
private X509Certificate2 GetCertificate (bool includePrivateKey)
{
return new X509Certificate2 (farscape_p12_pfx, "farscape");
}
private void AddChain (X509Certificate2Collection coll)
{
coll.Add (new X509Certificate2 (intca_cer));
coll.Add (new X509Certificate2 (root_cer));
}
[Test]
public void ConstructorEmpty ()
{
SignedCms sp = new SignedCms ();
// default properties
Assert.AreEqual (pkcs7Name, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (pkcs7Oid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (0, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (!sp.Detached, "Detached");
DefaultProperties (sp, 0);
}
[Test]
public void ConstructorContentInfo ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (ci);
// default properties
Assert.AreEqual (rsaName, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (rsaOid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (2, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (!sp.Detached, "Detached");
DefaultProperties (sp, 0);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorContentInfoNull ()
{
SignedCms sp = new SignedCms (null);
}
[Test]
public void ConstructorContentInfoDetachedTrue ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (ci, true);
// default properties
Assert.AreEqual (rsaName, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (rsaOid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (2, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (sp.Detached, "Detached");
DefaultProperties (sp, 0);
}
[Test]
public void ConstructorContentInfoDetachedFalse ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (ci, false);
// default properties
Assert.AreEqual (rsaName, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (rsaOid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (2, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (!sp.Detached, "Detached");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorContentInfoNullDetached ()
{
SignedCms sp = new SignedCms (null, true);
}
private void DefaultSubjectIdentifierTypePropertiesCms (SignedCms sp, int version)
{
Assert.AreEqual (pkcs7Name, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (pkcs7Oid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (0, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (!sp.Detached, "Detached");
DefaultProperties (sp, version);
}
[Test]
public void ConstructorSubjectIdentifierTypeIssuerAndSerialNumber ()
{
SignedCms sp = new SignedCms (SubjectIdentifierType.IssuerAndSerialNumber);
// default properties
DefaultSubjectIdentifierTypePropertiesCms (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeSubjectKeyIdentifier ()
{
SignedCms sp = new SignedCms (SubjectIdentifierType.SubjectKeyIdentifier);
// default properties
DefaultSubjectIdentifierTypePropertiesCms (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeUnknown ()
{
SignedCms sp = new SignedCms (SubjectIdentifierType.Unknown);
// default properties
DefaultSubjectIdentifierTypePropertiesCms (sp, 0);
}
private void DefaultSubjectIdentifierTypeProperties (SignedCms sp, int version)
{
Assert.AreEqual (rsaName, sp.ContentInfo.ContentType.FriendlyName, "ContentInfo.ContentType.FriendlyName");
Assert.AreEqual (rsaOid, sp.ContentInfo.ContentType.Value, "ContentInfo.ContentType.Value");
Assert.AreEqual (2, sp.ContentInfo.Content.Length, "ContentInfo.Content");
DefaultProperties (sp, version);
}
[Test]
public void ConstructorSubjectIdentifierTypeIssuerAndSerialNumberContentInfo ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci);
// default properties
Assert.IsTrue (!sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeSubjectKeyIdentifierContentInfo ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.SubjectKeyIdentifier, ci);
// default properties
Assert.IsTrue (!sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeUnknownContentInfo ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.Unknown, ci);
// default properties
Assert.IsTrue (!sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorSubjectIdentifierTypeContentInfoNull ()
{
SignedCms sp = new SignedCms (SubjectIdentifierType.Unknown, null);
}
[Test]
public void ConstructorSubjectIdentifierTypeIssuerAndSerialNumberContentInfoDetached ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.IssuerAndSerialNumber, ci, true);
// default properties
Assert.IsTrue (sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeSubjectKeyIdentifierContentInfoDetached ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.SubjectKeyIdentifier, ci, true);
// default properties
Assert.IsTrue (sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
public void ConstructorSubjectIdentifierTypeUnknownContentInfoDetached ()
{
Oid oid = new Oid (rsaOid);
ContentInfo ci = new ContentInfo (oid, asnNull);
SignedCms sp = new SignedCms (SubjectIdentifierType.Unknown, ci, true);
// default properties
Assert.IsTrue (sp.Detached, "Detached");
DefaultSubjectIdentifierTypeProperties (sp, 0);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void ConstructorSubjectIdentifierTypeContentInfoNullDetached ()
{
SignedCms sp = new SignedCms (SubjectIdentifierType.Unknown, null, true);
}
private void RoundTrip (byte[] encoded)
{
SignedCms sp = new SignedCms ();
sp.Decode (encoded);
sp.CheckSignature (true);
}
[Test]
[Ignore ("now broken everywhere")]
public void ComputeSignatureCmsSignerIssuerAndSerialNumber ()
{
ContentInfo ci = new ContentInfo (asnNull);
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.IssuerAndSerialNumber, GetCertificate (true));
signer.Certificates.Add (new X509Certificate2 (intca_cer));
signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();
string s = BitConverter.ToString (encoded);
#if DEBUG
FileStream fs = File.OpenWrite ("ComputeSignatureCmsSignerIssuerAndSerialNumber.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[Ignore ("now broken everywhere")]
public void ComputeSignatureCmsSignerSubjectKeyIdentifier ()
{
ContentInfo ci = new ContentInfo (asnNull);
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.SubjectKeyIdentifier, GetCertificate (true));
signer.Certificates.Add (new X509Certificate2 (intca_cer));
signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();
string s = BitConverter.ToString (encoded);
#if DEBUG
FileStream fs = File.OpenWrite ("ComputeSignaturePkcs7SignerSubjectKeyIdentifier.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[Ignore ("now broken everywhere")]
public void ComputeSignatureCmsSignerUnknown ()
{
ContentInfo ci = new ContentInfo (asnNull);
SignedCms sp = new SignedCms (ci);
CmsSigner signer = new CmsSigner (SubjectIdentifierType.Unknown, GetCertificate (true));
signer.Certificates.Add (new X509Certificate2 (intca_cer));
signer.Certificates.Add (new X509Certificate2 (root_cer));
sp.ComputeSignature (signer);
byte[] encoded = sp.Encode ();
string s = BitConverter.ToString (encoded);
#if DEBUG
FileStream fs = File.OpenWrite ("ComputeSignaturePkcs7SignerUnknown.der");
fs.Write (encoded, 0, encoded.Length);
fs.Close ();
#endif
RoundTrip (encoded);
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void ComputeEmptySignatureCmsSigner ()
{
CmsSigner signer = new CmsSigner ();
SignedCms sp = new SignedCms ();
sp.ComputeSignature (signer);
}
[Test]
[ExpectedException (typeof (CryptographicException))]
public void ComputeEmptySignature ()
{
SignedCms sp = new SignedCms ();
sp.ComputeSignature ();
}
private void CheckSignatureProperties (SignedCms sp, int version)
{
Assert.AreEqual (1, sp.Certificates.Count, "Certificates");
Assert.AreEqual (2, sp.ContentInfo.Content.Length, "ContentInfo.Content");
Assert.IsTrue (!sp.Detached, "Detached");
Assert.AreEqual (1, sp.SignerInfos.Count, "SignerInfos");
Assert.AreEqual (version, sp.Version, "Version");
}
[Test]
public void CheckSignatureCmsSignerIssuerAndSerialNumber ()
{
byte[] signature = { 0x30, 0x82, 0x03, 0x4C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x3D, 0x30, 0x82, 0x03, 0x39, 0x02, 0x01, 0x01, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA, 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x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0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94,
0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC, 0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
SignedCms sp = new SignedCms ();
sp.Decode (signature);
sp.CheckSignature (true);
CheckSignatureProperties (sp, 1);
}
[Test]
public void CheckSignatureCmsSignerSubjectKeyIdentifier ()
{
byte[] signature = { 0x30, 0x82, 0x03, 0x24, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x15, 0x30, 0x82, 0x03, 0x11, 0x02, 0x01, 0x03, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA, 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x32, 0x8A, 0x7E, 0xAD, 0xE7, 0x67, 0x9E, 0x5C, 0x4C, 0xD8, 0x33, 0x59, 0x68, 0xCF,
0x94, 0xC0, 0x36, 0x47, 0x7A, 0xA7, 0x85, 0xC2, 0xDD, 0xD8, 0xDA, 0x11, 0x3C, 0x66, 0xC1, 0x83, 0xE3, 0xAB, 0x33, 0x06, 0x7C, 0xE3, 0x6A, 0x15, 0x72, 0xB8, 0x83, 0x3D, 0x0B, 0xAB, 0x3C, 0xEE, 0x75, 0x13, 0xBD, 0x5C, 0x96, 0x25, 0x56, 0x36, 0x05, 0xFA, 0xAE, 0xD4, 0xF4, 0xCF, 0x52, 0xEC, 0x11, 0xB5, 0xEA, 0x9F, 0x20, 0xA3, 0xC8, 0x34, 0x72, 0x59, 0x09, 0x51, 0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0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC,
0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
SignedCms sp = new SignedCms ();
sp.Decode (signature);
sp.CheckSignature (true);
CheckSignatureProperties (sp, 3);
}
[Test]
public void CheckSignatureCmsSignerUnknown ()
{
byte[] signature = { 0x30, 0x82, 0x03, 0x4C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x3D, 0x30, 0x82, 0x03, 0x39, 0x02, 0x01, 0x01, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA, 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x32, 0x8A, 0x7E, 0xAD, 0xE7, 0x67, 0x9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0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94,
0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC, 0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
SignedCms sp = new SignedCms ();
sp.Decode (signature);
sp.CheckSignature (true);
CheckSignatureProperties (sp, 1);
}
[Test]
public void CheckSignatureDetachedSignedCms ()
{
string path = Path.Combine ("Test", "System.Security.Cryptography.Pkcs");
var signedBytes = File.ReadAllBytes (Path.Combine (path, "detached.data"));
var bytes = File.ReadAllBytes (Path.Combine (path, "detached.p7"));
var oid = new Oid ("1.2.840.113549.1.7.2");
var contentInfo = new ContentInfo (oid, signedBytes);
var signedCms = new SignedCms (contentInfo, true);
signedCms.Decode (bytes);
signedCms.CheckSignature (true);
}
}
}
#endif

View File

@@ -0,0 +1,139 @@
//
// SignerInfoCollectionTest.cs - NUnit tests for SignerInfoCollection
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class SignerInfoCollectionTest {
private SignerInfoCollection GetCollection ()
{
SignerInfo si = SignerInfoTest.GetSignerInfo (SignerInfoTest.subjectKeyIdentifierSignature);
return si.CounterSignerInfos;
}
[Test]
public void EmptyCollection ()
{
SignerInfoCollection sic = GetCollection ();
Assert.AreEqual (0, sic.Count, "Count");
Assert.IsFalse (sic.IsSynchronized, "IsSynchronized");
Assert.IsNotNull (sic.SyncRoot, "SyncRoot");
Assert.IsNotNull (sic.GetEnumerator (), "GetEnumerator");
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Indexer_MinusOne ()
{
SignerInfoCollection sic = GetCollection ();
Assert.IsNotNull (sic[-1]);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void Indexer_One ()
{
SignerInfoCollection sic = GetCollection ();
Assert.IsNotNull (sic[1]);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyTo_ArrayInt_Null ()
{
SignerInfoCollection sic = GetCollection ();
sic.CopyTo ((Array)null, 0);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void CopyTo_ArrayInt_MinusOne ()
{
ArrayList al = new ArrayList ();
SignerInfoCollection sic = GetCollection ();
sic.CopyTo (al.ToArray (), -1);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void CopyTo_ArrayInt_One ()
{
ArrayList al = new ArrayList ();
SignerInfoCollection sic = GetCollection ();
sic.CopyTo (al.ToArray (), 1);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CopyTo_SignerInfoInt_Null ()
{
SignerInfoCollection sic = GetCollection ();
sic.CopyTo ((SignerInfo[])null, 0);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void CopyTo_SignerInfoInt_MinusOne ()
{
SignerInfo[] sis = new SignerInfo[1];
SignerInfoCollection sic = GetCollection ();
sic.CopyTo (sis, -1);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void CopyTo_SignerInfoInt_One ()
{
SignerInfo[] sis = new SignerInfo[1];
SignerInfoCollection sic = GetCollection ();
sic.CopyTo (sis, 1);
}
[Test]
public void CopyTo_SignerInfoInt_Zero ()
{
SignerInfo[] sis = new SignerInfo[1];
SignerInfoCollection sic = GetCollection ();
sic.CopyTo (sis, 0);
}
}
}
#endif

View File

@@ -0,0 +1,107 @@
//
// SignerInfoTest.cs - NUnit tests for SignerInfo
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class SignerInfoTest {
static byte[] asnNull = { 0x05, 0x00 };
static string sha1Oid = "1.3.14.3.2.26";
static string sha1Name = "sha1";
static internal byte[] issuerAndSerialNumberSignature = { 0x30, 0x82, 0x03, 0x4C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x3D, 0x30, 0x82, 0x03, 0x39, 0x02, 0x01, 0x01, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0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xC6, 0xEA, 0x02, 0x76, 0x01, 0xE0, 0xBB, 0x8A, 0x70, 0xEB, 0x07, 0x86, 0xE8, 0x04, 0xE7, 0x48, 0xE4, 0x6C, 0x90, 0xE6, 0x16, 0x42, 0xB4, 0xBB, 0xC0, 0xC4, 0x82, 0x5F, 0xF8, 0xFB, 0x7E, 0xB2, 0x9E, 0xC2, 0x78, 0x26, 0x86, 0x31, 0x81, 0xE1, 0x30, 0x81, 0xDE, 0x02, 0x01, 0x01, 0x30, 0x3C, 0x30, 0x28,
0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94,
0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC, 0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
static internal byte[] subjectKeyIdentifierSignature = { 0x30, 0x82, 0x03, 0x24, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x15, 0x30, 0x82, 0x03, 0x11, 0x02, 0x01, 0x03, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA, 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x32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, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94, 0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC,
0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
static internal SignerInfo GetSignerInfo (byte[] signature)
{
SignedCms sp = new SignedCms ();
sp.Decode (signature);
return sp.SignerInfos [0];
}
[Test]
public void IssuerAndSerialNumberProperties ()
{
SignerInfo si = GetSignerInfo (issuerAndSerialNumberSignature);
// default properties
Assert.AreEqual (0, si.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (si.Certificate, "Certificate");
Assert.AreEqual (0, si.CounterSignerInfos.Count, "CounterSignerInfos");
Assert.AreEqual (sha1Name, si.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, si.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, si.SignerIdentifier.Type, "SignerIdentifier.Type");
Assert.IsTrue ((si.SignerIdentifier.Value.GetType () == typeof (X509IssuerSerial)), "SignerIdentifier.Value");
Assert.AreEqual (0, si.UnsignedAttributes.Count, "UnsignedAttributes");
Assert.AreEqual (1, si.Version, "Version");
}
[Test]
public void SubjectKeyIdentifierProperties ()
{
SignerInfo si = GetSignerInfo (subjectKeyIdentifierSignature);
// default properties
Assert.AreEqual (0, si.SignedAttributes.Count, "SignedAttributes");
Assert.IsNotNull (si.Certificate, "Certificate");
Assert.AreEqual (0, si.CounterSignerInfos.Count, "CounterSignerInfos");
Assert.AreEqual (sha1Name, si.DigestAlgorithm.FriendlyName, "DigestAlgorithm.FriendlyName");
Assert.AreEqual (sha1Oid, si.DigestAlgorithm.Value, "DigestAlgorithm.Value");
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, si.SignerIdentifier.Type, "SignerIdentifier.Type");
Assert.AreEqual ("02E1A73254AEFDC0A43236F6FE236A037228B1F7", (string)si.SignerIdentifier.Value, "SignerIdentifier.Value");
Assert.AreEqual (0, si.UnsignedAttributes.Count, "UnsignedAttributes");
Assert.AreEqual (3, si.Version, "Version");
}
}
}
#endif

View File

@@ -0,0 +1,90 @@
//
// SubjectIdentifierTest.cs - NUnit tests for SubjectIdentifier
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
namespace MonoTests.System.Security.Cryptography.Pkcs {
[TestFixture]
public class SubjectIdentifierTest {
static byte[] issuerAndSerialNumberSignature = { 0x30, 0x82, 0x03, 0x4C, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x3D, 0x30, 0x82, 0x03, 0x39, 0x02, 0x01, 0x01, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA, 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x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 0x74, 0x29, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x81, 0x80, 0x45, 0x88, 0x80, 0x58, 0xC7, 0x4F, 0xE4, 0xD8, 0x88, 0xB0, 0xC0, 0x08, 0x70, 0x84, 0xCC, 0x8E, 0xA7, 0xF1, 0xA4, 0x07, 0x41, 0x14, 0x3E, 0xF5, 0xEA, 0x6E, 0x05, 0x75, 0xB8, 0x58, 0xAA, 0x5C, 0x0E, 0xFD, 0x7A, 0x07, 0x09, 0xE1, 0x80, 0x94,
0xBD, 0xAA, 0x45, 0xBB, 0x55, 0x9C, 0xC2, 0xD9, 0x72, 0x14, 0x4B, 0xA4, 0x64, 0xFB, 0x38, 0x9F, 0xD3, 0x22, 0xED, 0xB3, 0x0B, 0xF7, 0xAE, 0x4D, 0xE6, 0x65, 0x4D, 0x2A, 0x31, 0x18, 0xB5, 0xB4, 0x2D, 0x9E, 0x4E, 0xD7, 0xC0, 0x44, 0x5F, 0xAC, 0x43, 0xDC, 0x4F, 0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
static byte[] subjectKeyIdentifierSignature = { 0x30, 0x82, 0x03, 0x24, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x03, 0x15, 0x30, 0x82, 0x03, 0x11, 0x02, 0x01, 0x03, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x30, 0x11, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x04, 0x04, 0x02, 0x05, 0x00, 0xA0, 0x82, 0x02, 0x2E, 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65,
0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32,
0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1, 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B,
0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0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0x3D, 0x6D, 0x2C, 0x8C, 0xA1, 0xFE, 0x08, 0x38, 0xB7, 0xC4, 0xC4, 0x08, 0xDB, 0xF8, 0xF0, 0xC1, 0x55, 0x54, 0x49, 0x9D, 0xA4, 0x7F, 0x76, 0xDE, 0xF4, 0x29, 0x1C, 0x0B, 0x95, 0x10, 0x90, 0xB5, 0x0A, 0x9A, 0xEC, 0xCA, 0x89, 0x9A, 0x85, 0x92, 0x76, 0x78, 0x6F, 0x97, 0x67 };
private SubjectIdentifier GetSubjectIdentifier (byte[] signature)
{
SignedCms sp = new SignedCms ();
sp.Decode (signature);
return sp.SignerInfos [0].SignerIdentifier;
}
[Test]
public void IssuerAndSerialNumber ()
{
SubjectIdentifier si = GetSubjectIdentifier (issuerAndSerialNumberSignature);
Assert.AreEqual (SubjectIdentifierType.IssuerAndSerialNumber, si.Type, "SignerIdentifier.Type");
Assert.IsTrue ((si.Value.GetType () == typeof (X509IssuerSerial)), "SignerIdentifier.Value");
X509IssuerSerial xis = (X509IssuerSerial) si.Value;
Assert.AreEqual ("CN=Motus Technologies inc.(test)", xis.IssuerName, "X509IssuerSerial.IssuerName");
Assert.AreEqual ("91C44B0DB7D81084422671B397B50097", xis.SerialNumber, "X509IssuerSerial.SerialNumber");
}
[Test]
public void SubjectKeyIdentifier ()
{
SubjectIdentifier si = GetSubjectIdentifier (subjectKeyIdentifierSignature);
Assert.AreEqual (SubjectIdentifierType.SubjectKeyIdentifier, si.Type, "Type");
Assert.AreEqual ("02E1A73254AEFDC0A43236F6FE236A037228B1F7", (string)si.Value, "SignerIdentifier.Value");
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More