diff testprof/modes_test.c @ 209:39d5d58461d6 libtomcrypt-orig LTC_1.05

Import of libtomcrypt 1.05
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Jul 2005 03:53:40 +0000
parents 1c15b283127b
children
line wrap: on
line diff
--- a/testprof/modes_test.c	Fri May 06 13:23:02 2005 +0000
+++ b/testprof/modes_test.c	Wed Jul 06 03:53:40 2005 +0000
@@ -19,7 +19,7 @@
    /* get idx of AES handy */
    cipher_idx = find_cipher("aes");
    if (cipher_idx == -1) {
-      printf("test requires AES");
+      fprintf(stderr, "test requires AES");
       return 1;
    }
    
@@ -30,7 +30,7 @@
    l = sizeof(iv2);
    DO(cbc_getiv(iv2, &l, &cbc));
    if (l != 16 || memcmp(iv2, iv, 16)) {
-      printf("cbc_getiv failed");
+      fprintf(stderr, "cbc_getiv failed");
       return 1;
    }
    DO(cbc_encrypt(pt, ct, 64, &cbc));
@@ -40,7 +40,7 @@
    zeromem(tmp, sizeof(tmp));
    DO(cbc_decrypt(ct, tmp, 64, &cbc));
    if (memcmp(tmp, pt, 64) != 0) {
-      printf("CBC failed");
+      fprintf(stderr, "CBC failed");
       return 1;
    }
 #endif
@@ -53,7 +53,7 @@
    DO(cfb_getiv(iv2, &l, &cfb));
    /* note we don't memcmp iv2/iv since cfb_start processes the IV for the first block */
    if (l != 16) {
-      printf("cfb_getiv failed");
+      fprintf(stderr, "cfb_getiv failed");
       return 1;
    }
    DO(cfb_encrypt(pt, ct, 64, &cfb));
@@ -63,7 +63,7 @@
    zeromem(tmp, sizeof(tmp));
    DO(cfb_decrypt(ct, tmp, 64, &cfb));
    if (memcmp(tmp, pt, 64) != 0) {
-      printf("CFB failed");
+      fprintf(stderr, "CFB failed");
       return 1;
    }
 #endif
@@ -75,7 +75,7 @@
    l = sizeof(iv2);
    DO(ofb_getiv(iv2, &l, &ofb));
    if (l != 16 || memcmp(iv2, iv, 16)) {
-      printf("ofb_getiv failed");
+      fprintf(stderr, "ofb_getiv failed");
       return 1;
    }
    DO(ofb_encrypt(pt, ct, 64, &ofb));
@@ -85,7 +85,7 @@
    zeromem(tmp, sizeof(tmp));
    DO(ofb_decrypt(ct, tmp, 64, &ofb));
    if (memcmp(tmp, pt, 64) != 0) {
-      printf("OFB failed");
+      fprintf(stderr, "OFB failed");
       return 1;
    }
 #endif
@@ -93,11 +93,11 @@
 #ifdef CTR   
    /* test CTR mode */
    /* encode the block */
-   DO(ctr_start(cipher_idx, iv, key, 16, 0, &ctr));
+   DO(ctr_start(cipher_idx, iv, key, 16, 0, CTR_COUNTER_LITTLE_ENDIAN, &ctr));
    l = sizeof(iv2);
    DO(ctr_getiv(iv2, &l, &ctr));
    if (l != 16 || memcmp(iv2, iv, 16)) {
-      printf("ctr_getiv failed");
+      fprintf(stderr, "ctr_getiv failed");
       return 1;
    }
    DO(ctr_encrypt(pt, ct, 57, &ctr));
@@ -107,10 +107,14 @@
    zeromem(tmp, sizeof(tmp));
    DO(ctr_decrypt(ct, tmp, 57, &ctr));
    if (memcmp(tmp, pt, 57) != 0) {
-      printf("CTR failed");
+      fprintf(stderr, "CTR failed");
       return 1;
    }
 #endif
          
    return 0;
 }
+
+/* $Source: /cvs/libtom/libtomcrypt/testprof/modes_test.c,v $ */
+/* $Revision: 1.6 $ */
+/* $Date: 2005/05/21 12:51:25 $ */