Code Example
Code Example
The following code example summarizes the
#include “aglobal.h” #include “bsafe.h” #include “demochos.h”
#define NULL_SURRENDER_PTR ((A_SURRENDER_CTX *)NULL_PTR)
int EncryptData
(output, outputLen, maxOutputLen, input, inputLen, keyValue, iv)
unsigned char *output; |
| /* pointer to output data */ |
unsigned int outputLen; |
| /* pointer to length of encrypted data */ |
unsigned int maxOutputLen; | /* size of output buffer */ | |
unsigned char *input; |
| /* pointer to input data buffer */ |
unsigned int inputLen; |
| /* length of input data */ |
unsigned char *keyValue; |
| /* pointer to |
unsigned char *iv; | /* pointer to |
{
B_ALGORITHM_OBJ desAlgorithm = (B_ALGORITHM_OBJ)NULL_PTR; B_KEY_OBJ desKey = (B_KEY_OBJ)NULL_PTR; B_BLK_CIPHER_W_FEEDBACK_PARAMS feedbackParams;
ITEM initVector; unsigned int partOutLen; int status;
/* break commands jump to the end of the do while (0) block */ do {
if ((status = B_CreateKeyObject (&desKey)) != 0) break;
if ((status = B_SetKeyInfo
(desKey, KI_DES8Strong, (POINTER)keyValue)) != 0) break;
C h a p t e r 1 I n t r o d u c t i o n | 5 |