RSA Security 5.2.2 manual Init

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 230
Image 230

Block Ciphers

rc2PBEParams.effectiveKeyBits = 64; rc2PBEParams.salt = saltData; rc2PBEParams.iterationCount = 5;

if ((status = B_SetAlgorithmInfo (pbEncrypter, AI_MD5WithRC2_CBCPad, (POINTER)&rc2PBEParams)) != 0)

break;

Step 3: Init

You need a key before you can initialize the algorithm object for encryption. In PBE, the password is the key. Simply enter the password data as the key data; Crypto-C will generate the symmetric key from the password and salt.

Step 3a: Creating A Key Object

#define MAX_PW_LEN 20

B_KEY_OBJ pbeKey = (B_KEY_OBJ)NULL_PTR;

if ((status = B_CreateKeyObject (&pbeKey)) != 0) break;

Step 3b: Setting The Key Object

In the Reference Manual Chapter 2 entry for AI_MD5WithRC2_CBCPad, you see you have only one choice for a KI: KI_Item. Looking up KI_Item in Chapter 3 of the Reference Manual, you find that the info you supply to B_SetKeyInfo is a pointer to an ITEM structure, which is:

typedef struct { unsigned char *data; unsigned int len;

}ITEM;

The data portion of the struct is the password. For this example, we will use the following method to enter the password. This method for entering a password is not

2 0 8

R S A B S A F E C r y p t o - C D e v e l o p e r ’s G u i d e

Page 230
Image 230
RSA Security 5.2.2 manual Init