mscorlib(4.0.0.0) API with additions
X509Extension.cs
2 
4 {
7  {
8  private bool m_critical;
9 
13  public bool Critical
14  {
15  get
16  {
17  return m_critical;
18  }
19  set
20  {
21  m_critical = value;
22  }
23  }
24 
25  internal X509Extension(string oid)
26  : base(new Oid(oid, System.Security.Cryptography.OidGroup.ExtensionOrAttribute, lookupFriendlyName: false))
27  {
28  }
29 
30  internal X509Extension(IntPtr pExtension)
31  {
32  CAPIBase.CERT_EXTENSION cERT_EXTENSION = (CAPIBase.CERT_EXTENSION)Marshal.PtrToStructure(pExtension, typeof(CAPIBase.CERT_EXTENSION));
33  m_critical = cERT_EXTENSION.fCritical;
34  string pszObjId = cERT_EXTENSION.pszObjId;
35  m_oid = new Oid(pszObjId, System.Security.Cryptography.OidGroup.ExtensionOrAttribute, lookupFriendlyName: false);
36  byte[] array = new byte[cERT_EXTENSION.Value.cbData];
37  if (cERT_EXTENSION.Value.pbData != IntPtr.Zero)
38  {
39  Marshal.Copy(cERT_EXTENSION.Value.pbData, array, 0, array.Length);
40  }
41  m_rawData = array;
42  }
43 
45  protected X509Extension()
46  {
47  }
48 
54  public X509Extension(string oid, byte[] rawData, bool critical)
55  : this(new Oid(oid, System.Security.Cryptography.OidGroup.ExtensionOrAttribute, lookupFriendlyName: true), rawData, critical)
56  {
57  }
58 
63  public X509Extension(AsnEncodedData encodedExtension, bool critical)
64  : this(encodedExtension.Oid, encodedExtension.RawData, critical)
65  {
66  }
67 
77  public X509Extension(Oid oid, byte[] rawData, bool critical)
78  : base(oid, rawData)
79  {
80  if (base.Oid == null || base.Oid.Value == null)
81  {
82  throw new ArgumentNullException("oid");
83  }
84  if (base.Oid.Value.Length == 0)
85  {
86  throw new ArgumentException(SR.GetString("Arg_EmptyOrNullString"), "oid.Value");
87  }
88  m_critical = critical;
89  }
90 
97  public override void CopyFrom(AsnEncodedData asnEncodedData)
98  {
99  if (asnEncodedData == null)
100  {
101  throw new ArgumentNullException("asnEncodedData");
102  }
103  X509Extension x509Extension = asnEncodedData as X509Extension;
104  if (x509Extension == null)
105  {
106  throw new ArgumentException(SR.GetString("Cryptography_X509_ExtensionMismatch"));
107  }
108  base.CopyFrom(asnEncodedData);
109  m_critical = x509Extension.Critical;
110  }
111  }
112 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Represents Abstract Syntax Notation One (ASN.1)-encoded data.
Oid Oid
Gets or sets the T:System.Security.Cryptography.Oid value for an T:System.Security....
Represents a cryptographic object identifier. This class cannot be inherited.
Definition: Oid.cs:6
The Windows group that is represented by CRYPT_EXT_OR_ATTR_OID_GROUP_ID.
X509Extension(Oid oid, byte[] rawData, bool critical)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
Definition: __Canon.cs:3
X509Extension(AsnEncodedData encodedExtension, bool critical)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
X509Extension()
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointe...
Definition: Marshal.cs:301
bool Critical
Gets a Boolean value indicating whether the extension is critical.
byte [] RawData
Gets or sets the Abstract Syntax Notation One (ASN.1)-encoded data represented in a byte array.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Definition: Marshal.cs:15
X509Extension(string oid, byte[] rawData, bool critical)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
The exception that is thrown when one of the arguments provided to a method is not valid.
static void PtrToStructure(IntPtr ptr, object structure)
Marshals data from an unmanaged block of memory to a managed object.
Definition: Marshal.cs:1198
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Definition: IntPtr.cs:20
override void CopyFrom(AsnEncodedData asnEncodedData)
Copies the extension properties of the specified T:System.Security.Cryptography.AsnEncodedData object...