cryptoapi

CryptoAPI returns incorrect result for HMAC_SHA1

血红的双手。 提交于 2019-12-22 11:07:45
问题 I'm using the code below with the Crypto API and I'm not getting the results I would expect based on testing with other API's and libraries. I'm using the key, " key " and the data is " message " For example, using Indy's TidHMACSHA1, I get 2088df74d5f2146b48146caf4965377e9d0be3a4 I get the same result using online generators (such as http://www.freeformatter.com/hmac-generator.html, for example). With the code I've written (see below) I get 4a52c3c0abc0a06049d1ab648bb4057e3ff5f359 The code

Memory Leak while verifying Authenticode Signature of Executables?

谁都会走 提交于 2019-12-22 07:52:27
问题 I am using WinVerifyTrust to verify the validity of some Windows executables with the following function, called in a loop from _tmain : int signature_is_valid(const wchar_t *filepath) { GUID guid = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_FILE_INFO file_info = { 0 }; WINTRUST_DATA wd; file_info.cbStruct = sizeof(file_info); file_info.pcwszFilePath = filepath; file_info.hFile = NULL; file_info.pgKnownSubject = NULL; ZeroMemory(&wd, sizeof(wd)); wd.cbStruct = sizeof(wd); wd.dwUIChoice = WTD

Memory Leak while verifying Authenticode Signature of Executables?

人盡茶涼 提交于 2019-12-22 07:51:30
问题 I am using WinVerifyTrust to verify the validity of some Windows executables with the following function, called in a loop from _tmain : int signature_is_valid(const wchar_t *filepath) { GUID guid = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_FILE_INFO file_info = { 0 }; WINTRUST_DATA wd; file_info.cbStruct = sizeof(file_info); file_info.pcwszFilePath = filepath; file_info.hFile = NULL; file_info.pgKnownSubject = NULL; ZeroMemory(&wd, sizeof(wd)); wd.cbStruct = sizeof(wd); wd.dwUIChoice = WTD

RSA_public_decrypt and MS Crypto API equivalent

懵懂的女人 提交于 2019-12-22 04:29:22
问题 I'm trying to develop a license verification solution. Licenses are encoded on server using OpenSSL's RSA_private_encrypt function. For Mac OX X I use RSA_public_decrypt and it works like a charm. On Windows I must use very tiny bit of code, so I can not link with OpenSSL or other lib AND I have to use MS Crypto API. I have spent several days trying to figure out what is wrong, but with no luck. I can successfully import public key, but here my success ends. I'm aware that I need to reverse

Digital signature made in C# does not verify in C++

会有一股神秘感。 提交于 2019-12-21 19:45:52
问题 I have a C# application which digitally signs data using RSA. The code is as follows: RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportCspBlob(privateKeyBlob); SHA1 sha1 = new SHA1CryptoServiceProvider(); sha1.ComputeHash(myData); byte[] signature = rsa.SignHash(sha1.Hash, CryptoConfig.MapNameToOID("SHA1")); I cannot verify the signature in C++. The code is as follows: HCRYPTPROV cryptProvider; CryptAcquireContext(&cryptProvider, 0, 0, PROV_RSA_FULL, CRYPT

RSA Encryption on iPhone

寵の児 提交于 2019-12-21 06:56:01
问题 According the discussion on http://forums.macrumors.com/showthread.php?t=551476 the code seen below would do for RSA encryption. The datatype of the key ("public") is SecKeyRef. I will not be using the keychain, though, as I'm only interested in encryption where the key is public and is no secret. Is it even possible to use the crypto API then? My current idea is to construct a SecKeyRef struct from my public key only and use the API. I don't know how the struct is declared, though. Does

Windows CryptoAPI: CryptSignHash with CALG_SHA_256 and private key from MY keystore

大兔子大兔子 提交于 2019-12-21 05:42:20
问题 I am trying to generate digital signatures on Windows (from XP SP3, but currently testing with Windows 7) with CryptoAPI that 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 a private key from the Windows "MY" keystore for signing. I managed to sign files using the SHA1 digest algorithm by using the following CryptoAPI functions (omitting parameters for

I'm using Wincrypt for Diffie-Hellman— can I export the shared secret in plain text?

最后都变了- 提交于 2019-12-21 05:30:13
问题 OK-- thanks to Mike, I was able to get Wincrypt to generate a Diffie-Hellman keypair. I figured out out to export the public key, and how to import the other party's public key. According to the docs, upon import of the other party's public key, the shared secret has been computed. Great. I now need to get ahold of that shared secret, but I don't think its possible. Simply calling CryptExportKey with a type of PLAINTEXTKEYBLOB fails unless I call CryptSetKeyParam to change the algorithm id

How to import private key in PEM format using WinCrypt and C++?

我怕爱的太早我们不能终老 提交于 2019-12-19 04:01:09
问题 I'm trying to use the WinCrypt API in C++. My application need to cipher, decipher, sign and verify files, and I know how to do that once I have the correct keys. But my problem is actually that that is NOT the same application which generates those keys. What I have is public and private keys in files in PEM format : -----BEGIN RSA PRIVATE KEY----- [Base64 encoded] -----END RSA PRIVATE KEY----- And : -----BEGIN RSA PUBLIC KEY----- [Base64 encoded] -----END RSA PUBLIC KEY----- After some

How to import private key in PEM format using WinCrypt and C++?

可紊 提交于 2019-12-19 04:00:42
问题 I'm trying to use the WinCrypt API in C++. My application need to cipher, decipher, sign and verify files, and I know how to do that once I have the correct keys. But my problem is actually that that is NOT the same application which generates those keys. What I have is public and private keys in files in PEM format : -----BEGIN RSA PRIVATE KEY----- [Base64 encoded] -----END RSA PRIVATE KEY----- And : -----BEGIN RSA PUBLIC KEY----- [Base64 encoded] -----END RSA PUBLIC KEY----- After some