views:

611

answers:

4

Hello,

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

A: 

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]

dtb
I'm using a key size of 256 bits. Since the problem occoures when the constructor gets called, and the constructor is working when called from a WebPart I don't know where the difference in the platform should be.
Reeen
A: 

Your exception states:

The specified cryptographic algorithm is not supported on this platform

You need to try another cryptoprovider. Not all cryptoproviders are available on all systems. MSDN has complete list of those.

Nikolay R
Yes the exeption states that the algorithm is not supportet on the platform. It works when called from within a webpart in the same application pool as the webservice.The exception only occurs only when it's called from the webservice.As the webservice and the webpart are running on the same platform this can't be the problem.
Reeen
You still should give a try to another provider. AFAIK this exception is pretty straight forward. Never heard of it being thrown udner wrong conditions.
Nikolay R
A: 

Where is your server located? Microsoft is not allowed to use high key strength crypto in certain areas of the world (china, north korea etc.)

Additionally, there are group policy settings which can be enforced to prevent certain crypto being used (eg governement agency mandates that only FIPS algorithms are allowed via group policy).

Spence
The server is located in Austria, I have not found anything stating that high key strength crypto is not supported in austria.
Reeen
Is there a restriction in the machine.config on AES?
Spence
A: 

I've kicked the ASP.Net Web Service and introduced a WCF Service and everything works fine now.

Reeen