Home

Awesome

libkcapi -- Linux Kernel Crypto API User Space Interface Library Build Status Code Quality: Cpp

libkcapi allows user-space to access the Linux kernel crypto API.

libkcapi uses this Netlink interface and exports easy to use APIs so that a developer does not need to consider the low-level Netlink interface handling.

The library does not implement any cipher algorithms. All consumer requests are sent to the kernel for processing. Results from the kernel crypto API are returned to the consumer via the library API.

The kernel interface and therefore this library can be used by unprivileged processes.

The focus during the development of this library is put on speed. This library does not perform any memcpy for processing the cryptographic data! The library uses scatter / gather lists to eliminate the need for moving data around in memory.

Directory Structure

lib/ -- directory holding the library

apps/ -- directory holding the applications discussed below; these applications link the library code in.

test/ -- functional verification code

speed-test/ -- performance tests

kernel-patches/ -- Linux kernel patches providing the interfaces for the asymmetric ciphers (akcipher) and the DH/ECDH ciphers (KPP). These patches must be applied to the Linux kernel if the respective configure options of either --enable-lib-asym or --enable-lib-kpp are used.

Applications

The libkcapi distribution contains the following applications which are intended as a drop-in replacement for the respective applications commonly available in all Linux distributions:

The output as well as the command line options are modeled according to the commands found in the coreutils package.

In addition, the following tool is available:

These applications do not depend on any user space library other than the C-lib.

Version Numbers

The version numbers for this library have the following schema: MAJOR.MINOR.PATCHLEVEL

Changes in the major number implies API and ABI incompatible changes, or functional changes that require consumer to be updated (as long as this number is zero, the API is not considered stable and can change without a bump of the major version).

Changes in the minor version are API compatible, but the ABI may change. Functional enhancements only are added. Thus, a consumer can be left unchanged if enhancements are not considered. The consumer only needs to be recompiled.

Patchlevel changes are API / ABI compatible. No functional changes, no enhancements are made. This release is a bug fixe release only. The consumer can be left unchanged and does not need to be recompiled.

Build instructions

The build system is based on autotools. First of all, you have to run the following command that will generate the Makefile and the configure script:

$ autoreconf -i

The configure script supports the following options:

For instance, to compile the library with the kcapi test program and to install them in /usr/:

$ ./configure --prefix=/usr/ --enable-kcapi-test

Then, run make to compile and make install to install in the folder specified by the --prefix option.

The Makefile compiles libkcapi as a shared library and as a static library.

Build documentation

xmlto is required to build the man pages and the documentation in doc/html. db2pdf and db2ps are required to build the documentation in PDF or in PS format.

Use the following targets to generate the documentation in the appropriate format:

To install the man pages run: make install-man.

Static Code analyzer

If clang or cppcheck are installed, you can use the following targets to run them on the source code:

Test cases

The test/ directory contains test cases to verify the correct operation of this library. In addition it allows the verification of the correct operation of the kernel crypto API.

The test cases are documented in test/README.

Integration of libkcapi into other projects

The libkcapi library does not have any dependencies except to the C-library (and the kernel, naturally). This allows developers to integrate the library into their project either as a shared library or natively by simply copying the required C and header files into the target project and compile them along.

When compiling them as part of a project, no special compile time flags are needed as the library is written in clean C. Though, the project author should consider the COMMON_CPPFLAGS and COMMON_LDFLAGS in Makefile.am as they collectively provide additional security checks offered by the compiler or the underlying platform.

To integrate the library source code directly into projects, the following files must always be copied into the target project irrespective of the cipher operations the project wants to use:

Now, a project may selectively copy the following files as required for the respective project. The listed files do not have mutual dependencies unless explicitly noted:

Author

Stephan Mueller smueller@chronox.de