Abb
Abb

Reputation:

RSACryptoServiceProvider <-> CryptImportKey Equivalency

If I have a key created from a unmanaged app and If I want to import this key in a managed app and generate another key or encrypt it. Basically the same key will be imported/exported back and forth from managed and unmanaged code.

Therefore what is the equivalent to

CryptExportKey(hKey, hPublicKey, SIMPLEBLOB, 0, lpData, &nSize);

and

CryptImportKey(hProv, lpData, nSize, NULL, 0, &hPublicKey);

in the managed world using RSACryptoServiceProvider?

What set of methods in the RSACryptoServiceProvider class are equivalent to the above Crypto APIs

Upvotes: 1

Views: 1903

Answers (2)

Riccardo Tramma
Riccardo Tramma

Reputation: 593


If you are interested, I wrote an article about RSA in C++ and C#. It contains the code and all you need to know to have RSA working in both languages, exchanging keys and messages between them :). I hope it answers all your questions.

You can find it here:
Crypt in C++ and Decrypt in C# (and C++)

Upvotes: 0

Related Questions