public void DecodeX509KeyUsageExtension(byte[] encoded, out X509KeyUsageFlags keyUsages) { unsafe { uint keyUsagesAsUint = 0; encoded.DecodeObject( CryptDecodeObjectStructType.X509_KEY_USAGE, delegate(void *pvDecoded, int cbDecoded) { Debug.Assert(cbDecoded >= sizeof(CRYPT_BIT_BLOB)); CRYPT_BIT_BLOB *pBlob = (CRYPT_BIT_BLOB *)pvDecoded; keyUsagesAsUint = 0; byte *pbData = pBlob->pbData; if (pbData != null) { Debug.Assert((uint)pBlob->cbData < 3, "Unexpected length for X509_KEY_USAGE data"); switch (pBlob->cbData) { case 1: keyUsagesAsUint = *pbData; break; case 2: keyUsagesAsUint = *(ushort *)(pbData); break; } } } ); keyUsages = (X509KeyUsageFlags)keyUsagesAsUint; } }
public void DecodeX509KeyUsageExtension(byte[] encoded, out X509KeyUsageFlags keyUsages) { unsafe { uint keyUsagesAsUint = 0; encoded.DecodeObject( CryptDecodeObjectStructType.X509_KEY_USAGE, delegate(void *pvDecoded) { CRYPT_BIT_BLOB *pBlob = (CRYPT_BIT_BLOB *)pvDecoded; keyUsagesAsUint = 0; if (pBlob->pbData != null) { keyUsagesAsUint = *(uint *)(pBlob->pbData); } } ); keyUsages = (X509KeyUsageFlags)keyUsagesAsUint; } }