Merge branch 'ppelleti/ltc-fixes' into develop
This commit is contained in:
commit
20f0c74d17
28
makefile
28
makefile
@ -329,23 +329,23 @@ profile:
|
|||||||
#This rule cleans the source tree of all compiled code, not including the pdf
|
#This rule cleans the source tree of all compiled code, not including the pdf
|
||||||
#documentation.
|
#documentation.
|
||||||
clean:
|
clean:
|
||||||
rm -f `find . -type f | grep "[.]o" | xargs`
|
rm -f `find . -type f -name "*.o" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]lo" | xargs`
|
rm -f `find . -type f -name "*.lo" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]a" | xargs`
|
rm -f `find . -type f -name "*.a" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]la" | xargs`
|
rm -f `find . -type f -name "*.la" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]obj" | xargs`
|
rm -f `find . -type f -name "*.obj" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]lib" | xargs`
|
rm -f `find . -type f -name "*.lib" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]exe" | xargs`
|
rm -f `find . -type f -name "*.exe" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]gcda" | xargs`
|
rm -f `find . -type f -name "*.gcda" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]gcno" | xargs`
|
rm -f `find . -type f -name "*.gcno" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]il" | xargs`
|
rm -f `find . -type f -name "*.il" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]dyn" | xargs`
|
rm -f `find . -type f -name "*.dyn" | xargs`
|
||||||
rm -f `find . -type f | grep "[.]dpi" | xargs`
|
rm -f `find . -type f -name "*.dpi" | xargs`
|
||||||
rm -rf `find . -type d | grep "[.]libs" | xargs`
|
rm -rf `find . -type d -name "*.libs" | xargs`
|
||||||
rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc
|
rm -f crypt.aux crypt.dvi crypt.idx crypt.ilg crypt.ind crypt.log crypt.toc
|
||||||
rm -f $(TV) $(PROF) $(SMALL) $(CRYPT) $(HASHSUM) $(MULTI) $(TIMING) $(TEST)
|
rm -f $(TV) $(PROF) $(SMALL) $(CRYPT) $(HASHSUM) $(MULTI) $(TIMING) $(TEST)
|
||||||
rm -rf doc/doxygen
|
rm -rf doc/doxygen
|
||||||
rm -f doc/*.pdf
|
rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs`
|
||||||
rm -f *.txt
|
rm -f *.txt
|
||||||
|
|
||||||
#build the doxy files (requires Doxygen, tetex and patience)
|
#build the doxy files (requires Doxygen, tetex and patience)
|
||||||
|
@ -686,6 +686,21 @@ int camellia_test(void)
|
|||||||
}
|
}
|
||||||
camellia_done(&skey);
|
camellia_done(&skey);
|
||||||
if (XMEMCMP(tests[x].ct, buf[0], 16) || XMEMCMP(tests[x].pt, buf[1], 16)) {
|
if (XMEMCMP(tests[x].ct, buf[0], 16) || XMEMCMP(tests[x].pt, buf[1], 16)) {
|
||||||
|
#if 0
|
||||||
|
int i, j;
|
||||||
|
printf ("\n\nLTC_CAMELLIA failed for x=%d, I got:\n", x);
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
const unsigned char *expected, *actual;
|
||||||
|
expected = (i ? tests[x].pt : tests[x].ct);
|
||||||
|
actual = buf[i];
|
||||||
|
printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
const char *eq = (expected[j] == actual[j] ? "==" : "!=");
|
||||||
|
printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
|
||||||
|
}
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return CRYPT_FAIL_TESTVECTOR;
|
return CRYPT_FAIL_TESTVECTOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,6 +346,21 @@ int kseed_test(void)
|
|||||||
kseed_ecb_encrypt(tests[x].pt, buf[0], &skey);
|
kseed_ecb_encrypt(tests[x].pt, buf[0], &skey);
|
||||||
kseed_ecb_decrypt(buf[0], buf[1], &skey);
|
kseed_ecb_decrypt(buf[0], buf[1], &skey);
|
||||||
if (XMEMCMP(buf[0], tests[x].ct, 16) || XMEMCMP(buf[1], tests[x].pt, 16)) {
|
if (XMEMCMP(buf[0], tests[x].ct, 16) || XMEMCMP(buf[1], tests[x].pt, 16)) {
|
||||||
|
#if 0
|
||||||
|
int i, j;
|
||||||
|
printf ("\n\nLTC_KSEED failed for x=%d, I got:\n", x);
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
const unsigned char *expected, *actual;
|
||||||
|
expected = (i ? tests[x].pt : tests[x].ct);
|
||||||
|
actual = buf[i];
|
||||||
|
printf ("expected actual (%s)\n", (i ? "plaintext" : "ciphertext"));
|
||||||
|
for (j = 0; j < 16; j++) {
|
||||||
|
const char *eq = (expected[j] == actual[j] ? "==" : "!=");
|
||||||
|
printf (" %02x %s %02x\n", expected[j], eq, actual[j]);
|
||||||
|
}
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return CRYPT_FAIL_TESTVECTOR;
|
return CRYPT_FAIL_TESTVECTOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,22 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
|
|||||||
#define ENDIAN_NEUTRAL
|
#define ENDIAN_NEUTRAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* gcc 4.3 and up has a bswap builtin; detect it by gcc version.
|
||||||
|
* clang also supports the bswap builtin, and although clang pretends
|
||||||
|
* to be gcc (macro-wise, anyway), clang pretends to be a version
|
||||||
|
* prior to gcc 4.3, so we can't detect bswap that way. Instead,
|
||||||
|
* clang has a __has_builtin mechanism that can be used to check
|
||||||
|
* for builtins:
|
||||||
|
* http://clang.llvm.org/docs/LanguageExtensions.html#feature_check */
|
||||||
|
#ifndef __has_builtin
|
||||||
|
#define __has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
#if !defined(LTC_NO_BSWAP) && defined(__GNUC__) && \
|
||||||
|
((__GNUC__ * 100 + __GNUC_MINOR__ >= 403) || \
|
||||||
|
(__has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)))
|
||||||
|
#define LTC_HAVE_BSWAP_BUILTIN
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,8 +306,8 @@
|
|||||||
/* #define LTC_RSA_BLINDING */
|
/* #define LTC_RSA_BLINDING */
|
||||||
|
|
||||||
/* Include Diffie-Hellman support */
|
/* Include Diffie-Hellman support */
|
||||||
#ifndef GPM_DESC
|
#ifndef GMP_DESC
|
||||||
/* is_prime fails for GPM */
|
/* is_prime fails for GMP */
|
||||||
#define MDH
|
#define MDH
|
||||||
/* Supported Key Sizes */
|
/* Supported Key Sizes */
|
||||||
#define DH768
|
#define DH768
|
||||||
|
@ -67,7 +67,17 @@
|
|||||||
|
|
||||||
#ifdef ENDIAN_LITTLE
|
#ifdef ENDIAN_LITTLE
|
||||||
|
|
||||||
#if !defined(LTC_NO_BSWAP) && (defined(INTEL_CC) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__) || defined(__x86_64__))))
|
#ifdef LTC_HAVE_BSWAP_BUILTIN
|
||||||
|
|
||||||
|
#define STORE32H(x, y) \
|
||||||
|
{ ulong32 __t = __builtin_bswap32 ((x)); \
|
||||||
|
XMEMCPY ((y), &__t, 4); }
|
||||||
|
|
||||||
|
#define LOAD32H(x, y) \
|
||||||
|
{ XMEMCPY (&(x), (y), 4); \
|
||||||
|
(x) = __builtin_bswap32 ((x)); }
|
||||||
|
|
||||||
|
#elif !defined(LTC_NO_BSWAP) && (defined(INTEL_CC) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__) || defined(__x86_64__))))
|
||||||
|
|
||||||
#define STORE32H(x, y) \
|
#define STORE32H(x, y) \
|
||||||
asm __volatile__ ( \
|
asm __volatile__ ( \
|
||||||
@ -96,22 +106,31 @@ asm __volatile__ ( \
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LTC_HAVE_BSWAP_BUILTIN
|
||||||
|
|
||||||
|
#define STORE64H(x, y) \
|
||||||
|
{ ulong64 __t = __builtin_bswap64 ((x)); \
|
||||||
|
XMEMCPY ((y), &__t, 8); }
|
||||||
|
|
||||||
|
#define LOAD64H(x, y) \
|
||||||
|
{ XMEMCPY (&(x), (y), 8); \
|
||||||
|
(x) = __builtin_bswap64 ((x)); }
|
||||||
|
|
||||||
/* x86_64 processor */
|
/* x86_64 processor */
|
||||||
#if !defined(LTC_NO_BSWAP) && (defined(__GNUC__) && defined(__x86_64__))
|
#elif !defined(LTC_NO_BSWAP) && (defined(__GNUC__) && defined(__x86_64__))
|
||||||
|
|
||||||
#define STORE64H(x, y) \
|
#define STORE64H(x, y) \
|
||||||
asm __volatile__ ( \
|
asm __volatile__ ( \
|
||||||
"bswapq %0 \n\t" \
|
"bswapq %0 \n\t" \
|
||||||
"movq %0,(%1)\n\t" \
|
"movq %0,(%1)\n\t" \
|
||||||
"bswapq %0 \n\t" \
|
"bswapq %0 \n\t" \
|
||||||
::"r"(x), "r"(y));
|
::"r"(x), "r"(y): "memory");
|
||||||
|
|
||||||
#define LOAD64H(x, y) \
|
#define LOAD64H(x, y) \
|
||||||
asm __volatile__ ( \
|
asm __volatile__ ( \
|
||||||
"movq (%1),%0\n\t" \
|
"movq (%1),%0\n\t" \
|
||||||
"bswapq %0\n\t" \
|
"bswapq %0\n\t" \
|
||||||
:"=r"(x): "r"(y));
|
:"=r"(x): "r"(y): "memory");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ const ltc_math_descriptor gmp_desc = {
|
|||||||
NULL,
|
NULL,
|
||||||
#endif /* LTC_ECC_SHAMIR */
|
#endif /* LTC_ECC_SHAMIR */
|
||||||
#else
|
#else
|
||||||
NULL, NULL, NULL, NULL, NULL
|
NULL, NULL, NULL, NULL, NULL,
|
||||||
#endif /* LTC_MECC */
|
#endif /* LTC_MECC */
|
||||||
|
|
||||||
#ifdef LTC_MRSA
|
#ifdef LTC_MRSA
|
||||||
|
@ -286,7 +286,9 @@ const char *crypt_build_settings =
|
|||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
" MSVC compiler detected.\n"
|
" MSVC compiler detected.\n"
|
||||||
#endif
|
#endif
|
||||||
#if defined(__GNUC__)
|
#if defined(__clang_version__)
|
||||||
|
" Clang compiler " __clang_version__ ".\n"
|
||||||
|
#elif defined(__GNUC__) /* clang also defines __GNUC__ */
|
||||||
" GCC compiler detected.\n"
|
" GCC compiler detected.\n"
|
||||||
#endif
|
#endif
|
||||||
#if defined(INTEL_CC)
|
#if defined(INTEL_CC)
|
||||||
|
@ -11,25 +11,25 @@ int cipher_hash_test(void)
|
|||||||
|
|
||||||
/* test ciphers */
|
/* test ciphers */
|
||||||
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
|
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
|
||||||
DO(cipher_descriptor[x].test());
|
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++) {
|
||||||
DO(hash_descriptor[x].test());
|
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++) {
|
||||||
DO(prng_descriptor[x].test());
|
DOX(prng_descriptor[x].test(), prng_descriptor[x].name);
|
||||||
DO(prng_descriptor[x].start(&nprng));
|
DOX(prng_descriptor[x].start(&nprng), prng_descriptor[x].name);
|
||||||
DO(prng_descriptor[x].add_entropy((unsigned char *)"helloworld12", 12, &nprng));
|
DOX(prng_descriptor[x].add_entropy((unsigned char *)"helloworld12", 12, &nprng), prng_descriptor[x].name);
|
||||||
DO(prng_descriptor[x].ready(&nprng));
|
DOX(prng_descriptor[x].ready(&nprng), prng_descriptor[x].name);
|
||||||
n = sizeof(buf);
|
n = sizeof(buf);
|
||||||
DO(prng_descriptor[x].pexport(buf, &n, &nprng));
|
DOX(prng_descriptor[x].pexport(buf, &n, &nprng), prng_descriptor[x].name);
|
||||||
prng_descriptor[x].done(&nprng);
|
prng_descriptor[x].done(&nprng);
|
||||||
DO(prng_descriptor[x].pimport(buf, n, &nprng));
|
DOX(prng_descriptor[x].pimport(buf, n, &nprng), prng_descriptor[x].name);
|
||||||
DO(prng_descriptor[x].ready(&nprng));
|
DOX(prng_descriptor[x].ready(&nprng), prng_descriptor[x].name);
|
||||||
if (prng_descriptor[x].read(buf, 100, &nprng) != 100) {
|
if (prng_descriptor[x].read(buf, 100, &nprng) != 100) {
|
||||||
fprintf(stderr, "Error reading from imported PRNG!\n");
|
fprintf(stderr, "Error reading from imported PRNG!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#include <tomcrypt_test.h>
|
#include <tomcrypt_test.h>
|
||||||
|
|
||||||
void run_cmd(int res, int line, char *file, char *cmd)
|
void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm)
|
||||||
{
|
{
|
||||||
if (res != CRYPT_OK) {
|
if (res != CRYPT_OK) {
|
||||||
fprintf(stderr, "%s (%d)\n%s:%d:%s\n", error_to_string(res), res, file, line, cmd);
|
fprintf(stderr, "%s (%d)%s%s\n%s:%d:%s\n",
|
||||||
|
error_to_string(res), res,
|
||||||
|
(algorithm ? " - " : ""), (algorithm ? algorithm : ""),
|
||||||
|
file, line, cmd);
|
||||||
if (res != CRYPT_NOP) {
|
if (res != CRYPT_NOP) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,14 @@ typedef struct {
|
|||||||
|
|
||||||
extern prng_state yarrow_prng;
|
extern prng_state yarrow_prng;
|
||||||
|
|
||||||
void run_cmd(int res, int line, char *file, char *cmd);
|
void run_cmd(int res, int line, char *file, char *cmd, const char *algorithm);
|
||||||
|
|
||||||
#ifdef LTC_VERBOSE
|
#ifdef LTC_VERBOSE
|
||||||
#define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x); } while (0);
|
#define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0);
|
||||||
|
#define DOX(x, str) do { fprintf(stderr, "%s - %s:\n", #x, (str)); run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0);
|
||||||
#else
|
#else
|
||||||
#define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x); } while (0);
|
#define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x, NULL); } while (0);
|
||||||
|
#define DOX(x, str) do { run_cmd((x), __LINE__, __FILE__, #x, (str)); } while (0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* TESTS */
|
/* TESTS */
|
||||||
|
Loading…
Reference in New Issue
Block a user