Development Environment Guidelines
This manual gives a number of application development guidelines that can be of benefit for both novice and advanced developers using SafeNet ProtectToolkit-C.
An API tutorial is provided in API Tutorial: Development of a Sample Application.
Further sample programs, for which source code has been provided, may be compiled and linked against the supplied libraries. Further details about the sample programs are covered in Chapter 5.
The additional libraries ctextra, ctutil, hex2bin and LMlib are static libraries that contain additional PKCS#11 support and helper functions that are not a part of the PKCS#11 standard. For full details on the content of these libraries please refer to:
>CTLUTIL.H Functionality Reference
The library HSMAdmin calls services on the HSM that are not part of the PKCS#11 standard – see HSMAdmin.H Library Reference for details.
This development kit may be used to build applications for any variant of the SafeNet ProtectToolkit-C runtimes.
NOTE It is assumed that the Native C/C++ compiler is being used.
Compiling and Linking Applications on AIX
It is important that new applications link against libraries in the /opt/safenet/protecttoolkit5/ptk/lib directory instead of the libraries in the /opt/safenet/protecttoolkit5/ptk/lib/legacy directory. This can be achieved by using the -L/opt/safenet/protecttoolkit5/SafeNet ProtectToolkit/lib argument to the compiler or linker. Do not specify the /opt/safenet/protecttoolkit5/ptk/lib/legacy library path, since the legacy shared libraries are deprecated, and support is to be removed in a future release.
You may also want to explicitly specify an embedded library path when linking your own applications and libraries, so that your applications automatically find the required libraries without requiring the LIBPATH environment variable to be set. Do this by using the -blibpath:/usr/lib:/lib:/opt/safenet/protecttoolkit5/ptk/lib option to the linker (ld), or alternatively (if using the compiler to link):
-Wl,-blibpath:/usr/lib:/lib:/opt/safenet/protecttoolkit5/ptk/lib
Compiling and Linking 64-bit Applications on AIX
To compile 64-bit applications for AIX specify the following compiler and linker flags:
-q64
Compiling and Linking 64-bit Applications for Solaris SPARC
To compile 64 bit applications for Solaris SPARC specify the following compiler flags:
-Xarch = v9 -DBITS64
The 64-bit libraries are to be found in the /opt/safenet/protecttoolkit5/ptk/lib/sparcv9 directory. To link against them instead of the libraries in the directory /opt/safenet/protecttoolkit5/ptk/lib, add the following argument to the compiler or linker:
-L /opt/safenet/protecttoolkit5/ptk/lib/sparcv9
NOTE It is assumed that the Sun C/C++ compiler is being used.
Compiling and Linking 64-bit Applications for HP‑UX
To compile 64-bit applications for HP-UX, specify the following compiler flags:
+DD64
The 64 bit libraries are to be found in the /opt/safenet/protecttoolkit5/ptk/lib/64 directory. To link against them instead of the libraries in the directory /opt/safenet/protecttoolkit5/ptk/lib, add the following argument to the compiler or linker:
-L /opt/safenet/protecttoolkit5/ptk/lib/64
MSVC Project Settings
In order to remove link errors when linking to the additional libraries ctextra and ctutil etc, you need to set the MSVC project settings to Multithreaded under the C/C++ tab of the Code generation category, since this is what the libraries were compiled with.
Also add “_WINDOWS” to the Preprocessor definitions under the C/C++ tab of the General category.
Modes of Operation
To switch the SafeNet ProtectToolkit-C operational mode, you will need to ensure that you are linking to the correct cryptoki.dll. As of version 5.3, the setmode tool has been provided for this purpose. Refer to the SafeNet ProtectToolkit-C Administration Guide for more information.