cng

Importing PKCS#8 encrypted key to RSACng?

本秂侑毒 提交于 2019-12-02 08:42:11
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 parameters and then they are imported into RSACng , thus the answer is no? CNG understands how to decrypt encrypted PKCS#8, but you need to give it a password. Since .NET doesn't ask you for the password (and it gets passed via a manner other than the properties) there isn't a good way to do it. Your options are pretty much: P/Invoke so you can specify

How to grant permission to private key from powershell

谁都会走 提交于 2019-12-01 19:31:35
I'm trying to find a way to grant permissions for private key from powershell script. Certificate is stored in CNG. All ideas are welcome. The answer above is technically correct however it did not help me when I was looking for the same thing because it fails to mention that you need to use assemblies loaded from the CLRSecurity project on codeplex https://clrsecurity.codeplex.com/ . Here is an extract of how I achieved the same thing including loading the CLR Security assembly that you need to use Security.Cryptography.dll. There are a couple of function declarations that are needed first. I

How to Export Private Key For ECDiffieHellmanCng

旧城冷巷雨未停 提交于 2019-12-01 06:16:30
I am trying to export the keys from a new instance of a ECDiffieHellmanCng object so I can create an instance of it later with the same keys. But I am getting an error when trying to export it. //Create new ECDiffieHellmanCng which automatically creates new keys var ecdh = new ECDiffieHellmanCng(); //Export the keys var privateKey = ecdh.Key.Export(CngKeyBlobFormat.EccPrivateBlob); I am getting a CryptographicException when I call the Export method with the message " The requested operation is not supported. " After putting some breakpoints in the code it looks like it is throwing the

How to chain BCryptEncrypt and BCryptDecrypt calls using AES in GCM mode?

我们两清 提交于 2019-11-30 17:58:04
Using the Windows CNG API, I am able to encrypt and decrypt individual blocks of data with authentication, using AES in GCM mode. I now want to encrypt and decrypt multiple buffers in a row. According to documentation for CNG , the following scenario is supported: If the input to encryption or decryption is scattered across multiple buffers, then you must chain calls to the BCryptEncrypt and BCryptDecrypt functions. Chaining is indicated by setting the BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG flag in the dwFlags member. If I understand it correctly, this means that I can invoke BCryptEncrypt

Importing ECC-based certificate from the Windows Certificate Store into CngKey

坚强是说给别人听的谎言 提交于 2019-11-30 08:57:48
问题 How can I get the public/private keys from an ECC-based X509Certificate2 's into CngKey 's for use with ECDsaCng and ECDiffieHellmanCng ? I'm currently using RSA 2048 bit key pairs to sign/encrypt stuff. I'm doing this by pulling the certificates from the X509Store where they are securely stored with private keys marked as non-exportable. I would like to convert the current implementation to use ECDSA and ECDH so that I can use smaller key sizes for equivalent security. I've successfully

How to chain BCryptEncrypt and BCryptDecrypt calls using AES in GCM mode?

瘦欲@ 提交于 2019-11-30 01:48:03
问题 Using the Windows CNG API, I am able to encrypt and decrypt individual blocks of data with authentication, using AES in GCM mode. I now want to encrypt and decrypt multiple buffers in a row. According to documentation for CNG, the following scenario is supported: If the input to encryption or decryption is scattered across multiple buffers, then you must chain calls to the BCryptEncrypt and BCryptDecrypt functions. Chaining is indicated by setting the BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG flag in

Export private key (PKCS#8) of CNG RSA certificate with oldschool .NET

守給你的承諾、 提交于 2019-11-28 14:33:25
I have a PKCS #12 (PFX) file that is a certificate with CNG RSA key and want to export the private key. MIIJ4gIBAzCCCZ4GCSqGSIb3DQEHAaCCCY8EggmLMIIJhzCCBgAGCSqGSIb3DQEHAaCCBfEEggXtMII F6TCCBeUGCyqGSIb3DQEMCgECoIIE/CCBPowHAYKKoZIhvcNAQwBAzAOBAjBalb3hEiYXQICB9AEggT Y80gGrPwpOpwdA1V9f55nVex6JzumPGb000ePt4jilZ3ktcY9SaE9krxBycNzRVFRVosJOZfHby8u2z 8PDj0bCgNUOE1yU5Jzf5yDyq1bRyLSi4zpwPaN5zj3CsJ3zqhvzzSmTRW2S4zeT1CgjQnsPkRHOMluX 0b+qNo+oY2v1fqRXwh5S2GX7joFHWOp5Xr425LiNLCZVxfnO64znKhzZLPJoG0jb8rfZkVC9p3zKt/J VJJodqV+9jmnBcdGkQTN1jY7GRpi3aykLHGyaxDmp+0dSKZ5yMognY2tabJxAVQBnesCfwhtmZlxPx2 KBN2GHyfGV

Import a Public key from somewhere else to CngKey?

醉酒当歌 提交于 2019-11-27 08:05:19
I am looking for a cross platform way to share public keys for ECDSA signing. I had a great thing going from a performance perspective with CngKey and the standard .NET crypto libraries, but then I couldn't figure out how a 33 (or 65) byte public key (using secp256r1/P256) was getting turned into 104 bytes by MS.. Ergo, I couldn't support cross platform signing and verifying.. I'm using BouncyCastle now, but holy handgranade is it SLOW! So, looking for suggestions for the following requirements: Cross platform/Languages (server is .NET, but this is served up via a JSON/Web.API interface)

Import a Public key from somewhere else to CngKey?

╄→гoц情女王★ 提交于 2019-11-26 12:27:53
问题 I am looking for a cross platform way to share public keys for ECDSA signing. I had a great thing going from a performance perspective with CngKey and the standard .NET crypto libraries, but then I couldn\'t figure out how a 33 (or 65) byte public key (using secp256r1/P256) was getting turned into 104 bytes by MS.. Ergo, I couldn\'t support cross platform signing and verifying.. I\'m using BouncyCastle now, but holy handgranade is it SLOW! So, looking for suggestions for the following