cryptoapi

JPK - CryptoAPI RSA 256/ECB/PKCS#1 one time secret password encryption with public key from certificate (solution)

不问归期 提交于 2019-12-08 09:56:52
问题 Polish government (MF - Ministry of Finance) recently implemented SAF-T (Standard Audit File-Tax / pl: JPK - Jednolity Plik Kontrolny). I had much trouble to implement one of the key parts of this solution in the right way. This part is to encrypt user generated password used to encrypt files, sended to Azure Cloud Storage, with RSA 256/ECB/PKCS#1 algorithm from MS CryptoAPI, using public key loaded from certificate file served by the MF. 回答1: My working solution to this is (uses JEDI API

Converting private key in windows store to PEM (for OpenSSL)

瘦欲@ 提交于 2019-12-08 05:42:29
问题 I want to get a private key from windows store and convert it to PEM in order to use it in OpenSSL. I've been looking for a way to do that for a few hours! I use CertFindCertificateInStore() to get CERT_CONTEXT (which I know it contains the private key using the search parameter). Next, I used CryptAcquireCertificatePrivateKey() to get HCRYPTPROV (just because of the name of the function). Now, I use CryptGetUserKey() to get HCRYPTKEY (just because it sounds right...?!) But now I'm stuck

Translate Windows RC4 CryptDeriveKey to PHP for openssl

半城伤御伤魂 提交于 2019-12-07 23:37:10
问题 This is the second component of the legacy system translation we’ve been trying to do. We have managed to match exactly the initial binary password/key that Windows ::CryptHashData generates. That password/key is passed to ::CryptDeriveKey where it performs a number of steps to create the final key to be used by ::CryptEncrypt. My research has led me to the CryptDeriveKey documentation where it clearly describes the steps required to derive the key for ::CryptEncrypt but so far I haven’t been

Error importing public key using cryptoapi CryptImportKey

吃可爱长大的小学妹 提交于 2019-12-07 15:02:40
问题 I want to import public key blob to a CSP. but error occurred. BYTE pbData[] ={0xEB,0x2A,0x38,0x56,0x86,0x61,0x88,0x7F,0xA1,0x80,0xBD,0xDB,0x5C,0xAB,0xD5,0xF2,0x1C,0x7B,0xFD,0x59,0xC0,0x90,0xCB,0x2D,0x24,0x5A,0x87,0xAC,0x25,0x30,0x62,0x88,0x27,0x29,0x29,0x3E,0x55,0x06,0x35,0x05,0x08,0xE7,0xF9,0xAA,0x3B,0xB7,0x7F,0x43,0x33,0x23,0x14,0x90,0xF9,0x15,0xF6,0xD6,0x3C,0x55,0xFE,0x2F,0x08,0xA4,0x9B,0x35,0x3F,0x44,0x4A,0xD3,0x99,0x3C,0xAC,0xC0,0x2D,0xB7,0x84,0xAB,0xBB,0x8E,0x42,0xA9,0xB1,0xBB,0xFF

How to export AES key derived using CryptoAPI

对着背影说爱祢 提交于 2019-12-07 10:26:11
问题 I want to use the Windows CryptoAPI functions for AES encryption. As you know, the API has a lot of functions to create, hash and change the entered key; it derives the key and you get a handle to it. My problem is that I want to know what the derived key is? #include <Windows.h> #include <stdio.h> int main() { HCRYPTPROV hProv = 0; HCRYPTKEY hKey = 0; HCRYPTHASH hHash = 0; DWORD dwCount = 5; BYTE rgData[512] = {0x01, 0x02, 0x03, 0x04, 0x05}; LPWSTR wszPassword = L"pass"; DWORD cbPassword =

CryptoAPI: Using CryptVerifySignature to verify a signature from openssl with public key

痞子三分冷 提交于 2019-12-05 22:39:15
问题 I am trying to port the AquaticPrime framework for Mac to Windows. On the Mac, it uses the opensll library, and I try to understand how to port this to Windows, where I have to use the CryptoAPI, I guess. I mainly need the code for validation of the generated signature with a given public key. Here's how verification is done with openssl: inputs: license data, public key and signature, both 128 bytes long. A SHA1 digest is calculated from the license data. A RSA context is set up with the

WinHttp: How to use a temporary certificate store?

我怕爱的太早我们不能终老 提交于 2019-12-05 21:28:46
I have a C++ application that makes a HTTPS connection to one of our servers. In my ideal world, I would like the following to occur: App Starts App makes Windows trust the server's root CA (no GUI please, just system calls) App talks to server, does its work, etc. App makes windows forget about the server's root CA done I do NOT want this root CA to necessarily be trusted by other apps. Therefore I don't want to install the cert system-wide. I also would like it if the user did not need Admin privileges. My initial plan was to create an in-memory (CERT_STORE_PROV_MEMORY) store, add my cert to

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

How to export AES key derived using CryptoAPI

戏子无情 提交于 2019-12-05 19:38:28
I want to use the Windows CryptoAPI functions for AES encryption. As you know, the API has a lot of functions to create, hash and change the entered key; it derives the key and you get a handle to it. My problem is that I want to know what the derived key is? #include <Windows.h> #include <stdio.h> int main() { HCRYPTPROV hProv = 0; HCRYPTKEY hKey = 0; HCRYPTHASH hHash = 0; DWORD dwCount = 5; BYTE rgData[512] = {0x01, 0x02, 0x03, 0x04, 0x05}; LPWSTR wszPassword = L"pass"; DWORD cbPassword = (wcslen(wszPassword)+1)*sizeof(WCHAR); if(!CryptAcquireContext( &hProv, NULL, MS_ENH_RSA_AES_PROV, PROV

Error importing public key using cryptoapi CryptImportKey

柔情痞子 提交于 2019-12-05 18:38:43
I want to import public key blob to a CSP. but error occurred. BYTE pbData[] ={0xEB,0x2A,0x38,0x56,0x86,0x61,0x88,0x7F,0xA1,0x80,0xBD,0xDB,0x5C,0xAB,0xD5,0xF2,0x1C,0x7B,0xFD,0x59,0xC0,0x90,0xCB,0x2D,0x24,0x5A,0x87,0xAC,0x25,0x30,0x62,0x88,0x27,0x29,0x29,0x3E,0x55,0x06,0x35,0x05,0x08,0xE7,0xF9,0xAA,0x3B,0xB7,0x7F,0x43,0x33,0x23,0x14,0x90,0xF9,0x15,0xF6,0xD6,0x3C,0x55,0xFE,0x2F,0x08,0xA4,0x9B,0x35,0x3F,0x44,0x4A,0xD3,0x99,0x3C,0xAC,0xC0,0x2D,0xB7,0x84,0xAB,0xBB,0x8E,0x42,0xA9,0xB1,0xBB,0xFF,0xFB,0x38,0xBE,0x18,0xD7,0x8E,0x87,0xA0,0xE4,0x1B,0x9B,0x8F,0x73,0xA9,0x28,0xEE,0x0C,0xCE,0xE1,0xF6,0x73