Chapter 4 Details of Crypto-C Functions 313
B_EncryptInit
B_EncryptInit
Description
B_EncryptInit initializes
algorithmObject
for encrypting data using the algorithm
specified by a previous call to B_SetAlgorithmInfo. The key object for supplying the
key information is
keyObject
. The chooser for selecting the algorithm method is
algorithmChooser
. The surrender context for processing and canceling during lengthy
operations is
surrenderContext
; if its value is (A_SURRENDER_CTX *)NULL_PTR, Crypto-C
does not use it.
B_EncryptInit only needs to be called once to set up a key. The B_EncryptUpdate
routine can be called multiple times to process blocks of data, and B_EncryptFinal is
called once to process the last block, which includes adding the trailing pad bytes.
After B_EncryptFinal is called, B_EncryptUpdate can be called to start processing
another sequence of blocks. If a different CBC Initialization Vector (IVs) is used with
each sequence of blocks, B_SetAlgorithmInfo can be called with AI_CBC_IV8 to set the
new IV before calling B_EncryptUpdate. There is no need to call B_EncryptInit again
with the same key.
Return value
int B_EncryptInit (
B_ALGORITHM_OBJ algorithmObject, /* algorithm object */
B_KEY_OBJ keyObject, /* key object */
B_ALGORITHM_CHOOSER algorithmChooser, /* algorithm chooser */
A_SURRENDER_CTX *surrenderContext /* surrender context */
);
Value Description
0 Operation was successful.
non-zero see Appendix A, “Crypto-C Error Types”