Questions tagged [cng]

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.

256 questions
2
votes
1 answer

Windows CNG ECDH Secret Agreement structure

I've spent a few days by searching what structure does ECDH secret agreement have, but no success. I found in MSDN that the NCryptSecretAgreement function sets a pointer to an NCRYPT_SECRET_HANDLE variable that receives a handle that represents the…
wilkexx
  • 113
  • 1
  • 7
2
votes
1 answer

RSACryptoServiceProvider.VerifyData doesn't work properly on different Windows versions

Introduction I have a digital code signing logic in my application. I use custom signing tool which signs dll files and create .sig text files with signed hash values. This tool runs on .NET 6, gets assembly list, path to pfx certificate file and a…
2
votes
1 answer

Store a known AES key with CngKey by name for later use

I want to store a known AES key (retrieved offline) by entering it into the application once, saving it to Cng for storage, then reference it only by name on subsequent use. I want to save the key in the Key Storage Provider so my application won't…
Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80
2
votes
1 answer

Certificate private key permissions in .NET 6

I'm trying to import a certificate with private key into the Windows Certificate Store. I can successfully import the certificate using the below X509Certificate2 certificate = new(certByteArray, certPassword, X509KeyStorageFlags.PersistKeySet |…
SpeedBird527
  • 149
  • 2
  • 4
  • 18
2
votes
0 answers

Cipher text generated by OpenSSL and Windows CNG is different for AES-128-CFB

I am encrypting the same plain text with AES-128-CFB but ciphertext generated by "Windows Cryptography API: Next Generation" and OpenSSL are different for the same IV, and key. Plain Text: The quick brown fox jumps over the lazy dog IV:…
Pavan
  • 507
  • 1
  • 3
  • 15
2
votes
1 answer

How to verify JWT token with ES384 algorithm with Nodejs tools signed with JwtSecurityTokenHandler using CNG keys

I'm trying to verify JWT token with Node.js tools signed with JwtSecurityTokenHandler using CNG generated keys I tried many Nood.js tools e.g. jsonwebtoken jwt.verify(token, publickey,{ algorithms: ['ES384'], ... But get wrong tag errors every…
2
votes
0 answers

Decrypt RijndaelManaged in C++ (CNG)

The C# code below outputs 0123456789012345678901234567890123456789: static void Main(string[] args) { byte[] salt = Encoding.ASCII.GetBytes("saltycrack"); …
Hans Malherbe
  • 2,988
  • 24
  • 19
2
votes
0 answers

Check if the legacy CSP supports 'PP_KEYSET_SEC_DESCR' flag

I imported a pfx in windows certificate store via GUI. When I checked the output of 'certutil -store my CN' it showed CSP as 'Microsoft Enhanced Cryptographic Provider v1.0' which is legacy CSP not the new CNG one. I'm using windows 2012 server. ( I…
Suraj
  • 184
  • 1
  • 14
2
votes
1 answer

Possible to encrypt non-multiple of 16 bytes when chaining BCryptEncrypt calls using AES in GCM mode?

Is it possible, using Windows CNG API and AES in GCM mode, to encrypt a buffer of data with a size that is not a multiple of 16 bytes (128 bits) when chaining is enabled? When I try to pass a buffer of 60 bytes to the BCryptEncrypt function with…
Pineapple
  • 61
  • 1
  • 4
2
votes
1 answer

CngKey import from a ECSsaP192 public key

I'm working on verifying a signature which public key is provided as MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEMyHD625uvsmGq4C43cQ9BnfN2xslVT5V1nOmAMP6qaRRUll3PB1JYmgSm+62sosG After a lot of research I think it is a ECDsaP192 standard key (Correct me if…
Emile
  • 187
  • 5
  • 17
2
votes
0 answers

Is there a way to require initial authentication before reading Minidriver containers?

I'm developing a Minidriver for a smartcard that requires card access number (CAN, printed on a card to prevent contactless skimming of the data) to read the public data (certificates) on it. The usual workflow with this card is: CAN…
2
votes
0 answers

Can desktop application users retrieve a key from a CNG keystore residing on a LAN server

I am trying to come up to speed on the ABCs of CNG. My goal is to secure a persistent long-term symmetric key, similar to the situation in this question. If the symmetric key can be encrypted and stored as a ciphertext in the application's…
Tim
  • 8,669
  • 31
  • 105
  • 183
2
votes
0 answers

How to Sign with RSA private key by CNG

1. How to sign with RSA private key? (SOLVED) I followed this sample to sign data with private key. I only reserve hash and sign functions, and use ECDSA P-256 private key like the sample. Here are my steps and the program work…
Assam
  • 179
  • 1
  • 13
2
votes
1 answer

How to convert CNG key to OpenSSL EVP_PKEY (and vice versa)?

I am writing a custom OpenSSL engine using Windows CNG API. While implementing the EVP_PKEY_meths to generate and use ECDH keys, I came across the issue of converting keys from OpenSSL EVP_PKEY to CNG BCRYPT_KEY and vice versa. I am facing this…
themadking
  • 67
  • 1
  • 7
2
votes
1 answer

Compile errors when using C++ and bcrypt header

I'm trying to test Windows Bcrypt. I have a test program: #include #include #include #pragma comment (lib, "bcrypt.lib") int main(int argc, char* argv[]) { return 0; } Attempting to compile it: >cl.exe…
jww
  • 97,681
  • 90
  • 411
  • 885