Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@@ -1,80 +0,0 @@
//
// AlgorithmIdentifier.cs - System.Security.Cryptography.Pkcs.AlgorithmIdentifier
//
// 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 SECURITY_DEP
namespace System.Security.Cryptography.Pkcs {
public sealed class AlgorithmIdentifier {
private Oid _oid;
private int _length;
private byte[] _params;
// constructors
public AlgorithmIdentifier ()
{
_oid = new Oid ("1.2.840.113549.3.7", "3des");
_params = new byte [0];
}
public AlgorithmIdentifier (Oid oid)
{
_oid = oid;
_params = new byte [0];
}
public AlgorithmIdentifier (Oid oid, int keyLength)
{
_oid = oid;
_length = keyLength;
_params = new byte [0];
}
// properties
public int KeyLength {
get { return _length; }
set { _length = value; }
}
public Oid Oid {
get { return _oid; }
set { _oid = value; }
}
public byte[] Parameters {
get { return _params; }
set { _params = value; }
}
}
}
#endif

View File

@@ -1,74 +0,0 @@
//
// System.Security.Cryptography.Pkcs.CmsRecipient class
//
// 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.
//
using System.Collections;
using System.Security.Cryptography.X509Certificates;
namespace System.Security.Cryptography.Pkcs {
public sealed class CmsRecipient {
private SubjectIdentifierType _recipient;
private X509Certificate2 _certificate;
// constructor
public CmsRecipient (X509Certificate2 certificate)
{
if (certificate == null)
throw new ArgumentNullException ("certificate");
_recipient = SubjectIdentifierType.IssuerAndSerialNumber;
_certificate = certificate;
}
public CmsRecipient (SubjectIdentifierType recipientIdentifierType, X509Certificate2 certificate)
{
if (certificate == null)
throw new ArgumentNullException ("certificate");
if (recipientIdentifierType == SubjectIdentifierType.Unknown)
_recipient = SubjectIdentifierType.IssuerAndSerialNumber;
else
_recipient = recipientIdentifierType;
_certificate = certificate;
}
// properties
public X509Certificate2 Certificate {
get { return _certificate; }
}
public SubjectIdentifierType RecipientIdentifierType {
get { return _recipient; }
}
}
}

View File

@@ -1,114 +0,0 @@
//
// System.Security.Cryptography.Pkcs.CmsRecipientCollection class
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2004-2005, 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 SECURITY_DEP
using System.Collections;
using System.Security.Cryptography.X509Certificates;
namespace System.Security.Cryptography.Pkcs {
public sealed class CmsRecipientCollection : ICollection, IEnumerable {
private ArrayList _list;
// constructors
public CmsRecipientCollection ()
{
_list = new ArrayList ();
}
public CmsRecipientCollection (CmsRecipient recipient)
{
_list.Add (recipient);
}
public CmsRecipientCollection (SubjectIdentifierType recipientIdentifierType, X509Certificate2Collection certificates)
{
// no null check, MS throws a NullReferenceException here
foreach (X509Certificate2 x509 in certificates) {
CmsRecipient p7r = new CmsRecipient (recipientIdentifierType, x509);
_list.Add (p7r);
}
}
// properties
public int Count {
get { return _list.Count; }
}
public bool IsSynchronized {
get { return _list.IsSynchronized; }
}
public CmsRecipient this [int index] {
get { return (CmsRecipient) _list [index]; }
}
public object SyncRoot {
get { return _list.SyncRoot; }
}
// methods
public int Add (CmsRecipient recipient)
{
return _list.Add (recipient);
}
public void CopyTo (Array array, int index)
{
_list.CopyTo (array, index);
}
public void CopyTo (CmsRecipient[] array, int index)
{
_list.CopyTo (array, index);
}
public CmsRecipientEnumerator GetEnumerator ()
{
return new CmsRecipientEnumerator (_list);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return new CmsRecipientEnumerator (_list);
}
public void Remove (CmsRecipient recipient)
{
_list.Remove (recipient);
}
}
}
#endif

View File

@@ -1,70 +0,0 @@
//
// System.Security.Cryptography.Pkcs.CmsRecipientEnumerator
//
// 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.
//
using System;
using System.Collections;
namespace System.Security.Cryptography.Pkcs {
public sealed class CmsRecipientEnumerator : IEnumerator {
private IEnumerator enumerator;
// constructors
internal CmsRecipientEnumerator (IEnumerable enumerable)
{
enumerator = enumerable.GetEnumerator ();
}
// properties
public CmsRecipient Current {
get { return (CmsRecipient) enumerator.Current; }
}
object IEnumerator.Current {
get { return enumerator.Current; }
}
// methods
public bool MoveNext ()
{
return enumerator.MoveNext ();
}
public void Reset ()
{
enumerator.Reset ();
}
}
}

View File

@@ -1,123 +0,0 @@
//
// System.Security.Cryptography.Pkcs.CmsSigner class
//
// 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 SECURITY_DEP
using System.Security.Cryptography.X509Certificates;
namespace System.Security.Cryptography.Pkcs {
public sealed class CmsSigner {
private SubjectIdentifierType _signer;
private X509Certificate2 _certificate;
private X509Certificate2Collection _coll;
private Oid _digest;
private X509IncludeOption _options;
private CryptographicAttributeObjectCollection _signed;
private CryptographicAttributeObjectCollection _unsigned;
// constructors
public CmsSigner ()
{
_signer = SubjectIdentifierType.IssuerAndSerialNumber;
_digest = new Oid ("1.3.14.3.2.26");
_options = X509IncludeOption.ExcludeRoot;
_signed = new CryptographicAttributeObjectCollection ();
_unsigned = new CryptographicAttributeObjectCollection ();
_coll = new X509Certificate2Collection ();
}
public CmsSigner (SubjectIdentifierType signerIdentifierType) : this ()
{
if (signerIdentifierType == SubjectIdentifierType.Unknown)
_signer = SubjectIdentifierType.IssuerAndSerialNumber;
else
_signer = signerIdentifierType;
}
public CmsSigner (SubjectIdentifierType signerIdentifierType, X509Certificate2 certificate)
: this (signerIdentifierType)
{
_certificate = certificate;
}
public CmsSigner (X509Certificate2 certificate) : this ()
{
_certificate = certificate;
}
[MonoTODO]
public CmsSigner (CspParameters parameters) : this ()
{
}
// properties
public CryptographicAttributeObjectCollection SignedAttributes {
get { return _signed; }
}
public X509Certificate2 Certificate {
get { return _certificate; }
set { _certificate = value; }
}
public X509Certificate2Collection Certificates {
get { return _coll; }
}
public Oid DigestAlgorithm {
get { return _digest; }
set { _digest = value; }
}
public X509IncludeOption IncludeOption {
get { return _options; }
set { _options = value; }
}
public SubjectIdentifierType SignerIdentifierType {
get { return _signer; }
set {
if (value == SubjectIdentifierType.Unknown)
throw new ArgumentException ("value");
_signer = value;
}
}
public CryptographicAttributeObjectCollection UnsignedAttributes {
get { return _unsigned; }
}
}
}
#endif

View File

