more trailing spaces + tabs outside of "src" dir

This commit is contained in:
Karel Miko 2017-02-24 20:50:37 +01:00
parent 477d621224
commit 953080bcea
14 changed files with 189 additions and 189 deletions

View File

@ -15,7 +15,7 @@ fi
CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" make -j$MAKE_JOBS -f $3 all_test 1>gcc_1.txt 2>gcc_2.txt
mret=$?
cnt=$(wc -l < gcc_2.txt)
# ignore 2 lines since ar prints to stderr instead of stdout and ar is called for
# ignore 2 lines since ar prints to stderr instead of stdout and ar is called for
# $(LIBNAME) and testprof/$(LIBTEST_S)
if [[ $mret -ne 0 ]] || [[ $cnt -gt 2 ]]; then
echo "build $1 failed! printing gcc_2.txt now for convenience"

View File

@ -20,9 +20,9 @@ bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4 -fprofile-arcs -ftest-coverage "
if [ -a testok.txt ] && [ -f testok.txt ]; then
echo
else
echo
echo "Test failed"
exit 1
echo
echo "Test failed"
exit 1
fi
./sizes
@ -30,9 +30,9 @@ fi
# if this was executed as './coverage.sh ...' create coverage locally
if [[ "${0%% *}" == "./${0##*/}" ]]; then
make lcov-single
make lcov-single
else
cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/'
cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/'
fi
exit 0

View File

