Performing Elliptic Curve Operations

if ((status = B_VerifyUpdate (ecDSAVerify, dataToSign, dataToSignLen, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 5: Final

Pass in the signature that was received with the message. B_VerifyFinal returns 0 if the signature verifies, or an error if it is an invalid signature:

if ((status = B_VerifyFinal (ecDSAVerify, signature, signatureLen, (B_ALGORITHM_OBJ)NULL_PTR, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 6: Destroy

Destroy all objects that are no longer needed:

T_free(signature);

B_DestoryAlgorithmObject (&ecDSAVerify);

Using ECAES

You can use the Elliptic Curve Authenticated Encryption System (ECAES) to perform public-key encryption. The example in this section corresponds to the file eces.c.

You will encrypt the following:

unsigned char *dataToEncrypt = “Encrypt this arbitrarily long sentence using ECAES!”;

unsigned int dataToEncryptLen = sizeof(dataToEncrypt) + 1;

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 9 7

Page 319
Image 319
RSA Security 5.2.2 manual Using Ecaes, Tfreesignature BDestoryAlgorithmObject &ecDSAVerify