RSA Security 5.2.2 manual Now you can set your algorithm object as follows, Unsigned int

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 207
Image 207

Block Ciphers

Once again, encryptionMethodName is the block cipher that you will use; in this example, use “rc2”. All the other parameters are the same as for DES, except encryptionParams. For the RC2 cipher, the Reference Manual indicates that you need to supply an A_RC2_PARAMS structure for the RC2 encryption algorithm:

typedef struct

{

 

unsigned int

effectiveKeyBits;

/* effective key size in bits */

}A_RC2_PARAMS;

There is a distinction between key size and effective key bits. The RC2 algorithm begins by building a 128-byte table based on the key. The total number of possible tables is limited by the number of effective key bits. Using 80 effective key bits is generally sufficient for most applications.

Use Cipher Block Chaining (CBC) for your feedback method. Once again, for this method, you need an initialization vector; use a random number generator to produce one. Remember, the IV is not secret and will not assist anyone in breaking the encryption. Its size will be eight bytes, because the RC2 cipher encrypts blocks of eight bytes. The Reference Manual says that feedbackParams is an ITEM structure containing the initialization vector:

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

}ITEM;

Now you can set your algorithm object as follows:

ITEM ivItem;

unsigned char initVector[BLOCK_SIZE]; A_RC2_PARAMS rc2Params; B_BLK_CIPHER_W_FEEDBACK_PARAMS fbParams;

/* Complete steps 1 - 4 of Generating Random Numbers, then call B_GenerateRandomBytes. */

if ((status = B_GenerateRandomBytes (randomAlgorithm, (unsigned char *)initVector, 8, (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

1 8 5

Page 207
Image 207
RSA Security 5.2.2 manual Now you can set your algorithm object as follows, Unsigned int