none
RSA Sign with Cryptography smartcard RRS feed

  • Question

  • Hi everybody!

    I'm trying to use the following code to sign some data using a key stored in smartcard

    1- CspParameters csp = new CspParameters(1, "Advanced Card Systems CSP v3.0");
    2- csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
    3- RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);

    the app work on the first time, but second time throws an exception while executing line "3".

    the exception message is "The parameter is incorrect.".



    Sunday, April 13, 2014 11:13 AM

Answers

  • Hello eldeperky,

    With your description, do you mean that when you secondly start the project, it throws an error:

    "The parameter is incorrect.", is it right?

    If it is, it makes me confused because I made a test which is similar with yours:

    using System;
    
    using System.Collections.Generic;
    
    using System.Diagnostics.Tracing;
    
    using System.Linq;
    
    using System.Text;
    
    using System.Diagnostics;
    
    using System.IO;
    
    using System.Security.Cryptography;
    
    namespace P201404
    
    {
    
        class Program
    
        {
    
            static void Main(string[] args)
    
            {
    
                #region http://social.msdn.microsoft.com/Forums/en-US/5e84a0d8-9895-4ed0-a057-cb35990d6d4e/rsa-sign-with-cryptography-smartcard?forum=netfxbcl
    
                CspParameters csp = new CspParameters(1, "Microsoft Strong Cryptographic Provider");//Microsoft Strong Cryptographic Provider
    
                csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
    
                RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
    
                #endregion
    
            }
    
        }
    
    }
    

    Whenever I start the project, it can work fine(Using Microsoft Strong Cryptographic Provider is because my fist is that). Is it that there are other codes which could affect it? Or you can upload project to skydrive.

    My test environment is VS2013 and .NET Framerwork 4.5.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 15, 2014 5:49 AM
    Moderator