@@ -1,112 +0,0 @@
//
// System.Security.Cryptography.Pkcs.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 SECURITY_DEP
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
/*
* ContentInfo ::= SEQUENCE {
* contentType ContentType,
* content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
* }
* ContentType ::= OBJECT IDENTIFIER
*/
public sealed class ContentInfo {
private Oid _oid;
private byte[] _content;
// constructors
public ContentInfo (byte[] content)
: this (new Oid ("1.2.840.113549.1.7.1"), content)
{
}
public ContentInfo (Oid contentType, byte[] content)
{
if (contentType == null)
throw new ArgumentNullException ("contentType");
if (content == null)
throw new ArgumentNullException ("content");
_oid = contentType;
_content = content;
}
~ContentInfo ()
{
}
// properties
public byte[] Content {
get { return (byte[]) _content.Clone (); }
}
public Oid ContentType {
get { return _oid; }
}
// static methods
[MonoTODO ("MS is stricter than us about the content structure")]
public static Oid GetContentType (byte[] encodedMessage)
{
if (encodedMessage == null)
throw new ArgumentNullException ("algorithm");
try {
PKCS7.ContentInfo ci = new PKCS7.ContentInfo (encodedMessage);
switch (ci.ContentType) {
case PKCS7.Oid.data:
case PKCS7.Oid.signedData: // see SignedCms class
case PKCS7.Oid.envelopedData: // see EnvelopedCms class
case PKCS7.Oid.digestedData:
case PKCS7.Oid.encryptedData:
return new Oid (ci.ContentType);
default:
// Note: the constructor will accept any "valid" OID (but that
// doesn't mean it's a valid ContentType structure - ASN.1 wise).
string msg = Locale.GetText ("Bad ASN1 - invalid OID '{0}'");
throw new CryptographicException (String.Format (msg, ci.ContentType));
}
}
catch (Exception e) {
throw new CryptographicException (Locale.GetText ("Bad ASN1 - invalid structure"), e);
}
}
}
}
#endif

View File

