Welcome to MSDN Blogs Sign in | Join | Help

Decrypt my World

Cryptography, Security, Debugging and more!

Browse by Tags

All Tags » CryptoAPI   (RSS)
CryptographicException: Unable to open the access token of the current thread
Hi all, When working with RSACryptoServiceProvider , we may get an exception like the following: System.Security.Cryptography. CryptographicException : Unable to open the access token of the current thread at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 Read More...
Threading issues with RSACryptoServiceProvider
Hi all, When using RSACryptoServiceProvider in i.e. ASP.NET you may get the following exception under a heavy load scenario: "System.Security.Cryptography.CryptographicException: CryptoAPI cryptographic service provider (CSP) for this implementation could Read More...
Threading issues with CryptoAPI
Hi all, Let's talk a bit about concurrency in CryptoAPI . When calling CryptoAPI from different threads , we have to take into consideration that key handles are not thread safe . The following document describes the threading issues when dealing with Read More...
Don't use default key containers if possible
Hi all, If you read CryptAcquireContext documentation, you'll see that setting pszContainer to NULL allow us to use a default key container . Microsoft recommends that every application creates its own key container instead of the default one, because Read More...
CryptAcquireContext fails with NTE_BAD_KEYSET
Hi all, When we try to access a key container, CryptAcquireContext may return NTE_BAD_KEYSET (or error # 0x80090016 or -2146893802 or "Keyset does not exist") for the following two reasons: 1) key container doesn't exist . You may repeat the call to CryptAcquireContext, Read More...
CryptAcquireContext fails with ERROR_FILE_NOT_FOUND
Hi all, welcome back, CryptAcquireContext API will fail with error #2 or ERROR_FILE_NOT_FOUND if: 1) the user's profile is not loaded, as we saw in my post RSACryptoServiceProvider fails when used with ASP.NET . 2) AppData registry value in the following Read More...
Certificate has private key but we get "the keyset does not exist" error
Hi all, welcome back, The other day we were using CAPICOM in a client script run in Internet Explorer . We were trying to sign some string with the private key of a certificate we previously installed in the client machine, but we kept getting the error Read More...
How to Encrypt and Decrypt with CryptoAPI and a user Certificate (Windows Mobile)
Hi all, welcome back, The other day I had the pleasure to collaborate with my colleague Raffaele Limosani on a CryptoAPI case in Windows Mobile . I don't give technical support to Windows Mobile, and I don't know the specifics on mobile development. He Read More...
PKCS#11 interface support on Windows 2000/Server 2003
Hi all, welcome back, I recently had some issues involving PKCS#11 interface on Windows, and it seems quite clear that we don't support it, at least on Windows 2000 & Server 2003, and as far as I know on any other version of Windows: Public Key Interoperability Read More...
How to select which Smart Card reader to perform actions on
Hi all, welcome back, Most of the time we only have a smart card reader in our machine, and we only use one smart card to perform crypto operations. But what if we have several readers and cards , and those cards share the same CSP (Cryptographic Service Read More...
How to sign a message and verify a message signature (C#)
Hi all, welcome back, Today we'll do some more P/Invoke with CryptoAPI and C# . The following sample is a conversion to C# of the C++ sample in Example C Program: Signing a Message and Verifying a Message Signature : <SAMPLE file="Class1.cs"> using Read More...
How to sign EXE files with an Authenticode certificate (VB.NET)
Hi, welcome back, Sorry it took me so long to write a new post. I'm visiting my colleagues at Milano, and I'm horribly busy these days. For Windows platforms, below are the only supported methods we can use to digitally sign Authenticode executables: Read More...
How to import a certificate without user interaction (C++ & C#)
Hi, welcome back, Today I'm posting a CryptoAPI sample which uses CryptUIWizImport to import a certificate without any user interaction: <SAMPLE Language="C++"> CRYPTUI_WIZ_IMPORT_SRC_INFO importSrc; memset(&importSrc, 0, sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO)); Read More...
How to generate key pairs, encrypt and decrypt data with CryptoAPI
Hi, welcome back, Today I'm posting a sample I did some time ago which shows how to generate key pairs , encrypt and decrypt data with C++ and CryptoAPI . The comments in the code should be self-explanatory. <SAMPLE> // INCLUDES #include "stdio.h" Read More...
How to sign and verify with CryptoAPI and a user certificate
Hi, welcome back, Today I will show how to sign data and verify that signature using CryptoAPI and a certificate from our Personal store. The comments in the code should help to understand it. Remember that this is just a sample, and some more cleanup Read More...
More Posts Next page »
Page view tracker