Skip to content

Commit ac2c11a

Browse files
authored
Merge pull request #683 from libtom/some-improvements
Some improvements
2 parents 54f0456 + 894f33b commit ac2c11a

File tree

12 files changed

+63
-19
lines changed

12 files changed

+63
-19
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818

1919
jobs:
2020
Docs:
21-
runs-on: ubuntu-20.04
21+
runs-on: ubuntu-24.04
2222
container: texlive/texlive:latest-medium
2323
steps:
2424
- uses: actions/checkout@v4
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
matrix:
3838
cc: [ gcc, clang ]
39-
os: [ ubuntu-20.04, ubuntu-22.04 ]
39+
os: [ ubuntu-22.04, ubuntu-24.04 ]
4040
config:
4141
- { BUILDNAME: 'META_BUILDS', BUILDOPTIONS: '-DGMP_DESC', BUILDSCRIPT: '.ci/meta_builds.sh' }
4242
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }

contrib/libtomcrypt.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# To find libtomcrypt no matter what the installation look like, start with
2+
# looking for the CMake specific configuration, and failing that, try the
3+
# pkg-config package instead. The resulting target is different in each
4+
# case, but is recorded in the variable ${LIBTOMCRYPT}, so please use that
5+
# for all targets that depend on libtomcrypt.
6+
7+
find_package(libtomcrypt QUIET)
8+
if (libtomcrypt_FOUND)
9+
set(LIBTOMCRYPT libtomcrypt)
10+
else()
11+
find_package(PkgConfig)
12+
pkg_check_modules(libtomcrypt REQUIRED IMPORTED_TARGET libtomcrypt)
13+
set(LIBTOMCRYPT PkgConfig::libtomcrypt)
14+
endif()

doc/crypt.tex

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8868,6 +8868,34 @@ \subsection{Installation Directories}
88688868
A shared library build can be done by setting \textbf{-DBUILD\_SHARED\_LIBS=On} when invoking the \textbf{cmake} command.
88698869
Tests can be enabled by setting \textbf{-DBUILD\_TESTING=On} when invoking the \textbf{cmake} command.
88708870

