Questions tagged [wincrypt]

The portion of Windows API dealing with cryptography.

The portion of Windows API dealing with cryptography.

85 questions
9
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,078
  • 10
  • 22
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
  • 479
  • 5
  • 16
5
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
  • 402
  • 1
  • 6
  • 22
5
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
  • 722
  • 12
  • 27
4
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…
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,…
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
  • 541
  • 5
  • 16
2
votes
1 answer

RC2 decryption from wincrypt API to Go

I want to rewrite old C code from 1990 to Go. But the pain point here is migration of cryptographic algorithms. I have the following Cpp code that successfully decrypts the cipher into plain text. #include #include #include…
maksadbek
  • 1,508
  • 2
  • 15
  • 28
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
  • 1,849
  • 18
  • 33
2
votes
1 answer

How do I install a certificate to trusted root certificates using python?

I need to write a python code that installs a certificate into my machine's (windows) or local user's trusted root certificates. I tried the below code. The code runs without error but looks like the store is not windows trusted root. I also read…
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
  • 632
  • 5
  • 22
2
votes
0 answers

CryptAcquireContext fails in Windows 10 Creators Update

I have a code that encrypts a file using AES CFB mode. While the code runs correctly in Windows 7, Windows 8 and previous versions of Windows 10, on Windows 10 Creators Update this line fails: if (!CryptAcquireContext(&hProv, NULL,…
MickCic
  • 145
  • 2
  • 10
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
1
2 3 4 5 6