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