Thanks for your reply Jaroslav.
I had used you sample example for signing and verify for signing and verifying.
using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, false))
{
// Find first slot with token present
Slot slot = Helpers.GetUsableSlot(pkcs11);
// Open RW session
using (Session session = slot.OpenSession(false))
{
// Login as normal user
session.Login(CKU.CKU_USER, Settings.NormalUserPin);
// Generate key pair
ObjectHandle publicKey = null;
ObjectHandle privateKey = null;
Helpers.GenerateKeyPair(session, out publicKey, out privateKey);
// Specify signing mechanism
Mechanism mechanism = new Mechanism(CKM.CKM_SHA1_RSA_PKCS);
byte[] sourceData = ConvertUtils.Utf8StringToBytes("Hello world");
// Sign data
byte[] signature = session.Sign(mechanism, privateKey, sourceData);
// Do something interesting with signature
// Verify signature
bool isValid = false;
session.Verify(mechanism, publicKey, sourceData, signature, out isValid);
session.DestroyObject(privateKey);
session.DestroyObject(publicKey);
session.Logout();
}
}
I want to do digital signing for XML using the same but the signature I am getting is not like the ones we get from XML signed data using X509 Digital certificate with Signature tag including tags of SignedInfo, SignatureMethod , SignatureValue, KeyInfo etc.......
I am getting unreadable data
Is there any other sample for signing XML data.