Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CryptAcquireContext fails on other machines

CryptAcquireContext fails on other machines

Scheduled Pinned Locked Moved C / C++ / MFC
cryptographyhelpquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KnaveR777
    wrote on last edited by
    #1

    Hello All, I have an application that runs without error on my own system. Even in release mode :-D. However, when i run the application on other systems, my app reports to me that it was undable to aquire a crypt context (CryptAcquireContext) due to an invalid param. This code is called in a simple C worker thread. Any Ideas? UINT stringHash(byte* message, char* hash){ DWORD hashLen = 16; HCRYPTPROV hCryptProv; HCRYPTHASH hHash; // zeroing just in case CryptAquireContext is getting garbage somehow ZeroMemory(&hCryptProv, sizeof(hCryptProv)); ZeroMemory(&hHash,sizeof(hHash)); BYTE hashedBytes[16]; // Aquire Crypto Handle - fails if (!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){ CryptReleaseContext(hCryptProv,0); return GetLastError(); } ...

    H 2 2 Replies Last reply
    0
    • K KnaveR777

      Hello All, I have an application that runs without error on my own system. Even in release mode :-D. However, when i run the application on other systems, my app reports to me that it was undable to aquire a crypt context (CryptAcquireContext) due to an invalid param. This code is called in a simple C worker thread. Any Ideas? UINT stringHash(byte* message, char* hash){ DWORD hashLen = 16; HCRYPTPROV hCryptProv; HCRYPTHASH hHash; // zeroing just in case CryptAquireContext is getting garbage somehow ZeroMemory(&hCryptProv, sizeof(hCryptProv)); ZeroMemory(&hHash,sizeof(hHash)); BYTE hashedBytes[16]; // Aquire Crypto Handle - fails if (!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){ CryptReleaseContext(hCryptProv,0); return GetLastError(); } ...

      H Offline
      H Offline
      HumanOsc
      wrote on last edited by
      #2

      Hello... Yes, i believe i have an idea... I think on the other machines it isn't the requested CSP installed (this are dll's which provides cryptography algorithm)... For more information read: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/seccrypto/security/cryptographic_service_providers.asp[^] Best regards...:)

      1 Reply Last reply
      0
      • K KnaveR777

        Hello All, I have an application that runs without error on my own system. Even in release mode :-D. However, when i run the application on other systems, my app reports to me that it was undable to aquire a crypt context (CryptAcquireContext) due to an invalid param. This code is called in a simple C worker thread. Any Ideas? UINT stringHash(byte* message, char* hash){ DWORD hashLen = 16; HCRYPTPROV hCryptProv; HCRYPTHASH hHash; // zeroing just in case CryptAquireContext is getting garbage somehow ZeroMemory(&hCryptProv, sizeof(hCryptProv)); ZeroMemory(&hHash,sizeof(hHash)); BYTE hashedBytes[16]; // Aquire Crypto Handle - fails if (!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){ CryptReleaseContext(hCryptProv,0); return GetLastError(); } ...

        2 Offline
        2 Offline
        224917
        wrote on last edited by
        #3

        knave45 wrote: if (!CryptAcquireContext(&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, 0)){ CryptReleaseContext(hCryptProv,0); return GetLastError(); } You are trying to acquire the handle to key container "Microsoft Enhanced Cryptographic Provider " with the parameter MS_ENHANCED_PROV . The 9x system may not be having this key container with it. So try to get handle to some other key container. Or use NULL to get the handle to the default key container. If you don't like defaults !! try MS_DEF_PROV which is there with all window flavors i guess... -- Best Regards Suhredayan


        suhredayan
        There is no spoon.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups