Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:

jobs:
Docs:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
container: texlive/texlive:latest-medium
steps:
- uses: actions/checkout@v4
Expand All @@ -36,7 +36,7 @@ jobs:
strategy:
matrix:
cc: [ gcc, clang ]
os: [ ubuntu-20.04, ubuntu-22.04 ]
os: [ ubuntu-22.04, ubuntu-24.04 ]
config:
- { BUILDNAME: 'META_BUILDS', BUILDOPTIONS: '-DGMP_DESC', BUILDSCRIPT: '.ci/meta_builds.sh' }
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }
Expand Down
14 changes: 14 additions & 0 deletions contrib/libtomcrypt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To find libtomcrypt no matter what the installation look like, start with
# looking for the CMake specific configuration, and failing that, try the
# pkg-config package instead. The resulting target is different in each
# case, but is recorded in the variable ${LIBTOMCRYPT}, so please use that
# for all targets that depend on libtomcrypt.

find_package(libtomcrypt QUIET)
if (libtomcrypt_FOUND)
set(LIBTOMCRYPT libtomcrypt)
else()
find_package(PkgConfig)
pkg_check_modules(libtomcrypt REQUIRED IMPORTED_TARGET libtomcrypt)
set(LIBTOMCRYPT PkgConfig::libtomcrypt)
endif()
28 changes: 28 additions & 0 deletions doc/crypt.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8868,6 +8868,34 @@ \subsection{Installation Directories}
A shared library build can be done by setting \textbf{-DBUILD\_SHARED\_LIBS=On} when invoking the \textbf{cmake} command.
Tests can be enabled by setting \textbf{-DBUILD\_TESTING=On} when invoking the \textbf{cmake} command.

\mysection{Building a libtomcrypt app with CMake}

Depending on if libtomcrypt was built and installed using the
available makefiles, or using CMake, different package files are
provided.

With the available makefiles, the pkg-config file
\texttt{libtomcrypt.pc} is produced, while with CMake, the CMake
config file \texttt{libtomcrypt-config.cmake} is produced.

The result is that different installations have different package
config files.

