There is a particular library (.net dll) we had used for cryptography. But it made use of Win32 routines. The issue here is we cannot use that for a 64-bit operating system. At least I think its so…we have code in the assembly written like this:
Friend Declare Function CryptAcquireContext Lib "advapi32.dll" Alias "CryptAcquireContextA" (ByRef phProv As Integer, ByVal pszContainer As String, ByVal pszProvider As String, ByVal dwProvType As Integer, ByVal dwFlags As Integer) As Integer
I see a 32 there; so I guess it is not meant for 64-bit machines. 🙁
Anyway, my ultimate goal is to convert that whole solution to a more portable code (so it can work on both 32 & 64 bit machines), but I can’t seem to understand how to write the equivalent .net code. After a lot of googling I found a C++ implementation which is similar to how things were done in the old .net dll. That can be found here
Being a novice in this area it is quite difficult for me to understand the process. I suppose they use the RSA algorithm. And I guess this is a symmetric algorithm, because we pass only one key to do the encryption/decryption. If you need any other details please add a comment; I’ll try to respond when I can…
Unfortunately, the function you are calling is not a regular crypto function, its something used to get a cryptographic service provider(CSP)Generally, access to CSP’s except via native code calls are unsupported in .net ≤ 4.0.
Absent your code,I can’t figure out what you are doing with the service provider once you grab the handle to it. If its one of the standard symmetric or asymmetric functions or something similar, you can probably do it entirely from managed code.
Try looking at System.security.cryptography. There is also a Microsoft written set of wrappers around CNG/CSP data providers here that might directly expose expose the exact CSP and its functionality . Finally, if you want really really portable code, try searching for the bouncy castle library which would handle both win32, windows ce, win8, and mono.