Blame SOURCES/Add-test-case-for-PKINIT-DH-renegotiation.patch

167778
From c88c2328ed284996a61281ae84dddbdff044e1d5 Mon Sep 17 00:00:00 2001
167778
From: Greg Hudson <ghudson@mit.edu>
167778
Date: Wed, 11 Jan 2017 10:49:30 -0500
167778
Subject: [PATCH] Add test case for PKINIT DH renegotiation
167778
167778
In t_pkinit.py, add a PKINIT test case where the KDC sends
167778
KDC_ERR_DH_KEY_PARAMETERS_NOT_ACCEPTED and the client retries with the
167778
KDC's TD_DH_PARAMETERS value, using the clpreauth tryagain method.
167778
Use the trace log to verify that the renegotiation actually takes
167778
place.
167778
167778
(cherry picked from commit 7ad7eb7fd591e6c789ea24b94eccbf74ee4d79f8)
167778
---
167778
 src/tests/t_pkinit.py | 18 ++++++++++++++++++
167778
 1 file changed, 18 insertions(+)
167778
167778
diff --git a/src/tests/t_pkinit.py b/src/tests/t_pkinit.py
167778
index ac4d326b6..183977750 100755
167778
--- a/src/tests/t_pkinit.py
167778
+++ b/src/tests/t_pkinit.py
167778
@@ -174,6 +174,24 @@ realm.kinit(realm.user_princ,
167778
                    '-X', 'flag_RSA_PROTOCOL=yes'])
167778
 realm.klist(realm.user_princ)
167778
 
167778
+# Test a DH parameter renegotiation by temporarily setting a 4096-bit
167778
+# minimum on the KDC.
167778
+tracefile = os.path.join(realm.testdir, 'trace')
167778
+minbits_kdc_conf = {'realms': {'$realm': {'pkinit_dh_min_bits': '4096'}}}
167778
+minbits_env = realm.special_env('restrict', True, kdc_conf=minbits_kdc_conf)
167778
+realm.stop_kdc()
167778
+realm.start_kdc(env=minbits_env)
167778
+realm.run(['env', 'KRB5_TRACE=' + tracefile, kinit, '-X',
167778
+           'X509_user_identity=' + file_identity, realm.user_princ])
167778
+with open(tracefile, 'r') as f:
167778
+    trace = f.read()
167778
+if ('Key parameters not accepted' not in trace or
167778
+    'Preauth tryagain input types' not in trace or
167778
+    'trying again with KDC-provided parameters' not in trace):
167778
+    fail('DH renegotiation steps not found in kinit trace log')
167778
+realm.stop_kdc()
167778
+realm.start_kdc()
167778
+
167778
 # Run the basic test - PKINIT with FILE: identity, with a password on the key,
167778
 # supplied by the prompter.
167778
 # Expect failure if the responder does nothing, and we have no prompter.