@@ -27,221 +27,25 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP
using System.Collections;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
using System.Text;
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
// References
// a. PKCS #7: Cryptographic Message Syntax, Version 1.5, Section 10
// http://www.faqs.org/rfcs/rfc2315.html
public sealed class EnvelopedCms {
private ContentInfo _content;
private AlgorithmIdentifier _identifier;
private X509Certificate2Collection _certs;
private RecipientInfoCollection _recipients;
private CryptographicAttributeObjectCollection _uattribs;
private SubjectIdentifierType _idType;
private int _version;
// constructors
public EnvelopedCms ()
{
_certs = new X509Certificate2Collection ();
_recipients = new RecipientInfoCollection ();
_uattribs = new CryptographicAttributeObjectCollection ();
}
public EnvelopedCms (ContentInfo contentInfo) : this ()
{
if (contentInfo == null)
throw new ArgumentNullException ("contentInfo");
_content = contentInfo;
}
public EnvelopedCms (ContentInfo contentInfo, AlgorithmIdentifier encryptionAlgorithm)
: this (contentInfo)
{
if (encryptionAlgorithm == null)
throw new ArgumentNullException ("encryptionAlgorithm");
_identifier = encryptionAlgorithm;
}
public sealed partial class EnvelopedCms {
public EnvelopedCms (SubjectIdentifierType recipientIdentifierType, ContentInfo contentInfo)
: this (contentInfo)
{
_idType = recipientIdentifierType;
if (_idType == SubjectIdentifierType.SubjectKeyIdentifier)
_version = 2;
if (recipientIdentifierType == SubjectIdentifierType.SubjectKeyIdentifier)
Version = 2;
}
public EnvelopedCms (SubjectIdentifierType recipientIdentifierType, ContentInfo contentInfo, AlgorithmIdentifier encryptionAlgorithm)
: this (contentInfo, encryptionAlgorithm)
{
_idType = recipientIdentifierType;
if (_idType == SubjectIdentifierType.SubjectKeyIdentifier)
_version = 2;
if (recipientIdentifierType == SubjectIdentifierType.SubjectKeyIdentifier)
Version = 2;
}
// properties
public X509Certificate2Collection Certificates {
get { return _certs; }
}
public AlgorithmIdentifier ContentEncryptionAlgorithm {
get {
if (_identifier == null)
_identifier = new AlgorithmIdentifier ();
return _identifier;
}
}
public ContentInfo ContentInfo {
get {
if (_content == null) {
Oid oid = new Oid (PKCS7.Oid.data);
_content = new ContentInfo (oid, new byte [0]);
}
return _content;
}
}
public RecipientInfoCollection RecipientInfos {
get { return _recipients; }
}
public CryptographicAttributeObjectCollection UnprotectedAttributes {
get { return _uattribs; }
}
public int Version {
get { return _version; }
}
// methods
private X509IssuerSerial GetIssuerSerial (string issuer, byte[] serial)
{
X509IssuerSerial xis = new X509IssuerSerial ();
xis.IssuerName = issuer;
StringBuilder sb = new StringBuilder ();
foreach (byte b in serial)
sb.Append (b.ToString ("X2"));
xis.SerialNumber = sb.ToString ();
return xis;
}
[MonoTODO]
public void Decode (byte[] encodedMessage)
{
if (encodedMessage == null)
throw new ArgumentNullException ("encodedMessage");
PKCS7.ContentInfo ci = new PKCS7.ContentInfo (encodedMessage);
if (ci.ContentType != PKCS7.Oid.envelopedData)
throw new Exception ("");
PKCS7.EnvelopedData ed = new PKCS7.EnvelopedData (ci.Content);
Oid oid = new Oid (ed.ContentInfo.ContentType);
_content = new ContentInfo (oid, new byte [0]); //ed.ContentInfo.Content.Value);
foreach (PKCS7.RecipientInfo ri in ed.RecipientInfos) {
Oid o = new Oid (ri.Oid);
AlgorithmIdentifier ai = new AlgorithmIdentifier (o);
SubjectIdentifier si = null;
if (ri.SubjectKeyIdentifier != null) {
si = new SubjectIdentifier (SubjectIdentifierType.SubjectKeyIdentifier, ri.SubjectKeyIdentifier);
}
else if ((ri.Issuer != null) && (ri.Serial != null)) {
X509IssuerSerial xis = GetIssuerSerial (ri.Issuer, ri.Serial);
si = new SubjectIdentifier (SubjectIdentifierType.IssuerAndSerialNumber, (object)xis);
}
KeyTransRecipientInfo _keyTrans = new KeyTransRecipientInfo (ri.Key, ai, si, ri.Version);
_recipients.Add (_keyTrans);
}
// TODO - Certificates
// TODO - UnprotectedAttributes
_version = ed.Version;
}
[MonoTODO]
public void Decrypt ()
{
throw new InvalidOperationException ("not encrypted");
}
[MonoTODO]
public void Decrypt (RecipientInfo recipientInfo)
{
if (recipientInfo == null)
throw new ArgumentNullException ("recipientInfo");
Decrypt ();
}
[MonoTODO]
public void Decrypt (RecipientInfo recipientInfo, X509Certificate2Collection extraStore)
{
if (recipientInfo == null)
throw new ArgumentNullException ("recipientInfo");
if (extraStore == null)
throw new ArgumentNullException ("extraStore");
Decrypt ();
}
[MonoTODO]
public void Decrypt (X509Certificate2Collection extraStore)
{
if (extraStore == null)
throw new ArgumentNullException ("extraStore");
Decrypt ();
}
[MonoTODO]
public byte[] Encode ()
{
throw new InvalidOperationException ("not encrypted");
}
[MonoTODO]
public void Encrypt ()
{
if ((_content == null) || (_content.Content == null) || (_content.Content.Length == 0))
throw new CryptographicException ("no content to encrypt");
}
[MonoTODO]
public void Encrypt (CmsRecipient recipient)
{
if (recipient == null)
throw new ArgumentNullException ("recipient");
// TODO
Encrypt ();
}
[MonoTODO]
public void Encrypt (CmsRecipientCollection recipients)
{
if (recipients == null)
throw new ArgumentNullException ("recipients");
// ? foreach on Encrypt CmsRecipient ?
Encrypt (new CmsRecipientCollection ());
}
}
}
#endif

View File

@@ -1,73 +0,0 @@
//
// System.Security.Cryptography.Pkcs.KeyAgreeRecipientInfo class
//
// 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 SECURITY_DEP
namespace System.Security.Cryptography.Pkcs {
[MonoTODO]
public sealed class KeyAgreeRecipientInfo : RecipientInfo {
// only accessible from EnvelopedCms.RecipientInfos
internal KeyAgreeRecipientInfo ()
: base (RecipientInfoType.KeyAgreement)
{
}
public DateTime Date {
get { return DateTime.MinValue; }
}
public override byte[] EncryptedKey {
get { return null; }
}
public override AlgorithmIdentifier KeyEncryptionAlgorithm {
get { return null; }
}
public SubjectIdentifierOrKey OriginatorIdentifierOrKey {
get { return null; }
}
public CryptographicAttributeObject OtherKeyAttribute {
get { return null; }
}
public override SubjectIdentifier RecipientIdentifier {
get { return null; }
}
public override int Version {
get { return 0; }
}
}
}
#endif

