Chapter 7 Public-Key Operations 231
MultiPrime
Step 5: Final
Step 6: Destroy
When you are done with all objects, remember to destroy them:
Optimal Asymetric Encryption Padding (OAEP)
See the rsaplccs2.c code sample for an example of RSA encryption with OAEP as
defined in PKCS V1.2. See the Setoaep.c code sample for an example showing RSA
encryption with OAEP as defined in the SET spec.
Raw RSA Encryption and Decryption
When you used AI_PKCS_RSAPublic, you could not encrypt more than k 11 bytes,
where k was the size of the modulus in bytes. That is because PKCS RSA encryption
pads, and the padding scheme needs 11 spare bytes to work. This is intended for
digital envelopes and digital signatures; in these situations, the number of bytes to
/* generalFlag is for the surrender function.*/
generalFlag = 0;
if ((status = B_DecryptUpdate
(rsaDecryptor, decryptedData, &outputLenUpdate, BLOCK_SIZE,
encryptedData, outputLenTotal, NULL_PTR,
&generalSurrenderContext)) != 0)
break;
unsigned int outputLenFinal;
/* generalFlag is for the surrender function.*/
generalFlag = 0;
if ((status = B_DecryptFinal
(rsaDecryptor, decryptedData + outputLenUpdate,
&outputLenFinal, BLOCK_SIZE - outputLenUpdate, NULL_PTR,
&generalSurrenderContext)) != 0)
break;
B_DestroyAlgorithmObject (&rsaDecryptor);
B_DestroyKeyObject (&privateKey);