This has proven problematic for other CMake-based projects. That is,
however, fairly easy to solve with this little CMake snippet (also
found in \texttt{contrib/libtomcrypt.cmake}:

\begin{verbatim}
find_package(libtomcrypt QUIET)
if (libtomcrypt_FOUND)
set(LIBTOMCRYPT libtomcrypt)
else()
find_package(PkgConfig)
pkg_check_modules(libtomcrypt REQUIRED IMPORTED_TARGET libtomcrypt)
set(LIBTOMCRYPT PkgConfig::libtomcrypt)
endif()
\end{verbatim}

\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.
Expand Down
4 changes: 2 additions & 2 deletions helper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ sub prepare_msvc_files_xml {
########### aes_enc "hack" disabled - discussion: https://github.com/libtom/libtomcrypt/pull/158
# if ($full eq 'src\ciphers\aes\aes.c') { #hack
# my %cmd = (
# 'Debug|Win32' => [ 'Debug/aes.obj;Debug/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/aes_enc.obj" /Fd"Debug/" /FD /GZ /c $(InputPath)
' ],
# 'Release|Win32' => [ 'Release/aes.obj;Release/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/" /Fd"Release/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LTC_SOURCE" /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/aes_enc.obj" /Fd"Release/" /FD /GZ /c $(InputPath)
' ],
# 'Debug|Win32' => [ 'Debug/aes.obj;Debug/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D /D "USE_LTM" /Fp"Debug/libtomcrypt.pch" /YX /Fo"Debug/aes_enc.obj" /Fd"Debug/" /FD /GZ /c $(InputPath)
' ],
# 'Release|Win32' => [ 'Release/aes.obj;Release/aes_enc.obj', 'cl /nologo /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/" /Fd"Release/" /FD /GZ /c $(InputPath)
cl /nologo /DENCRYPT_ONLY /MLd /W3 /Gm /GX /ZI /Od /I "src\headers" /I "..\libtommath" /D "_DEBUG" /D "LTM_DESC" /D "WIN32" /D "_MBCS" /D "_LIB" /D /D "USE_LTM" /Fp"Release/libtomcrypt.pch" /YX /Fo"Release/aes_enc.obj" /Fd"Release/" /FD /GZ /c $(InputPath)
' ],
# );
# for (@$targets) {
# next unless $cmd{$_};
Expand Down
8 changes: 4 additions & 4 deletions libtomcrypt_VS2008.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -123,7 +123,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
Expand Down Expand Up @@ -199,7 +199,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
Expand Down Expand Up @@ -277,7 +277,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
Expand Down
2 changes: 1 addition & 1 deletion makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
EXTRALIBS = -L../libtommath -ltommath

#Compilation flags
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
LTC_CFLAGS = -Isrc/headers -Itests $(CFLAGS)
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
VERSION=1.18.2-develop

Expand Down
2 changes: 1 addition & 1 deletion makefile.msvc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CFLAGS = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath
EXTRALIBS = ../libtommath/tommath.lib

#Compilation flags
LTC_CFLAGS = /nologo /Isrc/headers/ /Itests/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3 $(CFLAGS)
LTC_CFLAGS = /nologo /Isrc/headers/ /Itests/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
VERSION=1.18.2-develop

Expand Down
2 changes: 1 addition & 1 deletion makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PC_CFLAGS = -DLTM_DESC
PC_LIBS = -ltommath

#Compilation flags
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
LTC_CFLAGS = -Isrc/headers -Itests $(CFLAGS)
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
VERSION=1.18.2-develop
VERSION_PC=1.18.2
Expand Down
4 changes: 2 additions & 2 deletions makefile_include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ endef
# Also note that we're extending the environments' CFLAGS.
# If you think that our CFLAGS are not nice you can easily override them
# by giving them as a parameter to make:
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
# make CFLAGS="-I./src/headers/ ..." ...
#
ifneq ($(shell echo $(CFLAGS) | grep LTM_DESC),)
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I libtommath ${silent_stderr} || true)
Expand All @@ -85,7 +85,7 @@ endif
ifneq ($(shell echo $(CFLAGS) | grep GMP_DESC),)
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I gmp ${silent_stderr} || true)
endif
LTC_CFLAGS += -I./src/headers/ -DLTC_SOURCE -Wall -Wsign-compare -Wshadow
LTC_CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow

ifdef OLD_GCC
LTC_CFLAGS += -W
Expand Down
8 changes: 5 additions & 3 deletions src/headers/tomcrypt_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
#define ENDIAN_LITTLE
#define ENDIAN_64BITWORD
#define LTC_FAST
#if defined(_ILP32) || defined(__ILP32__)
#define ENDIAN_64BITWORD_X32
#endif
#endif

/* detect PPC32 */
Expand Down Expand Up @@ -178,6 +175,11 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
#define LTC_FAST
#endif

/* Detect ILP32, commonly known as x32 on Linux and also possible on AIX */
#if defined(_ILP32) || defined(__ILP32__)
#define ENDIAN_64BITWORD_ILP32
#endif

/* endianness fallback */
#if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
#if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \
Expand Down
4 changes: 2 additions & 2 deletions src/headers/tomcrypt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#define LTC_PAD_MASK (0xF000U)

/* only real 64bit, not x32 */
#if defined(ENDIAN_64BITWORD) && !defined(ENDIAN_64BITWORD_X32)
/* only real 64bit, not ILP32 */
#if defined(ENDIAN_64BITWORD) && !defined(ENDIAN_64BITWORD_ILP32)
#define CONSTPTR(n) CONST64(n)
#else
#define CONSTPTR(n) n ## uL
Expand Down
2 changes: 1 addition & 1 deletion tests/multi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int multi_test(void)

/* HASH testing */
len = sizeof(buf[0]);
#if defined(ENDIAN_32BITWORD) || defined(_WIN32) || defined(ENDIAN_64BITWORD_X32)
#if defined(ENDIAN_32BITWORD) || defined(_WIN32) || defined(ENDIAN_64BITWORD_ILP32)
len2 = 0x80000000UL;
#else
/* Check against the max. input limit of SHA-1 as of RFC8017 */
Expand Down