Merge pull request #672 from libtom/some-fixes
[libtomcrypt.git] / README.md
blob661fdbcce2fb335d19e13b883cb58e194ce84699
1 # libtomcrypt
3 Previously the git repository contained `doc/crypt.pdf` for detailed documentation.
4 This was changed and the file is now only available from the tarball of the appropriate version
5 or from the page https://github.com/libtom/libtomcrypt/releases .
7 ## Project Status
9 ### Travis CI
11 master: [![Build Status](https://github.com/libtom/libtomcrypt/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/libtom/libtomcrypt/actions/workflows/main.yml?query=branch%3Amaster+++) [![Coverage Status](https://coveralls.io/repos/libtom/libtomcrypt/badge.png?branch=master)](https://coveralls.io/r/libtom/libtomcrypt)
13 develop: [![Build Status](https://github.com/libtom/libtomcrypt/actions/workflows/main.yml/badge.svg?branch=develop)](https://github.com/libtom/libtomcrypt/actions/workflows/main.yml?query=branch%3Adevelop+++) [![Coverage Status](https://coveralls.io/repos/libtom/libtomcrypt/badge.png?branch=develop)](https://coveralls.io/r/libtom/libtomcrypt)
15 ### AppVeyor
17 master: [![Build status](https://ci.appveyor.com/api/projects/status/xyl2nbdsyp1tj9ye/branch/master?svg=true)](https://ci.appveyor.com/project/libtom/libtomcrypt/branch/master)
19 develop: [![Build status](https://ci.appveyor.com/api/projects/status/xyl2nbdsyp1tj9ye/branch/develop?svg=true)](https://ci.appveyor.com/project/libtom/libtomcrypt/branch/develop)
21 ### Coverity
23 [![Coverity Scan Build Status](https://scan.coverity.com/projects/487/badge.svg)](https://scan.coverity.com/projects/487)
25 ### ABI Laboratory
27 API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtomcrypt/)
29 ## Submitting patches
31 Please branch off from develop if you want to submit a patch.
33 Patch integration will be faster if tests and documentation are included.
35 Please update the makefiles in a separate commit. To update them simply run the `updatemakes.sh` script.
37 If you have something bigger to submit, feel free to contact us beforehand.
38 Then we can give you write access to this repo, so you can open your PR based on this repo
39 and we can easier follow the rebase-before-merge approach we're using (or even do the rebase ourself).
41 ### Reviews
43 We're using Pull Request reviews to make sure that the code is in line with the existing code base.
45 Please have a look [here](https://help.github.com/articles/approving-a-pull-request-with-required-reviews/) to get an idea of the approach.
47 ## Branches
49 Please be aware, that all branches besides _master_ and _develop_ __can__ and __will be__ force-pushed, rebased and/or removed!
51 If you want to rely on such an _unstable_ branch, create your own fork of this repository to make sure nothing breaks for you.
53 ## Configuration options
55 By default the library builds its entire feature set (besides `katja`) in a (depending on your needs more or less) optimal way.
57 There are numerous configuration options available if you want to trim down the functionality of the library.
59 Please have a look at `src/headers/tomcrypt_custom.h` for all available configuration options.
61 The following list is a small part of the available, but the most often required, configuration switches.
63 | Flag | Behavior |
64 | ---- | -------- |
65 | `LTC_NO_TEST` | Remove all algorithm self-tests from the library |
66 | `LTC_NO_FILE` | Remove all API functions requiring a pre-defined `FILE` data-type (mostly useful for embedded targets) |
67 | `GMP_DESC` | enable [gmp](https://gmplib.org/) as MPI provider *\*1* |
68 | `LTM_DESC` | enable [libtommath](http://www.libtom.net/) as MPI provider *\*1* |
69 | `TFM_DESC` | enable [tomsfastmath](http://www.libtom.net/) as MPI provider *\*1* *\*2* |
70 | `USE_GMP` | use `gmp` as MPI provider when building the binaries *\*3* |
71 | `USE_LTM` | use `libtommath` as MPI provider when building the binaries *\*3* |
72 | `USE_TFM` | use `tomsfastmath` as MPI provider when building the binaries *\*3* |
74 *\*1* It is possible to build the library against all MPI providers in parallel and choose at startup-time which math library should be used.
76 *\*2* Please be aware that `tomsfastmath` has the limitation of a fixed max size of MPI's.
78 *\*3* Only one is supported at the time & this is only required when building the binaries, not when building the library itself.
80 ## Building the library
82 There are several `makefile`s provided. Please choose the one that fits best for you.
84 | makefile | use-case |
85 | -------- | -------- |
86 | `makefile` | builds a static library (GNU Make required) |
87 | `makefile.shared` | builds a shared (and static) library (GNU Make required) |
88 | `makefile.unix` | for unusual UNIX platforms, or if you do not have GNU Make |
89 | `makefile.mingw` | for usage with the mingw compiler on MS Windows |
90 | `makefile.msvc` | for usage with the MSVC compiler on MS Windows |
91 | `libtomcrypt_VS2008.sln` | A VisualStudio 2008 project for MS Windows |
93 ### Make targets
95 The `makefile`s provide several targets to build (VS project excluded).
96 The following list does not claim to be complete resp. to be available across all `makefile` variants.
98 | target | application |
99 | ------ | ----------- |
100 | *empty target*/none given | c.f. `library`
101 | `library` | builds only the library |
102 | `hashsum` | builds the `hashsum` binary, similar to [`shasum`](https://linux.die.net/man/1/shasum), but with support for all hash-algorithms included in the library *\*4* |
103 | `ltcrypt` | builds the `ltcrypt` binary, implementing something similar to [`crypt`](https://linux.die.net/man/3/crypt) *\*4* |
104 | `sizes` | builds the `sizes` binary, printing all internal data sizes on invocation *\*4* |
105 | `constants` | builds the `constants` binary, printing all internal constants on invocation *\*4* |
106 | `openssl-enc` | builds the `openssl-enc` binary, which is more or less compatible to [`openssl enc`](https://linux.die.net/man/1/enc) *\*4* *\*5* |
107 | `test` | builds the `test` binary, which runs all algorithm self-tests + some extended tests *\*4* |
108 | `timing` | builds the `timing` binary, which can be used to measure timings for algorithms and modes *\*4* |
109 | `bins` | builds `hashsum` *\*4* |
110 | `all_test` | builds `test`, `hashsum`, `ltcrypt`, `small`, `tv_gen`, `sizes` & `constants` *\*4* |
111 | `docs` | builds the developer documentation `doc/crypt.pdf` |
112 | `install` | installs the `library` and header files *\*7* *\*8* |
113 | `install_bins` | installs the binaries created by the `bins` target *\*7* *\*8* |
114 | `install_docs` | installs the documentation created by the `docs` target *\*7* *\*8* |
115 | `install_test` | installs the test-app created by the `test` target *\*7* *\*8* |
116 | `install_all` | installs everything (i.e. `library`, `bins`, `docs` and `test`) *\*8* |
117 | `uninstall` | uninstalls the `library` and header files |
119 *\*4* also builds `library`
121 *\*5* broken build in some configurations, therefore not built by default
123 *\*7* also builds the necessary artifact(s) before installing it
125 *\*8* also have a look at the 'Installation' section of this file
127 ### Examples
129 You want to build the library as static library
131     make
133 You want to build the library as shared library
135     make -f makefile.shared
137 You have `libtommath` installed on your system and want to build a static library and the `test` binary to run the self-tests.
139     make CFLAGS="-DUSE_LTM -DLTM_DESC" EXTRALIBS="-ltommath" test
141 You have `tomsfastmath` installed on your system and want to build a shared library and all binaries
143     make -f makefile.shared CFLAGS="-DUSE_TFM -DTFM_DESC" EXTRALIBS="-ltfm" all demos
145 You have `gmp`, `libtommath` and `tomsfastmath` installed on your system and want to build a static library and the `timing` binary to measure timings against `gmp`.
147     make CFLAGS="-DUSE_GMP -DGMP_DESC -DLTM_DESC -DTFM_DESC" EXTRALIBS="-lgmp" timing
149 If you have `libtommath` in a non-standard location:
151     make CFLAGS="-DUSE_LTM -DLTM_DESC -I/opt/devel/ltm" EXTRALIBS="/opt/devel/ltm/libtommath.a" all
153 You want to enable AES-NI support:
155     make CFLAGS=-DLTC_AES_NI
157 ## Installation
159 There exist several _install_ make-targets which are described in the table above.
161 These targets support the standard ways (c.f. [[GNU]], [[FreeBSD]])
162 to modify the installation path via the following set of variables:
164     DESTDIR
165     PREFIX
166     LIBPATH
167     INCPATH
168     DATAPATH
169     BINPATH
171 The entire set of the variables is only supported in `makefile`, `makefile.shared` and `makefile.unix`.
173 In case you have to use one of the other makefiles, check in the file which variables are supported.
175 ### Examples
177 You want to install the static library to the default paths
179     make install
181 You want to install the shared library to a special path and use it from this path
183     make -f makefile.shared PREFIX=/opt/special/path
185 Have a look at the developer documentation, [[GNU]] or [[FreeBSD]] to get a detailed explanation of all the variables.
187 ## CMake support
189 The project provides support for the CMake build system.
192 git clone https://github.com/libtom/libtomcrypt.git
193 mkdir -p libtomcrypt/build
194 cd libtomcrypt/build
195 cmake ..
196 make -j$(nproc)
199 More details around building with CMake can be found in the developer documentation.
202 [GNU]: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
204 [FreeBSD]: https://www.freebsd.org/doc/en/books/porters-handbook/porting-prefix.html