'Verify a signature using this key.
@type signature: L{bytes}
@param signature: The signature to verify.
@type data: L{bytes}
@param data: The signed data.
@rtype: L{bool}
@return: C{True} if the signature is valid.'

def verify(self, signature, data):

    if (len(signature) == 40):
        (signatureType, signature) = ('ssh-dss', common.NS(signature))
    else:
        (signatureType, signature) = common.getNS(signature)
    if (signatureType != self.sshType()):
        return False
    keyType = self.type()
    if (keyType == 'RSA'):
        k = self._keyObject
        if (not self.isPublic()):
            k = k.public_key()
        args = (common.getNS(signature)[0], data, padding.PKCS1v15(), hashes.SHA1())
    elif (keyType == 'DSA'):
        concatenatedSignature = common.getNS(signature)[0]
        r = int_from_bytes(concatenatedSignature[:20], 'big')
        s = int_from_bytes(concatenatedSignature[20:], 'big')
        signature = encode_dss_signature(r, s)
        k = self._keyObject
        if (not self.isPublic()):
            k = k.public_key()
        args = (signature, data, hashes.SHA1())
    elif (keyType == 'EC'):
        concatenatedSignature = common.getNS(signature)[0]
        (rstr, sstr, rest) = common.getNS(concatenatedSignature, 2)
        r = int_from_bytes(rstr, 'big')
        s = int_from_bytes(sstr, 'big')
        signature = encode_dss_signature(r, s)
        k = self._keyObject
        if (not self.isPublic()):
            k = k.public_key()
        keySize = self.size()
        if (keySize <= 256):
            hashSize = hashes.SHA256()
        elif (keySize <= 384):
            hashSize = hashes.SHA384()
        else:
            hashSize = hashes.SHA512()
        args = (signature, data, ec.ECDSA(hashSize))
    try:
        k.verify(*args)
    except InvalidSignature:
        return False
    else:
        return True
