.. _rsa-primitives: RSA Primitives ============== The functions described in this section refer to RSA primitives. The application code for conducting a typical RSA encryption must perform the following sequence of operations, starting with building of a crypto system: #. Call the function `RSA_GetSizePublicKey `__ to get the size required to configure IppsRSAPublicKeyState context. #. Ensure that the required memory space is properly allocated. With the allocated memory, call the `RSA_InitPublicKey `__ function to initialize the context. #. Call `RSA_SetPublicKey `__ to set up RSA public key (*n*, *e*). #. Call the `RSA_GetBufferSizePublicKey `__ function to get the size of a temporary buffer. #. Invoke the `RSA_Encrypt `__ function with the established RSA public key to encode the plaintext into the respective ciphertext. #. Clean up secret data stored in the context. #. Free the memory allocated for the IppsRSAPublicKeyState context by calling the operating system memory free service function. The typical application code for the RSA decryption must perform the following sequence of operations: #. Call the function `GetSizePrivateKeyType1 or RSA_GetSizePrivateKeyType2 `__ to get the size required to configure IppsRSAPrivateKeyState context. #. Ensure that the required memory space is properly allocated. With the allocated memory, call the `InitPrivateKeyType1 or RSA_InitPrivateKeyType2 `__ function to initialize the context. #. Call the `RSA_GetBufferSizePrivateKey `__ function to get the size of a temporary buffer. #. Establish the RSA private key by means of either the `RSA_GenerateKeys `__ function or by the key setup function `RSA_SetPrivateKeyType1 or RSA_SetPrivateKeyType2 `__. The RSA_GenerateKeys function can generate both type 1 and type 2 private keys, while the choice of the key setup function depends on the representation of the private key you are using. #. Invoke the `RSA_Decrypt `__ function with the established RSA public key to decode the ciphertext into the respective plaintext. #. Clean up secret data stored in the context. #. Free the memory allocated for the IppsRSAPrivateKeyState context by calling the operating system memory free service function. You can perform up to 8 encryption/decryption operations at once using the `RSA_MB_Encrypt `__ and `RSA_MB_Decrypt `__ functions. For this, repeat steps 2-4 to set up the required number of keys, and then repeat steps 6-7 for each initialized context. .. rubric:: Related Information :ref:`data-security-considerations` .. toctree:: :maxdepth: 1 rsa_encrypt rsa_mb_encrypt rsa_decrypt rsa_mb_decrypt example-of-using-rsa-algorithm-functions