wincrypt

BCryptImportKeyPair returns STATUS_INVALID_PARAMETER when i try to import public key

我怕爱的太早我们不能终老 提交于 2019-12-08 10:55:49
问题 I followed this example. I am trying to add the public key which i got from the server into the key Pair and I am getting STATUS_INVALID_PARAMETER. BCRYPT_DH_KEY_BLOB header; header.dwMagic = BCRYPT_DH_PUBLIC_MAGIC; header.cbKey = (ULONG)(pub_key.size()); cout << "header contents " << header.dwMagic << " : " << header.cbKey << endl; memcpy(&pubKeyBlobFromServer[0], &header, sizeof(BCRYPT_DH_KEY_BLOB)); // copy Public key cout << "size of pub_key " << pub_key.size() << endl; cout << "size of

How export all my certificates of software separately to a .pfx file?

て烟熏妆下的殇ゞ 提交于 2019-12-08 05:26:45
问题 I want export programatically of a computer all my certificates of software separately to .pfx file to sign 2 new softwares that already are in final step of building in another pc. To make this i found a C++ code example (that after i translate to Delphi). My Delphi version still not was tested but even so i think that is working fine. program CertToPFX; {$APPTYPE CONSOLE} {$R *.res} uses Windows, WinCrypt, Classes, SysUtils; var CertContext: PCCERT_CONTEXT; CertPropId: DWORD; Data: array [0

CryptEncrypt does not encrypt whole text

只谈情不闲聊 提交于 2019-12-06 10:45:21
问题 I am trying to encrypt a text message with wincrypt. My code is however unpredictable. It doesn't encrypt/decrypt the whole plaintext but only a part of it. If i change the length of password (for example to "password123") it encrypts/decrypts a different amount of characters. Here is my code. #include <windows.h> #include <wincrypt.h> #include <stdio.h> int main() { const char* passw = "password12"; const char* toencrypt = "consectetur adipiscing elit. In tellus nisl, sodales non arcu quis,

Get RSA public key from CRYPT_BIT_BLOB in WinHTTP?

感情迁移 提交于 2019-12-04 23:12:32
问题 I am trying to get the RSA public key info in WinHTTP. So far I've got the certificate info in CERT_CONTEXT structure. I can get encryption algorithm and others as follows: PCCERT_CONTEXT cert; DWORD certLen = sizeof(PCCERT_CONTEXT); WinHttpQueryOption(hRequest, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &certLen); The encryption algorithm is got by LPSTR pubKeyAlgo = cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId; And we might get the public key as follows: CRYPT_BIT_BLOB pubKey =

CryptEncrypt does not encrypt whole text

为君一笑 提交于 2019-12-04 16:09:10
I am trying to encrypt a text message with wincrypt. My code is however unpredictable. It doesn't encrypt/decrypt the whole plaintext but only a part of it. If i change the length of password (for example to "password123") it encrypts/decrypts a different amount of characters. Here is my code. #include <windows.h> #include <wincrypt.h> #include <stdio.h> int main() { const char* passw = "password12"; const char* toencrypt = "consectetur adipiscing elit. In tellus nisl, sodales non arcu quis, sagittis maximus orci cras amet."; HCRYPTPROV hProv; HCRYPTHASH hHash; HCRYPTKEY hKey; DWORD todwSize =