void getAttributes(Asn1Reader asn)
 {
     asn.MoveNext();
     if (asn.PayloadLength == 0)
     {
         return;
     }
     do
     {
         X509Attribute attribute = X509Attribute.Decode(asn.GetTagRawData());
         if (attribute.Oid.Value == X509ExtensionOid.CertificateExtensions)
         {
             //Extensions
             var extensions = new X509ExtensionCollection();
             extensions.Decode(attribute.RawData);
             foreach (X509Extension extension in extensions)
             {
                 _extensions.Add(extension);
             }
         }
         else
         {
             _attributes.Add(attribute);
         }
     } while (asn.MoveNextCurrentLevel());
 }
Exemplo n.º 2
0
 void decodePkcs7()
 {
     ExternalData       = new PKCS7SignedMessage(RawData);
     Version            = ((X509CertificateRequest[])ExternalData.Content)[0].Version;
     SubjectDn          = ((X509CertificateRequest[])ExternalData.Content)[0].SubjectDn;
     PublicKey          = ((X509CertificateRequest[])ExternalData.Content)[0].PublicKey;
     SignatureIsValid   = ((X509CertificateRequest[])ExternalData.Content)[0].SignatureIsValid;
     SignatureAlgorithm = ((X509CertificateRequest[])ExternalData.Content)[0].SignatureAlgorithm;
     foreach (X509Attribute attrib in ((X509CertificateRequest[])ExternalData.Content)[0].Attributes)
     {
         _attribs.Add(attrib);
     }
     foreach (X509Extension ext in ((X509CertificateRequest[])ExternalData.Content)[0].Extensions)
     {
         exts.Add(ext);
     }
 }
Exemplo n.º 3
0
        void decodeUnauthAttr(Wincrypt.CRYPT_ATTRIBUTES unauthAttrs)
        {
            if (unauthAttrs.cAttr == 0)
            {
                return;
            }
            IntPtr rgValue = unauthAttrs.rgAttr;
            Int32  size    = Marshal.SizeOf(typeof(Wincrypt.CRYPT_ATTRIBUTE));

            UnauthenticatedAttributes = new X509AttributeCollection();
            for (Int32 index = 0; index < unauthAttrs.cAttr; index++)
            {
                Wincrypt.CRYPT_ATTRIBUTE attr = (Wincrypt.CRYPT_ATTRIBUTE)Marshal.PtrToStructure(rgValue, typeof(Wincrypt.CRYPT_ATTRIBUTE));
                UnauthenticatedAttributes.Add(new X509Attribute(attr));
                rgValue += size;
            }
        }
Exemplo n.º 4
0
        void get_ctlentries()
        {
            if (CTLInfo.cCTLEntry > 0)
            {
                Entries = new X509CTLEntryCollection();
                IntPtr rgCTLEntry = CTLInfo.rgCTLEntry;
                for (Int32 index = 0; index < CTLInfo.cCTLEntry; index++)
                {
                    StringBuilder           SB         = new StringBuilder();
                    X509AttributeCollection attributes = new X509AttributeCollection();

                    Wincrypt.CTL_ENTRY CTLEntry = (Wincrypt.CTL_ENTRY)Marshal.PtrToStructure(rgCTLEntry, typeof(Wincrypt.CTL_ENTRY));
                    byte[]             bytes    = new Byte[CTLEntry.SubjectIdentifier.cbData];
                    Marshal.Copy(CTLEntry.SubjectIdentifier.pbData, bytes, 0, bytes.Length);
                    foreach (Byte item in bytes)
                    {
                        SB.Append($"{item:X2}");
                    }
                    String thumbprint = SB.ToString();
                    if (CTLEntry.cAttribute > 0)
                    {
                        IntPtr rgAttribute = CTLEntry.rgAttribute;
                        for (Int32 indexx = 0; indexx < CTLEntry.cAttribute; indexx++)
                        {
                            Wincrypt.CRYPT_ATTRIBUTE attrib = (Wincrypt.CRYPT_ATTRIBUTE)Marshal.PtrToStructure(rgAttribute, typeof(Wincrypt.CRYPT_ATTRIBUTE));
                            Oid pszOid = new Oid(attrib.pszObjId);
                            Wincrypt.CRYPTOAPI_BLOB blob = (Wincrypt.CRYPTOAPI_BLOB)Marshal.PtrToStructure(attrib.rgValue, typeof(Wincrypt.CRYPTOAPI_BLOB));
                            bytes = new Byte[blob.cbData];
                            Marshal.Copy(blob.pbData, bytes, 0, bytes.Length);
                            attributes.Add(new X509Attribute(pszOid, bytes));
                            rgAttribute = (IntPtr)((UInt64)rgAttribute + (UInt32)Marshal.SizeOf(typeof(Wincrypt.CRYPT_ATTRIBUTE)));
                        }
                    }
                    Entries.Add(new X509CTLEntry(thumbprint, attributes));
                    rgCTLEntry = (IntPtr)((UInt64)rgCTLEntry + (UInt32)Marshal.SizeOf(typeof(Wincrypt.CTL_ENTRY)));
                }
            }
        }