A SERVICE OF

logo

Block Ciphers
208 RSA BSAFE Crypto-C Developers Guide
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
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:
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
rc2PBEParams.effectiveKeyBits = 64;
rc2PBEParams.salt = saltData;
rc2PBEParams.iterationCount = 5;
if ((status = B_SetAlgorithmInfo
(pbEncrypter, AI_MD5WithRC2_CBCPad,
(POINTER)&rc2PBEParams)) != 0)
break;
#define MAX_PW_LEN 20
B_KEY_OBJ pbeKey = (B_KEY_OBJ)NULL_PTR;
if ((status = B_CreateKeyObject (&pbeKey)) != 0)
break;
typedef struct {
unsigned char *data;
unsigned int len;
} ITEM;