8871+
\mysection{Building a libtomcrypt app with CMake}
8872+
8873+
Depending on if libtomcrypt was built and installed using the
8874+
available makefiles, or using CMake, different package files are
8875+
provided.
8876+
8877+
With the available makefiles, the pkg-config file
8878+
\texttt{libtomcrypt.pc} is produced, while with CMake, the CMake
8879+
config file \texttt{libtomcrypt-config.cmake} is produced.
8880+
8881+
The result is that different installations have different package
8882+
config files.
8883+
8884+
This has proven problematic for other CMake-based projects. That is,
8885+
however, fairly easy to solve with this little CMake snippet (also
8886+
found in \texttt{contrib/libtomcrypt.cmake}:
8887+
8888+
\begin{verbatim}
8889+
find_package(libtomcrypt QUIET)
8890+
if (libtomcrypt_FOUND)
8891+
set(LIBTOMCRYPT libtomcrypt)
8892+
else()
8893+
find_package(PkgConfig)
8894+
pkg_check_modules(libtomcrypt REQUIRED IMPORTED_TARGET libtomcrypt)
8895+
set(LIBTOMCRYPT PkgConfig::libtomcrypt)
8896+
endif()
8897+
\end{verbatim}
8898+
88718899
\mysection{Header Configuration}
88728900
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
88738901
stored in \textit{tomcrypt\_custom.h} which allow the enabling and disabling of various algorithms.

helper.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ sub prepare_msvc_files_xml {
233233
########### aes_enc "hack" disabled - discussion: https://github.com/libtom/libtomcrypt/pull/158
234234
# if ($full eq 'src\ciphers\aes\aes.c') { #hack
235235
# my %cmd = (
236-
# '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)
' ],
237-
# '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)
' ],
236+
# '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)
' ],
237+
# '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)
' ],
238238
# );
239239
# for (@$targets) {
240240
# next unless $cmd{$_};

libtomcrypt_VS2008.vcproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
Name="VCCLCompilerTool"
4747
Optimization="0"
4848
AdditionalIncludeDirectories="src\headers,..\libtommath"
49-
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
49+
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
5050
MinimalRebuild="true"
5151
ExceptionHandling="0"
5252
BasicRuntimeChecks="3"
@@ -123,7 +123,7 @@
123123
Optimization="2"
124124
InlineFunctionExpansion="1"
125125
AdditionalIncludeDirectories="src\headers,..\libtommath"
126-
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
126+
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
127127
StringPooling="true"
128128
ExceptionHandling="0"
129129
RuntimeLibrary="0"
@@ -199,7 +199,7 @@
199199
Name="VCCLCompilerTool"
200200
Optimization="0"
201201
AdditionalIncludeDirectories="src\headers,..\libtommath"
202-
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
202+
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
203203
MinimalRebuild="true"
204204
ExceptionHandling="0"
205205
BasicRuntimeChecks="3"
@@ -277,7 +277,7 @@
277277
Optimization="2"
278278
InlineFunctionExpansion="1"
279279
AdditionalIncludeDirectories="src\headers,..\libtommath"
280-
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
280+
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;LTM_DESC;LTC_NO_TEST;LTC_NO_PROTOTYPES"
281281
StringPooling="true"
282282
ExceptionHandling="0"
283283
RuntimeLibrary="0"

makefile.mingw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
2525
EXTRALIBS = -L../libtommath -ltommath
2626

2727
#Compilation flags
28-
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
28+
LTC_CFLAGS = -Isrc/headers -Itests $(CFLAGS)
2929
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
3030
VERSION=1.18.2-develop
3131

makefile.msvc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CFLAGS = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath
2020
EXTRALIBS = ../libtommath/tommath.lib
2121

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

makefile.unix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PC_CFLAGS = -DLTM_DESC
4040
PC_LIBS = -ltommath
4141

4242
#Compilation flags
43-
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
43+
LTC_CFLAGS = -Isrc/headers -Itests $(CFLAGS)
4444
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
4545
VERSION=1.18.2-develop
4646
VERSION_PC=1.18.2

makefile_include.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ endef
7474
# Also note that we're extending the environments' CFLAGS.
7575
# If you think that our CFLAGS are not nice you can easily override them
7676
# by giving them as a parameter to make:
77-
# make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
77+
# make CFLAGS="-I./src/headers/ ..." ...
7878
#
7979
ifneq ($(shell echo $(CFLAGS) | grep LTM_DESC),)
8080
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I libtommath ${silent_stderr} || true)
@@ -85,7 +85,7 @@ endif
8585
ifneq ($(shell echo $(CFLAGS) | grep GMP_DESC),)
8686
LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I gmp ${silent_stderr} || true)
8787
endif
88-
LTC_CFLAGS += -I./src/headers/ -DLTC_SOURCE -Wall -Wsign-compare -Wshadow
88+
LTC_CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow
8989

9090
ifdef OLD_GCC
9191
LTC_CFLAGS += -W

src/headers/tomcrypt_cfg.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
9191
#define ENDIAN_LITTLE
9292
#define ENDIAN_64BITWORD
9393
#define LTC_FAST
94-
#if defined(_ILP32) || defined(__ILP32__)
95-
#define ENDIAN_64BITWORD_X32
96-
#endif
9794
#endif
9895

9996
/* detect PPC32 */
@@ -178,6 +175,11 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
178175
#define LTC_FAST
179176
#endif
180177

178+
/* Detect ILP32, commonly known as x32 on Linux and also possible on AIX */
179+
#if defined(_ILP32) || defined(__ILP32__)
180+
#define ENDIAN_64BITWORD_ILP32
181+
#endif
182+
181183
/* endianness fallback */
182184
#if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
183185
#if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \

0 commit comments

Comments
 (0)