Skip to content

Commit 06a81ae

Browse files
authored
Merge pull request #584 from libtom/cleanup
Clean-up & minor improvements
2 parents 673f5ce + c8e4953 commit 06a81ae

Some content is hidden

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

44 files changed

+464
-327
lines changed

.ci/coverage.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ fi
3737
bash .ci/coverage_more.sh "$5" > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; }
3838

3939
make lcov-single
40-
# if this isn't run on Travis CI create coverage locally
41-
if [ "$TRAVIS" == "" ]; then
40+
# if this isn't run on CI create coverage locally
41+
if [ "$CI" == "" ]; then
4242
make lcov-html
4343
else
44-
coveralls-lcov coverage.info
44+
coveralls-lcov coverage.info --service-job-id="$GITHUB_RUN_ID" --service-name="github" --repo-token="$REPO_TOKEN" --branch="$GITHUB_REF_NAME" --service-pull-request="$PR_NUMBER"
4545
fi
4646

4747
exit 0

.github/workflows/main.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
- /^release\/.*$/
9+
pull_request:
10+
branches:
11+
- master
12+
- develop
13+
- /^release\/.*$/
14+
15+
jobs:
16+
Build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
cc: [ gcc, clang ]
21+
os: [ ubuntu-18.04 ]
22+
config:
23+
- { BUILDNAME: 'META_BUILDS', BUILDOPTIONS: '-DGMP_DESC', BUILDSCRIPT: '.ci/meta_builds.sh' }
24+
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }
25+
- { BUILDNAME: 'STOCK', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/run.sh' }
26+
- { BUILDNAME: 'STOCK-MPI', BUILDOPTIONS: '-ULTM_DESC -UTFM_DESC -UUSE_LTM -UUSE_TFM', BUILDSCRIPT: '.ci/run.sh' }
27+
- { BUILDNAME: 'EASY', BUILDOPTIONS: '-DLTC_EASY', BUILDSCRIPT: '.ci/run.sh' }
28+
- { BUILDNAME: 'SMALL', BUILDOPTIONS: '-DLTC_SMALL_CODE', BUILDSCRIPT: '.ci/run.sh' }
29+
- { BUILDNAME: 'NOTABLES', BUILDOPTIONS: '-DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
30+
- { BUILDNAME: 'SMALL+NOTABLES', BUILDOPTIONS: '-DLTC_SMALL_CODE -DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
31+
- { BUILDNAME: 'NO_FAST', BUILDOPTIONS: '-DLTC_NO_FAST', BUILDSCRIPT: '.ci/run.sh' }
32+
- { BUILDNAME: 'NO_FAST+NOTABLES', BUILDOPTIONS: '-DLTC_NO_FAST -DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
33+
- { BUILDNAME: 'NO_ASM', BUILDOPTIONS: '-DLTC_NO_ASM', BUILDSCRIPT: '.ci/run.sh' }
34+
- { BUILDNAME: 'NO_TIMING_RESISTANCE', BUILDOPTIONS: '-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING', BUILDSCRIPT: '.ci/run.sh' }
35+
- { BUILDNAME: 'PTHREAD', BUILDOPTIONS: '-DLTC_PTHREAD', BUILDSCRIPT: '.ci/run.sh' }
36+
- { BUILDNAME: 'STOCK+ARGTYPE=1', BUILDOPTIONS: '-DARGTYPE=1', BUILDSCRIPT: '.ci/run.sh' }
37+
- { BUILDNAME: 'STOCK+ARGTYPE=2', BUILDOPTIONS: '-DARGTYPE=2', BUILDSCRIPT: '.ci/run.sh' }
38+
- { BUILDNAME: 'STOCK+ARGTYPE=3', BUILDOPTIONS: '-DARGTYPE=3', BUILDSCRIPT: '.ci/run.sh' }
39+
- { BUILDNAME: 'STOCK+ARGTYPE=4', BUILDOPTIONS: '-DARGTYPE=4', BUILDSCRIPT: '.ci/run.sh' }
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: install dependencies
43+
run: |
44+
sudo apt-get update -qq
45+
sudo apt-get install -y libtommath-dev libgmp-dev libtfm-dev valgrind libtool-bin clang-tools lcov
46+
sudo gem install coveralls-lcov
47+
curl -s https://packagecloud.io/install/repositories/libtom/packages/script.deb.sh | sudo bash
48+
sudo apt-get install libtfm1=0.13-5ubuntu1
49+
- name: run tests
50+
env:
51+
CC: "${{ matrix.cc }}"
52+
PR_NUMBER: ${{ github.event.number }}
53+
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
bash "${{ matrix.config.BUILDSCRIPT }}" "${{ matrix.config.BUILDNAME }}" "-DUSE_LTM -DLTM_DESC" "makefile V=1" "${{ matrix.config.BUILDOPTIONS }}" "-ltommath"
56+
bash "${{ matrix.config.BUILDSCRIPT }}" "${{ matrix.config.BUILDNAME }}" "-DUSE_TFM -DTFM_DESC" "makefile.shared V=1" "${{ matrix.config.BUILDOPTIONS }}" "-ltfm"
57+
- name: regular logs
58+
if: ${{ !failure() }}
59+
run: |
60+
cat gcc_1.txt
61+
cat gcc_2.txt
62+
- name: error logs
63+
if: ${{ failure() }}
64+
run: |
65+
cat test_std.txt
66+
cat test_err.txt
67+
cat tv.txt

.travis.yml

-111
This file was deleted.

doc/crypt.tex

+25-25
Original file line numberDiff line numberDiff line change
@@ -604,30 +604,30 @@ \subsection{Simple Encryption Demonstration}
604604
\begin{figure}[hpbt]
605605
\begin{small}
606606
\begin{center}
607-
\begin{tabular}{|c|c|c|c|c|c|}
608-
\hline \textbf{Name} & \textbf{Descriptor Name} & \textbf{Block Size} & \textbf{Key Range} & \textbf{Rounds} \\
609-
\hline Blowfish & blowfish\_desc & 8 & 8 $\ldots$ 56 & 16 \\
610-
\hline X-Tea & xtea\_desc & 8 & 16 & 32 \\
611-
\hline RC2 & rc2\_desc & 8 & 5 $\ldots$ 128 & 16 \\
612-
\hline RC5-32/12/b & rc5\_desc & 8 & 8 $\ldots$ 128 & 12 $\ldots$ 24 \\
613-
\hline RC6-32/20/b & rc6\_desc & 16 & 8 $\ldots$ 128 & 20 \\
614-
\hline SAFER+ & saferp\_desc &16 & 16, 24, 32 & 8, 12, 16 \\
615-
\hline AES & aes\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
616-
& aes\_enc\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
617-
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 \\
618-
\hline DES & des\_desc & 8 & 8 & 16 \\
619-
\hline 3DES (EDE mode) & des3\_desc & 8 & 16, 24 & 16 \\
620-
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 \\
621-
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 \\
622-
\hline Skipjack & skipjack\_desc & 8 & 10 & 32 \\
623-
\hline Anubis & anubis\_desc & 16 & 16 $\ldots$ 40 & 12 $\ldots$ 18 \\
624-
\hline Khazad & khazad\_desc & 8 & 16 & 8 \\
625-
\hline SEED & kseed\_desc & 16 & 16 & 16 \\
626-
\hline KASUMI & kasumi\_desc & 8 & 16 & 8 \\
627-
\hline Camellia & camellia\_desc & 16 & 16, 24, 32 & 18, 24 \\
628-
\hline IDEA & idea\_desc & 8 & 16 & 8 \\
629-
\hline Serpent & serpent\_desc & 16 & 16, 24, 32 & 32 \\
630-
\hline TEA & tea\_desc & 8 & 16 & 32 \\
607+
\begin{tabular}{|c|c|c|c|c|c|c|}
608+
\hline \textbf{Name} & \textbf{Descriptor Name} & \textbf{Block Size} & \textbf{Key Range} & \textbf{Rounds} & \textbf{Id} \\
609+
\hline Blowfish & blowfish\_desc & 8 & 8 $\ldots$ 56 & 16 & 0 \\
610+
\hline X-Tea & xtea\_desc & 8 & 16 & 32 & 1 \\
611+
\hline RC2 & rc2\_desc & 8 & 5 $\ldots$ 128 & 16 & 12 \\
612+
\hline RC5-32/12/b & rc5\_desc & 8 & 8 $\ldots$ 128 & 12 $\ldots$ 24 & 2 \\
613+
\hline RC6-32/20/b & rc6\_desc & 16 & 8 $\ldots$ 128 & 20 & 3 \\
614+
\hline SAFER+ & saferp\_desc &16 & 16, 24, 32 & 8, 12, 16 & 4 \\
615+
\hline AES & aes\_desc & 16 & 16, 24, 32 & 10, 12, 14 & 6 \\
616+
& aes\_enc\_desc & 16 & 16, 24, 32 & 10, 12, 14 & 6 \\
617+
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 & 7 \\
618+
\hline DES & des\_desc & 8 & 8 & 16 & 13 \\
619+
\hline 3DES (EDE mode) & des3\_desc & 8 & 16, 24 & 16 & 14 \\
620+
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 & 15 \\
621+
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 & 16 \\
622+
\hline Skipjack & skipjack\_desc & 8 & 10 & 32 & 17 \\
623+
\hline Anubis & anubis\_desc & 16 & 16 $\ldots$ 40 & 12 $\ldots$ 18 & 19 \\
624+
\hline Khazad & khazad\_desc & 8 & 16 & 8 & 18 \\
625+
\hline SEED & kseed\_desc & 16 & 16 & 16 & 20 \\
626+
\hline KASUMI & kasumi\_desc & 8 & 16 & 8 & 21 \\
627+
\hline Camellia & camellia\_desc & 16 & 16, 24, 32 & 18, 24 & 23 \\
628+
\hline IDEA & idea\_desc & 8 & 16 & 8 & 24 \\
629+
\hline Serpent & serpent\_desc & 16 & 16, 24, 32 & 32 & 25 \\
630+
\hline TEA & tea\_desc & 8 & 16 & 32 & 26 \\
631631
\hline
632632
\end{tabular}
633633
\end{center}
@@ -1546,7 +1546,7 @@ \chapter{Stream Ciphers}
15461546
err = rc4_stream_done(&st);
15471547
\end{verbatim}
15481548

1549-
To encrypt plaintext (or decrypt ciphertext) using RC6 for data already in
1549+
To encrypt plaintext (or decrypt ciphertext) using RC4 for data already in
15501550
memory with a single function call, the following function may be used.
15511551
\begin{verbatim}
15521552
err = rc4_stream_memory(key, keylen, datain, datalen, dataout);

makefile_include.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ endif # LTC_SMALL
120120

121121
ifneq ($(findstring clang,$(CC)),)
122122
LTC_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
123-
LTC_CFLAGS += -Wno-missing-field-initializers -Wno-missing-braces
123+
LTC_CFLAGS += -Wno-missing-field-initializers -Wno-missing-braces -Wno-incomplete-setjmp-declaration
124124
endif
125125
ifneq ($(findstring mingw,$(CC)),)
126126
LTC_CFLAGS += -Wno-shadow -Wno-attributes

src/encauth/gcm/gcm_add_aad.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int gcm_add_aad(gcm_state *gcm,
8383

8484
x = 0;
8585
#ifdef LTC_FAST
86-
if (gcm->buflen == 0) {
86+
if (gcm->buflen == 0 && adatalen > 15) {
8787
for (x = 0; x < (adatalen & ~15); x += 16) {
8888
for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
8989
*(LTC_FAST_TYPE_PTR_CAST(&gcm->X[y])) ^= *(LTC_FAST_TYPE_PTR_CAST(&adata[x + y]));

src/headers/tomcrypt_custom.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114

115115
#define LTC_NO_MISC
116116
#define LTC_BASE64
117-
#endif
117+
#endif /* LTC_EASY */
118118

119119
/* The minimal set of functionality to run the tests */
120120
#ifdef LTC_MINIMAL
@@ -129,7 +129,7 @@
129129
#define LTC_TRY_URANDOM_FIRST
130130

131131
#undef LTC_NO_FILE
132-
#endif
132+
#endif /* LTC_MINIMAL */
133133

134134
/* Enable self-test test vector checking */
135135
#ifndef LTC_NO_TEST
@@ -357,7 +357,7 @@
357357
#define LTC_YARROW_AES 2
358358
#endif
359359

360-
#endif
360+
#endif /* LTC_YARROW */
361361

362362
#ifdef LTC_FORTUNA
363363

@@ -553,7 +553,7 @@
553553
#define LTC_ECC_SECP384R1
554554
#define LTC_ECC_SECP521R1
555555
#endif
556-
#endif
556+
#endif /* LTC_MECC */
557557

558558
#if defined(LTC_DER)
559559
#ifndef LTC_DER_MAX_RECURSION
@@ -690,15 +690,13 @@
690690
#define LTC_MUTEX_UNLOCK(x)
691691
#define LTC_MUTEX_DESTROY(x)
692692

693-
#endif
693+
#endif /* LTC_PTHREAD */
694694

695695
/* Debuggers */
696696

697697
/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and RC4 work (see the code) */
698698
/* #define LTC_VALGRIND */
699699

700-
#endif
701-
702700
#ifndef LTC_NO_FILE
703701
/* buffer size for reading from a file via fread(..) */
704702
#ifndef LTC_FILE_READ_BUFSIZE
@@ -739,3 +737,5 @@
739737
#define LTC_ECC_SECP521R1
740738
#undef LTC_ECC521
741739
#endif
740+
741+
#endif /* TOMCRYPT_CUSTOM_H_ */

src/headers/tomcrypt_misc.h

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ enum padding_type {
146146
LTC_PAD_ISO_10126 = 0x1000U,
147147
#endif
148148
LTC_PAD_ANSI_X923 = 0x2000U,
149+
LTC_PAD_SSH = 0x3000U,
149150
/* The following padding modes don't contain the padding
150151
* length as last byte of the padding.
151152
*/

src/headers/tomcrypt_private.h

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
*/
1515

1616
enum ltc_oid_id {
17-
PKA_RSA,
18-
PKA_DSA,
19-
PKA_EC,
20-
PKA_EC_PRIMEF,
21-
PKA_X25519,
22-
PKA_ED25519,
17+
LTC_OID_RSA,
18+
LTC_OID_DSA,
19+
LTC_OID_EC,
20+
LTC_OID_EC_PRIMEF,
21+
LTC_OID_X25519,
22+
LTC_OID_ED25519,
2323
};
2424

2525
/*
@@ -202,6 +202,17 @@ void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const
202202

203203
/* tomcrypt_misc.h */
204204

205+
typedef enum {
206+
/** Use `\r\n` as line separator */
207+
BASE64_PEM_CRLF = 1,
208+
/** Create output with 72 chars line length */
209+
BASE64_PEM_SSH = 2,
210+
} base64_pem_flags;
211+
212+
int base64_encode_pem(const unsigned char *in, unsigned long inlen,
213+
char *out, unsigned long *outlen,
214+
unsigned int flags);
215+
205216
void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz);
206217

207218
int pbes_decrypt(const pbes_arg *arg, unsigned char *dec_data, unsigned long *dec_size);
@@ -225,6 +236,7 @@ int rsa_init(rsa_key *key);
225236
void rsa_shrink_key(rsa_key *key);
226237
int rsa_make_key_bn_e(prng_state *prng, int wprng, int size, void *e,
227238
rsa_key *key); /* used by op-tee */
239+
int rsa_import_pkcs1(const unsigned char *in, unsigned long inlen, rsa_key *key);
228240
#endif /* LTC_MRSA */
229241

230242
/* ---- DH Routines ---- */

0 commit comments

Comments
 (0)