Common Data Security Architecture (CDSA) White Paper

How to Create a CDSA Add-In Module for HP-UX

For further conceptual information about GUIDs, see “Global Unique Identifier (GUID)” on page 49.

2.Define an initializer for each add-in module. The initialization routine is invoked by the system loader immediately after the shared library loads successfully. It is also invoked right before the library is unloaded.

NOTE

To ensure that initialization routines are named uniquely, HP

 

recommends the following naming convention:

 

YourCompanyName_RoutineName_Init()

 

 

The initialization routine is specified by the linker option +I when the library is created. For example:

ld -b -o libmylib.1 +I _MyAddIn_Init ....

In this example, _MyAddIn_Init() becomes your add-in library’s initializer and your add-in source must contain the _MyAddIn_Init routine.

The following is a skeletal example of an add-in initializer:

void _MyAddIn_Init (shl_t hInstance, int loading)

{

if (loading) { /* perform initialization */ #ifdef ISL_SELF_CHECK

/* self-check code here */

#endif

} else { /* perform termination */

/* un-register services by invoking CSSM_DeregisterServices. */

}

}

As this example shows, _MyAddIn_Init() is invoked with loading == 1, when the library is loaded (usually when applications invoke CSSM_ModuleAttach).

To perform termination, _MyAddIn_Init() is invoked again with loading == 0, when applications invoke CSSM_ModuleDetach().

The main purpose of initialization is to perform the add-in self-check. If the add-in module is a CSP, extensive self-checking is required. For CL, TP, and DL add-ins, the routine is

54

Chapter 1

Page 54
Image 54
HP UX Security Products and Features Software manual Ld -b -o libmylib.1 +I MyAddInInit