Sign and SignVerify Data using an RSA Key
To Sign and SignVerify data using an RSA key:
Create a NAE Session. Pass the NAE username, password, property file path as arguments.
NaeSession session = new NaeSession(user, passwd, propFilePath);
Create
NaeRsaKey
object. PassNaeSession
object and keyname as argument.NaeRsaKey rsaKey = new NaeRsaKey(session,keyName);
Set the Hash algorithm.
HashAlgorithmName algorithm = HashAlgorithmName.SHA256;
Call the
SignData
API and pass input bytes, hashing algorithm name, and RSASignaturePadding as arguments to get the signed bytes.byte[] outBytes = rsaKey.SignData(inputBytes, algorithm, padding);
Call the
VerifyData
API. Pass the signed bytes, input bytes,algorithm name, and RSASignaturePadding as arguments for the verification of signed data.bool result = rsaKey.VerifyData(inputBytes, outBytes, algorithm, padding);