From dcb4eb362862873928e3546cd10424ed833bc32d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 7 Jan 2011 22:24:29 +0100
Subject: [PATCH] (test_cipher_stream): More debug output on failure.

Rev: nettle/testsuite/testutils.c:1.11
---
 testsuite/testutils.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/testsuite/testutils.c b/testsuite/testutils.c
index 65a4ac15..a0b3924b 100644
--- a/testsuite/testutils.c
+++ b/testsuite/testutils.c
@@ -321,12 +321,22 @@ test_cipher_stream(const struct nettle_cipher *cipher,
 	  if (data[i + block] != 0x17)
 	    FAIL();
 	}
+
       cipher->encrypt(ctx, length - i, data + i, cleartext + i);
       if (data[length] != 0x17)
 	FAIL();
       
       if (!MEMEQ(length, data, ciphertext))
-	FAIL();
+	{
+	  fprintf(stderr, "Encrypt failed, block size %d\nInput:", block);
+	  print_hex(length, cleartext);
+	  fprintf(stderr, "\nOutput: ");
+	  print_hex(length, data);
+	  fprintf(stderr, "\nExpected:");
+	  print_hex(length, ciphertext);
+	  fprintf(stderr, "\n");
+	  FAIL();	    
+	}
     }
   
   cipher->set_decrypt_key(ctx, key_length, key);
@@ -336,7 +346,16 @@ test_cipher_stream(const struct nettle_cipher *cipher,
     FAIL();
 
   if (!MEMEQ(length, data, cleartext))
-    FAIL();
+    {
+      fprintf(stderr, "Decrypt failed\nInput:");
+      print_hex(length, ciphertext);
+      fprintf(stderr, "\nOutput: ");
+      print_hex(length, data);
+      fprintf(stderr, "\nExpected:");
+      print_hex(length, cleartext);
+      fprintf(stderr, "\n");
+      FAIL();	    
+    }
 
   free(ctx);
   free(data);
-- 
GitLab