Building for Other Environments

If you need leancrypto to work in other environments like small embedded systems, you need:

  1. Adjust the build system as needed to compile and link it

  2. Adjust the file ext_headers.h to point to the right header files and locations.

  3. set the flag LC_MEM_ON_HEAP if your environment only has a limited stack size. When set, functions with large memory requirements use the heap instead of the stack for this memory. The maximum stack size used by a function is 2048 bytes and is verified by a compiler check.

  4. If your environment does not offer an automated constructor logic that is invoked by the compiler attribute __attribute__((constructor)) you must add the appropriate handling to visibility.h by adding an appropriate LC_CONSTRUCTOR macro. It could be as easy as making LC_CONSTRUCTOR just defining the symbol (see how this macro is defined for LC_EFI) and require that leancrypto is initialized with lc_init.

An example on the approach is given with the Linux kernel support found in the directory linux_kernel.