Questions tagged [wincrypt]

The portion of Windows API dealing with cryptography.

The portion of Windows API dealing with cryptography.

72 questions
8
votes
1 answer

Get RSA public key from CRYPT_BIT_BLOB in WinHTTP?

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 =…
kushpf
  • 1,050
  • 10
  • 21
6
votes
1 answer

CertGetCertificateChain with a supporting memory store and Certificate Trust List

I need to mark a custom self-signed root certificate as trusted during certificate chain validation and, overall, I want to rely on the system API as much as possible. I create a temporary memory store. HCERTSTORE certStore =…
Eugen
  • 313
  • 2
  • 9
4
votes
0 answers

Microsoft CryptoApi - Create a new certificate signed by a root authority certificate

I am trying to sign a public/private key pair by a temporary Root CA, steps followed are next: Create a self-signed root authority certificate (CertCreateSelfSignCertificate) (Done) Generate public/private key pair (CryptGenKey) (Done) Sign…
Alberto Bricio
  • 53
  • 1
  • 14
4
votes
2 answers

WinAPI - CryptDecrypt() not working properly in AES 256

I used to work with crypto++ in Visual Studio before, but now I want to use of wincrypt.h API functions to encrypt a string with AES 256 with an IV (cbc mode). I did bellow steps but I'm confused about CryptEncrypt() and CryptDecrypt() functions,…
4
votes
1 answer

How to read certificate from smart card via python?

I have a Smart Card (actually USB Token) with some certificate and keys written on it. Now I need to retrieve this certificate using python on Windows. How can it be achieved? I had a look on pyscard package but it seems too low-level and probably…
fbjorn
  • 367
  • 3
  • 18
3
votes
1 answer

Why my encrypted text doesn't change?

I have this program working that encrypts a string of 9 bytes using AES128 from wincrypt.h but something strange happens when I change last character of the key: from L"3igcZhRdWq96m3GUmTAiv2" to for example L"3igcZhRdWq96m3GUmTAiv1" or…
user8554358
3
votes
1 answer

I get 0x80070057 error code on certcreatecertificatechainengine func

I use visual studio 2013 and windows 7 32bit. I want to verify digital signature by root and chain of certificate. So I get 0x80070057 error code in certcreatecertificatechainengine(). bool result = false; HCERTCHAINENGINE …
VOLVO
  • 482
  • 3
  • 14
2
votes
1 answer

RSA SHA512 signature generated by Windows CNG(Cryptography Next generation ) NCryptSignHash not matching with signature generated by openssl RSA_sign

We are trying to generate RSA SHA512 signature with CNG, we wrote code and generated hash value not matching with OpenSSL. Private key used for signing we generated with OpenSSL command in DER format as below. openssl genpkey -out privkey.pem…
2
votes
1 answer

WinAPI: How do you get the "Verified Publisher" the UAC shows for signed binaries?

I need to verify an .exe and ensure the publisher name matches the expected name (not based on a key since that can change as new code signing certificates are issued, the name is always the same). I found samples of using WinVerifyTrust to verify a…
user3161924
  • 856
  • 9
  • 23
2
votes
2 answers

Verify a signature file (PKCS7) with WinCrypt or CNG

I need to verify a signed JAR file using Windows crypto API methods. I have only a basic understanding of encryption and signing matters. I'm also new to those crypto APIs (WinCrypt, Bcrypt, Ncrypt). Verifying the file hashes wasn't a problem, but…
Simpleton
  • 421
  • 3
  • 11
2
votes
1 answer

CryptEncrypt does not encrypt whole text

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…
2
votes
0 answers

Convert AES encryption code in C++ to python using pycrypto

I am learning python and trying to convert the above code snippet found online to python. As my understanding, the below code is generating the session key based upon SHA1 hash of the password "Microsoft" but I am not sure how I can derive AES 256…
Yang Yu
  • 131
  • 3
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
  • 6
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,647
  • 2
  • 18
  • 37
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
  • 458
  • 3
  • 12
1
2 3 4 5