MultiPrime

/* generalFlag is for the surrender function.*/ generalFlag = 0;

if ((status = B_DecryptUpdate

(rsaDecryptor, decryptedData, &outputLenUpdate, BLOCK_SIZE, encryptedData, outputLenTotal, NULL_PTR, &generalSurrenderContext)) != 0)

break;

Step 5: Final

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;

Step 6: Destroy

When you are done with all objects, remember to destroy them:

B_DestroyAlgorithmObject (&rsaDecryptor);

B_DestroyKeyObject (&privateKey);

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

C h a p t e r 7 P u b l i c - K e y O p e r a t i o n s

2 3 1

Page 253
Image 253
RSA Security 5.2.2 manual Optimal Asymetric Encryption Padding Oaep, Raw RSA Encryption and Decryption