I\'m trying to implement some demo of XML signing with a certificate which stored in the HSM.
I found some interesting example from this link: Sign XML Document with
You need to implement custom class inherited from System.Security.Cryptography.RSA class, use Pkcs11Interop in its implementation and then use instance of your custom class as a SigningKey.
You can implement it yourself or you can use Pkcs11Interop.X509Store library which provides easy to use PKCS#11 based X.509 certificate store and contains Pkcs11RsaProvider class inherited from System.Security.Cryptography.RSA class. There's also a code sample available which demonstrates its usage with SignedXml class.