Blame SOURCES/0001-Do-not-use-arcfour-hmac-md5-when-discovering-the-sal.patch

79648a
From 158468507bb723aa62196846749c23c121d4b298 Mon Sep 17 00:00:00 2001
79648a
From: Sumit Bose <sbose@redhat.com>
79648a
Date: Mon, 8 Apr 2019 10:55:39 +0200
79648a
Subject: [PATCH] Do not use arcfour-hmac-md5 when discovering the salt
79648a
79648a
Since the arcfour-hmac-md5 encryption types does not use salts it cannot
79648a
be used to discover the right salt.
79648a
79648a
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1683745
79648a
---
79648a
 library/adkrb5.c | 21 ++++++++++++++++++++-
79648a
 1 file changed, 20 insertions(+), 1 deletion(-)
79648a
79648a
diff --git a/library/adkrb5.c b/library/adkrb5.c
79648a
index da835d7..be3ede5 100644
79648a
--- a/library/adkrb5.c
79648a
+++ b/library/adkrb5.c
79648a
@@ -395,15 +395,33 @@ _adcli_krb5_keytab_discover_salt (krb5_context k5,
79648a
 	krb5_keytab scratch;
79648a
 	krb5_error_code code;
79648a
 	int i;
79648a
+	krb5_enctype *salt_enctypes = NULL;
79648a
+	size_t c;
79648a
+	size_t s;
79648a
 
79648a
 	/* TODO: This should be a unique name */
79648a
 
79648a
 	code = krb5_kt_resolve (k5, "MEMORY:adcli-discover-salt", &scratch);
79648a
 	return_val_if_fail (code == 0, code);
79648a
 
79648a
+	for (c = 0; enctypes[c] != 0; c++); /* count enctypes */
79648a
+	salt_enctypes = calloc (c + 1, sizeof (krb5_enctype));
79648a
+	return_val_if_fail (salt_enctypes != NULL, ENOMEM);
79648a
+
79648a
+	/* ENCTYPE_ARCFOUR_HMAC does not use salts, so it cannot be used to
79648a
+	 * discover the right salt. */
79648a
+	s = 0;
79648a
+	for (c = 0; enctypes[c] != 0; c++) {
79648a
+		if (enctypes[c] == ENCTYPE_ARCFOUR_HMAC) {
79648a
+			continue;
79648a
+		}
79648a
+
79648a
+		salt_enctypes[s++] = enctypes[c];
79648a
+	}
79648a
+
79648a
 	for (i = 0; salts[i].data != NULL; i++) {
79648a
 		code = _adcli_krb5_keytab_test_salt (k5, scratch, principal, kvno,
79648a
-		                                     password, enctypes, &salts[i]);
79648a
+		                                     password, salt_enctypes, &salts[i]);
79648a
 		if (code == 0) {
79648a
 			*discovered = i;
79648a
 			break;
79648a
@@ -412,6 +430,7 @@ _adcli_krb5_keytab_discover_salt (krb5_context k5,
79648a
 		}
79648a
 	}
79648a
 
79648a
+	free (salt_enctypes);
79648a
 	krb5_kt_close (k5, scratch);
79648a
 	return code;
79648a
 }
79648a
-- 
79648a
2.21.0
79648a