Skip to content

Commit e8afa13

Browse files
authored
Merge pull request #476 from libtom/fix/474
Fix issue #474
2 parents 01c455c + 19e7f73 commit e8afa13

File tree

18 files changed

+87
-49
lines changed

18 files changed

+87
-49
lines changed

.ci/meta_builds.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ make clean &>/dev/null
8080

8181
EXTRALIBS="$5"
8282

83-
echo $2 | grep -q GMP && EXTRALIBS="$EXTRALIBS -lgmp"
83+
echo $* | grep -q GMP && EXTRALIBS="$EXTRALIBS -lgmp"
8484

8585
if [ -z "$(echo $CC | grep "clang")" ]; then
8686
run_gcc "$1" "$2" "$3" "$4" "$EXTRALIBS"
@@ -90,11 +90,11 @@ fi
9090

9191
make clean &>/dev/null
9292

93-
bash .ci/testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$3" "$4" "$5"
93+
bash .ci/testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$3" "$4" "$EXTRALIBS"
9494

9595
make clean &>/dev/null
9696

97-
bash .ci/testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$3" "$4" "$5"
97+
bash .ci/testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$3" "$4" "$EXTRALIBS"
9898

9999
make clean &>/dev/null
100100

.ci/testbuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo "$1 (Build Only, $2, $3)..."
1414
make clean 1>/dev/null 2>/dev/null
1515
echo -n "building..."
1616
touch testok.txt
17-
CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" make -j$MAKE_JOBS -f $3 test tv_gen 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && rm -f testok.txt && exit 1)
17+
make -j$MAKE_JOBS -f $3 test tv_gen CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && rm -f testok.txt && exit 1)
1818
if find testok.txt -type f 1>/dev/null 2>/dev/null ; then
1919
echo "successful"
2020
exit 0

.travis.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ compiler:
3434
- gcc
3535
- clang
3636
script:
37-
- bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile V=1" "-DUSE_LTM -DLTM_DESC" "-ltommath"
38-
- bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile.shared V=1" "-DUSE_TFM -DTFM_DESC" "-ltfm"
37+
- bash "${BUILDSCRIPT}" "${BUILDNAME}" "-DUSE_LTM -DLTM_DESC" "makefile V=1" "${BUILDOPTIONS}" "-ltommath" &&
38+
bash "${BUILDSCRIPT}" "${BUILDNAME}" "-DUSE_TFM -DTFM_DESC" "makefile.shared V=1" "${BUILDOPTIONS}" "-ltfm"
3939
env:
4040
- |
4141
BUILDSCRIPT=".ci/meta_builds.sh"
@@ -49,6 +49,10 @@ env:
4949
BUILDSCRIPT=".ci/run.sh"
5050
BUILDNAME="STOCK"
5151
BUILDOPTIONS=" "
52+
- |
53+
BUILDSCRIPT=".ci/run.sh"
54+
BUILDNAME="STOCK-MPI"
55+
BUILDOPTIONS="-ULTM_DESC -UTFM_DESC -UUSE_LTM -UUSE_TFM"
5256
- |
5357
BUILDSCRIPT=".ci/run.sh"
5458
BUILDNAME="EASY"
@@ -109,6 +113,22 @@ env:
109113
BUILDSCRIPT=".ci/run.sh"
110114
BUILDNAME="CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE+LTC_FORTUNA_RESEED_RATELIMIT_STATIC+PTHREAD"
111115
BUILDOPTIONS="-DLTC_CLEAN_STACK -DLTC_NO_TABLES -DLTC_SMALL_CODE -DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING -DLTC_FORTUNA_RESEED_RATELIMIT_STATIC -DLTC_PTHREAD"
116+
- |
117+
BUILDSCRIPT=".ci/run.sh"
118+
BUILDNAME="STOCK+ARGTYPE=1"
119+
BUILDOPTIONS="-DARGTYPE=1"
120+
- |
121+
BUILDSCRIPT=".ci/run.sh"
122+
BUILDNAME="STOCK+ARGTYPE=2"
123+
BUILDOPTIONS="-DARGTYPE=2"
124+
- |
125+
BUILDSCRIPT=".ci/run.sh"
126+
BUILDNAME="STOCK+ARGTYPE=3"
127+
BUILDOPTIONS="-DARGTYPE=3"
128+
- |
129+
BUILDSCRIPT=".ci/run.sh"
130+
BUILDNAME="STOCK+ARGTYPE=4"
131+
BUILDOPTIONS="-DARGTYPE=4"
112132
113133
after_failure:
114134
- cat test_std.txt

