Sign and SignVerify Data using an EC Key
To Sign and SignVerify data using an EC key:
Create a NAE Session. Pass the NAE username, password, property file path as arguments.
NaeSession session = new NaeSession(user, passwd, propFilePath);
Create
NaeECIESKey
object. PassNaeSession
object and curve as argument.NaeECIESKey ecKey = new NaeECIESKey (session, curve);
Curve can be set to
NaeECIESKey.SupportedCurves.brainpoolP256r1_256
Set the Hash algorithm.
HashAlgorithmName algorithm = HashAlgorithmName.SHA256;
Call the
SignData
API and pass input bytes, hashing algorithm name as arguments to get the signed bytes.byte[] outBytes = ecKey.SignData(inputBytes, hashalgorithm);
Call the
VerifyData
API. Pass the signed bytes, input bytes, offset, count, and hashing algorithm name as arguments for the verification of signed data.bool result = ecKey.VerifyData(inputBytes, offset, count, outBytes, hashalgorithm);