title: How can I get a NCRYPT_KEY_HANDLE for the private key of a PCCERT_CONTEXT?
body: <p>How can I get a <code>NCRYPT_KEY_HANDLE</code> for encryption/decryption with CNG from the private key of a <code>PCCERT_CONTEXT</code> from the windows certificate store?</p>
  
  <p>The <code>CryptEncrypt</code> function has been superceded by the <code>NCryptEncrypt</code> and <code>BCryptEncrypt</code> functions, but there is no immediately apparent way of obtaining a handle for either of these functions from a <code>PCCERT_CONTEXT</code> from the Windows certificate store.</p>
  
  <p>Is it even possible to use the CNG functions for encryption/decryption using (private keys of) certificates without resolving to brute force approaches like exporting the certificate?</p>