2 // Pkcs7Signer.cs - System.Security.Cryptography.Pkcs.Pkcs7Signer
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Security.Cryptography.X509Certificates;
36 namespace System.Security.Cryptography.Pkcs {
38 public sealed class Pkcs7Signer {
40 private SubjectIdentifierType _signer;
41 private X509CertificateEx _certificate;
43 private X509IncludeOption _options;
44 private Pkcs9AttributeCollection _auth;
45 private Pkcs9AttributeCollection _unauth;
51 _signer = SubjectIdentifierType.IssuerAndSerialNumber;
52 _digest = new Oid ("1.3.14.3.2.26");
53 _options = X509IncludeOption.ExcludeRoot;
54 _auth = new Pkcs9AttributeCollection ();
55 _unauth = new Pkcs9AttributeCollection ();
58 public Pkcs7Signer (SubjectIdentifierType signerIdentifierType) : this ()
60 if (signerIdentifierType == SubjectIdentifierType.Unknown)
61 _signer = SubjectIdentifierType.IssuerAndSerialNumber;
63 _signer = signerIdentifierType;
66 public Pkcs7Signer (SubjectIdentifierType signerIdentifierType, X509CertificateEx certificate)
67 : this (signerIdentifierType)
69 // FIXME: compatibility with fx 1.2.3400.0
70 // if (certificate == null)
71 // throw new ArgumentNullException ("certificate");
72 _certificate = certificate;
75 public Pkcs7Signer (X509CertificateEx certificate) : this ()
77 // FIXME: compatibility with fx 1.2.3400.0
78 // if (certificate == null)
79 // throw new ArgumentNullException ("certificate");
80 _certificate = certificate;
85 public Pkcs9AttributeCollection AuthenticatedAttributes {
89 public X509CertificateEx Certificate {
90 get { return _certificate; }
91 set { _certificate = value; }
94 public Oid DigestAlgorithm {
95 get { return _digest; }
96 set { _digest = value; }
99 public X509IncludeOption IncludeOption {
100 get { return _options; }
101 set { _options = value; }
104 public SubjectIdentifierType SignerIdentifierType {
105 get { return _signer; }
107 if (value == SubjectIdentifierType.Unknown)
108 throw new ArgumentException ("value");
114 public Pkcs9AttributeCollection UnauthenticatedAttributes {
115 get { return _unauth; }