intel/cryptography-primitives

Is there any example about how to generate RSA key pair by ippsRSA_GenerateKeys()?

Closed this issue · 2 comments

Is there any example about how to generate RSA key pair by ippsRSA_GenerateKeys(). Per my understanding, I have to allocate memory for pModulus, pPublicExp and pPrivateExp respectively before call ippsRSA_GenerateKeys(), right? If the bit size of n is 1024 and the bit size of e is 16, I can allocate memory for pModulus and pPublicExp easily. However, how can I allocate memory for pPrivateExp as I don't know the bit size of d. Is there any relationship between the bit size of n, e and d? Thanks.

No, unfortunately we don't have a complete example in the source tree, but you can refer to the Developer Reference page for description of the function and steps that should be taken to use it.

The bit size of the private exponent is at most bit size of modulus, so you should allocate an IppsBigNumState object of this size:

int size;
const int len = 1024 / 32;
ippsBigNumGetSize(len, &size);
IppsBigNumState* pBN = (IppsBigNumState*) malloc(size);
ippsBigNumInit(len, pBN);

Thanks for your answer.