Skip to content

Commit 50ae1e0

Browse files
committed
doc: add coding guidelines
Signed-off-by: Stephan Mueller <smueller@chronox.de>
1 parent 54324f4 commit 50ae1e0

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

coding-guidelines.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Code Structure
2+
3+
Due to the fact that leancrypto is compiled for many different execution environments, the compilation process must consider the specifics of each target execution environment. The leancrypto code implements target-specific code in independent source code files. Depending on the target environment, the source code files are or are not compiled.
4+
5+
## Modules
6+
7+
The leancrypto code contains different modules which are encapsulated into different directories.
8+
9+
The following modules are present:
10+
11+
* `aead`: Implements AEAD symmetric algorithms.
12+
13+
* `apps`: Applications provided with leancrypto
14+
15+
* `asn1`: ASN.1, X.509 and PKCS#7/CMS code
16+
17+
* `bike`: Code-based PQC algorithm of BIKE
18+
19+
* `curve25519`: Curve25519 implementation including EdDSA and ECDH
20+
21+
* `doc`: Doxygen generator
22+
23+
* `drng`: Deterministic random number generator including the seeded_rng implemenation with its link code to entropy sources.
24+
25+
* `efi`: Compilation support for EFI environment
26+
27+
* `hash`: hash implemenations of SHA2, SHA3, Ascon
28+
29+
* `hmac`: HMAC implementation
30+
31+
* `internal`: Support code
32+
33+
* `kdf`: Different key derivation functions
34+
35+
* `kmac`: SP800-185 KMAC
36+
37+
* `linux_kernel`: Linux kernel compilation support and code to register leancrypto with the kernel crypto API
38+
39+
* `ml-dsa`: FIPS 204 ML-DSA PQC algorithm
40+
41+
* `ml-kem`: FIPS 203 ML-KEM PQC algorithm
42+
43+
* `otp`: One-Time-Pad algorithms
44+
45+
* `slh-dsa`: FIPS 205 SLH-DSA algorithm
46+
47+
* `sym`: symmetric encryption algorithms with their block chaining modes
48+
49+
## Module Directories
50+
51+
The individual module directories have a common structure:
52+
53+
* `api`: Header files used in other parts of leancrypto or defining official APIs
54+
55+
* `doc`: Algorithm specifications
56+
57+
* `src`: Actual implementation
58+
59+
* `tests`: Unit tests for the implementation
60+
61+
## Coding Guidelines
62+
63+
Code changes should follow these guidelines:
64+
65+
* KNF code format (use `addon/clang-format-helper.sh`)
66+
67+
* All externally visible symbols are prefixed with `lc_`.
68+
69+
* All externally visible macros are prefixed with `LC_`.
70+
71+
* All header files defining external APIs must have a name starting with `lc_` and cannot include internal header files.
72+
73+
* Ifdef's in the C code should be reduced to an absolute minimum. Conditional compilation is defined by the build environment. If a C file that can be conditionally compiled provides services to other C files, the associated header file shall contain ifdef'ed NOOP functions.

0 commit comments

Comments
 (0)