From 8c488289f05c06fc4cb2641c26fa6042443d5d67 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sat, 12 Jul 2014 16:44:28 +0200 Subject: [PATCH] improve some error and informational output --- src/misc/crypt/crypt.c | 18 +++++++++++------- testprof/rsa_test.c | 5 +++-- testprof/x86_prof.c | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/misc/crypt/crypt.c b/src/misc/crypt/crypt.c index e6bbeaa..769f222 100644 --- a/src/misc/crypt/crypt.c +++ b/src/misc/crypt/crypt.c @@ -269,7 +269,7 @@ const char *crypt_build_settings = #if defined(LTC_MRSA) " RSA" #if defined(LTC_RSA_BLINDING) - " (with blinding)" + " (with blinding)" #endif "\n" #endif @@ -277,7 +277,11 @@ const char *crypt_build_settings = " DH\n" #endif #if defined(LTC_MECC) - " ECC\n" + " ECC" +#if defined(LTC_ECC_TIMING_RESISTANT) + " (with blinding)" +#endif + "\n" #endif #if defined(LTC_MDSA) " DSA\n" @@ -301,12 +305,12 @@ const char *crypt_build_settings = #endif #if defined(__clang_version__) " Clang compiler " __clang_version__ ".\n" -#elif defined(__GNUC__) /* clang also defines __GNUC__ */ - " GCC compiler detected.\n" -#endif -#if defined(INTEL_CC) - " Intel C Compiler detected.\n" +#elif defined(INTEL_CC) + " Intel C Compiler " __VERSION__ ".\n" +#elif defined(__GNUC__) /* clang and icc also define __GNUC__ */ + " GCC compiler " __VERSION__ ".\n" #endif + #if defined(__x86_64__) " x86-64 detected.\n" #endif diff --git a/testprof/rsa_test.c b/testprof/rsa_test.c index c842b25..0366dc9 100644 --- a/testprof/rsa_test.c +++ b/testprof/rsa_test.c @@ -181,7 +181,8 @@ for (cnt = 0; cnt < len; ) { len2 = rsa_msgsize; DO(rsa_decrypt_key(out, len, tmp, &len2, NULL, 0, hash_idx, &stat, &key)); if (!(stat == 1 && stat2 == 0)) { - fprintf(stderr, "rsa_decrypt_key failed"); + fprintf(stderr, "rsa_decrypt_key (without lparam) failed (rsa_msgsize = %lu)", rsa_msgsize); + fprintf(stderr, "\n stat: %i stat2: %i", stat, stat2); return 1; } if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) { @@ -226,7 +227,7 @@ for (cnt = 0; cnt < len; ) { len2 = rsa_msgsize; DO(rsa_decrypt_key(out, len, tmp, &len2, lparam, sizeof(lparam), hash_idx, &stat, &key)); if (!(stat == 1 && stat2 == 0)) { - fprintf(stderr, "rsa_decrypt_key failed"); + fprintf(stderr, "rsa_decrypt_key (with lparam) failed (rsa_msgsize = %lu)", rsa_msgsize); return 1; } if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) { diff --git a/testprof/x86_prof.c b/testprof/x86_prof.c index 8ff77cb..534a4fa 100644 --- a/testprof/x86_prof.c +++ b/testprof/x86_prof.c @@ -1306,7 +1306,7 @@ void time_macs_(unsigned long MAC_SIZE) hash_idx = find_hash("sha1"); if (cipher_idx == -1 || hash_idx == -1) { - fprintf(stderr, "Warning the MAC tests requires AES and LTC_SHA1 to operate... so sorry\n"); + fprintf(stderr, "Warning the MAC tests requires AES and SHA1 to operate... so sorry\n"); return; } @@ -1320,13 +1320,13 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read(); z = 16; if ((err = omac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) { - fprintf(stderr, "\n\nomac error... %s\n", error_to_string(err)); + fprintf(stderr, "\n\nomac-%s error... %s\n", cipher_descriptor[cipher_idx].name, error_to_string(err)); exit(EXIT_FAILURE); } t1 = t_read() - t1; if (t1 < t2) t2 = t1; } - fprintf(stderr, "LTC_OMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024)); + fprintf(stderr, "OMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024)); #endif #ifdef LTC_XCBC @@ -1336,7 +1336,7 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read(); z = 16; if ((err = xcbc_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) { - fprintf(stderr, "\n\nxcbc error... %s\n", error_to_string(err)); + fprintf(stderr, "\n\nxcbc-%s error... %s\n", cipher_descriptor[cipher_idx].name, error_to_string(err)); exit(EXIT_FAILURE); } t1 = t_read() - t1; @@ -1352,7 +1352,7 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read(); z = 16; if ((err = f9_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) { - fprintf(stderr, "\n\nF9 error... %s\n", error_to_string(err)); + fprintf(stderr, "\n\nF9-%s error... %s\n", cipher_descriptor[cipher_idx].name, error_to_string(err)); exit(EXIT_FAILURE); } t1 = t_read() - t1; @@ -1368,13 +1368,13 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read(); z = 16; if ((err = pmac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) { - fprintf(stderr, "\n\npmac error... %s\n", error_to_string(err)); + fprintf(stderr, "\n\npmac-%s error... %s\n", cipher_descriptor[cipher_idx].name, error_to_string(err)); exit(EXIT_FAILURE); } t1 = t_read() - t1; if (t1 < t2) t2 = t1; } - fprintf(stderr, "PMAC-AES\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); + fprintf(stderr, "PMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024)); #endif #ifdef LTC_PELICAN @@ -1390,7 +1390,7 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read() - t1; if (t1 < t2) t2 = t1; } - fprintf(stderr, "LTC_PELICAN \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); + fprintf(stderr, "PELICAN \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); #endif #ifdef LTC_HMAC @@ -1400,13 +1400,13 @@ void time_macs_(unsigned long MAC_SIZE) t1 = t_read(); z = 16; if ((err = hmac_memory(hash_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) { - fprintf(stderr, "\n\nhmac error... %s\n", error_to_string(err)); + fprintf(stderr, "\n\nhmac-%s error... %s\n", hash_descriptor[hash_idx].name, error_to_string(err)); exit(EXIT_FAILURE); } t1 = t_read() - t1; if (t1 < t2) t2 = t1; } - fprintf(stderr, "LTC_HMAC-%s\t\t%9llu\n", hash_descriptor[hash_idx].name, t2/(ulong64)(MAC_SIZE*1024)); + fprintf(stderr, "HMAC-%s\t\t%9llu\n", hash_descriptor[hash_idx].name, t2/(ulong64)(MAC_SIZE*1024)); #endif XFREE(buf);