Exemple #1
0
    def Valid(self):
        """
        This will make a hash and verify the signature by public key.

        PREPRO - should test certificate too.
        """
        hashcode = self.makehash()
        result = key.VerifySignature(self.publickey, hashcode,
                                     str(self.signature))
        if not result:
            # TODO: old code still has old identity format - but it is valid
            hashcode = self.makehash_old()
            result = key.VerifySignature(self.publickey, hashcode,
                                         str(self.signature))
        return result
Exemple #2
0
def verify_signature(coin_json, role):
    """
    """
    signature = coin_json[role]['signature']
    coin_json[role]['signature'] = ''
    # role_data = coin_json[role].copy()
    # signature = role_data.pop('signature')
    # _coin = dict(coin_json).c
    coin_hash = get_coin_hash(coin_json)
    coin_json[role]['signature'] = signature
    return key.VerifySignature(coin_json[role]['pubkey'], coin_hash, signature)
    def Valid(self):
        """
        This will make a hash and verify the signature by public key.

        PREPRO - should test certificate too.
        """
        hashcode = self.makehash()
        result = key.VerifySignature(
            self.publickey,
            hashcode,
            str(self.signature))
        return result
Exemple #4
0
def verify_key_info_signature(key_info):
    if 'signature' not in key_info or 'signature_pubkey' not in key_info:
        return False
    sorted_fields = sorted(key_info.keys())
    hash_items = []
    for field in sorted_fields:
        if field not in ['include_private', 'signature', 'private', ]:
            hash_items.append(strng.to_text(key_info[field]))
    hash_text = '-'.join(hash_items)
    hash_bin = key.Hash(strng.to_bin(hash_text))
    signature_bin = strng.to_bin(key_info['signature'])
    result = key.VerifySignature(key_info['signature_pubkey'], hash_bin, signature_bin)
    return result
Exemple #5
0
def verify_key_info_signature(key_info):
    if 'signature' not in key_info or 'signature_pubkey' not in key_info:
        lg.warn('signature was not found in the key info')
        return False
    hash_items = []
    for field in [
            'alias',
            'public',
            'signature_pubkey',
    ]:
        hash_items.append(strng.to_text(key_info[field]))
    hash_text = '-'.join(hash_items)
    if _Debug:
        lg.dbg(_DebugLevel, hash_text)
    hash_bin = key.Hash(strng.to_bin(hash_text))
    signature_bin = strng.to_bin(key_info['signature'])
    result = key.VerifySignature(key_info['signature_pubkey'], hash_bin,
                                 signature_bin)
    return result