mirror of
https://github.com/libtom/libtomcrypt
synced 2026-08-25 20:26:07 -04:00
minor changes for amalgamation
* de-duplicate `struct oid_to_pbes` * add makefile target * add amalgamation to release * fix `small` demo * add header guards for `tomcrypt_private.h` * update docs * add CI job with amalgamated library Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
parent
236477823a
commit
08b69be797
8 changed files with 74 additions and 10 deletions
21
.github/workflows/main.yml
vendored
21
.github/workflows/main.yml
vendored
|
|
@ -98,3 +98,24 @@ jobs:
|
|||
name: build-${{ github.run_id }}.tar.xz
|
||||
path: build-${{ github.run_id }}.tar.xz
|
||||
retention-days: 1
|
||||
|
||||
Amalgam:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
cc: [ gcc, clang ]
|
||||
os: [ ubuntu-22.04, ubuntu-24.04 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get remove -y libtommath1
|
||||
curl -s https://packagecloud.io/install/repositories/libtom/packages/script.deb.sh | sudo bash
|
||||
sudo apt-get install libtommath-git-dev
|
||||
- name: run tests
|
||||
env:
|
||||
CC: "${{ matrix.cc }}"
|
||||
run: |
|
||||
make pre_gen
|
||||
make CFLAGS="-DLTM_DESC -DUSE_LTM" EXTRALIBS="-ltommath" AMALGAM=1 -j$(nproc) check
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -10,6 +10,7 @@
|
|||
# release files
|
||||
/libtomcrypt-*
|
||||
/crypt-*
|
||||
pre_gen/
|
||||
|
||||
# suppress output of build process
|
||||
gcc_[12].txt
|
||||
|
|
|
|||
|
|
@ -8896,6 +8896,28 @@ else()
|
|||
endif()
|
||||
\end{verbatim}
|
||||
|
||||
|
||||
\mysection{Amalgamated library}
|
||||
|
||||
LibTomCrypt can also be built as an amalgamated library, i.e. as a single C source file + the header files.
|
||||
|
||||
A release of the library contains the amalgamation in the path \texttt{pre\_gen/tomcrypt\_amalgam.c}.
|
||||
|
||||
To create the amalgamation one can run:
|
||||
|
||||
\begin{verbatim}
|
||||
make pre_gen
|
||||
\end{verbatim}
|
||||
|
||||
The makefiles also support building the amalgamated library via:
|
||||
|
||||
\begin{verbatim}
|
||||
make CFLAGS="-DLTM_DESC" EXTRALIBS=-ltommath AMALGAM=1
|
||||
\end{verbatim}
|
||||
|
||||
This will build the library and link against LibTomMath (which must be installed on your system).
|
||||
|
||||
|
||||
\mysection{Header Configuration}
|
||||
The file \textit{tomcrypt\_cfg.h} is what lets you control various high level macros which control the behaviour of the library. Build options are also
|
||||
stored in \textit{tomcrypt\_custom.h} which allow the enabling and disabling of various algorithms.
|
||||
|
|
|
|||
13
makefile
13
makefile
|
|
@ -143,3 +143,16 @@ coverage: $(call print-help,coverage,Create code-coverage of the library - but b
|
|||
|
||||
# cleans everything - coverage output and standard 'clean'
|
||||
cleancov: cleancov-clean clean
|
||||
ifndef AMALGAM
|
||||
AMALGAM_FILTER_OUT = src/ciphers/aes/aes_tab.c src/ciphers/aes/aes_enc.c src/ciphers/aes/aes_enc_desc.c
|
||||
SOURCES = $(filter-out $(AMALGAM_FILTER_OUT),$(OBJECTS:.o=.c))
|
||||
pre_gen/tomcrypt_amalgam.c: $(SOURCES)
|
||||
mkdir -p pre_gen
|
||||
printf "/*\n * This file has been auto-generated, do not edit!\n */\n\n" > $@
|
||||
cat $(SOURCES) >> $@
|
||||
|
||||
pre_gen: pre_gen/tomcrypt_amalgam.c
|
||||
|
||||
.PHONY: pre_gen
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@ library: $(call print-help,library,Builds the library) $(LIBNAME)
|
|||
|
||||
|
||||
# List of objects to compile (all goes to libtomcrypt.a)
|
||||
ifndef AMALGAM
|
||||
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_desc.o src/ciphers/aes/aes_enc.o \
|
||||
src/ciphers/aes/aes_enc_desc.o src/ciphers/aes/aesni.o src/ciphers/anubis.o src/ciphers/blowfish.o \
|
||||
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/idea.o src/ciphers/kasumi.o \
|
||||
|
|
@ -401,6 +402,11 @@ src/stream/salsa20/xsalsa20_setup.o src/stream/salsa20/xsalsa20_test.o \
|
|||
src/stream/sober128/sober128_stream.o src/stream/sober128/sober128_stream_memory.o \
|
||||
src/stream/sober128/sober128_test.o src/stream/sosemanuk/sosemanuk.o \
|
||||
src/stream/sosemanuk/sosemanuk_memory.o src/stream/sosemanuk/sosemanuk_test.o
|
||||
else
|
||||
OBJECTS=pre_gen/tomcrypt_amalgam.o
|
||||
|
||||
LTC_CFLAGS := $(LTC_CFLAGS) -Wno-shadow -Isrc/ciphers/aes -Isrc/ciphers/safer -Isrc/ciphers/twofish -Isrc/hashes/whirl -Isrc/stream/sober128
|
||||
endif
|
||||
|
||||
# List of test objects to compile (all goes to libtomcrypt_prof.a)
|
||||
TOBJECTS=tests/base16_test.o tests/base32_test.o tests/base64_test.o tests/bcrypt_test.o \
|
||||
|
|
@ -537,6 +543,7 @@ zipup: $(call print-help,zipup,Prepare the archives for a release) doc/crypt.pdf
|
|||
-@(find libtomcrypt-$(VERSION)/ -type f | xargs grep 'FIXM[E]') && echo '############## BEWARE: the "fixme" marker was found !!! ##############' || true
|
||||
mkdir -p libtomcrypt-$(VERSION)/doc
|
||||
cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf
|
||||
$(MAKE) -C libtomcrypt-$(VERSION)/ pre_gen
|
||||
tar -c libtomcrypt-$(VERSION)/ | xz -6e -c - > crypt-$(VERSION).tar.xz
|
||||
zip -9rq crypt-$(VERSION).zip libtomcrypt-$(VERSION)
|
||||
rm -rf libtomcrypt-$(VERSION)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef TOMCRYPT_PRIVATE_H_
|
||||
#define TOMCRYPT_PRIVATE_H_
|
||||
|
||||
/*
|
||||
* Internal Macros
|
||||
*/
|
||||
|
|
@ -105,6 +108,11 @@ typedef struct
|
|||
unsigned long key_bits;
|
||||
} pbes_arg;
|
||||
|
||||
typedef struct {
|
||||
const pbes_properties *data;
|
||||
const char *oid;
|
||||
} oid_to_pbes;
|
||||
|
||||
/*
|
||||
* Internal functions
|
||||
*/
|
||||
|
|
@ -692,3 +700,5 @@ int which ## _export(unsigned char *out, unsigned long *outlen, prng_state *prng
|
|||
#define LTC_WIN32_BCRYPT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* TOMCRYPT_PRIVATE_H_ */
|
||||
|
|
|
|||
|
|
@ -50,11 +50,6 @@ static const pbes_properties s_pbes1_types[] = {
|
|||
{ s_pkcs_12_wrap, "sha1", "3des", 24, 8 },
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const pbes_properties *data;
|
||||
const char *oid;
|
||||
} oid_to_pbes;
|
||||
|
||||
static const oid_to_pbes s_pbes1_list[] = {
|
||||
{ &s_pbes1_types[0], "1.2.840.113549.1.5.1" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.1 pbeWithMD2AndDES-CBC */
|
||||
{ &s_pbes1_types[1], "1.2.840.113549.1.5.4" }, /* http://www.oid-info.com/get/1.2.840.113549.1.5.4 pbeWithMD2AndRC2-CBC */
|
||||
|
|
|
|||
|
|
@ -39,11 +39,6 @@ static const pbes_properties s_pbes2_default_types[] = {
|
|||
{ s_pkcs_5_alg2_wrap, "sha1", "aes", 32, 0 },
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const pbes_properties *data;
|
||||
const char* oid;
|
||||
} oid_to_pbes;
|
||||
|
||||
static const oid_to_pbes s_pbes2_list[] = {
|
||||
{ &s_pbes2_default_types[0], "1.3.14.3.2.7" }, /* http://www.oid-info.com/get/1.3.14.3.2.7 desCBC */
|
||||
{ &s_pbes2_default_types[1], "1.2.840.113549.3.2" }, /* http://www.oid-info.com/get/1.2.840.113549.3.2 rc2CBC */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue