Converting Data Between Binary and ASCII
174 RSA BSAFE Crypto-C Developers Guide
Step 5: Final
Finalize the encoding process, writing out any remaining bytes:
Step 6: Destroy
Remember to destroy all objects and free up any memory allocated when done:
Decoding ASCII-Encoded Data
Step 1: Creating An Algorithm Object
Declare a variable to be B_ALGORITHM_OBJ. As defined in the function prototype in
Chapter 4 of the Reference Manual, its address is the argument for
B_CreateAlgorithmObject:
Step 2: Setting The Algorithm Object
There is only one ASCII-encoding or decoding AI, AI_RFC1113Recode. The Reference
Manual Chapter 2 entry on this AI states that the format of
info
supplied to
B_SetAlgorithmInfo is NULL_PTR:
unsigned int asciiEncodingLenFinal;
if ((status = B_EncodeFinal
(asciiEncoder, asciiEncoding + asciiEncodingLenUpdate,
&asciiEncodingLenFinal,
(binaryDataLen * 2) - asciiEncodingLenUpdate)) != 0)
break;
B_DestroyAlgorithmObject (&asciiEncoder);
T_free (asciiEncoding);
B_ALGORITHM_OBJ asciiDecoder = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&asciiDecoder)) != 0)
break;