Skip to content

Commit

Permalink
Merge pull request #584 from libtom/cleanup
Browse files Browse the repository at this point in the history
Clean-up & minor improvements
  • Loading branch information
sjaeckel authored Mar 16, 2022
2 parents 673f5ce + c8e4953 commit 06a81ae
Show file tree
Hide file tree
Showing 44 changed files with 464 additions and 327 deletions.
6 changes: 3 additions & 3 deletions .ci/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ fi
bash .ci/coverage_more.sh "$5" > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; }

make lcov-single
# if this isn't run on Travis CI create coverage locally
if [ "$TRAVIS" == "" ]; then
# if this isn't run on CI create coverage locally
if [ "$CI" == "" ]; then
make lcov-html
else
coveralls-lcov coverage.info
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"
fi

exit 0
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
push:
branches:
- master
- develop
- /^release\/.*$/
pull_request:
branches:
- master
- develop
- /^release\/.*$/

jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
cc: [ gcc, clang ]
os: [ ubuntu-18.04 ]
config:
- { BUILDNAME: 'META_BUILDS', BUILDOPTIONS: '-DGMP_DESC', BUILDSCRIPT: '.ci/meta_builds.sh' }
- { BUILDNAME: 'VALGRIND', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/valgrind.sh' }
- { BUILDNAME: 'STOCK', BUILDOPTIONS: '', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'STOCK-MPI', BUILDOPTIONS: '-ULTM_DESC -UTFM_DESC -UUSE_LTM -UUSE_TFM', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'EASY', BUILDOPTIONS: '-DLTC_EASY', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'SMALL', BUILDOPTIONS: '-DLTC_SMALL_CODE', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'NOTABLES', BUILDOPTIONS: '-DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'SMALL+NOTABLES', BUILDOPTIONS: '-DLTC_SMALL_CODE -DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'NO_FAST', BUILDOPTIONS: '-DLTC_NO_FAST', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'NO_FAST+NOTABLES', BUILDOPTIONS: '-DLTC_NO_FAST -DLTC_NO_TABLES', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'NO_ASM', BUILDOPTIONS: '-DLTC_NO_ASM', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'NO_TIMING_RESISTANCE', BUILDOPTIONS: '-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'PTHREAD', BUILDOPTIONS: '-DLTC_PTHREAD', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'STOCK+ARGTYPE=1', BUILDOPTIONS: '-DARGTYPE=1', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'STOCK+ARGTYPE=2', BUILDOPTIONS: '-DARGTYPE=2', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'STOCK+ARGTYPE=3', BUILDOPTIONS: '-DARGTYPE=3', BUILDSCRIPT: '.ci/run.sh' }
- { BUILDNAME: 'STOCK+ARGTYPE=4', BUILDOPTIONS: '-DARGTYPE=4', BUILDSCRIPT: '.ci/run.sh' }
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y libtommath-dev libgmp-dev libtfm-dev valgrind libtool-bin clang-tools lcov
sudo gem install coveralls-lcov
curl -s https://packagecloud.io/install/repositories/libtom/packages/script.deb.sh | sudo bash
sudo apt-get install libtfm1=0.13-5ubuntu1
- name: run tests
env:
CC: "${{ matrix.cc }}"
PR_NUMBER: ${{ github.event.number }}
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash "${{ matrix.config.BUILDSCRIPT }}" "${{ matrix.config.BUILDNAME }}" "-DUSE_LTM -DLTM_DESC" "makefile V=1" "${{ matrix.config.BUILDOPTIONS }}" "-ltommath"
bash "${{ matrix.config.BUILDSCRIPT }}" "${{ matrix.config.BUILDNAME }}" "-DUSE_TFM -DTFM_DESC" "makefile.shared V=1" "${{ matrix.config.BUILDOPTIONS }}" "-ltfm"
- name: regular logs
if: ${{ !failure() }}
run: |
cat gcc_1.txt
cat gcc_2.txt
- name: error logs
if: ${{ failure() }}
run: |
cat test_std.txt
cat test_err.txt
cat tv.txt
111 changes: 0 additions & 111 deletions .travis.yml

This file was deleted.

50 changes: 25 additions & 25 deletions doc/crypt.tex
Original file line number Diff line number Diff line change
Expand Up @@ -604,30 +604,30 @@ \subsection{Simple Encryption Demonstration}
\begin{figure}[hpbt]
\begin{small}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|}
\hline \textbf{Name} & \textbf{Descriptor Name} & \textbf{Block Size} & \textbf{Key Range} & \textbf{Rounds} \\
\hline Blowfish & blowfish\_desc & 8 & 8 $\ldots$ 56 & 16 \\
\hline X-Tea & xtea\_desc & 8 & 16 & 32 \\
\hline RC2 & rc2\_desc & 8 & 5 $\ldots$ 128 & 16 \\
\hline RC5-32/12/b & rc5\_desc & 8 & 8 $\ldots$ 128 & 12 $\ldots$ 24 \\
\hline RC6-32/20/b & rc6\_desc & 16 & 8 $\ldots$ 128 & 20 \\
\hline SAFER+ & saferp\_desc &16 & 16, 24, 32 & 8, 12, 16 \\
\hline AES & aes\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
& aes\_enc\_desc & 16 & 16, 24, 32 & 10, 12, 14 \\
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 \\
\hline DES & des\_desc & 8 & 8 & 16 \\
\hline 3DES (EDE mode) & des3\_desc & 8 & 16, 24 & 16 \\
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 \\
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 \\
\hline Skipjack & skipjack\_desc & 8 & 10 & 32 \\
\hline Anubis & anubis\_desc & 16 & 16 $\ldots$ 40 & 12 $\ldots$ 18 \\
\hline Khazad & khazad\_desc & 8 & 16 & 8 \\
\hline SEED & kseed\_desc & 16 & 16 & 16 \\
\hline KASUMI & kasumi\_desc & 8 & 16 & 8 \\
\hline Camellia & camellia\_desc & 16 & 16, 24, 32 & 18, 24 \\
\hline IDEA & idea\_desc & 8 & 16 & 8 \\
\hline Serpent & serpent\_desc & 16 & 16, 24, 32 & 32 \\
\hline TEA & tea\_desc & 8 & 16 & 32 \\
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline \textbf{Name} & \textbf{Descriptor Name} & \textbf{Block Size} & \textbf{Key Range} & \textbf{Rounds} & \textbf{Id} \\
\hline Blowfish & blowfish\_desc & 8 & 8 $\ldots$ 56 & 16 & 0 \\
\hline X-Tea & xtea\_desc & 8 & 16 & 32 & 1 \\
\hline RC2 & rc2\_desc & 8 & 5 $\ldots$ 128 & 16 & 12 \\
\hline RC5-32/12/b & rc5\_desc & 8 & 8 $\ldots$ 128 & 12 $\ldots$ 24 & 2 \\
\hline RC6-32/20/b & rc6\_desc & 16 & 8 $\ldots$ 128 & 20 & 3 \\
\hline SAFER+ & saferp\_desc &16 & 16, 24, 32 & 8, 12, 16 & 4 \\
\hline AES & aes\_desc & 16 & 16, 24, 32 & 10, 12, 14 & 6 \\
& aes\_enc\_desc & 16 & 16, 24, 32 & 10, 12, 14 & 6 \\
\hline Twofish & twofish\_desc & 16 & 16, 24, 32 & 16 & 7 \\
\hline DES & des\_desc & 8 & 8 & 16 & 13 \\
\hline 3DES (EDE mode) & des3\_desc & 8 & 16, 24 & 16 & 14 \\
\hline CAST5 (CAST-128) & cast5\_desc & 8 & 5 $\ldots$ 16 & 12, 16 & 15 \\
\hline Noekeon & noekeon\_desc & 16 & 16 & 16 & 16 \\
\hline Skipjack & skipjack\_desc & 8 & 10 & 32 & 17 \\
\hline Anubis & anubis\_desc & 16 & 16 $\ldots$ 40 & 12 $\ldots$ 18 & 19 \\
\hline Khazad & khazad\_desc & 8 & 16 & 8 & 18 \\
\hline SEED & kseed\_desc & 16 & 16 & 16 & 20 \\
\hline KASUMI & kasumi\_desc & 8 & 16 & 8 & 21 \\
\hline Camellia & camellia\_desc & 16 & 16, 24, 32 & 18, 24 & 23 \\
\hline IDEA & idea\_desc & 8 & 16 & 8 & 24 \\
\hline Serpent & serpent\_desc & 16 & 16, 24, 32 & 32 & 25 \\
\hline TEA & tea\_desc & 8 & 16 & 32 & 26 \\
\hline
\end{tabular}
\end{center}
Expand Down Expand Up @@ -1546,7 +1546,7 @@ \chapter{Stream Ciphers}
err = rc4_stream_done(&st);
\end{verbatim}

To encrypt plaintext (or decrypt ciphertext) using RC6 for data already in
To encrypt plaintext (or decrypt ciphertext) using RC4 for data already in
memory with a single function call, the following function may be used.
\begin{verbatim}
err = rc4_stream_memory(key, keylen, datain, datalen, dataout);
Expand Down
2 changes: 1 addition & 1 deletion makefile_include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ endif # LTC_SMALL

ifneq ($(findstring clang,$(CC)),)
LTC_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header
LTC_CFLAGS += -Wno-missing-field-initializers -Wno-missing-braces
LTC_CFLAGS += -Wno-missing-field-initializers -Wno-missing-braces -Wno-incomplete-setjmp-declaration
endif
ifneq ($(findstring mingw,$(CC)),)
LTC_CFLAGS += -Wno-shadow -Wno-attributes
Expand Down
2 changes: 1 addition & 1 deletion src/encauth/gcm/gcm_add_aad.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int gcm_add_aad(gcm_state *gcm,

x = 0;
#ifdef LTC_FAST
if (gcm->buflen == 0) {
if (gcm->buflen == 0 && adatalen > 15) {
for (x = 0; x < (adatalen & ~15); x += 16) {
for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
*(LTC_FAST_TYPE_PTR_CAST(&gcm->X[y])) ^= *(LTC_FAST_TYPE_PTR_CAST(&adata[x + y]));
Expand Down
14 changes: 7 additions & 7 deletions src/headers/tomcrypt_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

#define LTC_NO_MISC
#define LTC_BASE64
#endif
#endif /* LTC_EASY */

/* The minimal set of functionality to run the tests */
#ifdef LTC_MINIMAL
Expand All @@ -129,7 +129,7 @@
#define LTC_TRY_URANDOM_FIRST

#undef LTC_NO_FILE
#endif
#endif /* LTC_MINIMAL */

/* Enable self-test test vector checking */
#ifndef LTC_NO_TEST
Expand Down Expand Up @@ -357,7 +357,7 @@
#define LTC_YARROW_AES 2
#endif

#endif
#endif /* LTC_YARROW */

#ifdef LTC_FORTUNA

Expand Down Expand Up @@ -553,7 +553,7 @@
#define LTC_ECC_SECP384R1
#define LTC_ECC_SECP521R1
#endif
#endif
#endif /* LTC_MECC */

#if defined(LTC_DER)
#ifndef LTC_DER_MAX_RECURSION
Expand Down Expand Up @@ -690,15 +690,13 @@
#define LTC_MUTEX_UNLOCK(x)
#define LTC_MUTEX_DESTROY(x)

#endif
#endif /* LTC_PTHREAD */

/* Debuggers */

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

#endif

#ifndef LTC_NO_FILE
/* buffer size for reading from a file via fread(..) */
#ifndef LTC_FILE_READ_BUFSIZE
Expand Down Expand Up @@ -739,3 +737,5 @@
#define LTC_ECC_SECP521R1
#undef LTC_ECC521
#endif

#endif /* TOMCRYPT_CUSTOM_H_ */
1 change: 1 addition & 0 deletions src/headers/tomcrypt_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ enum padding_type {
LTC_PAD_ISO_10126 = 0x1000U,
#endif
LTC_PAD_ANSI_X923 = 0x2000U,
LTC_PAD_SSH = 0x3000U,
/* The following padding modes don't contain the padding
* length as last byte of the padding.
*/
Expand Down
24 changes: 18 additions & 6 deletions src/headers/tomcrypt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/

enum ltc_oid_id {
PKA_RSA,
PKA_DSA,
PKA_EC,
PKA_EC_PRIMEF,
PKA_X25519,
PKA_ED25519,
LTC_OID_RSA,
LTC_OID_DSA,
LTC_OID_EC,
LTC_OID_EC_PRIMEF,
LTC_OID_X25519,
LTC_OID_ED25519,
};

/*
Expand Down Expand Up @@ -202,6 +202,17 @@ void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const

/* tomcrypt_misc.h */

typedef enum {
/** Use `\r\n` as line separator */
BASE64_PEM_CRLF = 1,
/** Create output with 72 chars line length */
BASE64_PEM_SSH = 2,
} base64_pem_flags;

int base64_encode_pem(const unsigned char *in, unsigned long inlen,
char *out, unsigned long *outlen,
unsigned int flags);

void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz);

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

/* ---- DH Routines ---- */
Expand Down
Loading

0 comments on commit 06a81ae

Please sign in to comment.