@ -1,54 +1,54 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file demo_crypt_constants.c
Demo how to get various constants to dynamic languages
like Python
Larry Bugbee, February 2013
*/
int main(void) {
// given a specific constant name, get and print its value
char name[] = "CTR_COUNTER_BIG_ENDIAN";
int value;
if (crypt_get_constant(name, &value) != 0)
exit(EXIT_FAILURE);
printf("\n %s is %d \n\n", name, value);
// get and print the length of the names (and values) list
char *names_list;
unsigned int names_list_len;
if (crypt_list_all_constants(NULL, &names_list_len) != 0)
exit(EXIT_FAILURE);
printf(" need to allocate %u bytes \n\n", names_list_len);
// get and print the names (and values) list
if ((names_list = malloc(names_list_len)) == NULL)
exit(EXIT_FAILURE);
if (crypt_list_all_constants(names_list, &names_list_len) != 0)
exit(EXIT_FAILURE);
printf(" supported constants:\n\n%s\n\n", names_list);
free(names_list);
return 0;
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file demo_crypt_constants.c
Demo how to get various constants to dynamic languages
like Python
Larry Bugbee, February 2013
*/
int main(void) {
// given a specific constant name, get and print its value
char name[] = "CTR_COUNTER_BIG_ENDIAN";
int value;
if (crypt_get_constant(name, &value) != 0)
exit(EXIT_FAILURE);
printf("\n %s is %d \n\n", name, value);
// get and print the length of the names (and values) list
char *names_list;
unsigned int names_list_len;
if (crypt_list_all_constants(NULL, &names_list_len) != 0)
exit(EXIT_FAILURE);
printf(" need to allocate %u bytes \n\n", names_list_len);
// get and print the names (and values) list
if ((names_list = malloc(names_list_len)) == NULL)
exit(EXIT_FAILURE);
if (crypt_list_all_constants(names_list, &names_list_len) != 0)
exit(EXIT_FAILURE);
printf(" supported constants:\n\n%s\n\n", names_list);
free(names_list);
return 0;
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@ -1,42 +1,42 @@
"""
"""
demo_dynamic.py v1
This program demonstrates Python's use of the dynamic
language support additions to LTC, namely access to LTC
constants, struct and union sizes, and the binding of a
math package to LTC. Also provided are simple code
fragments to illustrate how one might write a Python
wrapper for LTC and how an app might call the wrapper.
This or a similar model should work for Ruby and other
This program demonstrates Python's use of the dynamic
language support additions to LTC, namely access to LTC
constants, struct and union sizes, and the binding of a
math package to LTC. Also provided are simple code
fragments to illustrate how one might write a Python
wrapper for LTC and how an app might call the wrapper.
This or a similar model should work for Ruby and other
dynamic languages.
This instance uses Python's ctypes and requires a single
.dylib linking together LTC and a math library. Building
a single .dylib is needed because LTC wants a fairly tight
relationship between itself and the mathlib. (ctypes can
load multiple .dylibs, but it does not support this level
This instance uses Python's ctypes and requires a single
.dylib linking together LTC and a math library. Building
a single .dylib is needed because LTC wants a fairly tight
relationship between itself and the mathlib. (ctypes can
load multiple .dylibs, but it does not support this level
of tight coupling between otherwise independent libraries.)
My .dylib was created on OSX with the following steps:
1- compile LTC to a .a static lib:
CFLAGS="-DLTM_DESC -DUSE_LTM" make
2- link LTC and LTM into a single .dylib:
ar2dylib_with tomcrypt tommath
where ar2dylib_with is a shell script that combines
where ar2dylib_with is a shell script that combines
the LTC .a with the LTM .dylib
Reminder: you don't need to bind in a math library unless
you are going to use LTC functions that depend
on a mathlib. For example, public key crypto
needs a mathlib; hashing and symmetric encryption
you are going to use LTC functions that depend
on a mathlib. For example, public key crypto
needs a mathlib; hashing and symmetric encryption
do not.
This code was written for Python 2.7.
Larry Bugbee
March 2014
@ -65,34 +65,34 @@ print
#---------------------------------------------------------------
# get list of all supported constants followed by a list of all
# supported sizes. One alternative: these lists may be parsed
# get list of all supported constants followed by a list of all
# supported sizes. One alternative: these lists may be parsed
# and used as needed.
if 1:
print ' all supported constants and their values:'
# get size to allocate for constants output list
str_len = c_int(0)
ret = LTC.crypt_list_all_constants(None, byref(str_len))
print ' need to allocate %d bytes \n' % str_len.value
# allocate that size and get (name, size) pairs, each pair
# separated by a newline char.
names_sizes = c_buffer(str_len.value)
ret = LTC.crypt_list_all_constants(names_sizes, byref(str_len))
print names_sizes.value
print
if 1:
print ' all supported sizes:'
# get size to allocate for sizes output list
str_len = c_int(0)
ret = LTC.crypt_list_all_sizes(None, byref(str_len))
print ' need to allocate %d bytes \n' % str_len.value
# allocate that size and get (name, size) pairs, each pair
# separated by a newline char.
names_sizes = c_buffer(str_len.value)
@ -107,7 +107,7 @@ if 1:
# print selected constants
if 1:
print '\n selected constants:'
names = [
'ENDIAN_LITTLE',
'ENDIAN_64BITWORD',
@ -124,7 +124,7 @@ if 1:
# print selected sizes
if 1:
print '\n selected sizes:'
names = [
'rijndael_key',
'rsa_key',
@ -143,7 +143,7 @@ if 1:
#---------------------------------------------------------------
#---------------------------------------------------------------
# ctypes getting a list of this build's supported algorithms
# ctypes getting a list of this build's supported algorithms
# and compiler switches
def get_named_string(lib, name):
@ -160,7 +160,7 @@ if 0:
#---------------------------------------------------------------
#---------------------------------------------------------------
# here is an example of how a wrapper can make Python access
# here is an example of how a wrapper can make Python access
# more Pythonic
# - - - - - - - - - - - - -

View File

@ -1,48 +1,48 @@
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file demo_crypt_sizes.c
Demo how to get various sizes to dynamic languages
like Python - Larry Bugbee, February 2013
*/
int main(void) {
// given a specific size name, get and print its size
char name[] = "ecc_key";
unsigned int size;
if(crypt_get_size(name, &size) != 0)
exit(EXIT_FAILURE);
printf("\n size of '%s' is %u \n\n", name, size);
// get and print the length of the names (and sizes) list
char *sizes_list;
unsigned int sizes_list_len;
if(crypt_list_all_sizes(NULL, &sizes_list_len) != 0)
exit(EXIT_FAILURE);
printf(" need to allocate %u bytes \n\n", sizes_list_len);
// get and print the names (and sizes) list
sizes_list = malloc(sizes_list_len);
if(crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0)
exit(EXIT_FAILURE);
printf(" supported sizes:\n\n%s\n\n", sizes_list);
return 0;
}
/* $Source: $ */
/* $Revision: $ */
/* $Date: $ */
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
*
* LibTomCrypt is a library that provides various cryptographic
* algorithms in a highly modular and flexible manner.
*
* The library is free for all purposes without any express
* guarantee it works.
*
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file demo_crypt_sizes.c
Demo how to get various sizes to dynamic languages
like Python - Larry Bugbee, February 2013
*/
int main(void) {
// given a specific size name, get and print its size
char name[] = "ecc_key";
unsigned int size;
if(crypt_get_size(name, &size) != 0)
exit(EXIT_FAILURE);
printf("\n size of '%s' is %u \n\n", name, size);
// get and print the length of the names (and sizes) list
char *sizes_list;
unsigned int sizes_list_len;
if(crypt_list_all_sizes(NULL, &sizes_list_len) != 0)
exit(EXIT_FAILURE);
printf(" need to allocate %u bytes \n\n", sizes_list_len);
// get and print the names (and sizes) list
sizes_list = malloc(sizes_list_len);
if(crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0)
exit(EXIT_FAILURE);
printf(" supported sizes:\n\n%s\n\n", sizes_list);
return 0;
}
/* $Source: $ */
/* $Revision: $ */
/* $Date: $ */

View File

@ -1,8 +1,8 @@
#!/usr/bin/perl
#
# Splits the list of files and outputs for makefile type files
# wrapped at 80 chars
#
# Splits the list of files and outputs for makefile type files
# wrapped at 80 chars
#
# Tom St Denis
@a = split(" ", $ARGV[1]);
$b = "$ARGV[0]=";

View File

@ -3,7 +3,7 @@
version=$(git describe --tags --always --dirty 2>/dev/null)
if [ ! -e ".git" ] || [ -z $version ]
then
version=$(grep "^VERSION=" makefile | sed "s/.*=//")
version=$(grep "^VERSION=" makefile | sed "s/.*=//")
fi
echo "Testing version:" $version
#grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"`
@ -14,7 +14,7 @@ echo "uname="`uname -a`
# get gcc name
if [ -z ${CC} ]
then
CC="gcc"
CC="gcc"
fi
echo "${CC}="`${CC} -dumpversion`
echo

18
run.sh
View File

@ -7,9 +7,9 @@ bash build.sh " $1" "$2 -O2" "$3 IGNORE_SPEED=1" "$4" "$5"
if [ -a testok.txt ] && [ -f testok.txt ]; then
echo
else
echo
echo "Test failed"
exit 1
echo
echo "Test failed"
exit 1
fi
rm -f testok.txt
@ -17,9 +17,9 @@ bash build.sh " $1" "$2 -Os" " $3 IGNORE_SPEED=1 LTC_SMALL=1" "$4" "$5"
if [ -a testok.txt ] && [ -f testok.txt ]; then
echo
else
echo
echo "Test failed"
exit 1
echo
echo "Test failed"
exit 1
fi
rm -f testok.txt
@ -27,9 +27,9 @@ bash build.sh " $1" " $2" " $3 " "$4" "$5"
if [ -a testok.txt ] && [ -f testok.txt ]; then
echo
else
echo
echo "Test failed"
exit 1
echo
echo "Test failed"
exit 1
fi
exit 0

View File

@ -55,6 +55,6 @@ bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$1" "$2" "$3" || exit 1
# test build with no file routines
bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$1" "$2" "$3" || exit 1
# $Source$
# $Revision$
# $Date$
# $Source$
# $Revision$
# $Date$

View File

@ -8,17 +8,17 @@ int cipher_hash_test(void)
unsigned char buf[4096];
unsigned long n;
prng_state nprng;
/* test ciphers */
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
DOX(cipher_descriptor[x].test(), cipher_descriptor[x].name);
}
/* test hashes */
for (x = 0; hash_descriptor[x].name != NULL; x++) {
DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
}
/* test prngs (test, import/export */
for (x = 0; prng_descriptor[x].name != NULL; x++) {
DOX(prng_descriptor[x].test(), prng_descriptor[x].name);
@ -36,7 +36,7 @@ int cipher_hash_test(void)
}
prng_descriptor[x].done(&nprng);
}
return 0;
}

View File

@ -18,7 +18,7 @@ int katja_test(void)
}
for (size = 1024; size <= 2048; size += 256) {
/* make 10 random key */
for (cnt = 0; cnt < 10; cnt++) {
DO(katja_make_key(&yarrow_prng, prng_idx, size/8, &key));
@ -65,7 +65,7 @@ for (cnt = 0; cnt < len; ) {
len = sizeof(out);
len2 = kat_msgsize;
DO(katja_encrypt_key(in, kat_msgsize, out, &len, NULL, 0, &yarrow_prng, prng_idx, hash_idx, &key));
/* change a byte */
out[8] ^= 1;
@ -86,7 +86,7 @@ for (cnt = 0; cnt < len; ) {
if (len2 != kat_msgsize || memcmp(tmp, in, kat_msgsize)) {
unsigned long x;
fprintf(stderr, "\nkatja_decrypt_key mismatch, len %lu (second decrypt)\n", len2);
fprintf(stderr, "Original contents: \n");
fprintf(stderr, "Original contents: \n");
for (x = 0; x < kat_msgsize; ) {
fprintf(stderr, "%02x ", in[x]);
if (!(++x % 16)) {
@ -94,13 +94,13 @@ for (cnt = 0; cnt < len; ) {
}
}
fprintf(stderr, "\n");
fprintf(stderr, "Output contents: \n");
fprintf(stderr, "Output contents: \n");
for (x = 0; x < kat_msgsize; ) {
fprintf(stderr, "%02x ", out[x]);
if (!(++x % 16)) {
fprintf(stderr, "\n");
}
}
}
fprintf(stderr, "\n");
return 1;
}
@ -142,8 +142,8 @@ for (cnt = 0; cnt < len; ) {
/* export key and import as both private and public */
len2 = sizeof(tmp);
DO(katja_export(tmp, &len2, PK_PRIVATE, &key));
DO(katja_import(tmp, len2, &privKey));
DO(katja_export(tmp, &len2, PK_PRIVATE, &key));
DO(katja_import(tmp, len2, &privKey));
len2 = sizeof(tmp);
DO(katja_export(tmp, &len2, PK_PUBLIC, &key));
DO(katja_import(tmp, len2, &pubKey));
@ -153,7 +153,7 @@ for (cnt = 0; cnt < len; ) {
/* change a byte */
in[0] ^= 1;
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &key));
if (!(stat == 1 && stat2 == 0)) {
fprintf(stderr, "katja_verify_hash (unsalted, origKey) failed, %d, %d", stat, stat2);
katja_free(&key);
@ -169,7 +169,7 @@ for (cnt = 0; cnt < len; ) {
/* change a byte */
in[0] ^= 1;
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &privKey));
if (!(stat == 1 && stat2 == 0)) {
fprintf(stderr, "katja_verify_hash (unsalted, privKey) failed, %d, %d", stat, stat2);
katja_free(&key);
@ -185,7 +185,7 @@ for (cnt = 0; cnt < len; ) {
/* change a byte */
in[0] ^= 1;
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &pubKey));
if (!(stat == 1 && stat2 == 0)) {
fprintf(stderr, "katja_verify_hash (unsalted, pubkey) failed, %d, %d", stat, stat2);
katja_free(&key);
@ -201,7 +201,7 @@ for (cnt = 0; cnt < len; ) {
/* change a byte */
in[0] ^= 1;
DO(katja_verify_hash(out, len, in, 20, hash_idx, 8, &stat2, &pubKey));
if (!(stat == 1 && stat2 == 0)) {
fprintf(stderr, "katja_verify_hash (salted) failed, %d, %d", stat, stat2);
katja_free(&key);
@ -215,7 +215,7 @@ for (cnt = 0; cnt < len; ) {
katja_free(&pubKey);
katja_free(&privKey);
}
/* free the key and return */
return 0;
}

View File

@ -4,13 +4,13 @@
int mac_test(void)
{
#ifdef LTC_HMAC
DO(hmac_test());
DO(hmac_test());
#endif
#ifdef LTC_PMAC
DO(pmac_test());
DO(pmac_test());
#endif
#ifdef LTC_OMAC
DO(omac_test());
DO(omac_test());
#endif
#ifdef LTC_XCBC
DO(xcbc_test());
@ -19,13 +19,13 @@ int mac_test(void)
DO(f9_test());
#endif
#ifdef LTC_EAX_MODE
DO(eax_test());
DO(eax_test());
#endif
#ifdef LTC_OCB_MODE
DO(ocb_test());
DO(ocb_test());
#endif
#ifdef LTC_OCB3_MODE
DO(ocb3_test());
DO(ocb3_test());
#endif
#ifdef LTC_CCM_MODE
DO(ccm_test());

View File

@ -1,4 +1,4 @@
CFLAGS += -I../src/headers -I./
CFLAGS += -I../src/headers -I./
CC?=icc
OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o \

View File

@ -1099,7 +1099,7 @@ void time_rsa(void)
t2 <<= 8;
break;
#endif
}
}
t2 >>= 8;
fprintf(stderr, "RSA-%lu sign_hash took %15"PRI64"u cycles\n", x, t2);
@ -1121,7 +1121,7 @@ void time_rsa(void)
t2 <<= 11;
break;
#endif
}
}
t2 >>= 11;
fprintf(stderr, "RSA-%lu verify_hash took %15"PRI64"u cycles\n", x, t2);
fprintf(stderr, "\n\n");
@ -1317,7 +1317,7 @@ void time_ecc(void)
t2 <<= 8;
break;
#endif
}
}
t2 >>= 8;
fprintf(stderr, "ECC-%lu sign_hash took %15"PRI64"u cycles\n", x*8, t2);
@ -1339,7 +1339,7 @@ void time_ecc(void)
t2 <<= 8;
break;
#endif
}
}
t2 >>= 8;
fprintf(stderr, "ECC-%lu verify_hash took %15"PRI64"u cycles\n", x*8, t2);