/// <summary> /// Parse X509 Certificate Chain /// (parser index is updated according to parsed length) /// </summary> /// <param name="data">data to be parsed</param> /// <param name="currentIndex">current parser index</param> /// <param name="size">cert data size</param> /// <returns>X509 Certificate Chain</returns> private X509_CERTIFICATE_CHAIN ParseX509CertificateChain(byte[] data, ref int currentIndex, int size) { X509_CERTIFICATE_CHAIN cert = new X509_CERTIFICATE_CHAIN(); cert.NumCertBlobs = (int)ParseUInt32(data, ref currentIndex, false); for (int i = 0; i < cert.CertBlobArray.Length; i++) { cert.CertBlobArray[i].cbCert = (int)ParseUInt32(data, ref currentIndex, false); cert.CertBlobArray[i].abCert = GetBytes(data, ref currentIndex, cert.CertBlobArray[i].cbCert); } cert.Padding = GetBytes(data, ref currentIndex, 8 + 4 * cert.NumCertBlobs); return cert; }