Performing Elliptic Curve Operations
302 RSA BSAFE Crypto-C Developers Guide
ECAES Private-Key Decryption
The steps for decryption are similar to those for encryption.
Step 1: Create
Create an algorithm object:
Step 2: Set
Associate the algorithm object with AI_EC_ES and pass NULL_PTR as the third
argument:
Step 3: Init
At this point, commit your algorithm object to perform decryption with a particular
private key. Be sure that EC_CHOOSER contains the appropriate algorithm methods:
Step 4: Update
Since you know that the length of the plaintext cant be larger than the length of the
ciphertext, youll use this approximation to allocate space for the decrypted data:
B_ALGORITHM_OBJ ecESDecrypt = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&ecESDecrypt)) != 0)
break;
if ((status = B_SetAlgorithmInfo
(ecESDecrypt, AI_EC_ES, NULL_PTR)) != 0)
break;
B_ALGORITHM_METHOD *EC_CHOOSER[] = {
&AM_ECFP_DECRYPT,
&AM_ECF2POLY_DECRYPT,
(B_ALGORITHM_METHOD *)NULL_PTR
};
if ((status = B_DecryptInit (ecESDecrypt, privateKey, EC_CHOOSER,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;