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

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