View File

@@ -1,71 +0,0 @@
//
// KeyTransRecipientInfo.cs - System.Security.Cryptography.Pkcs.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 SECURITY_DEP
using System.Collections;
namespace System.Security.Cryptography.Pkcs {
public sealed class KeyTransRecipientInfo : RecipientInfo {
private byte[] _encryptedKey;
private AlgorithmIdentifier _keyEncryptionAlgorithm;
private SubjectIdentifier _recipientIdentifier;
private int _version;
// only accessible from EnvelopedCms.RecipientInfos
internal KeyTransRecipientInfo (byte[] encryptedKey, AlgorithmIdentifier keyEncryptionAlgorithm, SubjectIdentifier recipientIdentifier, int version)
: base (RecipientInfoType.KeyTransport)
{
_encryptedKey = encryptedKey;
_keyEncryptionAlgorithm = keyEncryptionAlgorithm;
_recipientIdentifier = recipientIdentifier;
_version = version;
}
public override byte[] EncryptedKey {
get { return _encryptedKey; }
}
public override AlgorithmIdentifier KeyEncryptionAlgorithm {
get { return _keyEncryptionAlgorithm; }
}
public override SubjectIdentifier RecipientIdentifier {
get { return _recipientIdentifier; }
}
public override int Version {
get { return _version; }
}
}
}
#endif

View File

@@ -1,79 +0,0 @@
//
// System.Security.Cryptography.Pkcs.Pkcs9AttributeObject class
//
// 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 SECURITY_DEP
using System.Collections;
namespace System.Security.Cryptography.Pkcs {
public class Pkcs9AttributeObject : AsnEncodedData {
// constructors
public Pkcs9AttributeObject ()
: base ()
{
}
public Pkcs9AttributeObject (AsnEncodedData asnEncodedData)
: base (asnEncodedData)
{
}
public Pkcs9AttributeObject (Oid oid, byte[] encodedData)
{
if (oid == null)
throw new ArgumentNullException ("oid");
base.Oid = oid;
RawData = encodedData;
}
public Pkcs9AttributeObject (string oid, byte[] encodedData)
: base (oid, encodedData)
{
}
// this (sadly) removes the "set" accessor
public new Oid Oid {
get { return base.Oid; }
internal set { base.Oid = value; }
}
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
if (asnEncodedData == null)
throw new ArgumentNullException ("asnEncodedData");
throw new ArgumentException ("Cannot convert the PKCS#9 attribute.");
}
}
}
#endif

View File

@@ -1,111 +0,0 @@
//
// Pkcs9ContentType.cs - System.Security.Cryptography.Pkcs.Pkcs9ContentType
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) Tim Coleman, 2004
// 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 SECURITY_DEP
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
public sealed class Pkcs9ContentType : Pkcs9AttributeObject {
internal const string oid = "1.2.840.113549.1.9.3";
internal const string friendlyName = "Content Type";
private Oid _contentType;
private byte[] _encoded;
// constructors
public Pkcs9ContentType ()
{
// Pkcs9Attribute remove the "set" accessor on Oid :-(
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_encoded = null;
}
internal Pkcs9ContentType (string contentType)
{
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_contentType = new Oid (contentType);
RawData = Encode ();
_encoded = null;
}
internal Pkcs9ContentType (byte[] encodedContentType)
{
if (encodedContentType == null)
throw new ArgumentNullException ("encodedContentType");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
RawData = encodedContentType;
Decode (encodedContentType);
}
// properties
public Oid ContentType {
get {
if (_encoded != null)
Decode (_encoded);
return _contentType;
}
}
// methods
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
base.CopyFrom (asnEncodedData);
_encoded = asnEncodedData.RawData;
}
// internal stuff
internal void Decode (byte[] attribute)
{
if ((attribute == null) || (attribute [0] != 0x06))
throw new CryptographicException (Locale.GetText ("Expected an OID."));
ASN1 oid = new ASN1 (attribute);
_contentType = new Oid (ASN1Convert.ToOid (oid));
_encoded = null;
}
internal byte[] Encode ()
{
if (_contentType == null)
return null;
return ASN1Convert.FromOid (_contentType.Value).GetBytes ();
}
}
}
#endif

