Home » .Net Framework

RSA crypto provider on compact framework 2.0 SP2 : Unknown exception when signing with sign key type

The RSA crypto provider on compact framework 2.0 SP2 is throwing an unknown exception when signing with sign key type. The full framework works fine.

Using an exchange key it works fine on both framework.


string message = "Tous les chats sont gris la nuit.";


            RSACryptoServiceProvider.UseMachineKeyStore = true;

            RSACryptoServiceProvider rsaCryptoServiceProvider = null;


            CspParameters parameters = newCspParameters();

            parameters.KeyContainerName = "TEST";

            parameters.KeyNumber = 2; //2 = forSignature; 1 = forExchanging

            parameters.Flags = CspProviderFlags.UseMachineKeyStore;




                rsaCryptoServiceProvider = newRSACryptoServiceProvider(parameters);


                rsaCryptoServiceProvider.PersistKeyInCsp = true;


                byte[] data = Encoding.UTF8.GetBytes(message);

                HashAlgorithm hasher = SHA1.Create(); // Our chosen hashing algorithm.


                // when the parameters.KeyNumber has forSignature value, I receive this

                // error : System.Security.Cryptography.CryptographicException was unhandled

                // Message="Unknown Error '80007015'."

                byte[] signedHash = rsaCryptoServiceProvider.SignData(data, hasher);







                if (rsaCryptoServiceProvider != null)

                    //remove it (we don't want garbage in our machine) this operation is performed

                    //  only for testing purpose.

                    rsaCryptoServiceProvider.PersistKeyInCsp = false;





Thanks for your help.


1 Answer Found


Answer 1

Is this happening with Windows Vista or Seven? or with Windows XP?

If the problem is happening with Vista or Seven, this post and the following codeplex proyect will help you:





<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure