CryptoAPI Next Generation (CNG) is the next version of the Windows CryptoAPI available since Vista. It adds NSA Suite B algoritms (including elliptic-curve cryptography) and is FIPS 140-2 certified.
Questions tagged [cng]
256 questions
1
vote
1 answer
CNG Microsoft Smart Card Key Storage Provider AcquireContext
I'm trying to acquire the Microsoft Smart Card Key Storage Provider using:
CryptAcquireContext(&hProv, contName ,L"Microsoft Smart Card Key Storage Provider", PROV_RSA_FULL , flags);
but, this fails with error: NTE_KEYSET_NOT_DEF (0x80090019)
if I…

dominik
- 1,319
- 13
- 23
1
vote
0 answers
How to create a self-signed Certificate using CLR Security to use with EnvelopedCms?
I am trying to create a self-signed Certificate using the CLR-Security library Security.Cryptography.dll (their homepage: http://clrsecurity.codeplex.com)
I am able to create the certificate and even to Encrypt with it,
but Decrypt fails with the…

Roman
- 91
- 10
1
vote
1 answer
Is there a way to view the ECDH Shared Secret generated within microsoft CNG?
I am trying to perform a ECDH key exchange between MS CNG and another device. In order to debug things, I would like to see what shared secret is being generated in CNG so i can compare it with the secret generated by my other device. Anybody know…

Daniel Scire
- 221
- 1
- 9
0
votes
1 answer
Random number and Microsoft CNG
I need to use the Microsoft CNG API to generate secure random numbers for cryptography.
Am I supposed to generate all the numbers using this API, or just obtain a seed value for another random generator from it?
Any help appreciated!
Thanks.

James
- 1,430
- 4
- 20
- 27
0
votes
0 answers
How to export public key with NCryptExportKey into a file
I've created a RSA key with NCryptCreatePersistedKey and then later I want to use the NCryptExportKey to export its public key into a blob then write out into a file (DER or PEM doesnt matter).
I've tried with this sample:
NCryptExportKey(
…

wildfrontier
- 25
- 1
- 6
0
votes
0 answers
Is there a way to log CNG function calls?
I need to log CNG(BCrypt/NCrypt) function calls. I've managed to find the respective channels in Windows Event Log, but they don't provide the complete information - some calls aren't logged, and the function argument values aren't logged. What I…

Макс
- 1
0
votes
0 answers
NCryptExportKey fails when trying to export RSA key
I'm trying to create a RSA private key with NCryptCreatePersistedKey and then later to export it into a BLOB with NCryptExportKey, but I don't understand why it fails.
This is how I create the private key:
if…

wildfrontier
- 25
- 1
- 6
0
votes
0 answers
CNG keyStore, MS Keystorage Provider Key expiration
"Hello, community! I have a couple of questions regarding the Microsoft key store provider. Firstly, does a key stored in the Microsoft key store provider expire automatically? I'm curious to know if there's a predefined expiration mechanism for…

Anup Deshpande
- 1
- 1
0
votes
0 answers
CngProvider.SetProviderProperty in .NET?
How to set a CNG provider property with .NET?
There is a CngKey.SetProperty method, but under the hood it calls SetKeyProperty. How to call SetProviderProperty instead? CngProvider does not seem to have a SetProperty method.

D.R.
- 20,268
- 21
- 102
- 205
0
votes
1 answer
Bcryptdecrypt unable to decrypt data correctly
I have some data that was previously encrtypted with cryptdecrypt APIs. Since it is deprecated I am supposed to move to the latest bcryptdecrypt (CNG)APIs. But with this code I am not able to decrypt the data correctly. I still see junk in…

RituV
- 63
- 1
- 9
0
votes
0 answers
How to duplicate NCRYPT_KEY_HANDLE?
How do I duplicate NCRYPT_KEY_HANDLE? With BCRYPT_KEY_HANDLE one might have used BCryptDuplicateKey() from bcrypt.h but I cannot seem to find a similar function for this data type.

Lipovlan
- 23
- 1
- 5
0
votes
1 answer
Updating from Windows CryptDecrypt() to NCryptDecrypt() returns NTE_INVALID_PARAMETER(0x80090027) or STATUS_UNSUCCESSFUL(0xC0000001)?
Currently updating from Windows CryptDecrypt() [API is deprecated] to NCryptDecrypt() [Cryptography Next Generation].
The minimal sample code below tries to encrypt/decrypt using RSA 1024-bit.
Running with Microsoft Visual Studio Professional 2019,…

vengy
- 1,548
- 10
- 18
0
votes
0 answers
How do I correctly print a ciphertext encrypted by BCryptEncrypt?
I am trying to use BCryptEncrypt to encrypt some basic plain text and I would like to save it in a Notepad; but I want to actually print and see the encrypted text in the console. What is the correct format for wprintf?
Here's part of my code:
//…

Sergio Calderon
- 837
- 1
- 13
- 32
0
votes
1 answer
BCryptDecrypt failes with STATUS_INVALID_PARAMETER
I am trying to RSA encrypt an buffer using Windows api cng's Bcrypt library. But my first call to BCryptDecrypt failes with STATUS_INVALID_PARAMETER...
status = BCryptDecrypt(
hKey,
pbEncryptedBuffer,
cbEncryptedBuffer,
…

woldgrep
- 97
- 2
- 12
0
votes
0 answers
Converting CNG RSA BLOB to openssl BLOB?
I want to make application windows exchange pair key and use it in openssl php , how I can change BCRYPT_RSAKEY_BLOB to openSSL ?
I used but RSA SEQUENCE still deffrent :
PBYTE pbASN;
// Length of the ASN.1 encoded key
DWORD cbASN;
// Generate the…

dree3
- 1
- 1