private static unsafe byte[] EncodeExtension(X509KeyUsageFlags keyUsages) { CAPIBase.CRYPT_BIT_BLOB crypt_bit_blob = new CAPIBase.CRYPT_BIT_BLOB { cbData = 2, pbData = new IntPtr((void*) &keyUsages), cUnusedBits = 0 }; byte[] encodedData = null; if (!CAPI.EncodeObject("2.5.29.15", new IntPtr((void*) &crypt_bit_blob), out encodedData)) { throw new CryptographicException(Marshal.GetLastWin32Error()); } return encodedData; }
internal CMSG_CTRL_KEY_AGREE_DECRYPT_PARA(int size) { this.cbSize = (uint) size; this.hCryptProv = IntPtr.Zero; this.dwKeySpec = 0; this.pKeyAgree = IntPtr.Zero; this.dwRecipientIndex = 0; this.dwRecipientEncryptedKeyIndex = 0; this.OriginatorPublicKey = new CAPIBase.CRYPT_BIT_BLOB(); }