Global Context Structure

The primary data structure in Security Builder Crypto is the global context (sb_GlobalCtx).

Every Security Builder function takes a global context as a parameter. A global context contains the information needed to map each function to the corresponding feature in the cyptographic provider. This information is stored in the context when you call the registration function for the provider (that is, hu_RegisterSbg56()).

To create a global context, call hu_GlobalCtxCreate() as follows:

sb_GlobalCtx globalCtx;
hu_GlobalCtxCreate(mallocFunc, freeFunc,
                   memcpyFunc, memcmpFunc,
                   memsetFunc, timeFunc,
                   cbData, &globalCtx);

The first six parameters to this function are pointers to callback functions. These callback functions are mandatory; you must supply specific implementations. Whenever the library needs to perform any memory operation, it calls the appropriate callback function(s). The type definitions for the callback functions are described in huctx.h .

As a convenience, your package includes default implementations of the callback functions. To create a global context with default implementations of the callback functions, call hu_GlobalCtxCreateDefault(). The binary and source code for the default callback functions are supplied in your package.

You can use the cbData parameter to pass data to your callback functions. When an API function calls one of your callback functions, it passes cbData as a parameter.

At the end of your application, you must call hu_GlobalCtxDestroy() to destroy the global context.