Blame SOURCES/Use-SHA-256-instead-of-MD5-for-audit-ticket-IDs.patch

167778
From ec9660539473b0fe00974b6ef30078e0f3c0041f Mon Sep 17 00:00:00 2001
167778
From: Greg Hudson <ghudson@mit.edu>
167778
Date: Tue, 10 Jul 2018 16:17:15 -0400
167778
Subject: [PATCH] Use SHA-256 instead of MD5 for audit ticket IDs
167778
167778
ticket: 8711 (new)
167778
(cherry picked from commit c1e1bfa26bd2f045e88e6013c500fca9428c98f3)
167778
---
167778
 src/kdc/kdc_audit.c | 21 ++++++++++-----------
167778
 1 file changed, 10 insertions(+), 11 deletions(-)
167778
167778
diff --git a/src/kdc/kdc_audit.c b/src/kdc/kdc_audit.c
167778
index c9a7f9f9d..f40913dc8 100644
167778
--- a/src/kdc/kdc_audit.c
167778
+++ b/src/kdc/kdc_audit.c
167778
@@ -146,7 +146,7 @@ kau_make_tkt_id(krb5_context context,
167778
 {
167778
     krb5_error_code ret = 0;
167778
     char *hash = NULL, *ptr;
167778
-    krb5_checksum cksum;
167778
+    uint8_t hashbytes[K5_SHA256_HASHLEN];
167778
     unsigned int i;
167778
 
167778
     *out = NULL;
167778
@@ -154,19 +154,18 @@ kau_make_tkt_id(krb5_context context,
167778
     if (ticket == NULL)
167778
         return EINVAL;
167778
 
167778
-    ret = krb5_c_make_checksum(context, CKSUMTYPE_RSA_MD5, NULL, 0,
167778
-                               &ticket->enc_part.ciphertext, &cksum);
167778
+    ret = k5_sha256(&ticket->enc_part.ciphertext, 1, hashbytes);
167778
     if (ret)
167778
         return ret;
167778
 
167778
-    hash = k5alloc(cksum.length * 2 + 1, &ret;;
167778
-    if (hash != NULL) {
167778
-        for (i = 0, ptr = hash; i < cksum.length; i++, ptr += 2)
167778
-            snprintf(ptr, 3, "%02X", cksum.contents[i]);
167778
-        *ptr = '\0';
167778
-        *out = hash;
167778
-    }
167778
-    krb5_free_checksum_contents(context, &cksum);
167778
+    hash = k5alloc(sizeof(hashbytes) * 2 + 1, &ret;;
167778
+    if (hash == NULL)
167778
+        return ret;
167778
+
167778
+    for (i = 0, ptr = hash; i < sizeof(hashbytes); i++, ptr += 2)
167778
+        snprintf(ptr, 3, "%02X", hashbytes[i]);
167778
+    *ptr = '\0';
167778
+    *out = hash;
167778
 
167778
     return 0;
167778
 }