"Mark Shasby" <mark@shasby.com> wrote in message
> Ahhh good point, thanks - if I view locals at the time of the exception it
> is actually a
[quoted text clipped - 5 lines]
> System.Security.Cryptography.RSA<something> or should I do something else?
> Casting didn't seem to work :(
(for clarity I've abbreviated
Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider to
RSACryptoServiceProvider2 and
System.Security.Cryptography.RSACryptoServiceProvider to
RSACryptoServiceProvider)
Here are your options:
1] use the RSACryptoServiceProvider2.ExportParameters(true) method to export
the private key to an RSAParameters structure and then use
RSACryptoServiceProvider.ImportParameters to import it in a 'normal'
RSACryptoServiceProvider instance. There are two problems with this
approach. Firstly, it's unlikely that the call to ExportParameters(true)
will succeed since private keys may be unexportable (for security reasons,
it may be on a smartcard, ...). Secondly, you'll have to create an instance
of the RSACryptoServiceProvider before calling the ImportParameters method.
Unfortunately, the constructor of the RSACryptoServiceProvider will
automatically generate an RSA key for you (which is then thrown away after
calling ImportParameters) and this may degrade performance significantly.
2] cast the RSA instance to an RSACryptoServiceProvider2 and call the
SignHash method directly. In case you're wondering what the value of the
oidHash parameter should be, it's "1.2.840.113549.2.5" for MD5 and
"1.3.14.3.2.26" for SHA1.
3] perhaps there's a class in WSE2 that does PKCS#1 signature formatting. If
there is one, it's preferable to use this class of course, but I wasn't able
to find one.
Regards,
Pieter Philippaerts
Mark Shasby - 25 Jun 2004 23:36 GMT
Thanks, I'm sure I'll get something to work now.
:)
> "Mark Shasby" <mark@shasby.com> wrote in message
> > Ahhh good point, thanks - if I view locals at the time of the exception it
[quoted text clipped - 38 lines]
> Regards,
> Pieter Philippaerts