View File

@@ -1,105 +0,0 @@
//
// System.Security.Cryptography.Pkcs.Pkcs9DocumentDescription class
//
// 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 SECURITY_DEP
using System.Text;
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
public sealed class Pkcs9DocumentDescription : Pkcs9AttributeObject {
internal const string oid = "1.3.6.1.4.1.311.88.2.2";
internal const string friendlyName = null;
private string _desc;
public Pkcs9DocumentDescription ()
{
// Pkcs9Attribute remove the "set" accessor on Oid :-(
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
}
public Pkcs9DocumentDescription (string documentDescription)
{
if (documentDescription == null)
throw new ArgumentNullException ("documentName");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_desc = documentDescription;
RawData = Encode ();
}
public Pkcs9DocumentDescription (byte[] encodedDocumentDescription)
{
if (encodedDocumentDescription == null)
throw new ArgumentNullException ("encodedDocumentDescription");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
RawData = encodedDocumentDescription;
Decode (encodedDocumentDescription);
}
public string DocumentDescription {
get { return _desc; }
}
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
base.CopyFrom (asnEncodedData);
Decode (this.RawData);
}
// internal stuff
internal void Decode (byte[] attribute)
{
if (attribute [0] != 0x04)
return; // throw ?
ASN1 attr = new ASN1 (attribute);
byte[] str = attr.Value;
int length = str.Length;
if (str [length - 2] == 0x00)
length -= 2; // zero-terminated (normal)
_desc = Encoding.Unicode.GetString (str, 0, length);
}
internal byte[] Encode ()
{
// OCTETSTRING (0x04) Of the zero-terminated unicode string
ASN1 attr = new ASN1 (0x04, Encoding.Unicode.GetBytes (_desc + (char)0));
return attr.GetBytes ();
}
}
}
#endif

View File

@@ -1,105 +0,0 @@
//
// Pkcs9DocumentName.cs - System.Security.Cryptography.Pkcs.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 SECURITY_DEP
using System.Text;
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
public sealed class Pkcs9DocumentName : Pkcs9AttributeObject {
internal const string oid = "1.3.6.1.4.1.311.88.2.1";
internal const string friendlyName = null;
private string _name;
public Pkcs9DocumentName ()
{
// Pkcs9Attribute remove the "set" accessor on Oid :-(
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
}
public Pkcs9DocumentName (string documentName)
{
if (documentName == null)
throw new ArgumentNullException ("documentName");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_name = documentName;
RawData = Encode ();
}
public Pkcs9DocumentName (byte[] encodedDocumentName)
{
if (encodedDocumentName == null)
throw new ArgumentNullException ("encodedDocumentName");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
RawData = encodedDocumentName;
Decode (encodedDocumentName);
}
public string DocumentName {
get { return _name; }
}
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
base.CopyFrom (asnEncodedData);
Decode (this.RawData);
}
// internal stuff
internal void Decode (byte[] attribute)
{
if (attribute [0] != 0x04)
return; // throw ?
ASN1 attr = new ASN1 (attribute);
byte[] str = attr.Value;
int length = str.Length;
if (str [length - 2] == 0x00)
length -= 2; // zero-terminated (normal)
_name = Encoding.Unicode.GetString (str, 0, length);
}
internal byte[] Encode ()
{
// OCTETSTRING (0x04) Of the zero-terminated unicode string
ASN1 attr = new ASN1 (0x04, Encoding.Unicode.GetBytes (_name + (char)0));
return attr.GetBytes ();
}
}
}
#endif

View File

