I am trying to create digital signatures on Windows (with XP SP3, but I'm currently testing with Windows 7) with CryptoAPI, which will be compatible with the following openssl commands:
openssl dgst -sha256 -sign <parameters> (for signing)
openssl dgst -sha256 -verify <parameters> (for validation)
I want to use the private key from the MY keystore for Windows.
I managed to sign the files using the SHA1 digest algorithm, using the following CryptoAPI functions (omitting the parameters for brevity):
CertOpenStore
CertFindCertificateInStore
CryptAcquireCertificatePrivateKey
CryptCreateHash (with CALG_SHA1)
CryptHashData
CryptSignHash
The generated signature is compatible with "openssl dgst -sha1 -verify" (as soon as the byte order is canceled).
: CALG_SHA_256 CryptCreateHash, 80090008 (NTE_BAD_ALGID). googling , , (PROV_RSA_AES) . , CryptAcquireCertificatePrivateKey CryptGetUserKey. , :
CryptAcquireContext (with PROV_RSA_AES)
CertOpenStore
CertFindCertificateInStore
CryptGetUserKey
CryptCreateHash (with CALG_SHA256)
CryptHashData
CryptSignHash
, , : CryptGetUserKey 8009000D (NTE_NO_KEY). CryptGetUserKey, CryptSignHash, 80090016 (NTE_BAD_KEYSET). , , SHA1.
, CertFindCertificateInStore: , , CryptGetUserKey, CryptSignHash .
, , 2048 , , , SHA1. , !