@@ -1536,20 +1536,25 @@ def _check_signature(self, decoded_xml, item, node_name=NODE_NAME, origdoc=None,
15361536 # - or the exclusive canonicalization transforms
15371537 # (with the identifier http://www.w3.org/2001/10/xml-exc-c14n#
15381538 # or http://www.w3.org/2001/10/xml-exc-c14n#WithComments).
1539- transform_alogs = [
1539+ transform_algos = [
15401540 transform .algorithm
15411541 for transform in references [0 ].transforms .transform
15421542 ]
1543- transform_alogs_n = len (transform_alogs )
1544- only_up_to_two_transforms_are_defined = (
1543+ tranform_algos_valid = ALLOWED_TRANSFORMS .intersection (transform_algos )
1544+ transform_algos_n = len (transform_algos )
1545+ tranform_algos_valid_n = len (tranform_algos_valid )
1546+
1547+ the_number_of_transforms_is_one_or_two = (
15451548 signatures_must_have_a_single_reference_element
1546- and 1 <= transform_alogs_n <= 2
1549+ and 1 <= transform_algos_n <= 2
15471550 )
15481551 all_transform_algs_are_allowed = (
1549- only_up_to_two_transforms_are_defined
1550- and transform_alogs_n == len (
1551- ALLOWED_TRANSFORMS .intersection (transform_alogs )
1552- )
1552+ the_number_of_transforms_is_one_or_two
1553+ and transform_algos_n == tranform_algos_valid_n
1554+ )
1555+ the_enveloped_signature_transform_is_defined = (
1556+ the_number_of_transforms_is_one_or_two
1557+ and TRANSFORM_ENVELOPED in transform_algos
15531558 )
15541559
15551560 # The <ds:Object> element is not defined for use with SAML signatures,
@@ -1572,10 +1577,13 @@ def _check_signature(self, decoded_xml, item, node_name=NODE_NAME, origdoc=None,
15721577 the_anchor_points_to_the_enclosing_element_ID_attribute
15731578 ),
15741579 "canonicalization method is c14n" : canonicalization_method_is_c14n ,
1575- "only up to two transforms are defined " : (
1576- only_up_to_two_transforms_are_defined
1580+ "the number of transforms is one or two " : (
1581+ the_number_of_transforms_is_one_or_two
15771582 ),
15781583 "all transform algs are allowed" : all_transform_algs_are_allowed ,
1584+ "the enveloped signature transform is defined" : (
1585+ the_enveloped_signature_transform_is_defined
1586+ ),
15791587 "object element is not present" : object_element_is_not_present ,
15801588 }
15811589 if not all (validators .values ()):
0 commit comments