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
Converting a .NET ECDSA P1363 signature to a Bouncy Castle ASN.1 Signature
I am trying to use an existing ECDSA key from .NET (CNG provider) so sign data with Bouncy Castle and then to convert between the two signature formats (P1363 and ASN.1). However, I always end up with different signatures. I am not quite sure…

terminal
- 105
- 1
- 8
1
vote
0 answers
Different label and MGF1 hash functions using RsaCng with OAEP
We've to decrypt a ciphertext encrypted using RSA OAEP and we're trying to use RsaCng. The ciphertext was produced using Java, and the Java API allows you to specify a different hash function for the label and for the mask generation function…

Dinis Paes
- 11
- 1
1
vote
1 answer
How to use BCrypt for RSA (asymmetric encryption)
I'm trying to make simple working example of encryption and decryption with BCrypt but I'm can't get it to work because I don't understand exactly how.
From BCryptEncrypt Function, Microsoft Docs:
NTSTATUS BCryptEncrypt(
BCRYPT_KEY_HANDLE hKey,
…

roberto carlos
- 83
- 1
- 9
1
vote
0 answers
Use Custom CNG provider to get Private key from the HSM
I have our own CNG provider. Using c# with .net framework 4.6.1 with window 7. I am using clrsecurity.
string fp = "223298a5c7c9f78a42d83a5ffbxxxxxxxx";
//string fp = "331ffa497d90d19446171f85xxxxxxxx"; //MS
// Load the certificate with the…

jiten
- 5,128
- 4
- 44
- 73
1
vote
1 answer
How to determine which of 23 parameters are STATUS_INVALID_PARAMETER?
I'm trying to use BCryptEncrypt to authenticate some AAD but the function is failing with STATUS_INVALID_PARAMETER. BCryptEncrypt takes 10 parameters. One of the parameters is BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.…

jww
- 97,681
- 90
- 411
- 885
1
vote
0 answers
SetProperty on CngKey always updates the key while Assign permission to machine key. Is this right behaviour?
SetProperty on CngKey while giving access on machineKey always updates the CngKey. Is this correct behaviour?
I am setting permissions ACL on the CngKey. When permissions are set on the key using SetProperty, it gets updated every time i apply the…

sagar yadwad
- 133
- 1
- 3
- 11
1
vote
0 answers
in Xamarin.Forms CngKey.Create shows "operation not implemented" error
I develop Xamarin.Forms Application and right now I'm debugging it on my Android device (it's 4.4 ver. of Android, if it matters). I need to use cryptography with ECDsa, so I've found that System.Security.Cryptography.Cng is needed for…

Drovosek2703
- 45
- 6
1
vote
1 answer
std::ifstream read file as BYTE (unsigned char) not char
I'm using Microsoft's CNG Cryptography API's to compute the hash of a file, so far all works fine except that computed hash is wrong comparing to hash computed with external 3rd party program.
I'm not 100% sure but I think the problem is that I read…
user11157650
1
vote
0 answers
Does Windows have AEAD API? (c.f. CryptProtectData, but using a key)
Does Windows provide a high-level, tested, supported, function to perform authenticated encryption using a symmetric key?
Of course AEAD (Authenticated Encryption with Additional Data) would be better. But this question is only asking AE…

Ian Boyd
- 246,734
- 253
- 869
- 1,219
1
vote
6 answers
Convert HEX to printable string/char
I'm using CNG to generate a hash.
Result of BCryptFinishHash call is MD5 of a input in hex form.
Example:
char *outHash = "\x02\x34\x75\01..."
I want to convert it to printable string: 02347501...
How can I do that?

Keet Kate
- 107
- 8
1
vote
1 answer
Opening Encryption Key Works in Powershell Not in C#
I am opening an encryption key stored in an HSM. I have the HSM's client library installed on my machine. If I run the following Windows Powershell snippet:
##Open an existing Key
$keyName = 'foo'
$providername = 'SafeNetProtectApp Key Storage…

Adam
- 3,891
- 3
- 19
- 42
1
vote
1 answer
How to use bcrypt_gensalt with /dev/urandom on Windows?
I used this BCrypt lib to generate a hash with salt: https://github.com/rg3/libbcrypt
The problem is in bcrypt.c (int bcrypt_gensalt). open("/dev/urandom", O_RDONLY) does not work on Windows. I have tried the following:
int bcrypt_gensalt(int…

Zhavok
- 31
- 4
1
vote
1 answer
RSACng and CngKeyBlobFormat import and export formats
I have a ASN.1 encoded RSA private key in a pem file in this format:
-----BEGIN RSA PRIVATE KEY-----
base64 encoded pkcs8 key
-----END RSA PRIVATE KEY-----
Now, to import it into my RSACng object I neeed to follow these steps:
Read the file and…

karolyzz
- 480
- 4
- 28
1
vote
1 answer
BCRYPT_XTS_AES_ALGORITHM CNG algorithm fails in BCryptGenerateSymmetricKey API
I am trying to use Windows CNG BCRYPT_XTS_AES_ALGORITHM algorithm to encrypt and decrypt the files. As part of this, I had written the following code for encryption and decryption.
When I use this code with BCRYPT_AES_ALGORITHM algorithm, both…

Dev
- 21
- 3
1
vote
1 answer
CngKey Assign permission to machine key
I've created a machine wide CngKey (MachineKey=true), but my applications aren't able to access it.
How to I assign permissions to so that my App Pool can access the key? Preferably pragmatically so that I can build it into the installer.…

Swifty
- 1,422
- 2
- 18
- 38