demos/gcm-file/gcm_file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
@param out The output file
3838
@param taglen The MAC tag length
3939
@param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
40+
@param res [out] Result of the operation, 1==valid, 0==invalid
4041
@return CRYPT_OK on success
4142
*/
4243
int gcm_file( int cipher,
@@ -56,6 +57,8 @@ int gcm_file( int cipher,
5657
LTC_ARGCHK(out != NULL);
5758
LTC_ARGCHK(res != NULL);
5859

60+
*res = 0;
61+
5962
f_in = fopen(in, "rb");
6063
if (f_in == NULL) {
6164
err = CRYPT_FILE_NOTFOUND;

demos/gcm-file/gcm_filehandle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
@param out The output file
5656
@param taglen The MAC tag length
5757
@param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
58+
@param res [out] Result of the operation, 1==valid, 0==invalid
5859
@return CRYPT_OK on success
5960
*/
6061
int gcm_filehandle( int cipher,

demos/ltcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <tomcrypt.h>
2020

21-
static int NORETURN usage(char *name)
21+
static int LTC_NORETURN usage(char *name)
2222
{
2323
int x;
2424

demos/tv_gen.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,6 @@ int main(void)
786786
#elif defined(EXT_MATH_LIB)
787787
extern ltc_math_descriptor EXT_MATH_LIB;
788788
ltc_mp = EXT_MATH_LIB;
789-
#else
790-
fprintf(stderr, "No MPI provider available\n");
791-
exit(EXIT_FAILURE);
792789
#endif
793790

794791
printf("Generating hash vectors..."); fflush(stdout); hash_gen(); printf("done\n");
@@ -816,8 +813,10 @@ int main(void)
816813
printf("Generating GCM vectors..."); fflush(stdout); gcm_gen(); printf("done\n");
817814
#endif
818815
printf("Generating BASE64 vectors..."); fflush(stdout); base64_gen(); printf("done\n");
819-
printf("Generating MATH vectors..."); fflush(stdout); math_gen(); printf("done\n");
820-
printf("Generating ECC vectors..."); fflush(stdout); ecc_gen(); printf("done\n");
816+
if (ltc_mp.name != NULL) {
817+
printf("Generating MATH vectors..."); fflush(stdout); math_gen(); printf("done\n");
818+
printf("Generating ECC vectors..."); fflush(stdout); ecc_gen(); printf("done\n");
819+
}
821820
#ifdef LTC_LRW_MODE
822821
printf("Generating LRW vectors..."); fflush(stdout); lrw_gen(); printf("done\n");
823822
#endif

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).
7171
ifneq ($V,1)
7272
@echo " * $${CC} $$@"
7373
endif
74-
$${silent} $$(CC) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(LTC_EXTRALIBS) -o $(1)
74+
$${silent} $$(CC) $$(LTC_LDFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(LTC_EXTRALIBS) -o $(1)
7575
endef
7676

7777
$(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))

src/headers/tomcrypt_argchk.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@
99

1010
/* Defines the LTC_ARGCHK macro used within the library */
1111
/* ARGTYPE is defined in tomcrypt_cfg.h */
12+
13+
/* ARGTYPE is per default defined to 0 */
1214
#if ARGTYPE == 0
1315

1416
#include <signal.h>
1517

16-
/* this is the default LibTomCrypt macro */
17-
#if defined(__clang__) || defined(__GNUC_MINOR__)
18-
#define NORETURN __attribute__ ((noreturn))
19-
#else
20-
#define NORETURN
21-
#endif
22-
23-
void crypt_argchk(const char *v, const char *s, int d) NORETURN;
18+
void crypt_argchk(const char *v, const char *s, int d) LTC_NORETURN;
2419
#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
2520
#define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
2621

@@ -37,7 +32,7 @@ void crypt_argchk(const char *v, const char *s, int d) NORETURN;
3732

3833
#elif ARGTYPE == 3
3934

40-
#define LTC_ARGCHK(x)
35+
#define LTC_ARGCHK(x) LTC_UNUSED_PARAM(x)
4136
#define LTC_ARGCHKVD(x) LTC_ARGCHK(x)
4237

4338
#elif ARGTYPE == 4

src/headers/tomcrypt_cfg.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
6161
#define LTC_INLINE
6262
#endif
6363

64+
#if defined(__clang__) || defined(__GNUC_MINOR__)
65+
#define LTC_NORETURN __attribute__ ((noreturn))
66+
#elif defined(_MSC_VER)
67+
#define LTC_NORETURN __declspec(noreturn)
68+
#else
69+
#define LTC_NORETURN
70+
#endif
71+
6472
/* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */
6573
#ifndef ARGTYPE
6674
#define ARGTYPE 0

0 commit comments

Comments
 (0)