Performing Elliptic Curve Operations
300 RSA BSAFE Crypto-C Developerโ€™s Guide
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 AI_EC_ES:
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:
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.
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;
A_EC_PARAMS *ecParamInfo;
unsigned int fieldElementLen;
if ((status = B_GetAlgorithmInfo ((POINTER *)&ecParamInfo, ecParamsObj,
AI_ECParameters)) != 0)
break;
fieldElementLen = (ecParamInfo->fieldElementBits + 7) / 8;