Performing Elliptic Curve Operations

unsigned char *decryptedData; unsigned int maxDecryptedDataLen; unsigned int outputLenUpdate;

maxDecryptedDataLen = outputLenTotal;

/* Use the outputLenTotal from */

 

 

/* Step 5 of ECAES encryption */

decryptedData

= T_malloc(maxDecryptedDataLen);

if ((status =

(decryptedData == NULL_PTR))

!= 0)

break;

 

 

if ((status =

B_DecryptUpdate

 

 

(ecESDecrypt, decryptedData,

&outputLenUpdate,

maxDecryptedDataLen, encryptedData, outputLenTotal, (B_ALGORITHM_OBJ)NULL_PTR,

(A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 5: Final

unsigned int outputLenFinal, outputLenTotal;

if ((status = B_DecryptFinal

(ecESDecrypt, decryptedData + outputLenUpdate, &outputLenFinal, maxDecryptedDataLen - outputLenUpdate, (B_ALGORITHM_OBJ)NULL_PTR,

(A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

outputLenTotal = outputLenUpdate + outputLenFinal;

Step 6: Destroy

Destroy any objects that are no longer needed. Also, be sure to zeroize and free any allocated memory when it is no longer needed.

B_DestroyAlgorithmObject (&ecESDecrypt);

B_DestroyKeyObject (&privateKey);

T_free (decryptedData);

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

3 0 3

Page 325
Image 325
RSA Security 5.2.2 MaxDecryptedDataLen = outputLenTotal, = TmallocmaxDecryptedDataLen, BDecryptUpdate, OutputLenUpdate