@@ -1,109 +0,0 @@
//
// System.Security.Cryptography.Pkcs.Pkcs9MessageDigest class
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) Tim Coleman, 2004
// 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 SECURITY_DEP
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
public sealed class Pkcs9MessageDigest : Pkcs9AttributeObject {
internal const string oid = "1.2.840.113549.1.9.4";
internal const string friendlyName = "Message Digest";
private byte[] _messageDigest;
private byte[] _encoded;
// constructors
public Pkcs9MessageDigest ()
{
// Pkcs9Attribute remove the "set" accessor on Oid :-(
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_encoded = null;
}
internal Pkcs9MessageDigest (byte[] messageDigest, bool encoded)
{
if (messageDigest == null)
throw new ArgumentNullException ("messageDigest");
if (encoded) {
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
RawData = messageDigest;
Decode (messageDigest);
} else {
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_messageDigest = (byte[]) _messageDigest.Clone ();
RawData = Encode ();
}
}
// properties
public byte[] MessageDigest {
get {
if (_encoded != null)
Decode (_encoded);
// FIXME: beta2 returns a reference
return _messageDigest;
}
}
// methods
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
base.CopyFrom (asnEncodedData);
_encoded = asnEncodedData.RawData;
}
// internal stuff
internal void Decode (byte[] attribute)
{
if ((attribute == null) || (attribute [0] != 0x04))
throw new CryptographicException (Locale.GetText ("Expected an OCTETSTRING."));
ASN1 md = new ASN1 (attribute);
_messageDigest = md.Value;
_encoded = null;
}
internal byte[] Encode ()
{
ASN1 md = new ASN1 (0x04, _messageDigest);
return md.GetBytes ();
}
}
}
#endif

View File

