more trailing spaces + tabs outside of "src" dir
This commit is contained in:
parent
477d621224
commit
953080bcea
2
build.sh
2
build.sh
@ -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
|
CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" make -j$MAKE_JOBS -f $3 all_test 1>gcc_1.txt 2>gcc_2.txt
|
||||||
mret=$?
|
mret=$?
|
||||||
cnt=$(wc -l < gcc_2.txt)
|
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)
|
# $(LIBNAME) and testprof/$(LIBTEST_S)
|
||||||
if [[ $mret -ne 0 ]] || [[ $cnt -gt 2 ]]; then
|
if [[ $mret -ne 0 ]] || [[ $cnt -gt 2 ]]; then
|
||||||
echo "build $1 failed! printing gcc_2.txt now for convenience"
|
echo "build $1 failed! printing gcc_2.txt now for convenience"
|
||||||
|
10
coverage.sh
10
coverage.sh
@ -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
|
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Test failed"
|
echo "Test failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./sizes
|
./sizes
|
||||||
@ -30,9 +30,9 @@ fi
|
|||||||
|
|
||||||
# if this was executed as './coverage.sh ...' create coverage locally
|
# if this was executed as './coverage.sh ...' create coverage locally
|
||||||
if [[ "${0%% *}" == "./${0##*/}" ]]; then
|
if [[ "${0%% *}" == "./${0##*/}" ]]; then
|
||||||
make lcov-single
|
make lcov-single
|
||||||
else
|
else
|
||||||
cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/'
|
cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||||
*
|
*
|
||||||
* LibTomCrypt is a library that provides various cryptographic
|
* LibTomCrypt is a library that provides various cryptographic
|
||||||
* algorithms in a highly modular and flexible manner.
|
* algorithms in a highly modular and flexible manner.
|
||||||
*
|
*
|
||||||
* The library is free for all purposes without any express
|
* The library is free for all purposes without any express
|
||||||
* guarantee it works.
|
* guarantee it works.
|
||||||
*
|
*
|
||||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||||
*/
|
*/
|
||||||
#include "tomcrypt.h"
|
#include "tomcrypt.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file demo_crypt_constants.c
|
@file demo_crypt_constants.c
|
||||||
|
|
||||||
Demo how to get various constants to dynamic languages
|
Demo how to get various constants to dynamic languages
|
||||||
like Python
|
like Python
|
||||||
|
|
||||||
Larry Bugbee, February 2013
|
Larry Bugbee, February 2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
// given a specific constant name, get and print its value
|
// given a specific constant name, get and print its value
|
||||||
char name[] = "CTR_COUNTER_BIG_ENDIAN";
|
char name[] = "CTR_COUNTER_BIG_ENDIAN";
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (crypt_get_constant(name, &value) != 0)
|
if (crypt_get_constant(name, &value) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf("\n %s is %d \n\n", name, value);
|
printf("\n %s is %d \n\n", name, value);
|
||||||
|
|
||||||
// get and print the length of the names (and values) list
|
// get and print the length of the names (and values) list
|
||||||
char *names_list;
|
char *names_list;
|
||||||
unsigned int names_list_len;
|
unsigned int names_list_len;
|
||||||
|
|
||||||
if (crypt_list_all_constants(NULL, &names_list_len) != 0)
|
if (crypt_list_all_constants(NULL, &names_list_len) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf(" need to allocate %u bytes \n\n", names_list_len);
|
printf(" need to allocate %u bytes \n\n", names_list_len);
|
||||||
|
|
||||||
// get and print the names (and values) list
|
// get and print the names (and values) list
|
||||||
if ((names_list = malloc(names_list_len)) == NULL)
|
if ((names_list = malloc(names_list_len)) == NULL)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
if (crypt_list_all_constants(names_list, &names_list_len) != 0)
|
if (crypt_list_all_constants(names_list, &names_list_len) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf(" supported constants:\n\n%s\n\n", names_list);
|
printf(" supported constants:\n\n%s\n\n", names_list);
|
||||||
free(names_list);
|
free(names_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Source$ */
|
/* $Source$ */
|
||||||
/* $Revision$ */
|
/* $Revision$ */
|
||||||
/* $Date$ */
|
/* $Date$ */
|
||||||
|
@ -1,42 +1,42 @@
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
demo_dynamic.py v1
|
demo_dynamic.py v1
|
||||||
|
|
||||||
This program demonstrates Python's use of the dynamic
|
This program demonstrates Python's use of the dynamic
|
||||||
language support additions to LTC, namely access to LTC
|
language support additions to LTC, namely access to LTC
|
||||||
constants, struct and union sizes, and the binding of a
|
constants, struct and union sizes, and the binding of a
|
||||||
math package to LTC. Also provided are simple code
|
math package to LTC. Also provided are simple code
|
||||||
fragments to illustrate how one might write a Python
|
fragments to illustrate how one might write a Python
|
||||||
wrapper for LTC and how an app might call the wrapper.
|
wrapper for LTC and how an app might call the wrapper.
|
||||||
This or a similar model should work for Ruby and other
|
This or a similar model should work for Ruby and other
|
||||||
dynamic languages.
|
dynamic languages.
|
||||||
|
|
||||||
This instance uses Python's ctypes and requires a single
|
This instance uses Python's ctypes and requires a single
|
||||||
.dylib linking together LTC and a math library. Building
|
.dylib linking together LTC and a math library. Building
|
||||||
a single .dylib is needed because LTC wants a fairly tight
|
a single .dylib is needed because LTC wants a fairly tight
|
||||||
relationship between itself and the mathlib. (ctypes can
|
relationship between itself and the mathlib. (ctypes can
|
||||||
load multiple .dylibs, but it does not support this level
|
load multiple .dylibs, but it does not support this level
|
||||||
of tight coupling between otherwise independent libraries.)
|
of tight coupling between otherwise independent libraries.)
|
||||||
|
|
||||||
My .dylib was created on OSX with the following steps:
|
My .dylib was created on OSX with the following steps:
|
||||||
|
|
||||||
1- compile LTC to a .a static lib:
|
1- compile LTC to a .a static lib:
|
||||||
CFLAGS="-DLTM_DESC -DUSE_LTM" make
|
CFLAGS="-DLTM_DESC -DUSE_LTM" make
|
||||||
|
|
||||||
2- link LTC and LTM into a single .dylib:
|
2- link LTC and LTM into a single .dylib:
|
||||||
ar2dylib_with tomcrypt tommath
|
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
|
the LTC .a with the LTM .dylib
|
||||||
|
|
||||||
Reminder: you don't need to bind in a math library unless
|
Reminder: you don't need to bind in a math library unless
|
||||||
you are going to use LTC functions that depend
|
you are going to use LTC functions that depend
|
||||||
on a mathlib. For example, public key crypto
|
on a mathlib. For example, public key crypto
|
||||||
needs a mathlib; hashing and symmetric encryption
|
needs a mathlib; hashing and symmetric encryption
|
||||||
do not.
|
do not.
|
||||||
|
|
||||||
This code was written for Python 2.7.
|
This code was written for Python 2.7.
|
||||||
|
|
||||||
Larry Bugbee
|
Larry Bugbee
|
||||||
March 2014
|
March 2014
|
||||||
|
|
||||||
@ -65,34 +65,34 @@ print
|
|||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
# get list of all supported constants followed by a list of all
|
# get list of all supported constants followed by a list of all
|
||||||
# supported sizes. One alternative: these lists may be parsed
|
# supported sizes. One alternative: these lists may be parsed
|
||||||
# and used as needed.
|
# and used as needed.
|
||||||
|
|
||||||
if 1:
|
if 1:
|
||||||
print ' all supported constants and their values:'
|
print ' all supported constants and their values:'
|
||||||
|
|
||||||
# get size to allocate for constants output list
|
# get size to allocate for constants output list
|
||||||
str_len = c_int(0)
|
str_len = c_int(0)
|
||||||
ret = LTC.crypt_list_all_constants(None, byref(str_len))
|
ret = LTC.crypt_list_all_constants(None, byref(str_len))
|
||||||
print ' need to allocate %d bytes \n' % str_len.value
|
print ' need to allocate %d bytes \n' % str_len.value
|
||||||
|
|
||||||
# allocate that size and get (name, size) pairs, each pair
|
# allocate that size and get (name, size) pairs, each pair
|
||||||
# separated by a newline char.
|
# separated by a newline char.
|
||||||
names_sizes = c_buffer(str_len.value)
|
names_sizes = c_buffer(str_len.value)
|
||||||
ret = LTC.crypt_list_all_constants(names_sizes, byref(str_len))
|
ret = LTC.crypt_list_all_constants(names_sizes, byref(str_len))
|
||||||
print names_sizes.value
|
print names_sizes.value
|
||||||
print
|
print
|
||||||
|
|
||||||
|
|
||||||
if 1:
|
if 1:
|
||||||
print ' all supported sizes:'
|
print ' all supported sizes:'
|
||||||
|
|
||||||
# get size to allocate for sizes output list
|
# get size to allocate for sizes output list
|
||||||
str_len = c_int(0)
|
str_len = c_int(0)
|
||||||
ret = LTC.crypt_list_all_sizes(None, byref(str_len))
|
ret = LTC.crypt_list_all_sizes(None, byref(str_len))
|
||||||
print ' need to allocate %d bytes \n' % str_len.value
|
print ' need to allocate %d bytes \n' % str_len.value
|
||||||
|
|
||||||
# allocate that size and get (name, size) pairs, each pair
|
# allocate that size and get (name, size) pairs, each pair
|
||||||
# separated by a newline char.
|
# separated by a newline char.
|
||||||
names_sizes = c_buffer(str_len.value)
|
names_sizes = c_buffer(str_len.value)
|
||||||
@ -107,7 +107,7 @@ if 1:
|
|||||||
# print selected constants
|
# print selected constants
|
||||||
if 1:
|
if 1:
|
||||||
print '\n selected constants:'
|
print '\n selected constants:'
|
||||||
|
|
||||||
names = [
|
names = [
|
||||||
'ENDIAN_LITTLE',
|
'ENDIAN_LITTLE',
|
||||||
'ENDIAN_64BITWORD',
|
'ENDIAN_64BITWORD',
|
||||||
@ -124,7 +124,7 @@ if 1:
|
|||||||
# print selected sizes
|
# print selected sizes
|
||||||
if 1:
|
if 1:
|
||||||
print '\n selected sizes:'
|
print '\n selected sizes:'
|
||||||
|
|
||||||
names = [
|
names = [
|
||||||
'rijndael_key',
|
'rijndael_key',
|
||||||
'rsa_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
|
# and compiler switches
|
||||||
|
|
||||||
def get_named_string(lib, name):
|
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
|
# more Pythonic
|
||||||
|
|
||||||
# - - - - - - - - - - - - -
|
# - - - - - - - - - - - - -
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||||
*
|
*
|
||||||
* LibTomCrypt is a library that provides various cryptographic
|
* LibTomCrypt is a library that provides various cryptographic
|
||||||
* algorithms in a highly modular and flexible manner.
|
* algorithms in a highly modular and flexible manner.
|
||||||
*
|
*
|
||||||
* The library is free for all purposes without any express
|
* The library is free for all purposes without any express
|
||||||
* guarantee it works.
|
* guarantee it works.
|
||||||
*
|
*
|
||||||
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
|
||||||
*/
|
*/
|
||||||
#include "tomcrypt.h"
|
#include "tomcrypt.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file demo_crypt_sizes.c
|
@file demo_crypt_sizes.c
|
||||||
|
|
||||||
Demo how to get various sizes to dynamic languages
|
Demo how to get various sizes to dynamic languages
|
||||||
like Python - Larry Bugbee, February 2013
|
like Python - Larry Bugbee, February 2013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
// given a specific size name, get and print its size
|
// given a specific size name, get and print its size
|
||||||
char name[] = "ecc_key";
|
char name[] = "ecc_key";
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
if(crypt_get_size(name, &size) != 0)
|
if(crypt_get_size(name, &size) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf("\n size of '%s' is %u \n\n", name, size);
|
printf("\n size of '%s' is %u \n\n", name, size);
|
||||||
|
|
||||||
// get and print the length of the names (and sizes) list
|
// get and print the length of the names (and sizes) list
|
||||||
char *sizes_list;
|
char *sizes_list;
|
||||||
unsigned int sizes_list_len;
|
unsigned int sizes_list_len;
|
||||||
if(crypt_list_all_sizes(NULL, &sizes_list_len) != 0)
|
if(crypt_list_all_sizes(NULL, &sizes_list_len) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf(" need to allocate %u bytes \n\n", sizes_list_len);
|
printf(" need to allocate %u bytes \n\n", sizes_list_len);
|
||||||
|
|
||||||
// get and print the names (and sizes) list
|
// get and print the names (and sizes) list
|
||||||
sizes_list = malloc(sizes_list_len);
|
sizes_list = malloc(sizes_list_len);
|
||||||
if(crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0)
|
if(crypt_list_all_sizes(sizes_list, &sizes_list_len) != 0)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
printf(" supported sizes:\n\n%s\n\n", sizes_list);
|
printf(" supported sizes:\n\n%s\n\n", sizes_list);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Source: $ */
|
/* $Source: $ */
|
||||||
/* $Revision: $ */
|
/* $Revision: $ */
|
||||||
/* $Date: $ */
|
/* $Date: $ */
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
#
|
#
|
||||||
# Splits the list of files and outputs for makefile type files
|
# Splits the list of files and outputs for makefile type files
|
||||||
# wrapped at 80 chars
|
# wrapped at 80 chars
|
||||||
#
|
#
|
||||||
# Tom St Denis
|
# Tom St Denis
|
||||||
@a = split(" ", $ARGV[1]);
|
@a = split(" ", $ARGV[1]);
|
||||||
$b = "$ARGV[0]=";
|
$b = "$ARGV[0]=";
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
version=$(git describe --tags --always --dirty 2>/dev/null)
|
version=$(git describe --tags --always --dirty 2>/dev/null)
|
||||||
if [ ! -e ".git" ] || [ -z $version ]
|
if [ ! -e ".git" ] || [ -z $version ]
|
||||||
then
|
then
|
||||||
version=$(grep "^VERSION=" makefile | sed "s/.*=//")
|
version=$(grep "^VERSION=" makefile | sed "s/.*=//")
|
||||||
fi
|
fi
|
||||||
echo "Testing version:" $version
|
echo "Testing version:" $version
|
||||||
#grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"`
|
#grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"`
|
||||||
@ -14,7 +14,7 @@ echo "uname="`uname -a`
|
|||||||
# get gcc name
|
# get gcc name
|
||||||
if [ -z ${CC} ]
|
if [ -z ${CC} ]
|
||||||
then
|
then
|
||||||
CC="gcc"
|
CC="gcc"
|
||||||
fi
|
fi
|
||||||
echo "${CC}="`${CC} -dumpversion`
|
echo "${CC}="`${CC} -dumpversion`
|
||||||
echo
|
echo
|
||||||
|
18
run.sh
18
run.sh
@ -7,9 +7,9 @@ bash build.sh " $1" "$2 -O2" "$3 IGNORE_SPEED=1" "$4" "$5"
|
|||||||
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Test failed"
|
echo "Test failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f testok.txt
|
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
|
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Test failed"
|
echo "Test failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f testok.txt
|
rm -f testok.txt
|
||||||
@ -27,9 +27,9 @@ bash build.sh " $1" " $2" " $3 " "$4" "$5"
|
|||||||
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
if [ -a testok.txt ] && [ -f testok.txt ]; then
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "Test failed"
|
echo "Test failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -55,6 +55,6 @@ bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$1" "$2" "$3" || exit 1
|
|||||||
# test build with no file routines
|
# test build with no file routines
|
||||||
bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$1" "$2" "$3" || exit 1
|
bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$1" "$2" "$3" || exit 1
|
||||||
|
|
||||||
# $Source$
|
# $Source$
|
||||||
# $Revision$
|
# $Revision$
|
||||||
# $Date$
|
# $Date$
|
||||||
|
@ -8,17 +8,17 @@ int cipher_hash_test(void)
|
|||||||
unsigned char buf[4096];
|
unsigned char buf[4096];
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
prng_state nprng;
|
prng_state nprng;
|
||||||
|
|
||||||
/* test ciphers */
|
/* test ciphers */
|
||||||
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
|
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
|
||||||
DOX(cipher_descriptor[x].test(), cipher_descriptor[x].name);
|
DOX(cipher_descriptor[x].test(), cipher_descriptor[x].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test hashes */
|
/* test hashes */
|
||||||
for (x = 0; hash_descriptor[x].name != NULL; x++) {
|
for (x = 0; hash_descriptor[x].name != NULL; x++) {
|
||||||
DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
|
DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test prngs (test, import/export */
|
/* test prngs (test, import/export */
|
||||||
for (x = 0; prng_descriptor[x].name != NULL; x++) {
|
for (x = 0; prng_descriptor[x].name != NULL; x++) {
|
||||||
DOX(prng_descriptor[x].test(), prng_descriptor[x].name);
|
DOX(prng_descriptor[x].test(), prng_descriptor[x].name);
|
||||||
@ -36,7 +36,7 @@ int cipher_hash_test(void)
|
|||||||
}
|
}
|
||||||
prng_descriptor[x].done(&nprng);
|
prng_descriptor[x].done(&nprng);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ int katja_test(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size = 1024; size <= 2048; size += 256) {
|
for (size = 1024; size <= 2048; size += 256) {
|
||||||
|
|
||||||
/* make 10 random key */
|
/* make 10 random key */
|
||||||
for (cnt = 0; cnt < 10; cnt++) {
|
for (cnt = 0; cnt < 10; cnt++) {
|
||||||
DO(katja_make_key(&yarrow_prng, prng_idx, size/8, &key));
|
DO(katja_make_key(&yarrow_prng, prng_idx, size/8, &key));
|
||||||
@ -65,7 +65,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
|
|
||||||
len = sizeof(out);
|
len = sizeof(out);
|
||||||
len2 = kat_msgsize;
|
len2 = kat_msgsize;
|
||||||
|
|
||||||
DO(katja_encrypt_key(in, kat_msgsize, out, &len, NULL, 0, &yarrow_prng, prng_idx, hash_idx, &key));
|
DO(katja_encrypt_key(in, kat_msgsize, out, &len, NULL, 0, &yarrow_prng, prng_idx, hash_idx, &key));
|
||||||
/* change a byte */
|
/* change a byte */
|
||||||
out[8] ^= 1;
|
out[8] ^= 1;
|
||||||
@ -86,7 +86,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
if (len2 != kat_msgsize || memcmp(tmp, in, kat_msgsize)) {
|
if (len2 != kat_msgsize || memcmp(tmp, in, kat_msgsize)) {
|
||||||
unsigned long x;
|
unsigned long x;
|
||||||
fprintf(stderr, "\nkatja_decrypt_key mismatch, len %lu (second decrypt)\n", len2);
|
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; ) {
|
for (x = 0; x < kat_msgsize; ) {
|
||||||
fprintf(stderr, "%02x ", in[x]);
|
fprintf(stderr, "%02x ", in[x]);
|
||||||
if (!(++x % 16)) {
|
if (!(++x % 16)) {
|
||||||
@ -94,13 +94,13 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "Output contents: \n");
|
fprintf(stderr, "Output contents: \n");
|
||||||
for (x = 0; x < kat_msgsize; ) {
|
for (x = 0; x < kat_msgsize; ) {
|
||||||
fprintf(stderr, "%02x ", out[x]);
|
fprintf(stderr, "%02x ", out[x]);
|
||||||
if (!(++x % 16)) {
|
if (!(++x % 16)) {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -142,8 +142,8 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
|
|
||||||
/* export key and import as both private and public */
|
/* export key and import as both private and public */
|
||||||
len2 = sizeof(tmp);
|
len2 = sizeof(tmp);
|
||||||
DO(katja_export(tmp, &len2, PK_PRIVATE, &key));
|
DO(katja_export(tmp, &len2, PK_PRIVATE, &key));
|
||||||
DO(katja_import(tmp, len2, &privKey));
|
DO(katja_import(tmp, len2, &privKey));
|
||||||
len2 = sizeof(tmp);
|
len2 = sizeof(tmp);
|
||||||
DO(katja_export(tmp, &len2, PK_PUBLIC, &key));
|
DO(katja_export(tmp, &len2, PK_PUBLIC, &key));
|
||||||
DO(katja_import(tmp, len2, &pubKey));
|
DO(katja_import(tmp, len2, &pubKey));
|
||||||
@ -153,7 +153,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
/* change a byte */
|
/* change a byte */
|
||||||
in[0] ^= 1;
|
in[0] ^= 1;
|
||||||
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &key));
|
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &key));
|
||||||
|
|
||||||
if (!(stat == 1 && stat2 == 0)) {
|
if (!(stat == 1 && stat2 == 0)) {
|
||||||
fprintf(stderr, "katja_verify_hash (unsalted, origKey) failed, %d, %d", stat, stat2);
|
fprintf(stderr, "katja_verify_hash (unsalted, origKey) failed, %d, %d", stat, stat2);
|
||||||
katja_free(&key);
|
katja_free(&key);
|
||||||
@ -169,7 +169,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
/* change a byte */
|
/* change a byte */
|
||||||
in[0] ^= 1;
|
in[0] ^= 1;
|
||||||
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &privKey));
|
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &privKey));
|
||||||
|
|
||||||
if (!(stat == 1 && stat2 == 0)) {
|
if (!(stat == 1 && stat2 == 0)) {
|
||||||
fprintf(stderr, "katja_verify_hash (unsalted, privKey) failed, %d, %d", stat, stat2);
|
fprintf(stderr, "katja_verify_hash (unsalted, privKey) failed, %d, %d", stat, stat2);
|
||||||
katja_free(&key);
|
katja_free(&key);
|
||||||
@ -185,7 +185,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
/* change a byte */
|
/* change a byte */
|
||||||
in[0] ^= 1;
|
in[0] ^= 1;
|
||||||
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &pubKey));
|
DO(katja_verify_hash(out, len, in, 20, hash_idx, 0, &stat2, &pubKey));
|
||||||
|
|
||||||
if (!(stat == 1 && stat2 == 0)) {
|
if (!(stat == 1 && stat2 == 0)) {
|
||||||
fprintf(stderr, "katja_verify_hash (unsalted, pubkey) failed, %d, %d", stat, stat2);
|
fprintf(stderr, "katja_verify_hash (unsalted, pubkey) failed, %d, %d", stat, stat2);
|
||||||
katja_free(&key);
|
katja_free(&key);
|
||||||
@ -201,7 +201,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
/* change a byte */
|
/* change a byte */
|
||||||
in[0] ^= 1;
|
in[0] ^= 1;
|
||||||
DO(katja_verify_hash(out, len, in, 20, hash_idx, 8, &stat2, &pubKey));
|
DO(katja_verify_hash(out, len, in, 20, hash_idx, 8, &stat2, &pubKey));
|
||||||
|
|
||||||
if (!(stat == 1 && stat2 == 0)) {
|
if (!(stat == 1 && stat2 == 0)) {
|
||||||
fprintf(stderr, "katja_verify_hash (salted) failed, %d, %d", stat, stat2);
|
fprintf(stderr, "katja_verify_hash (salted) failed, %d, %d", stat, stat2);
|
||||||
katja_free(&key);
|
katja_free(&key);
|
||||||
@ -215,7 +215,7 @@ for (cnt = 0; cnt < len; ) {
|
|||||||
katja_free(&pubKey);
|
katja_free(&pubKey);
|
||||||
katja_free(&privKey);
|
katja_free(&privKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free the key and return */
|
/* free the key and return */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
int mac_test(void)
|
int mac_test(void)
|
||||||
{
|
{
|
||||||
#ifdef LTC_HMAC
|
#ifdef LTC_HMAC
|
||||||
DO(hmac_test());
|
DO(hmac_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_PMAC
|
#ifdef LTC_PMAC
|
||||||
DO(pmac_test());
|
DO(pmac_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_OMAC
|
#ifdef LTC_OMAC
|
||||||
DO(omac_test());
|
DO(omac_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_XCBC
|
#ifdef LTC_XCBC
|
||||||
DO(xcbc_test());
|
DO(xcbc_test());
|
||||||
@ -19,13 +19,13 @@ int mac_test(void)
|
|||||||
DO(f9_test());
|
DO(f9_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_EAX_MODE
|
#ifdef LTC_EAX_MODE
|
||||||
DO(eax_test());
|
DO(eax_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_OCB_MODE
|
#ifdef LTC_OCB_MODE
|
||||||
DO(ocb_test());
|
DO(ocb_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_OCB3_MODE
|
#ifdef LTC_OCB3_MODE
|
||||||
DO(ocb3_test());
|
DO(ocb3_test());
|
||||||
#endif
|
#endif
|
||||||
#ifdef LTC_CCM_MODE
|
#ifdef LTC_CCM_MODE
|
||||||
DO(ccm_test());
|
DO(ccm_test());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
CFLAGS += -I../src/headers -I./
|
CFLAGS += -I../src/headers -I./
|
||||||
CC?=icc
|
CC?=icc
|
||||||
|
|
||||||
OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o \
|
OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o \
|
||||||
|
@ -1099,7 +1099,7 @@ void time_rsa(void)
|
|||||||
t2 <<= 8;
|
t2 <<= 8;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
t2 >>= 8;
|
t2 >>= 8;
|
||||||
fprintf(stderr, "RSA-%lu sign_hash took %15"PRI64"u cycles\n", x, t2);
|
fprintf(stderr, "RSA-%lu sign_hash took %15"PRI64"u cycles\n", x, t2);
|
||||||
|
|
||||||
@ -1121,7 +1121,7 @@ void time_rsa(void)
|
|||||||
t2 <<= 11;
|
t2 <<= 11;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
t2 >>= 11;
|
t2 >>= 11;
|
||||||
fprintf(stderr, "RSA-%lu verify_hash took %15"PRI64"u cycles\n", x, t2);
|
fprintf(stderr, "RSA-%lu verify_hash took %15"PRI64"u cycles\n", x, t2);
|
||||||
fprintf(stderr, "\n\n");
|
fprintf(stderr, "\n\n");
|
||||||
@ -1317,7 +1317,7 @@ void time_ecc(void)
|
|||||||
t2 <<= 8;
|
t2 <<= 8;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
t2 >>= 8;
|
t2 >>= 8;
|
||||||
fprintf(stderr, "ECC-%lu sign_hash took %15"PRI64"u cycles\n", x*8, t2);
|
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;
|
t2 <<= 8;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
t2 >>= 8;
|
t2 >>= 8;
|
||||||
fprintf(stderr, "ECC-%lu verify_hash took %15"PRI64"u cycles\n", x*8, t2);
|
fprintf(stderr, "ECC-%lu verify_hash took %15"PRI64"u cycles\n", x*8, t2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user