RSA Security 5.2.2 manual If status = BDecodeInit asciiDecoder != 0 break

Models: 5.2.2

1 376
Download 376 pages 13.91 Kb
Page 197
Image 197

Converting Data Between Binary and ASCII

if ((status = B_SetAlgorithmInfo

(asciiDecoder, AI_RFC1113Recode, NULL_PTR)) != 0) break;

Step 3: Init

To initialize decoding, call B_DecodeInit. This function takes only one argument, the algorithm object:

if ((status = B_DecodeInit (asciiDecoder)) != 0) break;

Step 4: Update

Enter the data to decode through B_DecodeUpdate. The application is responsible for allocating the space for the output of this routine. When decoding, there will be three bytes of output for every four bytes of input. If memory is a concern, you may want to determine the exact number of bytes you will need. If memory is not a concern, make the output size equal to the input length.

Given your pre-existing ASCII input, your call to the Update function would be as follows:

/* We are assuming asciiEncoding already points to allocated space and contains the data to decode into binary. Also, asciiEncodingLenTotal is already set with the length of the asciiEncoding.

*/

unsigned char *asciiEncoding; unsigned int asciiEncodingLenTotal; unsigned char *binaryDecoding = NULL_PTR; unsigned int binaryDecodingLenUpdate;

/* Allocate a buffer the same size as the ascii data. */ binaryDecoding = T_malloc (asciiEncodingLenTotal);

if ((status = (binaryDecoding == NULL_PTR)) != 0) break;

C h a p t e r 5 N o n - C r y p t o g r a p h i c O p e r a t i o n s

1 7 5

Page 197
Image 197
RSA Security 5.2.2 manual If status = BDecodeInit asciiDecoder != 0 break, If status = binaryDecoding == Nullptr != 0 break