Browse Source

improve some error and informational output

Steffen Jaeckel 11 years ago
parent
commit
8c488289f0
3 changed files with 24 additions and 19 deletions
  1. 11 7
      src/misc/crypt/crypt.c
  2. 3 2
      testprof/rsa_test.c
  3. 10 10
      testprof/x86_prof.c

+ 11 - 7
src/misc/crypt/crypt.c

@@ -269,7 +269,7 @@ const char *crypt_build_settings =
 #if defined(LTC_MRSA)
 #if defined(LTC_MRSA)
     "   RSA"
     "   RSA"
 #if defined(LTC_RSA_BLINDING)
 #if defined(LTC_RSA_BLINDING)
-    "   (with blinding)"
+    " (with blinding)"
 #endif
 #endif
     "\n"
     "\n"
 #endif
 #endif
@@ -277,7 +277,11 @@ const char *crypt_build_settings =
     "   DH\n"
     "   DH\n"
 #endif
 #endif
 #if defined(LTC_MECC)
 #if defined(LTC_MECC)
-    "   ECC\n"
+    "   ECC"
+#if defined(LTC_ECC_TIMING_RESISTANT)
+    " (with blinding)"
+#endif
+    "\n"
 #endif
 #endif
 #if defined(LTC_MDSA)
 #if defined(LTC_MDSA)
     "   DSA\n"
     "   DSA\n"
@@ -301,12 +305,12 @@ const char *crypt_build_settings =
 #endif
 #endif
 #if defined(__clang_version__)
 #if defined(__clang_version__)
     "   Clang compiler " __clang_version__ ".\n"
     "   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
 #endif
+
 #if defined(__x86_64__)
 #if defined(__x86_64__)
     "   x86-64 detected.\n"
     "   x86-64 detected.\n"
 #endif
 #endif

+ 3 - 2
testprof/rsa_test.c

@@ -181,7 +181,8 @@ for (cnt = 0; cnt < len; ) {
       len2 = rsa_msgsize;
       len2 = rsa_msgsize;
       DO(rsa_decrypt_key(out, len, tmp, &len2, NULL, 0, hash_idx, &stat, &key));
       DO(rsa_decrypt_key(out, len, tmp, &len2, NULL, 0, hash_idx, &stat, &key));
       if (!(stat == 1 && stat2 == 0)) {
       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;
          return 1;
       }
       }
       if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) {
       if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) {
@@ -226,7 +227,7 @@ for (cnt = 0; cnt < len; ) {
       len2 = rsa_msgsize;
       len2 = rsa_msgsize;
       DO(rsa_decrypt_key(out, len, tmp, &len2, lparam, sizeof(lparam), hash_idx, &stat, &key));
       DO(rsa_decrypt_key(out, len, tmp, &len2, lparam, sizeof(lparam), hash_idx, &stat, &key));
       if (!(stat == 1 && stat2 == 0)) {
       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;
          return 1;
       }
       }
       if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) {
       if (len2 != rsa_msgsize || memcmp(tmp, in, rsa_msgsize)) {

+ 10 - 10
testprof/x86_prof.c

@@ -1306,7 +1306,7 @@ void time_macs_(unsigned long MAC_SIZE)
    hash_idx   = find_hash("sha1");
    hash_idx   = find_hash("sha1");
 
 
    if (cipher_idx == -1 || hash_idx == -1) {
    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;
       return;
    }
    }
 
 
@@ -1320,13 +1320,13 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read();
         t1 = t_read();
         z = 16;
         z = 16;
         if ((err = omac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
         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);
            exit(EXIT_FAILURE);
         }
         }
         t1 = t_read() - t1;
         t1 = t_read() - t1;
         if (t1 < t2) t2 = 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
 #endif
 
 
 #ifdef LTC_XCBC
 #ifdef LTC_XCBC
@@ -1336,7 +1336,7 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read();
         t1 = t_read();
         z = 16;
         z = 16;
         if ((err = xcbc_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
         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);
            exit(EXIT_FAILURE);
         }
         }
         t1 = t_read() - t1;
         t1 = t_read() - t1;
@@ -1352,7 +1352,7 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read();
         t1 = t_read();
         z = 16;
         z = 16;
         if ((err = f9_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
         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);
            exit(EXIT_FAILURE);
         }
         }
         t1 = t_read() - t1;
         t1 = t_read() - t1;
@@ -1368,13 +1368,13 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read();
         t1 = t_read();
         z = 16;
         z = 16;
         if ((err = pmac_memory(cipher_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
         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);
            exit(EXIT_FAILURE);
         }
         }
         t1 = t_read() - t1;
         t1 = t_read() - t1;
         if (t1 < t2) t2 = 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
 #endif
 
 
 #ifdef LTC_PELICAN
 #ifdef LTC_PELICAN
@@ -1390,7 +1390,7 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read() - t1;
         t1 = t_read() - t1;
         if (t1 < t2) t2 = 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
 #endif
 
 
 #ifdef LTC_HMAC
 #ifdef LTC_HMAC
@@ -1400,13 +1400,13 @@ void time_macs_(unsigned long MAC_SIZE)
         t1 = t_read();
         t1 = t_read();
         z = 16;
         z = 16;
         if ((err = hmac_memory(hash_idx, key, 16, buf, MAC_SIZE*1024, tag, &z)) != CRYPT_OK) {
         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);
            exit(EXIT_FAILURE);
         }
         }
         t1 = t_read() - t1;
         t1 = t_read() - t1;
         if (t1 < t2) t2 = 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
 #endif
 
 
    XFREE(buf);
    XFREE(buf);