mscapi

How can I import an RSA public key from either XML or modulus/exponent in native code for use with Windows CAPI's CryptVerifySignature?

北慕城南 提交于 2020-01-14 05:29:06
问题 In C#, I am able to validate a hash against a public key in either of the following ways: // Import from raw modulus and exponent using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { RSAParameters rsaKeyInfo = new RSAParameters {Modulus = modulus, Exponent = exponent}; rsa.ImportParameters(rsaKeyInfo); return rsa.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA512"), signature); } // Import from XML using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { rsa

How can I import an RSA public key from either XML or modulus/exponent in native code for use with Windows CAPI's CryptVerifySignature?

让人想犯罪 __ 提交于 2020-01-14 05:29:06
问题 In C#, I am able to validate a hash against a public key in either of the following ways: // Import from raw modulus and exponent using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { RSAParameters rsaKeyInfo = new RSAParameters {Modulus = modulus, Exponent = exponent}; rsa.ImportParameters(rsaKeyInfo); return rsa.VerifyHash(hash, CryptoConfig.MapNameToOID("SHA512"), signature); } // Import from XML using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { rsa

C# Generate a non self signed client CX509Certificate Request without a CA using the certenroll.dll

蓝咒 提交于 2019-12-19 04:07:55
问题 I have a self signed root certificate that I generated in C# using CERTENROLL.dll's CX509CertificateRequest Certificate functionality. I would like to write a function that generates client certificates signed by my root using the same API. However the only CertEnroll option I can find that does not generate a self signed certificate requires a authenticated CA. There seems to be a flag for setting a SignerCertificate but it always fails to initialize. //Initialize cert var cert = new

Saving/Restoring certs with MS CryptoAPI invalidates attached private key

ε祈祈猫儿з 提交于 2019-12-18 18:29:46
问题 I've written a program which is supposed to save and restore a users certificates using the windows Crypto API. I was under the impression that it was working fine but now a user has complained that the private key that was attached to the certificate is invalid after the cert has been restored. I was saving the certificates using: HCERTSTORE hCertStore = CertOpenStore(CERT_STORE_PROV_PHYSICAL_W, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY

MS CryptoAPI doesn't work on Windows XP with CryptAcquireContext()

泄露秘密 提交于 2019-12-12 09:52:00
问题 I wrote some code using the Microsoft CryptoAPI to calculate a SHA-1 and got the compiled exe working on Windows 7, Win Server 2008, Win Server 2003. However, when I run it under Windows XP SP3, it does not work. I narrowed down the failure to the CryptAcquireContext() call. I did notice that a previous post talked about the XP faulty naming of " … (Prototype) " and it must be accounted for by using a WinXP specific macro MS_ENH_RSA_AES_PROV_XP. I did the XP specific code modifications and it

how to use Microsoft Crypto API with USB Dongle following PKCS#11

倖福魔咒の 提交于 2019-12-11 03:10:59
问题 I have safenet authentication usb token which was given by a company and they told me they have digital public key certificate inside. They gave me a password and a software by which i can see that it can detect certificate inside. Now i need to access this token's certificate and then i need to use signing , encryption and decryption using my development code. But the company didn't gave me any sdk so i have to do everything by C++ Microsoft CryptoAPI. I searched on google but i am not sure

MS CryptoAPI doesn't work on Windows XP with CryptAcquireContext()

半城伤御伤魂 提交于 2019-12-05 20:19:14
I wrote some code using the Microsoft CryptoAPI to calculate a SHA-1 and got the compiled exe working on Windows 7, Win Server 2008, Win Server 2003. However, when I run it under Windows XP SP3, it does not work. I narrowed down the failure to the CryptAcquireContext() call. I did notice that a previous post talked about the XP faulty naming of " … (Prototype) " and it must be accounted for by using a WinXP specific macro MS_ENH_RSA_AES_PROV_XP. I did the XP specific code modifications and it still doesn't work. (The bResult returns 0 false on Win XP, all other platforms bResult returns 1 true

Microsoft CryptoAPI: how to convert PUBLICKEYBLOB to DER/PEM?

折月煮酒 提交于 2019-12-04 06:52:16
问题 I have a generated RSA key pair stored as PRIVATEKEYBLOB and PUBLICKEYBLOB, and I need to be able to convert these keys to DER or PEM formats so I could use it in PHP or Python. I figured out that I could use CryptEncodeObject function to convert my PRIVATEKEYBLOB to DER. In order to do that I need to use PKCS_RSA_PRIVATE_KEY encoding flag. But I couldn't find any clue on how to convert PUBLICKEYBLOB to DER. Here is my code for PRIVATEKEYBLOB convertion: LPCSTR type = PKCS_RSA_PRIVATE_KEY;

How to get KeyStore from usb token in Java

梦想与她 提交于 2019-12-03 14:56:42
问题 I have a SafeNet 5100 eToken already with a valid certificate in it that I use to access a web application from my company that requires it (multi-factor authentication). I'm creating a desktop application to access this website. I am already able to add the website's certificate to the TrustStore and get my certificate into a KeyStore . What I've got so far is: System.setProperty("javax.net.ssl.trustStore", "U:\\Certificados\\efau.truestore"); System.setProperty("javax.net.ssl.trustStoreType

Microsoft CryptoAPI: how to convert PUBLICKEYBLOB to DER/PEM?

痴心易碎 提交于 2019-12-02 12:59:46
I have a generated RSA key pair stored as PRIVATEKEYBLOB and PUBLICKEYBLOB, and I need to be able to convert these keys to DER or PEM formats so I could use it in PHP or Python. I figured out that I could use CryptEncodeObject function to convert my PRIVATEKEYBLOB to DER. In order to do that I need to use PKCS_RSA_PRIVATE_KEY encoding flag. But I couldn't find any clue on how to convert PUBLICKEYBLOB to DER. Here is my code for PRIVATEKEYBLOB convertion: LPCSTR type = PKCS_RSA_PRIVATE_KEY; DWORD encd = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING; DWORD dlen = 0; if(!CryptEncodeObject(encd, type,