mscapi

How to use CAPI's CryptImportKey with PEM encode public key from OpenSSL?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 00:27:51
问题 How do I get the Microsoft's CryptoAPI CryptImportKey function to import a PEM encoded key? It actually works but CryptDecrypt returns an error. // 1. Generate a Public/Private RSA key pair like so: openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -out public.pem -outform PEM -pubout // 2. Create a digital signaure using OpenSSL // Load Private key // -----BEGIN RSA PRIVATE KEY----- // BLAHBLAHBLAH // -----END RSA PRIVATE KEY----- // Concat user details std::string sUser =

OpenSSL and MS CryptoAPI: different digital signatures

故事扮演 提交于 2019-12-01 05:54:41
I generated X509 certificate with private key using makecert utility makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=tempCert" -ic RootCATest.cer -sr currentuser -ss my -sky signature —pe Then I converted RootCATest.pvk to RootCATest.pem with OpenSSL. And I extracted public key: pubRootCATest.pem I have small file called 'msg'. And I sign this file using SHA1. openssl dgst -sha1 -sign c:\RootCATest.pem -out c:\openssl c:\msg Then I want to obtain the same digital signature using MS CryptoAPI. Here is my code (Note: this is the

OpenSSL and MS CryptoAPI: different digital signatures

你。 提交于 2019-12-01 04:08:20
问题 I generated X509 certificate with private key using makecert utility makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=tempCert" -ic RootCATest.cer -sr currentuser -ss my -sky signature —pe Then I converted RootCATest.pvk to RootCATest.pem with OpenSSL. And I extracted public key: pubRootCATest.pem I have small file called 'msg'. And I sign this file using SHA1. openssl dgst -sha1 -sign c:\RootCATest.pem -out c:\openssl c:\msg

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

旧巷老猫 提交于 2019-12-01 00:45:09
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 CX509CertificateRequestCertificate(); //take care of signer cert.Issuer = issuen; CSignerCertificate sc = new

Saving/Restoring certs with MS CryptoAPI invalidates attached private key

天涯浪子 提交于 2019-11-30 17:04:23
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_FLAG | CERT_STORE_UPDATE_KEYID_FLAG, (PVOID) storeName.c_str()); And then later: if (!CertSaveStore

Digital Signature SunMSCAPI provider & MS Crypto API

只愿长相守 提交于 2019-11-30 08:48:11
问题 I want to sign file with the SunMSCAPI provider. As public key and signatures needs to be imported using MS Crypto API. Generally generating signatures with SHA1withRSA , ends up with big-endian to little-endian (byte order) conversion. //generate keystore with java keytool $Keytool -genkey -alias tsign -keystore c:\test\tsignjks.p12 - keyalg rsa -storetype pkcs12 In Java application: //for signing and getting keystore, assuming windows certificate is installed ..ks = KeyStore.getInstance(

MS Crypto API behavior on Windows XP vs Vista/7

左心房为你撑大大i 提交于 2019-11-30 03:50:09
问题 I'm trying to understand how to get a public key imported from PEM format (sample included in the code below) across XP, Vista and Windows 7. The sample code will import the key on both XP and Windows Vista/7, but not the same way. On Windows XP, the string "(Prototype)" is required in the cryptographic provider's name, and allows the call to CryptImportPublicKeyInfo to pass. On Windows 7, the "(Prototype)" provider is apparently present, but does not support the call to

Digital Signature SunMSCAPI provider & MS Crypto API

我只是一个虾纸丫 提交于 2019-11-29 08:05:38
I want to sign file with the SunMSCAPI provider. As public key and signatures needs to be imported using MS Crypto API. Generally generating signatures with SHA1withRSA , ends up with big-endian to little-endian (byte order) conversion. //generate keystore with java keytool $Keytool -genkey -alias tsign -keystore c:\test\tsignjks.p12 - keyalg rsa -storetype pkcs12 In Java application: //for signing and getting keystore, assuming windows certificate is installed ..ks = KeyStore.getInstance("Windows-MY","SunMSCAPI"); PrivateKey priv = ks.getKey("tsign",password); Signature rsa = Signature

Window C/C++ Crypto API Examples and tips

雨燕双飞 提交于 2019-11-27 17:32:14
I'm asking this question because I've spent the best part of a day trawling through msdn docs and other opaque sources for simple straightforward guidelines on how to get started with the Windows C/C++ Crypto API. What I'd like to see is some example code, typical include paths, linking guidelines, etc, anything useful really. I know this is an imprecise question but I reckon imprecise answers are better none at all. I'll get the ball rolling with my own meager findings... Gearoid Murphy Here's a bunch of examples I've found.... Example C Program: Listing the Certificates in a Store Example C

Window C/C++ Crypto API Examples and tips

◇◆丶佛笑我妖孽 提交于 2019-11-26 19:03:33
问题 I'm asking this question because I've spent the best part of a day trawling through msdn docs and other opaque sources for simple straightforward guidelines on how to get started with the Windows C/C++ Crypto API. What I'd like to see is some example code, typical include paths, linking guidelines, etc, anything useful really. I know this is an imprecise question but I reckon imprecise answers are better none at all. I'll get the ball rolling with my own meager findings... 回答1: Here's a bunch