|
20 | 20 | from saml2test.interaction import Interaction
|
21 | 21 | from saml2test.interaction import InteractionNeeded
|
22 | 22 |
|
| 23 | +import xmldsig as ds |
| 24 | + |
23 | 25 | from sp_test.tests import ErrorResponse
|
24 | 26 | from sp_test.check import VerifyEchopageContents
|
25 | 27 |
|
@@ -276,27 +278,39 @@ def send_idp_response(self, req, resp):
|
276 | 278 | _op = camel2underscore.sub(r'_\1', req._class.c_tag).lower()
|
277 | 279 | func = getattr(self.instance, "create_%s_response" % _op)
|
278 | 280 |
|
| 281 | + # get from config which parts shall be signed |
279 | 282 | sign = []
|
280 | 283 | for styp in ["sign_assertion", "sign_response"]:
|
281 | 284 | if styp in args:
|
| 285 | + if args[styp].lower() == "always": |
| 286 | + sign.append(styp) |
282 | 287 | del args[styp]
|
283 |
| - sign.append(styp) |
284 | 288 |
|
285 | 289 | response = func(**args)
|
286 | 290 | response = resp(self).pre_processing(response)
|
287 | 291 | # and now for signing
|
288 | 292 | if sign:
|
289 | 293 | to_sign = []
|
| 294 | + try: |
| 295 | + _digest_alg=args["sign_digest_alg"] |
| 296 | + except KeyError: |
| 297 | + _digest_alg=None |
| 298 | + try: |
| 299 | + _sign_alg=args["sign_signature_alg"] |
| 300 | + except KeyError: |
| 301 | + _sign_alg=None |
290 | 302 | # Order is important, first assertion and then response if both
|
291 | 303 | if "sign_assertion" in sign:
|
292 | 304 | to_sign = [(class_name(response.assertion),
|
293 | 305 | response.assertion.id)]
|
294 | 306 | response.assertion.signature = pre_signature_part(
|
295 |
| - response.assertion.id, self.instance.sec.my_cert, 1) |
| 307 | + response.assertion.id, self.instance.sec.my_cert, 1, |
| 308 | + digest_alg=_digest_alg, sign_alg=_sign_alg) |
296 | 309 | if "sign_response" in sign:
|
297 | 310 | to_sign = [(class_name(response), response.id)]
|
298 | 311 | response.signature = pre_signature_part(
|
299 |
| - response.id, self.instance.sec.my_cert, 1) |
| 312 | + response.id, self.instance.sec.my_cert, 1, |
| 313 | + digest_alg=_digest_alg, sign_alg=_sign_alg) |
300 | 314 |
|
301 | 315 | response = signed_instance_factory(response, self.instance.sec,
|
302 | 316 | to_sign)
|
|
0 commit comments