def calculate_reference(self, reference, sign=True):
        """
        Calculates or verifies the digest of the reference
        :param reference: Reference node
        :type reference: lxml.etree.Element
        :param sign: It marks if we must sign or check a signature
        :type sign: bool
        :return: None
        """
        node = self.get_uri(reference.get('URI', ''), reference)
        transforms = reference.find(
            'ds:Transforms', namespaces=constants.NS_MAP
        )
        if transforms is not None:
            for transform in transforms.findall(
                    'ds:Transform', namespaces=constants.NS_MAP
            ):
                node = self.transform(transform, node)
        digest_value = self.digest(
            reference.find(
                'ds:DigestMethod', namespaces=constants.NS_MAP
            ).get('Algorithm'),
            node
        )
        if not sign:
            return digest_value.decode() == reference.find(
                'ds:DigestValue', namespaces=constants.NS_MAP
            ).text

        reference.find(
            'ds:DigestValue', namespaces=constants.NS_MAP
        ).text = digest_value
def calculate_reference ( self , reference , sign = True ) : node = self . get_uri ( reference . get ( 'URI' , '' ) , reference ) transforms = reference . find ( 'ds:Transforms' , namespaces = constants . NS_MAP ) if transforms is not None : for transform in transforms . findall ( 'ds:Transform' , namespaces = constants . NS_MAP ) : node = self . transform ( transform , node ) digest_value = self . digest ( reference . find ( 'ds:DigestMethod' , namespaces = constants . NS_MAP ) . get ( 'Algorithm' ) , node ) if not sign : return digest_value . decode ( ) == reference . find ( 'ds:DigestValue' , namespaces = constants . NS_MAP ) . text reference . find ( 'ds:DigestValue' , namespaces = constants . NS_MAP ) . text = digest_value
Calculates or verifies the digest of the reference
        :param reference: Reference node
        :type reference: lxml.etree.Element
        :param sign: It marks if we must sign or check a signature
        :type sign: bool
        :return: None