Developing an app

The BlackBerry 10 Native SDK contains the BlackBerry OS Cryptographic Kernel (version 5.6), which has been validated to FIPS 140-2, Level 1, under Certificate # 1578. Access to Native SDK functionality is provided through Security Builder Crypto.

To use this functionality with your app, you must link your app with libhuapi.so.5 .

Your app must call functions from Security Builder Crypto in the following order for proper usage:

  1. Create a global context by calling hu_GlobalCtxCreate().
  2. Enable support for the Security Builder GSE algorithms by calling hu_RegisterSbg56() .
  3. Enable a system-specific source of seed by calling hu_RegisterSystemSeed().
  4. Initialize the BlackBerry OS Cryptographic Kernel by calling hu_InitSbg56() .
  5. Call Security Builder Crypto functions as required by your app.
  6. Call hu_GlobalCtxDestroy() to destroy the global context before exiting your app.

Multithreading and thread safety

All functions from Security Builder Crypto are thread-safe and re-entrant, and they can be used in a multithreaded app.

However, the opaque objects (discussed in Opaque data types) cannot be shared across threads. Each thread that requires the use of one or more of these objects must create its own instances of them.

Global contexts

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

Every Security Builder Crypto function takes a global context as a parameter. A global context contains the information that's needed to map each function to the corresponding feature in the cryptographic 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:

Not applicable

sb_GlobalCtx globalCtx;
hu_GlobalCtxCreate(mallocFunc, freeFunc,
                   memcpyFunc, memcmpFunc,
                   memsetFunc, timeFunc,
                   cbData, &globalCtx);
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. You must supply specific implementations for the callback functions. Whenever the library needs to perform any memory operations, it calls the appropriate callback functions. The type definitions for the callback functions are described in huctx.h.

As a convenience, default implementations of the callback functions are provided. 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 app, you must call hu_GlobalCtxDestroy() to destroy the global context.

Last modified: 2015-07-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus