Performing Elliptic Curve Operations
284 RSA BSAFE Crypto-C Developers Guide

Step 5: Phase 2

By the time you have reached this step, Alice and Bob have exchanged public values.
Assume that the pointer
bobPublicValue
points to Bobs public value and
bobPublicValueLen
gives the length of Bob's public value:
Using Bobs public value, Alice can compute the secret key that she and Bob will use
to communicate with each other:
Step 6: Destroy
Always destroy key objects and algorithm objects once they are no longer needed:
Performing ECDSA in Compliance with ANSI X9.62
The Elliptic Curve Digital Signature Agreement (ECDSA) is an elliptic curve analogue
of DSA. This section shows how to perform ECDSA in compliance with the ANSI
X9.62 Standard, which specifies an implementation of ECDSA.
unsigned char *bobPublicValue;
unsigned int bobPublicValueLen;
unsigned char *aliceSecretValue = NULL_PTR;
unsigned int aliceSecretValueLen;
aliceSecretValue = T_malloc(maxPhase2Len);
if ((status = (aliceSecretValue == NULL_PTR)) != 0)
break;
if ((status = B_KeyAgreePhase2(alice, aliceSecretValue,
&aliceSecretValueLen, maxPhase2Len,
bobPublicValue, bobPublicValueLen,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
T_free (alicePublicValue);
T_free (aliceSecretValue);
B_DestroyAlgorithmObject(&randomAlgorithm);
B_DestroyAlgorithmObject(&alice);