Signing Files

  • Thread starter Thread starter Marcelo López
  • Start date Start date
M

Marcelo López

Hello Everybody.

I'm developing an encrypted file system for a college project,

I have to sign a byte[] using a private key. I'm working with WSDE instead
of CAPICOM library.

I have an example in which i find the certificate in the store, and by using
the RSACryptoServiceProvider
i can obtain the private key to sign, only if the certificate EXPORTS its
private key.

So i don't know how can i obtain my own key given when the CA authorized my
certificate, and i don´t know how i have to set the private key to the rsa
object to sign with a specific private key (i could give it an string saved
in my db).

How can i signed it without using CAPICOM, wich results lot confussed to me
??

Regards
Marcelo

My code to sign is something like this:

Microsoft.Web.Services.Security.X509.X509CertificateStore store =
Microsoft.Web.Services.Security.X509.X509CertificateStore.CurrentUserStore(
Microsoft.Web.Services.Security.X509.X509CertificateStore.MyStore );

store.OpenRead();

Microsoft.Web.Services.Security.X509.X509Certificate sender
=(Microsoft.Web.Services.Security.X509.X509Certificate)store.Certificates[0]
;

System.Windows.Forms.MessageBox.Show ("Certificado del que firma:" +
sender.GetName());

RSAParameters sender_private = sender.Key.ExportParameters( true );

// SENDER-SIDE: Sign the text with own private key

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

rsa.ImportParameters( sender_private );

byte[] signature = rsa.SignData( data, new SHA1CryptoServiceProvider() );


return Convert.ToBase64String(signature);
 
Back
Top