summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto
diff options
context:
space:
mode:
authorEzra Peisach <epeisach@mit.edu>2010-01-08 03:43:37 +0000
committerEzra Peisach <epeisach@mit.edu>2010-01-08 03:43:37 +0000
commit5be0ba2a546fd4f112107cc15790782d2198d4e1 (patch)
tree973cd95b9f2d314108fe09394311b57fe49e1761 /src/lib/crypto
parentf6b381170552b311793a593e10e2108a10b0397b (diff)
downloadkrb5-5be0ba2a546fd4f112107cc15790782d2198d4e1.tar.gz
krb5-5be0ba2a546fd4f112107cc15790782d2198d4e1.tar.xz
krb5-5be0ba2a546fd4f112107cc15790782d2198d4e1.zip
Set enctype in crypto_tests to prevent memory leaks
The key caching is causing memory leaks if enctype is not set as the enctype specific cleanup handlers are not called. ticket: 6627 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23611 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto')
-rw-r--r--src/lib/crypto/crypto_tests/aes-test.c14
-rw-r--r--src/lib/crypto/crypto_tests/t_cts.c16
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) {