Skip to content

Commit 7e7eb69

Browse files
committed
Merge branch 'release/1.18.2'
2 parents e08fd86 + a015a8f commit 7e7eb69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+385
-136
lines changed

changes

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
July 1st, 2018
2+
v1.18.2
3+
-- Fix Side Channel Based ECDSA Key Extraction (CVE-2018-12437) (PR #408)
4+
-- Fix potential stack overflow when DER flexi-decoding (CVE-2018-0739) (PR #373)
5+
-- Fix two-key 3DES (PR #390)
6+
-- Fix accelerated CTR mode (PR #359)
7+
-- Fix Fortuna PRNG (PR #363)
8+
-- Fix compilation on platforms where cc doesn't point to gcc (PR #382)
9+
-- Fix using the wrong environment variable LT instead of LIBTOOL (PR #392)
10+
-- Fix build on platforms where the compiler provides __WCHAR_MAX__ but wchar.h is not available (PR #390)
11+
-- Fix & re-factor crypt_list_all_sizes() and crypt_list_all_constants() (PR #414)
12+
-- Minor fixes (PR's #350 #351 #375 #377 #378 #379)
13+
114
January 22nd, 2018
215
v1.18.1
316
-- Fix wrong SHA3 blocksizes, thanks to Claus Fischer for reporting this via Mail (PR #329)

demos/constants.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ int main(int argc, char **argv)
6565
/* get and print the length of the names (and values) list */
6666
if (crypt_list_all_constants(NULL, &names_list_len) != 0) exit(EXIT_FAILURE);
6767
/* get and print the names (and values) list */
68-
names_list = malloc(names_list_len);
68+
if ((names_list = malloc(names_list_len)) == NULL) exit(EXIT_FAILURE);
6969
if (crypt_list_all_constants(names_list, &names_list_len) != 0) exit(EXIT_FAILURE);
7070
printf("%s\n", names_list);
71+
free(names_list);
7172
}
7273
} else if (argc == 3) {
7374
if (strcmp(argv[1], "-s") == 0) {

demos/sizes.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ int main(int argc, char **argv)
4242
printf(" need to allocate %u bytes \n\n", sizes_list_len);
4343

4444
/* get and print the names (and sizes) list */
45-
sizes_list = malloc(sizes_list_len);
45+
if ((sizes_list = malloc(sizes_list_len)) == NULL) exit(EXIT_FAILURE);
4646
if (crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0) exit(EXIT_FAILURE);
4747
printf(" supported sizes:\n\n%s\n\n", sizes_list);
48+
free(sizes_list);
4849
} else if (argc == 2) {
4950
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
5051
char* base = strdup(basename(argv[0]));
@@ -60,9 +61,10 @@ int main(int argc, char **argv)
6061
/* get and print the length of the names (and sizes) list */
6162
if (crypt_list_all_sizes(NULL, &sizes_list_len) != 0) exit(EXIT_FAILURE);
6263
/* get and print the names (and sizes) list */
63-
sizes_list = malloc(sizes_list_len);
64+
if ((sizes_list = malloc(sizes_list_len)) == NULL) exit(EXIT_FAILURE);
6465
if (crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0) exit(EXIT_FAILURE);
6566
printf("%s\n", sizes_list);
67+
free(sizes_list);
6668
}
6769
} else if (argc == 3) {
6870
if (strcmp(argv[1], "-s") == 0) {

demos/timing.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static void time_cipher_lrw(void)
466466
tally_results(1);
467467
}
468468
#else
469-
static void time_cipher_lrw(void) { fprintf(stderr, "NO LRW\n"); return 0; }
469+
static void time_cipher_lrw(void) { fprintf(stderr, "NO LRW\n"); }
470470
#endif
471471

472472

demos/tv_gen.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void cipher_gen(void)
7878
printf("keysize error: %s\n", error_to_string(err));
7979
exit(EXIT_FAILURE);
8080
}
81-
if (kl == lastkl) break;
81+
if (kl == lastkl) continue;
8282
lastkl = kl;
8383
fprintf(out, "Key Size: %d bytes\n", kl);
8484

doc/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = LibTomCrypt
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER=1.18.1
41+
PROJECT_NUMBER=1.18.2
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

doc/crypt.tex

+5-1
Original file line numberDiff line numberDiff line change
@@ -3666,11 +3666,15 @@ \subsubsection{Fortuna}
36663666
it has been fixed to those choices.
36673667

36683668
Fortuna is more secure than Yarrow in the sense that attackers who learn parts of the entropy being
3669-
added to the PRNG learn far less about the state than that of Yarrow. Without getting into to many
3669+
added to the PRNG learn far less about the state than that of Yarrow. Without getting into too many
36703670
details Fortuna has the ability to recover from state determination attacks where the attacker starts
36713671
to learn information from the PRNGs output about the internal state. Yarrow on the other hand, cannot
36723672
recover from that problem until new entropy is added to the pool and put to use through the ready() function.
36733673

3674+
For detailed information on how the algorithm works and what you have to do to maintain the secure state
3675+
get a copy of the book\footnote{Niels Ferguson and Bruce Schneier, Practical Cryptography. ISBN 0-471-22357-3.} or
3676+
read the paper online\footnote{\url{https://www.schneier.com/academic/paperfiles/fortuna.pdf} [Accessed on 7th Dec. 2017]}.
3677+
36743678
\subsubsection{RC4}
36753679

36763680
RC4 is an old stream cipher that can also double duty as a PRNG in a pinch. You key RC4 by

makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).
6969
ifneq ($V,1)
7070
@echo " * $${CC} $$@"
7171
endif
72-
$${silent} $$(CC) $$(LTC_CFLAGS) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
72+
$${silent} $$(CC) $$< $$(LIB_PRE) $$(LIBNAME) $$(LIB_POST) $$(EXTRALIBS) -o $(1)
7373
endef
7474

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

makefile.mingw

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ EXTRALIBS = -L../libtommath -ltommath
2727
#Compilation flags
2828
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
2929
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
30-
VERSION=1.18.1
30+
VERSION=1.18.2
3131

3232
#Libraries to be created
3333
LIBMAIN_S =libtomcrypt.a

makefile.msvc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EXTRALIBS = ../libtommath/tommath.lib
2222
#Compilation flags
2323
LTC_CFLAGS = /nologo /Isrc/headers/ /Itests/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3 $(CFLAGS)
2424
LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
25-
VERSION=1.18.1
25+
VERSION=1.18.2
2626

2727
#Libraries to be created (this makefile builds only static libraries)
2828
LIBMAIN_S =tomcrypt.lib

makefile.shared

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616

1717
PLATFORM := $(shell uname | sed -e 's/_.*//')
1818

19-
ifndef LT
19+
ifndef LIBTOOL
2020
ifeq ($(PLATFORM), Darwin)
21-
LT:=glibtool
21+
LIBTOOL:=glibtool
2222
else
23-
LT:=libtool
23+
LIBTOOL:=libtool
2424
endif
2525
endif
2626
ifeq ($(PLATFORM), CYGWIN)
2727
NO_UNDEFINED:=-no-undefined
2828
endif
29-
LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
30-
INSTALL_CMD = $(LT) --mode=install install
31-
UNINSTALL_CMD = $(LT) --mode=uninstall rm
29+
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC)
30+
INSTALL_CMD = $(LIBTOOL) --mode=install install
31+
UNINSTALL_CMD = $(LIBTOOL) --mode=uninstall rm
3232

3333
#Output filenames for various targets.
3434
ifndef LIBNAME
@@ -49,15 +49,15 @@ src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
4949
LOBJECTS = $(OBJECTS:.o=.lo)
5050

5151
$(LIBNAME): $(OBJECTS)
52-
$(LT) --mode=link --tag=CC $(CC) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
52+
$(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) $(LOBJECTS) $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT) $(NO_UNDEFINED)
5353

5454
test: $(call print-help,test,Builds the library and the 'test' application to run all self-tests) $(LIBNAME) $(TOBJECTS)
55-
$(LT) --mode=link --tag=CC $(CC) $(LTC_CFLAGS) $(CPPFLAGS) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
55+
$(LIBTOOL) --mode=link --tag=CC $(CC) $(LTC_LDFLAGS) -o $(TEST) $(TOBJECTS) $(LIBNAME) $(EXTRALIBS)
5656

5757
# build the demos from a template
5858
define DEMO_template
5959
$(1): $(call print-help,$(1),Builds the library and the '$(1)' demo) demos/$(1).o $$(LIBNAME)
60-
$$(LT) --mode=link --tag=CC $$(CC) $$(LTC_CFLAGS) $$(CPPFLAGS) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
60+
$$(LIBTOOL) --mode=link --tag=CC $$(CC) $$(LTC_LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
6161
endef
6262

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

makefile.unix

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ EXTRALIBS = ../libtommath/libtommath.a
3939
#Compilation flags
4040
LTC_CFLAGS = -Isrc/headers -Itests -DLTC_SOURCE $(CFLAGS)
4141
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
42-
VERSION=1.18.1
42+
VERSION=1.18.2
4343

4444
#Libraries to be created (this makefile builds only static libraries)
4545
LIBMAIN_S =libtomcrypt.a

makefile_include.mk

+25-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# (GNU make only)
44

55
# The version - BEWARE: VERSION, VERSION_PC and VERSION_LT are updated via ./updatemakes.sh
6-
VERSION=1.18.1
7-
VERSION_PC=1.18.1
6+
VERSION=1.18.2
7+
VERSION_PC=1.18.2
88
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
99
VERSION_LT=1:1
1010

@@ -13,9 +13,23 @@ ifndef CROSS_COMPILE
1313
CROSS_COMPILE:=
1414
endif
1515

16-
ifeq ($(CC),cc)
17-
CC := $(CROSS_COMPILE)gcc
16+
# We only need to go through this dance of determining the right compiler if we're using
17+
# cross compilation, otherwise $(CC) is fine as-is.
18+
ifneq (,$(CROSS_COMPILE))
19+
ifeq ($(origin CC),default)
20+
CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
21+
ifeq ($(PLATFORM),FreeBSD)
22+
# XXX: FreeBSD needs extra escaping for some reason
23+
CSTR := $$$(CSTR)
1824
endif
25+
ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
26+
CC := $(CROSS_COMPILE)clang
27+
else
28+
CC := $(CROSS_COMPILE)gcc
29+
endif # Clang
30+
endif # cc is Make's default
31+
endif # CROSS_COMPILE non-empty
32+
1933
LD:=$(CROSS_COMPILE)ld
2034
AR:=$(CROSS_COMPILE)ar
2135

@@ -24,7 +38,12 @@ AR:=$(CROSS_COMPILE)ar
2438
ARFLAGS:=r
2539

2640
ifndef MAKE
27-
MAKE:=make
41+
# BSDs refer to GNU Make as gmake
42+
ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
43+
MAKE=gmake
44+
else
45+
MAKE=make
46+
endif
2847
endif
2948

3049
ifndef INSTALL_CMD
@@ -389,7 +408,7 @@ doc/crypt.pdf: $(call print-help,doc/crypt.pdf,Builds the Developer Manual)
389408
$(MAKE) -C doc/ crypt.pdf V=$(V)
390409

391410

392-
install_all: $(call print-help,install_all,Install everything - library bins docs tests) install install_bins install_docs install_test
411+
install_all: $(call print-help,install_all,Install everything - library bins docs tests) install install_bins install_docs
393412

394413
INSTALL_OPTS ?= -m 644
395414

notes/cipher_tv.txt

+52
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,58 @@ Key Size: 8 bytes
14341434

14351435

14361436
Cipher: 3des
1437+
Key Size: 16 bytes
1438+
0: DF0B6C9C31CD0CE4
1439+
1: 9B3503FDF249920B
1440+
2: 653924639C39E7FF
1441+
3: 6A29E0A7F42025BB
1442+
4: 1628B719BC875D20
1443+
5: 7D77004A18D0C0B2
1444+
6: 4D21684EFE962DC1
1445+
7: B6BD7F82B648A364
1446+
8: 1F87ABAD83D19E96
1447+
9: 3DF3533220C3CDED
1448+
10: D0E7D0ABFBA68747
1449+
11: 109FE5B38D74E6C9
1450+
12: AE12C4B4D523784F
1451+
13: 953CD7F264166764
1452+
14: 70B3A87D72FA0A22
1453+
15: 9C9D09AC66AB8F6D
1454+
16: 4A15AEACB35B76F0
1455+
17: EFA32F95623BCF1A
1456+
18: 679901F7737E195C
1457+
19: 221BB06209DDFCF4
1458+
20: 0889A953C60BB1BF
1459+
21: 88F2249380E2D5D9
1460+
22: 5AB26168B7FA24D5
1461+
23: 934229150997D390
1462+
24: 535E4F4C4DA97062
1463+
25: 03E8D711AC2B8154
1464+
26: CB5EF6E72EA3EC49
1465+
27: 9278A864F488C94A
1466+
28: CB91B77401DAF004
1467+
29: 4D0BA1C9794E0099
1468+
30: 9CFA24A21F48043F
1469+
31: BB6B3A33AEEC01F4
1470+
32: F2A8566E0FF6033D
1471+
33: E6AC213000E955E6
1472+
34: 91F5FF42BBE0B81B
1473+
35: 6506D72ADEA70E12
1474+
36: F9BD8C0506C7CC4E
1475+
37: 89CD85D1C98439ED
1476+
38: 409410E3E7D66B10
1477+
39: 4CA64F96F4F3D216
1478+
40: 383D18FBF8C006BC
1479+
41: 3806A8CB006EC243
1480+
42: EE73C06D903D2FCF
1481+
43: 624BFD3FAD7ED9EB
1482+
44: 1B5457F2731FB5D1
1483+
45: 4EC4632DFAC9D5D6
1484+
46: 8F0B3100FAD612C5
1485+
47: F955FCAD55AC6C90
1486+
48: BEB5F023BD413960
1487+
49: BDC369F3288ED754
1488+
14371489
Key Size: 24 bytes
14381490
0: 58ED248F77F6B19E
14391491
1: DA5C39983FD34F30

src/ciphers/aes/aes_tab.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static const ulong32 TE0[256] = {
9494
0x7bb0b0cbUL, 0xa85454fcUL, 0x6dbbbbd6UL, 0x2c16163aUL,
9595
};
9696

97-
#ifndef PELI_TAB
97+
#if !defined(PELI_TAB) && defined(LTC_SMALL_CODE)
9898
static const ulong32 Te4[256] = {
9999
0x63636363UL, 0x7c7c7c7cUL, 0x77777777UL, 0x7b7b7b7bUL,
100100
0xf2f2f2f2UL, 0x6b6b6b6bUL, 0x6f6f6f6fUL, 0xc5c5c5c5UL,
@@ -1017,11 +1017,13 @@ static const ulong32 Tks3[] = {
10171017

10181018
#endif /* SMALL CODE */
10191019

1020+
#ifndef PELI_TAB
10201021
static const ulong32 rcon[] = {
10211022
0x01000000UL, 0x02000000UL, 0x04000000UL, 0x08000000UL,
10221023
0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL,
10231024
0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
10241025
};
1026+
#endif
10251027

10261028
#endif /* __LTC_AES_TAB_C__ */
10271029

src/ciphers/des.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const struct ltc_cipher_descriptor des3_desc =
3636
{
3737
"3des",
3838
14,
39-
24, 24, 8, 16,
39+
16, 24, 8, 16,
4040
&des3_setup,
4141
&des3_ecb_encrypt,
4242
&des3_ecb_decrypt,
@@ -2068,8 +2068,11 @@ int des_keysize(int *keysize)
20682068
int des3_keysize(int *keysize)
20692069
{
20702070
LTC_ARGCHK(keysize != NULL);
2071-
if(*keysize < 24) {
2072-
return CRYPT_INVALID_KEYSIZE;
2071+
if (*keysize < 16)
2072+
return CRYPT_INVALID_KEYSIZE;
2073+
if (*keysize < 24) {
2074+
*keysize = 16;
2075+
return CRYPT_OK;
20732076
}
20742077
*keysize = 24;
20752078
return CRYPT_OK;

src/encauth/ccm/ccm_memory.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int ccm_memory(int cipher,
5252
int err;
5353
unsigned long len, L, x, y, z, CTRlen;
5454
#ifdef LTC_FAST
55-
LTC_FAST_TYPE fastMask = ~0; /* initialize fastMask at all zeroes */
55+
LTC_FAST_TYPE fastMask = ~(LTC_FAST_TYPE)0; /* initialize fastMask at all zeroes */
5656
#endif
5757
unsigned char mask = 0xff; /* initialize mask at all zeroes */
5858

src/headers/tomcrypt.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ extern "C" {
2727

2828
/* version */
2929
#define CRYPT 0x0118
30-
#define SCRYPT "1.18.1"
30+
#define SCRYPT "1.18.2"
3131

3232
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
3333
#define MAXBLOCKSIZE 128
3434

35+
#ifndef TAB_SIZE
3536
/* descriptor table size */
3637
#define TAB_SIZE 32
38+
#endif
3739

3840
/* error codes [will be expanded in future releases] */
3941
enum {

src/headers/tomcrypt_custom.h

+7
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,13 @@
472472
#endif
473473
#endif
474474

475+
#if defined(LTC_DER)
476+
#ifndef LTC_DER_MAX_RECURSION
477+
/* Maximum recursion limit when processing nested ASN.1 types. */
478+
#define LTC_DER_MAX_RECURSION 30
479+
#endif
480+
#endif
481+
475482
#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(LTC_MKAT)
476483
/* Include the MPI functionality? (required by the PK algorithms) */
477484
#define LTC_MPI

0 commit comments

Comments
 (0)