I am trying to create a function for a dll that takes in a char* to a string and encrypts the string. I am not sure why I get a ippStscontextMatchErr when I send in my context to the ippsRSASetkey function. I am following the steps stated in the user manual for cryptography:
"The application code for conducting a typical RSA encryption must perform the following sequence of operations, starting with building of a crypto system:
1. Call the function RSAGetSize to get the size required to configure IppsRSAState context.
2. Ensure that the required memory space is properly allocated. With the allocated memory, call the RSAInit function to initialize the context for the RSA encryption.
3. Keep calling the RSASetKey to set up RSA public key (n, e).
4. Invoke the RSAEncrypt function with the established RSA public key to encode the plaintext into the respective ciphertext.
5. Free the memory allocated for the IppsRSAState context by calling the operating system memory free service function."
//not sure if I can just pass in a char* like the AES IPP ippsRSAEncrypt((IppsBigNumState*)myString, pY, pCtx);
memcpy(encrypted, pY, strlen(myString)); }
So all in all, the call to ippsRSASetkey throws a return value of -17 which says that the context parameter does not match the operation. I am confused as I thought the ippsRSAinit function takes care of the context (pCtx).
the main problem of code snippet you provide is that it does not use ippsBigNumber data type (just casting of memory buffer to ippsBigNumber type is not enoughand is notcorrect). Please refer to IPP documentation for more details.
ippsRSAEncrypt((IppsBigNumState*)myString, pY, pCtx); [gres] Both "myString" and "Y" are not ippsBigNumState. That is why "ippStscontextMatchErr" is detected