Good day!
Thank you for your attention, I really need help.
Before using NKryptoki, I had the following signature code:
private static string _GenerateDigitalSignature (string body, string privateKeyText)
{
var hash = HashBody (body);
byte [] signedHash;
using (var privateKey = ImportPrivateKey (privateKeyText))
{
signedHash = privateKey.SignHash (hash, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}
var encodedHash = Convert.ToBase64String (signedHash);
return encodedHash;
}
private static byte [] HashBody (string content)
{
var contentBytes = Encoding.UTF8.GetBytes (content);
using (var provider = new SHA256Managed ())
{
var hash = provider.ComputeHash (contentBytes);
return hash;
}
}
private static RSACryptoServiceProvider ImportPrivateKey (string pem)
{
StringReader sr = new StringReader (pem);
PemReader pr = new PemReader (sr);
AsymmetricKeyParameter Key;
Key = (AsymmetricKeyParameter) pr.ReadObject ();
pr.Reader.Close ();
sr.Close ();
var rsaParameters = DotNetUtilities.ToRSAParameters ((RsaPrivateCrtKeyParameters) Key);
var csp = new RSACryptoServiceProvider ();
csp.ImportParameters (rsaParameters);
return csp;
}
Which signature mechanism should I choose so that the results match?
Very much I ask for your advice!