internal static unsafe X509IssuerSerial DecodeIssuerSerial(CAPI.CERT_ISSUER_SERIAL_NUMBER pIssuerAndSerial) { SafeLocalAllocHandle invalidHandle = SafeLocalAllocHandle.InvalidHandle; uint csz = CAPI.CAPISafe.CertNameToStrW(65537U, new IntPtr((void *)&pIssuerAndSerial.Issuer), 33554435U, invalidHandle, 0U); if (csz <= 1U) { throw new CryptographicException(Marshal.GetLastWin32Error()); } SafeLocalAllocHandle psz = CAPI.LocalAlloc(0U, new IntPtr((long)(2U * csz))); if (CAPI.CAPISafe.CertNameToStrW(65537U, new IntPtr((void *)&pIssuerAndSerial.Issuer), 33554435U, psz, csz) <= 1U) { throw new CryptographicException(Marshal.GetLastWin32Error()); } X509IssuerSerial x509IssuerSerial = new X509IssuerSerial(); x509IssuerSerial.IssuerName = Marshal.PtrToStringUni(psz.DangerousGetHandle()); byte[] numArray = new byte[(IntPtr)pIssuerAndSerial.SerialNumber.cbData]; Marshal.Copy(pIssuerAndSerial.SerialNumber.pbData, numArray, 0, numArray.Length); x509IssuerSerial.SerialNumber = X509Utils.EncodeHexStringFromInt(numArray); psz.Dispose(); return(x509IssuerSerial); }
internal static string EncodeHexStringFromInt(byte[] sArray) { return(X509Utils.EncodeHexStringFromInt(sArray, 0U, (uint)sArray.Length)); }