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

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