Ian Warburton
Ian Warburton

Reputation: 15676

Using RSACryptoServiceProvider, how does one store a key exchange key and signature key in the same key container?

I want to use a key pair for encryption and a separate key pair for signing. How can I store them in the same key container using RSACryptoServiceProvider?

Upvotes: 1

Views: 128

Answers (1)

bartonjs
bartonjs

Reputation: 33098

The best answer is: don't -- just create different key containers.

RSACryptoServiceProvider is built on Windows CAPI, which is the older of the two Windows Cryptography libraries (and is considered Deprecated now). The (side-by-side) replacement, Windows CNG, no longer has the "signing key" and "exchange key" distinction... each "named key" is only one key. CNG can reach back into CAPI, but it'll only use one of the two keys (I believe exchange wins), since it has no way of asking which key you cared about.

Some parts of .NET now only use RSACng preferentially, and if one of those places runs into your two-keys key container you'll potentially have problems.

Upvotes: 1

Related Questions