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