Questions tagged [wincrypt]

The portion of Windows API dealing with cryptography.

The portion of Windows API dealing with cryptography.

85 questions
2
votes
2 answers

Files not decrypting fully, AES CBC mode. First block not decrpyted. WCAPI

Ok so I have 5 files I am encrypting. I am not setting the IV. The fist file decrypt's fine, then the first block of the remaining files is not decrypted. So the files decrypt 99%. Ive tried setting the IV to a static value and a random value, same…
swayz
  • 65
  • 7
1
vote
1 answer

How to decode ASN1 blob using Windows wincrypt api?

I'm trying to extract attributes from a certificate on Windows and have been using Wincrypt api's for that. When I encouter the SUBJECT_ALT_NAME certificate extension (szOID_SUBJECT_ALT_NAME "2.5.29.7") with the "OTHER_NAME" option - I get…
YNWA
  • 680
  • 2
  • 9
  • 19
1
vote
1 answer

How to add certificate in store?

I am trying to add certificate to store, but I am new in it. I've been searching for information about how to install certificate to store without finding certificate context from store (I have no certificate in store). Everything I found I've been…
Jessica
  • 75
  • 8
1
vote
0 answers

How to acquire a valid CNG private key handle from a certificate

I am trying to acquire a CNG private key handle to sign data per a certificate. But I am struggling to get a valid key handle, in the first place. The certificate lookup via fingerprint is working. I am recieving the context of a self signed…
René Hoffmann
  • 2,766
  • 2
  • 20
  • 43
1
vote
1 answer

PFXExportCertStoreEx API not exporting private key to PFX file

I am trying to create creating a pfx file using PFXExportCertStoreEx API for a self-signed certificate and its corresponding private key. Self-signed Certificate exporting to pfx but private key not exporting to a pfx file. I set the export policy…
Pavan
  • 507
  • 1
  • 3
  • 15
1
vote
1 answer

WinCrypt RSA vs Java org.bouncycastle

So here is a question. I have an old code on a Windows system that just takes a short string and makes CryptEncrypt on it with a public RSA key. The minimum working example is here (avoiding any checks to make it shorter. avoiding freeing as…
Sergio Pv
  • 271
  • 1
  • 7
1
vote
3 answers

How to check the revocation status of a x509 certificate in c++ with wincrypt.h?

I'm trying to check the revocation state of a X509 certificate in a c++ program with the use of wincrypt.h. Sadly I'm not able to find a comprehensive example. In c# the code would be the following: X509Certificate2 certificate = new…
Rufus Buschart
  • 362
  • 1
  • 13
1
vote
0 answers

Encrypting a packet using AES

I am attempting to encrypt the buffer which I send trough Winsock. I don't know that much about encryption at all except the absolute basics and I went with Windows' WinCrypt library since it seems the most basic and easiest I can implement,…
dksue
  • 61
  • 3
1
vote
0 answers

data leak when generate key with winapi function

I have question: when I'm trying to generate AES key 128 lenght with CryptGenKey I have data leak? Code below: void GeKey(HCRYPTKEY hKey, HCRYPTPROV hProvs) { DWORD len_iv = 0; if (!CryptGenKey(hProvs, CALG_AES_128, CRYPT_EXPORTABLE,…
1
vote
1 answer

Verify Signed PE File

(Sorry for my bad English.) I have some problems in my code.so I will try to explain my problem. I have a simple exe file with signed(pkcs7). I want to verify this file (without an internet connection). I don't want to use WinVerifyTrust() because I…
Anfield
  • 27
  • 4
1
vote
1 answer

Crash during the function CryptEncrypt

I'm writting little program that will generate RSA key pair, export\import keys and encrypt string. So, I have written this code: void EncryptString(std::string data) { int lenght = strlen(data.c_str()); DWORD temp = data.length() *…
veter0
  • 23
  • 6
1
vote
1 answer

Generation RSA-2048 keys (public and private)

I'm making simple implementation RSA-2048. I found some code on another forum. #include #include #include #include using namespace std; #pragma comment (lib, "Crypt32.lib") BYTE* Crypt(const string&…
1
vote
0 answers

CertOpenStore "Memory" returns file not found

The code below used to work. I think it broke after some .NET Framework or Windows 10 upgrade, but not sure. It opens a temporary certificate store for generating self-signed certificates. using System; using…
fernacolo
  • 7,012
  • 5
  • 40
  • 61
1
vote
1 answer

Don't encrypting correctly wincrypt

I'm trying to encrypt a string as size of 8 bytes (64 bits) using AES128 from wincrypt.h, note that the string is smaller than the block size of AES which is 128 bits. HCRYPTKEY hKey; if (!CryptDeriveKey(hProv, CALG_AES_128, hHash, 0, &hKey)) { …
user8554358
1
vote
1 answer

Access Violation exception before entering into a function

I have this function which simply encrypts a string (this function works fine, and tested). DWORD SomeObj::Encrypt(string * To_Enc) { DWORD text_len = (To_Enc->length()); if (!CryptEncrypt(this->hKey, NULL, // hHash = no hash …
rafiki
  • 91
  • 1
  • 8