From 3c3dc7a6e10f7b1f0794ea7482343a5beda127a3 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Fri, 8 Jan 2010 23:43:15 +0000 Subject: [PATCH] pull up r23611 from trunk ------------------------------------------------------------------------ r23611 | epeisach | 2010-01-07 22:43:37 -0500 (Thu, 07 Jan 2010) | 7 lines 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. ticket: 6627 version_fixed: 1.8 status: resolved git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-8@23620 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/crypto_tests/aes-test.c | 14 ++++++++------ src/lib/crypto/crypto_tests/t_cts.c | 16 +++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/lib/crypto/crypto_tests/aes-test.c b/src/lib/crypto/crypto_tests/aes-test.c index 714d08e2e..4c0618a47 100644 --- a/src/lib/crypto/crypto_tests/aes-test.c +++ b/src/lib/crypto/crypto_tests/aes-test.c @@ -74,11 +74,12 @@ static void set_bit(char *ptr, int bitnum) } /* 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_1(int len) } 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_1(int len) } 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); } diff --git a/src/lib/crypto/crypto_tests/t_cts.c b/src/lib/crypto/crypto_tests/t_cts.c index 9f7b5e7e0..da697bde1 100644 --- a/src/lib/crypto/crypto_tests/t_cts.c +++ b/src/lib/crypto/crypto_tests/t_cts.c @@ -43,6 +43,7 @@ const char *whoami; +#if 0 static void printhex (size_t len, const char *p) { while (len--) @@ -54,19 +55,14 @@ static void printstringhex (const char *p) { printhex (strlen (p), p); } 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! */ -static void -keyToData (krb5_keyblock *k, krb5_data *d) -{ - d->length = k->length; - d->data = k->contents; -} - +#if 0 static void check_error (int r, int line) { if (r != 0) { @@ -76,10 +72,7 @@ check_error (int r, int line) { } } #define CHECK check_error(r, __LINE__) - -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; +#endif static void printd (const char *descr, krb5_data *d) { int i, j; @@ -133,6 +126,7 @@ static void test_cts() 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) { -- 2.26.2