Hey there.
from an example on msdn on how to use cspparameter i get this:
--------------------------------------------------------------------------------------------
// Create a new CspParameters object that identifies a
// Smart Card CryptoGraphic Provider.
// The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft
\Cryptography\Defaults\Provider Types.
// The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft
\Cryptography\Defaults\Provider.
CspParameters csp = new CspParameters(1, "Datakey RSA CSP");
csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
//password do token
System.Security.SecureString pwd = new System.Security.SecureString();
pwd.AppendChar('1'); pwd.AppendChar('2'); pwd.AppendChar('3');
pwd.AppendChar('4');
csp.KeyPassword = pwd;
csp.KeyNumber = (int)KeyNumber.Signature;
// Initialize an RSACryptoServiceProvider object using
// the CspParameters object.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
// Create some data to sign.
byte[] data = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
Console.WriteLine("Data : " + BitConverter.ToString(data));
// Sign the data using the Smart Card CryptoGraphic Provider.
byte[] sig = rsa.SignData(data, "SHA1");
Console.WriteLine("Signature : " + BitConverter.ToString(sig));
// Verify the data using the Smart Card CryptoGraphic Provider.
bool verified = rsa.VerifyData(data, "SHA1", sig);
Console.WriteLine("Verified : " + verified);
--------------------------------------------------------------------------------------------
And, it it working, meaning, it does not ask me the pin for the
smartcard.
so, now that i know that it does work, i need to find a way to do the
same in :
--------------------------------------------------------------------------------------------
(from
http://msdn2.microsoft.com/en-us/library/aa480472.aspx)
static public byte[] SignMsg(Byte[] msg, X509CertificateEx signerCert)
{
// Place message in a ContentInfo object.
// This is required to build a SignedCms object.
ContentInfo contentInfo = new ContentInfo(msg);
// Instantiate SignedCms object with the ContentInfo
// above.
// Has default SubjectIdentifierType IssuerAndSerialNumber.
// Has default Detached property value false, so message is
// included in the encoded SignedCms.
SignedCms signedCms = new SignedCms(contentInfo);
// Formulate a CmsSigner object, which has all the needed
// characteristics of the signer.
CmsSigner cmsSigner = new CmsSigner(signerCert);
// Sign the PKCS #7 message.
signedCms.ComputeSignature(cmsSigner);
// Encode the PKCS #7 message.
return signedCms.Encode();
}
--------------------------------------------------------------------------------------------
i need to create a new CmsSigner with a CspParameters like in the RSA
example above.
something like:
CmsSigner cmsSigner = new CmsSigner(cps);
and it compiles just fine, just... stills asks for the pin, and (after
input the pin) the byte[] that it returns, is not right.
From this i must assume that creating a CmsSigner like that, does not
do the job.
Ant thought on that?
On Feb 15, 11:06 am, "Andrew Badera" <
and...@badera.us> wrote:
> You might find some value here:
>
>
http://msdn2.microsoft.com/en-gb/library/bb931379(VS.85).aspx
>
> Though it's talking in terms of mapping xenroll (XP) to certenroll (Vista),
> I think it was one of the better demo sources I found that wasn't purely
> C++.
>
> And possibly here:
>
>
http://support.microsoft.com/kb/922706
>
> I suspect a lot of xenroll information has been deprecated along with the
> object itself, in favor of certenroll ... I'll keep digging, if you find
> anything though, let me know please!
>