Performing Elliptic Curve Operations

ECAES Private-Key Decryption

The steps for decryption are similar to those for encryption.

Step 1: Create

Create an algorithm object:

B_ALGORITHM_OBJ ecESDecrypt = (B_ALGORITHM_OBJ)NULL_PTR;

if ((status = B_CreateAlgorithmObject (&ecESDecrypt)) != 0) break;

Step 2: Set

Associate the algorithm object with AI_EC_ES and pass NULL_PTR as the third argument:

if ((status = B_SetAlgorithmInfo

(ecESDecrypt, AI_EC_ES, NULL_PTR)) != 0)

break;

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:

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;

Step 4: Update

Since you know that the length of the plaintext can’t be larger than the length of the ciphertext, you’ll use this approximation to allocate space for the decrypted data:

3 0 2

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 324
Image 324
RSA Security 5.2.2 manual Ecaes Private-Key Decryption, Steps for decryption are similar to those for encryption