68bf20
From d8166808a98fd1c3772de5d75e27656ed2ab124d Mon Sep 17 00:00:00 2001
68bf20
From: Simo Sorce <simo@redhat.com>
68bf20
Date: Tue, 27 Feb 2018 11:59:25 -0500
68bf20
Subject: [PATCH] Always use the encype we selected
68bf20
68bf20
The enctype is selected from the keytab or from the fallback code.
68bf20
Either way make sure to use the enctype stored in the key block.
68bf20
68bf20
Signed-off-by: Simo Sorce <simo@redhat.com>
68bf20
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
68bf20
Merges: #226
68bf20
(cherry picked from commit d73c96d658059ce64ecd41ff2924071d86f2b54f)
68bf20
---
68bf20
 proxy/src/gp_export.c | 7 +++----
68bf20
 1 file changed, 3 insertions(+), 4 deletions(-)
68bf20
68bf20
diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c
68bf20
index c9f5fd4..5e8e160 100644
68bf20
--- a/proxy/src/gp_export.c
68bf20
+++ b/proxy/src/gp_export.c
68bf20
@@ -168,11 +168,10 @@ uint32_t gp_init_creds_handle(uint32_t *min, const char *svc_name,
68bf20
                                  GP_CREDS_HANDLE_KEY_ENCTYPE, 0,
68bf20
                                  &handle->key);
68bf20
         if (ret == 0) {
68bf20
-            ret = krb5_c_make_random_key(handle->context,
68bf20
-                                         GP_CREDS_HANDLE_KEY_ENCTYPE,
68bf20
+            ret = krb5_c_make_random_key(handle->context, handle->key->enctype,
68bf20
                                          handle->key);
68bf20
             GPDEBUG("Service: %s, Enckey: [ephemeral], Enctype: %d\n",
68bf20
-                    svc_name, GP_CREDS_HANDLE_KEY_ENCTYPE);
68bf20
+                    svc_name, handle->key->enctype);
68bf20
         }
68bf20
         if (ret) {
68bf20
             ret_min = ret;
68bf20
@@ -254,7 +253,7 @@ static int gp_decrypt_buffer(krb5_context context, krb5_keyblock *key,
68bf20
 
68bf20
     memset(&enc_handle, '\0', sizeof(krb5_enc_data));
68bf20
 
68bf20
-    enc_handle.enctype = GP_CREDS_HANDLE_KEY_ENCTYPE;
68bf20
+    enc_handle.enctype = key->enctype;
68bf20
     enc_handle.ciphertext.data = in->octet_string_val;
68bf20
     enc_handle.ciphertext.length = in->octet_string_len;
68bf20