Integrating Security Builder Engine for OpenSSL into your applications

To integrate Security Builder Engine for OpenSSL into your own OpenSSL based applications, you need to include code to load the engine.

A convenience function is provided to load the engine. You must also ensure that the operating system will be able to find the dynamically-loaded Security Builder Engine for OpenSSL library at runtime.

The convenience function ENGINE_load_sb() is defined in the header file sbengine.h. Its use is optional; you can also directly call OpenSSL APIs to load the engine.

You must call the OpenSSL ENGINE_cleanup() function before program exit, to avoid memory leaks.

The following code snippet demonstrates how you can use the convenience function to load the Security Builder Engine for OpenSSL from within an application:

#include <openssl/engine.h>
#include "sbengine.h"

/* sbengine variables */
ENGINE * engine = NULL;

/* Register the error strings for all OpenSSL functions */
ERR_load_crypto_strings();

/* Load all the OpenSSL bundled ENGINEs into memory and 
   make them visible */
ENGINE_load_builtin_engines();

/* Load the Security Builder ENGINE (for OpenSSL) into memory
   and make it visible.

   The ENGINE_METHOD_ALL parameter will configure OpenSSL to make
   the Security Builder ENGINE default for all algorithms
   supported by the Security Builder ENGINE.
   
   If ENGINE_METHOD_NONE was used instead then the Security
   Builder ENGINE would not be configured as default.
   See documentation for ENGINE_load_sb(). */
ENGINE_load_sb( ENGINE_METHOD_ALL );

/* Obtain an ENGINE instance of the Security Builder ENGINE */
engine = ENGINE_by_id(SBENGINE_ID);

if (!engine){
    fprintf(stderr," %s - find engine by id '%s': %s\n", __FILE__,
            SBENGINE_ID, !engine ?"failed" : "success");
    exit(1);
}
/* end sbengine code */

ENGINE_cleanup();
            

Prerequisites

You must link a set of libraries in a certain order to successfully integrate Security Builder Engine for OpenSSL with your app.

If you're using a makefile to build your app, include the following:

LIBS+=crypto loadsbengine ssl loadsbengine                   
               

If you're using a .profile to build your app, include the following:

LIBS += -lcrypto
LIBS += -lloadsbengine
LIBS += -lsbgse56                   
LIBS += -lssl
               

Last modified: 2015-07-24



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

comments powered by Disqus