RSA Security 5.2.2 Projection Television User Manual


 
Introductory Example
10 RSA BSAFE Crypto-C Developers Guide
specify the type of algorithm that is being used, supply any special information or
parameters that the algorithm requires, and generate or supply a key for algorithms
that need one.
In Step 1, we simply create the object. We do this by declaring a variable to be an
algorithm object and calling
B_CreateAlgorithmObject.
In this case, we name our algorithm object
rc4Encrypter
and declare it as follows:
The data type
B_ALGORITHM_OBJ is defined in bsafe.h:
typedef POINTER B_ALGORITHM_OBJ;
where POINTER is defined in aglobal.h:
typedef unsigned char *POINTER;
and NULL_PTR is also defined in aglobal.h:
#define NULL_PTR ((POINTER)0)
So our variable,
rc4Encrypter
, is a pointer. To prevent problems when the algorithm
object is destroyed, it is a good idea to initialize it to
NULL_PTR. See Step 6 for details.
To create an algorithm object, we call
B_CreateAlgorithmObject. Chapter 4 of the
Reference Manual gives the function prototypes and descriptions of all the Crypto-C
calls. For
B_CreateAlgorithmObject, we find:
Because
B_CreateAlgorithmObject takes a pointer to a B_ALGORITHM_OBJ as its
argument, we have to pass the address of
rc4Encrypter
. The return value is an int.
Most Crypto-C calls return either a 0 (zero), which indicates success, or a non-zero
error code. After the call, look at the return value: if it is 0, continue; if not, stop. At
RSA Security, the tradition is to name the return value
status
:
B_ALGORITHM_OBJ rc4Encrypter = (B_ALGORITHM_OBJ)NULL_PTR;
int B_CreateAlgorithmObject (
B_ALGORITHM_OBJ *algorithmObject /* new algorithm object */
);