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
1 answer

Importing PKCS#8 encrypted key to RSACng?

If I have encrypted RSA key in PKCS#8, can I somehow import it to RSACng as CngKeyBlobFormat.Pkcs8PrivateBlob? Or does this CngKeyBlobFormat.Pkcs8PrivateBlob just shows the CngKey that during import the key must be decoded from DER to get key…
karolyzz
  • 480
  • 4
  • 28
0
votes
1 answer

Importing exported CngKey to RSA and exporting it again

I export a key in CngKeyBlobFormat.Pkcs8PrivateBlob format, then try to import this information into a new CngKey and then I try to export the new key again. Problem is, when you simply import a key with CngKey.Import() you can't choose the…
karolyzz
  • 480
  • 4
  • 28
0
votes
1 answer

Import a private RSACryptoServiceProvider blob into CNGKey.Import

From a legacy program: bye[] rsaPrivateKeyExport = RSACryptoProvider.ExportCspBlob(true); These keys are stored in a file. As part of a legacy refresh, I need to use CNG RSA keys. So something like reading the old blob and then converting: CngKey…
rbrayb
  • 46,440
  • 34
  • 114
  • 174
0
votes
0 answers

How to stop showing smartcard selection dialog in NCryptOpenKey from minidriver if key container not available

I am working on a minidriver project which can generate keypair in smartcard. To generate a keypair from a test application I have to check if there is a keypair exist with the specified container name, if found I have to delete that. To check if a…
iOS-Developer84
  • 654
  • 8
  • 19
0
votes
2 answers

Can someone explain C# CngKey.Import please?

I'm encrypting a db using Always Encrypted with the master key in the software ksp. The key is created with CngKey.Create, I can also export it, but I'm stuck after that. Using the CngKey.Import creates a non-named key, meaning IsEphemeral=true, so…
Swifty
  • 1,422
  • 2
  • 18
  • 38
0
votes
0 answers

Generate private key in specific pkcs8 format (custom CNG)

I have a task to develope a CNG. I got a working source code of CNG which supports some algorithms like GOST and etc. I need to make it to generate private key (pkcs8 format) and support x509 certificates in other structures. For example: this is…
0
votes
0 answers

own CryptoProvider for Windows 10

I am required to make my own realization of the crypto algorithm and make it available for Windows applications. I made a crypto provider library for working through CryptoAPI under the instruction (in the article Service Provider Cookbook), except…
Robert
  • 11
  • 3
0
votes
1 answer

How to reliably arrive at a non negative serial number from a SHA1 hash?

I am using CNG to generate serial numbers for certificates. My algorithm takes the common name of the Certificate Authority, appends 10 random bytes and then computes a SHA1 hash of that. The SHA1 hash is consistently 20 bytes in length and I use…
Timothy John Laird
  • 1,101
  • 2
  • 13
  • 24
0
votes
1 answer

Why are CNG requirements in .NET lower than in unmanaged CNG?

Is there a logical reason why the minimum requirements for CNG in .NET and in unmanaged code are so inconsistent? For example, NCryptDeleteKey (unmanaged CNG) requires Windows Vista or Server…
Timothy John Laird
  • 1,101
  • 2
  • 13
  • 24
0
votes
0 answers

Not able to import back CngKey from raw bytes

I am generating a CngKey using below given powershell code and exporting the key in a file using bytes. the same created file is not getting imported and getting created as key when run again. It says Bad Data when same is imported again.…
Ronnie Kapoor
  • 133
  • 2
  • 12
0
votes
1 answer

How to calculate Subject Key Identifier in CNG?

My goal is to populate the Subject Key Identifier Extension (2.5.29.14) for a certificate using Microsoft CNG. I did it previously with Microsoft CAPI but the function I…
Timothy John Laird
  • 1,101
  • 2
  • 13
  • 24
0
votes
1 answer

How to create a AES persistent key with Crypto API Next Generation on Windows 7

On Windows 7 Pro x64, I try to create a persistent AES key with Cryptography API Next Generation. The problem is that the NCryptCreatePersistedKey function returns NTE_NOT_SUPPORTED. My code: #include "Windows.h" #include "bcrypt.h" #include…
Sebou
  • 13
  • 4
0
votes
1 answer

How to decrypt AES cipherText with NCryptDecrypt on Windows

I'm trying to use Ncrypt.lib to encrypt plain text with AES and then decrypt it. I use Ncrypt.lib because I want to use a persistent symetric key. My problem is that the decryption works partially. Indeed, I don't have my first 16 bytes decrypted…
Sebou
  • 13
  • 4
0
votes
1 answer

Microsoft CAPI returns NTE_BADKEYSET while using SHA256

I have my private key in HSM and i am using Microsoft CAPI (SignerSignEx) to sign a file . If am able to generate a sha1 signature successfully ,but if i try to generate a sha256 signature using the same cert and same key on my hsm SignerSignEx()…
0
votes
1 answer

BCryptImportKeyPair returns STATUS_INVALID_PARAMETER when i try to import public key

I followed this example. I am trying to add the public key which i got from the server into the key Pair and I am getting STATUS_INVALID_PARAMETER. BCRYPT_DH_KEY_BLOB header; header.dwMagic = BCRYPT_DH_PUBLIC_MAGIC; header.cbKey =…
Prakash N
  • 1,020
  • 1
  • 8
  • 20