Decrypting the Introductory Example
26 RSA BSAFE Crypto-C Developers Guide
Decrypting the Introductory Example
Decrypting data is similar to encrypting. The RC4 cipher uses symmetric-key
encryption, which means the key that was used to encrypt will be the key needed for
decryption.
The example in this section corresponds to the file dintroex.c.
Step 1: Creating an Algorithm Object
First create the algorithm object.
Step 2: Setting the Algorithm Object
Use the same AI and parameters as for encryption:
Step 3: Init
Use the same key data as for encryption. Once again, we must create and set the key
object.

Step 3a: Creating the Key Object

As before, we name our key object
rc4Key
and declare it as follows:
Then we allocate space for the key object using B_CreateKeyObject:
B_ALGORITHM_OBJ rc4Decrypter = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&rc4Decrypter)) != 0)
break;
if ((status = B_SetAlgorithmInfo
(rc4Decrypter, AI_RC4, NULL_PTR)) != 0)
break;
B_KEY_OBJ rc4Key = (B_KEY_OBJ)NULL_PTR;
if ((status = B_CreateKeyObject (&rc4Key)) != 0)
break;