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
0
votes
0 answers

Converting CNG RSA key pair to string and vice versa

I have started working on Windows CNG APIs. I am generating RSA keypair using BCRYPT_ALG_HANDLE alg; BCryptOpenAlgorithmProvider(out alg, BCRYPT_RSA_ALGORITHM, null, 0); BCRYPT_KEY_HANDLE key; BCryptGenerateKeyPair(alg, out key, 2048,…
0
votes
1 answer

C++ CNG NCrypt: Can't open persisted key from Key Storage Provider

I have two programms. One creates a persisted key and saves it to key storage provider, then signs the hash and write the sign to the regedit. Second program opens the key from provider and verifies the sign gotten from the regedit. But my problem…
Alexandr
  • 9
  • 2
0
votes
0 answers

Creating BCRYPT_ECCKEY_BLOB from a compressed key using Windows APIs only

Is there a way to create BCRYPT_ECCKEY_BLOB from a compressed key (say P256) using Windows API only and without linking to a big number library and performing EC math manually.
Kirill Kovalenko
  • 2,121
  • 16
  • 18
0
votes
1 answer

How to get public and private key from CNG (BCrypt) RSA algorithm?

I am kind of stuck, I want to generate new pair of public and private keys. But I can't find a way to extract them. I used this: (C++) status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RSA_ALGORITHM, …
B00t
  • 9
  • 3
0
votes
1 answer

How to encrypt data in one instance of Windows and decrypt in different OS instance running on the same system?

This is an extension of How to encrypt data in one app and decrypt it in different Windows app with RSA keys tied to local system?. From the linked question above, I was able to encrypt/decrypt data between multiple apps under same OS instance (i.e.…
videoguy
  • 1,732
  • 2
  • 24
  • 49
0
votes
1 answer

How to encrypt data in one app and decrypt it in different Windows app with RSA keys tied to local system?

I have a setup where I need to encrypt blob of data in one app and decrypt it in different app. I built a sample app that creates a named CngKey object. Then create a RSACng using CngKey object. Then use RSACng object to do encryption/decryption.…
videoguy
  • 1,732
  • 2
  • 24
  • 49
0
votes
1 answer

Always encrypted provisioning CNG with powershell exception

I'm having a problem while making a powershell script for creation of Always Encrypted column encryption keys When I run these functions from the SqlServer powershell module, I get the following error. # $cngProviderName "Microsoft Software Key…
Sotem
  • 25
  • 5
0
votes
1 answer

Microsoft Key Storage Provider get keys

I am trying to get the details of keys in Microsoft Key Storage Provider. For this I open the storage provider using the below API call: NCryptOpenStorageProvider(&prov, MS_KEY_STORAGE_PROVIDER, 0); Then I call NCryptEnumKeys in a while loop to get…
0
votes
0 answers

AES GCM BCryptDecrypt

I have this code in python and I am trying to convent it into C++ using CNG. What's wrong with code import sys sys.dont_write_bytecode = True #!/usr/bin/env python3 import hashlib,base64, binascii, argparse,sys,base64,hashlib,sys from…
osand
  • 1
  • 2
0
votes
0 answers

Import public key using Windows C CNG/Crypto API

I need to verify a signature on multiple platforms, say Windows and Linux. I am open to any public key format as long as I can write a platform-specific C code that can verify this signature using the provided public key (the same public key for…
Alexander
  • 2,761
  • 1
  • 28
  • 33
0
votes
0 answers

Creating IV for CNG encryption

I'm trying to rework the CNG encryption example in the Microsoft documentation. One peculiar thing about the example is that the encryption IV is hard coded. I don't know a lot about encryption but my understanding is that it is more secure to…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
0
votes
1 answer

.NET Framework RsaCng exception

I am learning about Cryptography in .NET and I wrote the following function as a test: byte[] foo(byte[] input, string keyContainerName) { CngKey key = CngKey.Open(keyContainerName); RSACng rsa = new RSACng(key); rsa.KeySize = 2048; …
0
votes
0 answers

Rsa decription with same key pair doesn't work

I am working on a cryptographic app in C# with .NET Framework. One of it's functions is to let the user store an (or multiple) RSA asymmetric key pair in the Windows KSP, export the public key to a BLOB and decrypt messages (in fact, it will use RSA…
0
votes
1 answer

Set ACL on private key in HSM

On Windows Server A, we can generate a key in an HSM, and make it available to AD CS. The key is used to generate a CSR, which is signed by a public CA, and imported into the cert store on the same host. Can use certutil -repairstore to link the…
rip...
  • 996
  • 5
  • 20
0
votes
1 answer

how to extend features of HSM (Linux) using MSCAPI in Windows?

I am newbie for HSM. I want to access crypto functionality from HSM in Linux environment using MSCAPI. My client requirement is HSM should be accessible using MSCAPI. So I am in great confusion with how to extend HSM (HSM running in Linux) features…
Virudhai Paul
  • 81
  • 1
  • 9