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
0
votes
1 answer
CryptoAPI: difference Between CALG_* and BCRYPT_*_ALGORITHM
What is the difference between CALG_* and BCRYPT_*_ALGORITHM
for example: SHA_256 is defined both as:
#define CALG_SHA_256 (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_SHA_256)
and
#define BCRYPT_SHA256_ALGORITHM L"SHA256"

Wheatley
- 153
- 1
- 12
0
votes
1 answer
.NET - Porting RSACryptoServiceProvider to CNG for signing data
I'm trying to port an RSA signing function written in C#, from the (relatively easy to use) RSACryptoServiceProvider.SignHash method, to the CNG API, in order to use a specific cryptographic service provider.
This is the original (before porting)…

fernacolo
- 7,012
- 5
- 40
- 61
0
votes
3 answers
CNG provider, how to convert an EC key to BCRYPT_ECCKEY_BLOB structure?
I am writing a CNG provider. Specifically, stuck on implementing NCryptExportKey API. I am trying to convert an EC key (for signing, ECDSA256) from a hardware key manager. The h/w keymanager provides key in ASN format. I referred to MSDN…

Maulik Soni
- 79
- 1
- 5
0
votes
1 answer
c++ Import RSA private key in CAPI/CNG from xml
I read in this question about Importing a public key from native components.
I tried doing the same for private key based on the BLOB documentation, but I'm getting a NTE_BAD_DATA error.
Is my idea feasible? If so, Can you help?
My Try:
void…

Orr Goldman
- 35
- 1
- 7
0
votes
0 answers
Not able to Initializing a new instance of the RSACng class with a specified key pair
I want to create a new instance of RSACng class but with a specified key pair.
var rsa = new RSACng();
The above will initialize a new instance of the RSACng class with a random 2,048-bit key pair.
However we can pass an instance of CngKey while…

Darshnik Swamy
- 61
- 1
- 11
0
votes
1 answer
Structure of the certificate pointed to by NCRYPT_KEY_HANDLE
I've written a credential provider and a key storage provider to logon to windows via certificate. As the documentation in this points is quite vague I used different samples from Microsoft to get things working.
I think I'm nearly there, but the…

Frank
- 2,036
- 1
- 20
- 32
0
votes
1 answer
Mapping of access mask in DACL for CNG keys
(Note: IMO the question is mainly about WinAPI and DACL and not about CNG, so please read on!)
I'm currently trying to modify the sample CNG key storage provider of Microsoft's Cryptographic Provider Development Kit in such a way that it does not…

dannyM
- 108
- 4
0
votes
1 answer
Key does not exist - using self signed ECDSA certificate
I have an issue with digitally signing an XML message. Requirements dictate that an ECDSA certificate is to be used with a specific curve. Meaning that the RSA and DSA functionality that is provided by the SignedXml.ComputeSignature(...) method…

Geek
- 415
- 4
- 16
0
votes
1 answer
Random numbers for Windows Phone 8 and Windows Store 8?
I'm struggling with a port of a couple of security libraries to the Windows Phone 8 and Windows Store 8 platform. I need a function which provides random numbers.
Win32 has CryptGenRandom and even RtlGenRandom. Windows Store 10 and Universal Windows…

jww
- 97,681
- 90
- 411
- 885
0
votes
0 answers
Unresolved external symbol _BCryptEnumRegisteredProviders@8 when using CNG on Windows 10
I'm trying to do my first step with CNG (Cryptography Next Generation) in VC++ 2015 (Windows 10 x64). Here's the code:
#include "stdafx.h"
#include
int main()
{
NTSTATUS status;
ULONG cbBufSize = 0;
PCRYPT_PROVIDERS pBuf =…

Vova
- 53
- 7
0
votes
0 answers
Encryption/Decryption using bcrypt library
I am calling the BCryptDecrypt function which is returning an error. I get the error 120 using getlasterror which means this function is not supported in this system (in msdn).
status = BCryptDecrypt( hKey, pbInput, cbInput, NULL, NULL,…

Sarbjeet Singh
- 1
- 3
0
votes
3 answers
NCryptOpenKey()
I am trying to create a CNG (Windows Cryptography API Next Generation) key handle by calling NCryptOpenKey() and using the certificate's thumbprint as the key name parameter:
LPCWSTR keyName =…

kitomer
- 33
- 1
- 7
-1
votes
0 answers
Can't create a custom CSR using mmc and certificates snap-in on Windows 10
I am trying to generate a custom CSR using the certificates snap-in for mmc on Windows 10. The certificate I want to create is a client authentication cert using ECC. However, I have run into a persistent issue that is preventing me from generating…

hkc94501
- 1
-1
votes
1 answer
Getting the EC curve of a EC public key in CNG
I have a Public key in CNG (BCRYPT_KEY_HANDLE), and I need to know the curve it uses. I tried BCryptGetProperty with BCRYPT_ALGORITHM_NAME parameter, but it only gives ECDH_P256 back, not the exact curve type. I need to know if its prime256v1 or…

Zsolt Czikó
- 1
- 1
-1
votes
1 answer
CNGKey.Create won't persist
I'm playing with CNGKey and the storage. I would like to store the key, and later retrieve it for encryption.
I am usingCngKey.Create and I see that it is persisted in the file system. To test access to it, immediately after the Create command I get…

Moutabreath
- 184
- 1
- 6
- 19