Skip to content

Cryptography Next Generation APIs and PlatformNotSupportedException #38197

Answered by vcsjones
adamjstone asked this question in General
Discussion options

You must be logged in to vote

Which platforms do not support use of the CNG APIs

CNG is Windows-specific. The CNG types (RSACng, etc) will only work on Windows, and throw PlatformNotSupportedException on non-Windows platforms.

If you want cross-platform cryptographic primitives, the factory methods on the primitives should be used. For example:

using (var rsa = System.Security.Cryptography.RSA.Create())
{
   //Use `rsa` here
}

and Create will give you an RSA implementation that will work for the current platform it is running on. The same approach works for other cryptographic primitives like ECDsa, Aes, etc.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adamjstone
Comment options

Answer selected by adamjstone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants