svn rev #23611: trunk/src/lib/crypto/crypto_tests/

epeisach@MIT.EDU epeisach at MIT.EDU
Thu Jan 7 22:43:37 EST 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23611
Commit By: epeisach
Log Message:
subject: Set enctype in crypto_tests to prevent memory leaks
ticket: 6627
tags: pullup

The key caching is causing memory leaks if enctype is not set as the
enctype specific cleanup handlers are not called.




Changed Files:
U   trunk/src/lib/crypto/crypto_tests/aes-test.c
U   trunk/src/lib/crypto/crypto_tests/t_cts.c
Modified: trunk/src/lib/crypto/crypto_tests/aes-test.c
===================================================================
--- trunk/src/lib/crypto/crypto_tests/aes-test.c	2010-01-08 02:43:21 UTC (rev 23610)
+++ trunk/src/lib/crypto/crypto_tests/aes-test.c	2010-01-08 03:43:37 UTC (rev 23611)
@@ -74,11 +74,12 @@
 }
 
 /* Variable-Key tests */
-static void vk_test_1(int len)
+static void vk_test_1(int len, krb5_enctype etype)
 {
     int i;
 
     enc_key.length = len;
+    enc_key.enctype = etype;
     printf("\nKEYSIZE=%d\n\n", len * 8);
     memset(plain, 0, sizeof(plain));
     hexdump("PT", plain, 16);
@@ -94,16 +95,17 @@
 }
 static void vk_test()
 {
-    vk_test_1(16);
-    vk_test_1(32);
+    vk_test_1(16, ENCTYPE_AES128_CTS_HMAC_SHA1_96);
+    vk_test_1(32, ENCTYPE_AES256_CTS_HMAC_SHA1_96);
 }
 
 /* Variable-Text tests */
-static void vt_test_1(int len)
+static void vt_test_1(int len, krb5_enctype etype)
 {
     int i;
 
     enc_key.length = len;
+    enc_key.enctype = etype;
     printf("\nKEYSIZE=%d\n\n", len * 8);
     memset(key, 0, len);
     hexdump("KEY", key, len);
@@ -119,8 +121,8 @@
 }
 static void vt_test()
 {
-    vt_test_1(16);
-    vt_test_1(32);
+    vt_test_1(16, ENCTYPE_AES128_CTS_HMAC_SHA1_96);
+    vt_test_1(32, ENCTYPE_AES256_CTS_HMAC_SHA1_96);
 }
 
 

Modified: trunk/src/lib/crypto/crypto_tests/t_cts.c
===================================================================
--- trunk/src/lib/crypto/crypto_tests/t_cts.c	2010-01-08 02:43:21 UTC (rev 23610)
+++ trunk/src/lib/crypto/crypto_tests/t_cts.c	2010-01-08 03:43:37 UTC (rev 23611)
@@ -43,6 +43,7 @@
 
 const char *whoami;
 
+#if 0
 static void printhex (size_t len, const char *p)
 {
     while (len--)
@@ -54,20 +55,15 @@
 static void printdata (krb5_data *d) { printhex (d->length, d->data); }
 
 static void printkey (krb5_keyblock *k) { printhex (k->length, k->contents); }
+#endif
 
 
 #define JURISIC "Juri\305\241i\304\207" /* hi Miro */
 #define ESZETT "\303\237"
 #define GCLEF  "\360\235\204\236" /* outside BMP, woo hoo!  */
 
+#if 0
 static void
-keyToData (krb5_keyblock *k, krb5_data *d)
-{
-    d->length = k->length;
-    d->data = k->contents;
-}
-
-static void
 check_error (int r, int line) {
     if (r != 0) {
         fprintf (stderr, "%s:%d: %s\n", __FILE__, line,
@@ -76,11 +72,8 @@
     }
 }
 #define CHECK check_error(r, __LINE__)
+#endif
 
-extern struct krb5_enc_provider krb5int_enc_des3;
-struct krb5_enc_provider *enc = &krb5int_enc_des3;
-extern struct krb5_enc_provider krb5int_enc_aes128, krb5int_enc_aes256;
-
 static void printd (const char *descr, krb5_data *d) {
     int i, j;
     const int r = 16;
@@ -133,6 +126,7 @@
     deciv.data = decivbuf;
     keyblock.contents = aeskey;
     keyblock.length = 16;
+    keyblock.enctype = ENCTYPE_AES128_CTS_HMAC_SHA1_96;
 
     err = krb5_k_create_key(NULL, &keyblock, &key);
     if (err) {




More information about the cvs-krb5 mailing list