0

I have made such code that will create contex for aes encryption (with Win32API support):

if (!CryptAcquireContext(&hProvs, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT))
    {
        if (!CryptAcquireContext(&hProvs, NULL, NULL, PROV_RSA_AES, CRYPT_NEWKEYSET | CRYPT_VERIFYCONTEXT))
        {
            printf("%d\n", GetLastError());
            getchar();
            ExitProcess(0);
        }
    }

It works fine on Windows 7 or higher but when I start it on Windows XP, I got no errors, just closed application. And nothing. What’s wrong?

  • security on win XP, are you serious? – phuclv Oct 02 '19 at 09:48
  • @phuclv why not – Jureg Arahig Oct 02 '19 at 18:04
  • you know that win XP has been unsupported for years, do you? And there are tons of vulnerabilities that MS didn't bother to fix, except the two that affects spread too fast to newer versions of Windows because of XP – phuclv Oct 03 '19 at 01:30
  • even just connecting a win XP machine to the network poses a great threat to other PCs. [Threat of a Windows XP machine connected to a local network via WIFI (today in 2018)](https://security.stackexchange.com/q/185085/89181), [Is it possible to protect my Windows XP users now that Microsoft is no longer releasing security updates?](https://security.stackexchange.com/q/59342/89181) – phuclv Oct 03 '19 at 01:36

1 Answers1

0

https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta

Important: This API is deprecated. New and existing software should start using Cryptography Next Generation APIs. Microsoft may remove this API in future releases.

Suarez Zhou
  • 174
  • 7
  • It’s not solution of my problem – Jureg Arahig Oct 02 '19 at 06:33
  • @Jureg, I thought it failed on the new system. I am sorry that I misunderstand the meaning. Did you debug to see where the program exits, is there an error code returned from GetLastError()? – Suarez Zhou Oct 02 '19 at 09:42
  • I tried to get last error but no output. It closes cmd immediately. It’s closing when trying to acquire contex – Jureg Arahig Oct 02 '19 at 13:47
  • @Jureg, I'm sorry I didn't reply to you in time, set breakpoints or system ("pause") to suspend the program, so that you can see in detail how your program works. – Suarez Zhou Oct 09 '19 at 02:50