C# – System.PlatformNotSupportedException AesCryptoServiceProvider

aescryptoserviceprovidercsharepointweb services

I've got the following problem.

I've created a class that uses AesCryptoServiceProvider to encrypt and decrypt some data. I'm using the class in a SharePoint WebPart and everything works fine. I'm also using the same class on the same webapplication in a custom SharePoint webservice and every time the constructor of the System.Security.Cryptography.AesCryptoServiceProvider is called it throws a System.PlatformNotSupportedException with the following stack trace.

System.PlatformNotSupportedException: The specified cryptographic algorithm is not supported on this platform.
   at System.Security.Cryptography.CapiNative.AcquireCsp(String keyContainer, String providerName, ProviderType providerType, CryptAcquireContextFlags flags, Boolean throwPlatformException)
   at System.Security.Cryptography.AesCryptoServiceProvider..ctor()
   at m2009_wu.ProvisioningLibrary.ConfigManager..ctor()

I've tried to compile the webservice and the library with the class in it for different platforms without any change.

The system my development environment is running on is a Windows Server 2008 Standard SP1 x64 with Microsoft Office SharePoint Server 2007 SP2 x64 and Visual Studio 2008 SP1. The .Net Framework 3.5 SP1 is installed on the server.

I'd be greatful if anyone could point me in the right direction.

Kind regards
Rene Windegger

Best Answer

From MSDN:

PlatformNotSupportedException - There is no supported key size for the current platform. [Link]

What key size do you use?

The minimum size of the key is 128 bits, and the maximum size is 256 bits. [Link]

Related Topic