RSA Security 5.2.2 manual Int BSetKeyInfo, Key information

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 36
Image 36
KI_Item

Introductory Example

object as an RC4 key, we need to use B_SetKeyInfo. See Chapter 4 of the Reference Manual for this function’s description and prototype:

int B_SetKeyInfo (

 

B_KEY_OBJ

keyObject,

/* key object */

B_INFO_TYPE

infoType,

/* type of key information */

POINTER

info

/* key information */

);

 

 

 

 

 

This function is similar to B_SetAlgorithmInfo. The first argument is the key object just created, rc4Key. The second argument is a key info type (KI), and the third argument is information that must accompany the given KI. We want to use a KI compatible with RC4 encryption, so we return to the entry for our AI, AI_RC4, in Chapter 2 of the Reference Manual:

Key info types for keyObject in B_EncryptInit or B_DecryptInit: that gives the address and length of the RC4 key.

Key info types are described in Chapter 3 of the Reference Manual. Under the entry for KI_ITEM we find that the format of info supplied to B_SetKeyInfo is a pointer to an ITEM structure:

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

}ITEM;

len is the length of the key in bytes. The RC4 cipher takes key sizes of 1 to 256 bytes. A 10-byte key is generally sufficient for most applications. data is the key data. A real application would use a random number generator to produce 10 bytes for the key (see “Generating Random Numbers” on page 165). For this example, we can simply use:

1 4

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 36
Image 36
RSA Security 5.2.2 manual Int BSetKeyInfo, Key information