AI_EC_ES:

Performing Elliptic Curve Operations

Step 3: Init

You must initialize the algorithm object to perform encryption. You also need to provide the key that will be used for encryption. The algorithm chooser should contain the encryption algorithm methods listed in the Reference Manual for

B_ALGORITHM_METHOD *EC_CHOOSER[] = { &AM_ECFP_ENCRYPT, &AM_ECF2POLY_ENCRYPT, (B_ALGORITHM_METHOD *)NULL_PTR

};

if ((status = B_EncryptInit (ecESEncrypt, publicKey, EC_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

Step 4: Update

To update, first find the field element length in bytes. Remember that, earlier in “Using Elliptic Curve Parameters” on page 298, you placed the elliptic curve parameters in your algorithm object, ecParamsObj. You can use this object to retrieve the field element length:

A_EC_PARAMS *ecParamInfo; unsigned int fieldElementLen;

if ((status = B_GetAlgorithmInfo ((POINTER *)&ecParamInfo, ecParamsObj, AI_ECParameters)) != 0)

break;

fieldElementLen = (ecParamInfo->fieldElementBits + 7) / 8;

Next, you must allocate space to hold the encrypted data. According to the Reference Manual Chapter 2 entry for AI_EC_ES, the length of the encrypted data will be as much as (21 + 2 · (the size of a field element in bytes) + (length of input in bytes)) bytes.

3 0 0

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 322
Image 322
RSA Security 5.2.2 manual Init, Break FieldElementLen = ecParamInfo-fieldElementBits + 7