@@ -1,114 +0,0 @@
//
// System.Security.Cryptography.Pkcs.Pkcs9SigningTime class
//
// 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 SECURITY_DEP
using System.Globalization;
using System.Text;
using Mono.Security;
namespace System.Security.Cryptography.Pkcs {
public sealed class Pkcs9SigningTime : Pkcs9AttributeObject {
internal const string oid = "1.2.840.113549.1.9.5";
internal const string friendlyName = "Signing Time";
private DateTime _signingTime;
public Pkcs9SigningTime ()
{
// Pkcs9Attribute remove the "set" accessor on Oid :-(
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_signingTime = DateTime.Now;
RawData = Encode ();
}
public Pkcs9SigningTime (DateTime signingTime)
{
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
_signingTime = signingTime;
RawData = Encode ();
}
public Pkcs9SigningTime (byte[] encodedSigningTime)
{
if (encodedSigningTime == null)
throw new ArgumentNullException ("encodedSigningTime");
(this as AsnEncodedData).Oid = new Oid (oid, friendlyName);
RawData = encodedSigningTime;
Decode (encodedSigningTime);
}
public DateTime SigningTime {
get { return _signingTime; }
}
public override void CopyFrom (AsnEncodedData asnEncodedData)
{
if (asnEncodedData == null)
throw new ArgumentNullException ("asnEncodedData");
Decode (asnEncodedData.RawData);
Oid = asnEncodedData.Oid;
RawData = asnEncodedData.RawData;
}
// internal stuff
internal void Decode (byte[] attribute)
{
// Only UTCTIME is supported by FX 2.0
if (attribute [0] != 0x17)
throw new CryptographicException (Locale.GetText ("Only UTCTIME is supported."));
ASN1 attr = new ASN1 (attribute);
byte[] value = attr.Value;
string date = Encoding.ASCII.GetString (value, 0, value.Length - 1);
_signingTime = DateTime.ParseExact (date, "yyMMddHHmmss", null);
}
internal byte[] Encode ()
{
if (_signingTime.Year <= 1600)
throw new ArgumentOutOfRangeException ("<= 1600");
// Only UTCTIME is supported by FX 2.0
if ((_signingTime.Year < 1950) || (_signingTime.Year >= 2050))
throw new CryptographicException ("[1950,2049]");
string date = _signingTime.ToString ("yyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
ASN1 attr = new ASN1 (0x17, Encoding.ASCII.GetBytes (date));
return attr.GetBytes ();
}
}
}
#endif

View File

@@ -1,63 +0,0 @@
//
// PublicKeyInfo.cs - System.Security.Cryptography.Pkcs.PublicKeyInfo
//
// 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 SECURITY_DEP
using System;
namespace System.Security.Cryptography.Pkcs {
public sealed class PublicKeyInfo {
private AlgorithmIdentifier _algorithm;
private byte[] _key;
// constructors
// only used in KeyAgreeRecipientInfo.OriginatorIdentifierOrKey.Value
// when SubjectIdentifierOrKeyType == PublicKeyInfo
internal PublicKeyInfo (AlgorithmIdentifier algorithm, byte[] key)
{
_algorithm = algorithm;
_key = key;
}
// properties
public AlgorithmIdentifier Algorithm {
get { return _algorithm; }
}
public byte[] KeyValue {
get { return _key; }
}
}
}
#endif

View File

@@ -1,65 +0,0 @@
//
// RecipientInfo.cs - System.Security.Cryptography.Pkcs.RecipientInfo
//
// 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 SECURITY_DEP
using System;
namespace System.Security.Cryptography.Pkcs {
public abstract class RecipientInfo {
private RecipientInfoType _type;
// constructors
// documented as protected at http://longhorn.msdn.microsoft.com
// but not present in the 1.2 beta SDK
internal RecipientInfo (RecipientInfoType recipInfoType)
{
_type = recipInfoType;
}
// properties
public abstract byte[] EncryptedKey { get; }
public abstract AlgorithmIdentifier KeyEncryptionAlgorithm { get; }
public abstract SubjectIdentifier RecipientIdentifier { get; }
public RecipientInfoType Type {
get { return _type; }
}
public abstract int Version { get; }
}
}
#endif

View File

@@ -1,94 +0,0 @@
//
// RecipientInfoCollection.cs - System.Security.Cryptography.Pkcs.RecipientInfoCollection
//
// 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 SECURITY_DEP
using System;
using System.Collections;
namespace System.Security.Cryptography.Pkcs {
public sealed class RecipientInfoCollection : ICollection {
private ArrayList _list;
// only accessible from EnvelopedPkcs7.RecipientInfos
internal RecipientInfoCollection ()
{
_list = new ArrayList ();
}
// properties
public int Count {
get { return _list.Count; }
}
public bool IsSynchronized {
get { return _list.IsSynchronized; }
}
public RecipientInfo this [int index] {
get { return (RecipientInfo) _list [index]; }
}
public object SyncRoot {
get { return _list.SyncRoot; }
}
// methods
internal int Add (RecipientInfo ri)
{
return _list.Add (ri);
}
public void CopyTo (Array array, int index)
{
_list.CopyTo (array, index);
}
public void CopyTo (RecipientInfo[] array, int index)
{
_list.CopyTo (array, index);
}
public RecipientInfoEnumerator GetEnumerator ()
{
return new RecipientInfoEnumerator (_list);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return new RecipientInfoEnumerator (_list);
}
}
}
#endif

View File

@@ -1,72 +0,0 @@
//
// RecipientInfoEnumerator.cs - System.Security.Cryptography.Pkcs.RecipientInfoEnumerator
//
// 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 SECURITY_DEP
using System;
using System.Collections;
namespace System.Security.Cryptography.Pkcs {
public sealed class RecipientInfoEnumerator : IEnumerator {
private IEnumerator enumerator;
// constructors
internal RecipientInfoEnumerator (IEnumerable enumerable)
{
enumerator = enumerable.GetEnumerator ();
}
// properties
public RecipientInfo Current {
get { return (RecipientInfo) enumerator.Current; }
}
object IEnumerator.Current {
get { return enumerator.Current; }
}
// methods
public bool MoveNext ()
{
return enumerator.MoveNext ();
}
public void Reset ()
{
enumerator.Reset ();
}
}
}
#endif

View File

@@ -1,41 +0,0 @@
//
// RecipientInfoType.cs - System.Security.Cryptography.Pkcs.RecipientInfoType
//
// 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.
//
using System;
namespace System.Security.Cryptography.Pkcs {
public enum RecipientInfoType {
Unknown,
KeyTransport,
KeyAgreement
}
}

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