NULL_PTR

Block Ciphers

secure; it is used for illustrative purposes only. It is not for duplication:

unsigned char enteredPassword[MAX_PW_LEN]; ITEM pbeKeyItem;

puts ("Enter the password, then press Return or Enter"); gets ((char *)enteredPassword);

pbeKeyItem.data = enteredPassword; pbeKeyItem.len = strlen (enteredPassword);

if ((status = B_SetKeyInfo

(pbeKey, KI_Item, (POINTER)&pbeKeyItem)) != 0) break;

You should zeroize any sensitive data after leaving the do-while. In fact, you might want to zeroize the memory immediately after you set the key:

T_memset (pbeKeyItem.data, 0, MAX_PW_LEN);

Now that you have a key, you need an algorithm chooser and a surrender context.

This is a speedy function, so it is reasonable to use a properly castfor the surrender context. You do want to build a chooser:

B_ALGORITHM_METHOD *PBE_CHOOSER[] = { &AM_MD5,

&AM_RC2_CBC_ENCRYPT,

(B_ALGORITHM_METHOD *)NULL_PTR

};

if ((status = B_EncryptInit (pbEncrypter, pbeKey, PBE_CHOOSER, (A_SURRENDER_CTX *)NULL_PTR)) != 0)

break;

C h a p t e r 6 S y m m e t r i c - K e y O p e r a t i o n s

2 0 9

Page 231
Image 231
RSA Security 5.2.2 manual Tmemset pbeKeyItem.data, 0, Maxpwlen