summaryrefslogtreecommitdiffhomepage
path: root/testprof/modes_test.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-01-11 02:39:21 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-01-11 02:39:21 +0000
commit28ad393b008b34bc3cdbaa192440b8cc615329f0 (patch)
tree00fcfa9acba720e69b2665fd48d8744822f1f0fb /testprof/modes_test.c
parent33defd1f9b6c4889fe5b075e6abb0b24c00f3a59 (diff)
parentf3b834d5366011e1e4b340c7acdbd582c7e50689 (diff)
propagate from branch 'au.asn.ucc.matt.ltc.orig' (head 52840647ac7f5c707c3bd158d119a15734a7ef28)
to branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3) --HG-- branch : libtomcrypt-dropbear extra : convert_revision : 2af22fb4e878750b88f80f90d439b316d229796f
Diffstat (limited to 'testprof/modes_test.c')
-rw-r--r--testprof/modes_test.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/testprof/modes_test.c b/testprof/modes_test.c
index d394267..8999c0d 100644
--- a/testprof/modes_test.c
+++ b/testprof/modes_test.c
@@ -5,10 +5,15 @@ int modes_test(void)
{
unsigned char pt[64], ct[64], tmp[64], key[16], iv[16], iv2[16];
int cipher_idx;
+#ifdef LTC_CBC_MODE
symmetric_CBC cbc;
+#endif
+#ifdef LTC_CFB_MODE
symmetric_CFB cfb;
+#endif
+#ifdef LTC_OFB_MODE
symmetric_OFB ofb;
- symmetric_CTR ctr;
+#endif
unsigned long l;
/* make a random pt, key and iv */
@@ -23,7 +28,15 @@ int modes_test(void)
return 1;
}
-#ifdef CBC
+#ifdef LTC_F8_MODE
+ DO(f8_test_mode());
+#endif
+
+#ifdef LTC_LRW_MODE
+ DO(lrw_test());
+#endif
+
+#ifdef LTC_CBC_MODE
/* test CBC mode */
/* encode the block */
DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc));
@@ -45,7 +58,7 @@ int modes_test(void)
}
#endif
-#ifdef CFB
+#ifdef LTC_CFB_MODE
/* test CFB mode */
/* encode the block */
DO(cfb_start(cipher_idx, iv, key, 16, 0, &cfb));
@@ -68,7 +81,7 @@ int modes_test(void)
}
#endif
-#ifdef OFB
+#ifdef LTC_OFB_MODE
/* test OFB mode */
/* encode the block */
DO(ofb_start(cipher_idx, iv, key, 16, 0, &ofb));
@@ -90,31 +103,13 @@ int modes_test(void)
}
#endif
-#ifdef CTR
- /* test CTR mode */
- /* encode the block */
- 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)) {
- fprintf(stderr, "ctr_getiv failed");
- return 1;
- }
- DO(ctr_encrypt(pt, ct, 57, &ctr));
-
- /* decode the block */
- DO(ctr_setiv(iv2, l, &ctr));
- zeromem(tmp, sizeof(tmp));
- DO(ctr_decrypt(ct, tmp, 57, &ctr));
- if (memcmp(tmp, pt, 57) != 0) {
- fprintf(stderr, "CTR failed");
- return 1;
- }
+#ifdef LTC_CTR_MODE
+ DO(ctr_test());
#endif
return 0;
}
/* $Source: /cvs/libtom/libtomcrypt/testprof/modes_test.c,v $ */
-/* $Revision: 1.6 $ */
-/* $Date: 2005/05/21 12:51:25 $ */
+/* $Revision: 1.14 $ */
+/* $Date: 2006/11/13 11:55:25 $ */