Debian Codegraph @

README.md

raw symbols SCIP
1 libkcapi -- Linux Kernel Crypto API User Space Interface Library [![Build Status](https://github.com/smuellerDD/libkcapi/workflows/checks/badge.svg)](https://github.com/smuellerDD/libkcapi/actions?query=branch%3Amaster)
2 [![Code Quality: Cpp](https://img.shields.io/lgtm/grade/cpp/github/smuellerDD/libkcapi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/smuellerDD/libkcapi/context:cpp)
3 ================================================================
4
5 libkcapi allows user-space to access the Linux kernel crypto API.
6
7 libkcapi uses this Netlink interface and exports easy to use APIs so that
8 a developer does not need to consider the low-level Netlink interface handling.
9
10 The library does not implement any cipher algorithms. All consumer requests
11 are sent to the kernel for processing. Results from the kernel crypto API
12 are returned to the consumer via the library API.
13
14 The kernel interface and therefore this library can be used by unprivileged
15 processes.
16
17 The focus during the development of this library is put on speed. This library
18 does not perform any memcpy for processing the cryptographic data! The library
19 uses scatter / gather lists to eliminate the need for moving data around in
20 memory.
21
22 Directory Structure
23 ===================
24
25 `lib/` -- directory holding the library
26
27 `apps/` -- directory holding the applications discussed below; these
28 applications link the library code in.
29
30 `test/` -- functional verification code
31
32 `speed-test/` -- performance tests
33
34 `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.
35
36 Applications
37 ============
38
39 The libkcapi distribution contains the following applications which are
40 intended as a drop-in replacement for the respective applications commonly
41 available in all Linux distributions:
42
43 * coreutils: sha512sum, sha384sum, sha256sum, sha224sum, sha1sum, md5sum
44
45 * libfipscheck: fipscheck / fipshmac
46
47 * hmaccalc: sha512hmac, sha384hmac, sha256hmac, sha224hmac, sha1hmac, sm3hmac
48
49 The output as well as the command line options are modeled according to the
50 commands found in the coreutils package.
51
52 In addition, the following tool is available:
53
54 * `kcapi-rng`: This tool allows obtaining random numbers from the kernel
55 crypto API RNGs. It shall allow users a similar operation as a
56 `cat /dev/hwrand` call.
57
58 * `kcapi-enc`: This tool provides command line access to the symmetric ciphers
59 of the kernel crypto API. It is conceptually similar to the openssl enc
60 tool.
61
62 * `kcapi-dgst`: To generate message digests and keyed message digests using
63 the kernel crypto API ciphers, this command line tool can be used. It is
64 conceptually similar to openssl dgst.
65
66 These applications do not depend on any user space library other than the
67 C-lib.
68
69
70 Version Numbers
71 ===============
72 The version numbers for this library have the following schema:
73 MAJOR.MINOR.PATCHLEVEL
74
75 Changes in the major number implies API and ABI incompatible changes, or
76 functional changes that require consumer to be updated (as long as this
77 number is zero, the API is not considered stable and can change without a
78 bump of the major version).
79
80 Changes in the minor version are API compatible, but the ABI may change.
81 Functional enhancements only are added. Thus, a consumer can be left
82 unchanged if enhancements are not considered. The consumer only needs to
83 be recompiled.
84
85 Patchlevel changes are API / ABI compatible. No functional changes, no
86 enhancements are made. This release is a bug fixe release only. The
87 consumer can be left unchanged and does not need to be recompiled.
88
89 Build instructions
90 ==================
91 The build system is based on `autotools`. First of all, you have to run the
92 following command that will generate the `Makefile` and the `configure` script:
93 ```
94 $ autoreconf -i
95 ```
96 The `configure` script supports the following options:
97 * `--prefix=$PREFIX`: install the library and the applications to
98 `$PREFIX`
99 * `--enable-kcapi-test`: compile and install the `kcapi` test program
100 * `--enable-kcapi-speed`: compile and install `kcapi-speed` test program
101 * `--enable-kcapi-hasher`: compile and install the drop-in replacement
102 applications
103 * `--enable-kcapi-rngapp`: compile and install the kcapi-rng application
104 * `--enable-kcapi-encapp`: compile and install the kcapi-enc application
105 * `--enable-kcapi-dgstapp`: compile and install the kcapi-dgst application
106 * The various `--disable-lib-*` options allows the disabling of different
107 library functions to allow minimizing the binary.
108 * The various `--enable-lib-*` options allow the enabling of the different
109 library functions. All library functions referenced there do not have an
110 equivalent kernel support in the upstream Linux kernel. Yet, patches are
111 available in the `kernel-patches` directory that provide that interface
112 which need to be added to the kernel if desired.
113
114 For instance, to compile the library with the `kcapi` test program and to
115 install them in `/usr/`:
116 ```
117 $ ./configure --prefix=/usr/ --enable-kcapi-test
118 ```
119
120 Then, run `make` to compile and `make install` to install in the folder
121 specified by the `--prefix` option.
122
123 The Makefile compiles libkcapi as a shared library and as a static libary.
124
125 Build documentation
126 -------------------
127 `xmlto` is required to build the man pages and the documentation in doc/html.
128 `db2pdf` and `db2ps` are required to build the documentation in PDF or in PS format.
129
130 Use the following targets to generate the documentation in the appropriate format:
131 * `make man`
132 * `make pdf`
133 * `make ps`
134 * `make html`
135
136 To install the man pages run: `make install-man`.
137
138 Static Code analyzer
139 --------------------
140 If `clang` or `cppcheck` are installed, you can use the following targets to
141 run them on the source code:
142 * `make scan`
143 * `make cppcheck`
144
145 Test cases
146 ==========
147
148 The test/ directory contains test cases to verify the correct operation of
149 this library. In addition it allows the verification of the correct operation
150 of the kernel crypto API.
151
152 The test cases are documented in test/README.
153
154
155 Integration of libkcapi into other projects
156 ===========================================
157
158 The libkcapi library does not have any dependencies except to the C-library
159 (and the kernel, naturally). This allows developers to integrate the
160 library into their project either as a shared library or natively by simply
161 copying the required C and header files into the target project and compile
162 them along.
163
164 When compiling them as part of a project, no special compile time flags are
165 needed as the library is written in clean C. Though, the project author should
166 consider the COMMON_CPPFLAGS and COMMON_LDFLAGS in Makefile.am as they
167 collectively provide additional security checks offered by the compiler or
168 the underlying platform.
169
170 To integrate the library source code directly into projects, the following
171 files must always be copied into the target project irrespective of the cipher
172 operations the project wants to use:
173
174 * kcapi-kernel-if.c (this provides the basic kernel interface logic)
175
176 * all header files
177
178 Now, a project may selectively copy the following files as required for the
179 respective project. The listed files do not have mutual dependencies unless
180 explicitly noted:
181
182 * kcapi-aead.c (AEAD cipher support providing kcapi_aead_* functions)
183
184 * kcapi-asym.c (asymmetric cipher support providing all kcapi_akcipher_* functions)
185
186 * kcapi-md.c (message digest and keyed message digest support providing all kcapi_md_* functions)
187
188 * kcapi-rng.c (random number generator support providing all kcapi_rng_* functions)
189
190 * kcapi-sym.c (symmetric cipher support providing all kcapi_cipher_* functions)
191
192 * kcapi-kdf.c (depending on the presence of kcapi-md.c -- providing the KDF, HKDF and PBKDF implementations with the functions of kcapi_*kdf_*)
193
194 * kcapi-utils.c (small helper functions providing, including versioning APIs)
195
196 * kcapi-kpp.c (key protocol primitives (i.e. Diffie-Hellman and EC Diffie-Hellman) support providing all kcapi_kpp_* functions)
197
198 Author
199 ======
200 Stephan Mueller <[email protected]>