Programming examples for openCryptoki

The provided program segments in C illustrate some openCryptoki sample APIs to be used for EP11.

The contained openCryptoki code samples provide an insight into how to deal with the openCryptoki API's. After describing some basic functions such as initialization, session and log-in handling, the samples provide an introduction about how to create key objects and process symmetric encryption/decryption (AES). The last section shows RSA key generation with RSA encrypt and decrypt operations.

To develop an application that uses the openCryptoki library, you need to access the library. You achieve the loading of shared objects by using dynamic library calls (dlopen) as described in the sample provided in Base procedures.

At compile time, you need to specify the openCryptoki library:
gcc test_ock.c -g -O0 -o test_ock -lopencryptoki -ldl
-I /usr/include/opencryptoki/
The exact location of the include files depends on your Linux distribution.

The following sample categories are provided:

  • Base procedures
  • Session and log-in
  • Object handling
  • Cryptographic operations