def assert_signature(key_type, public_key, data, signature, argument): if signature == None: raise ex.SignatureNullException() alg = crypt_all.find_alg(key_type) if not alg.verify_signature(public_key, data, signature): raise ex.BadSignatureException(key_type, public_key, data, signature, argument)
def createPrivateKey(key_type, key_parameters, passphrase = None): alg = crypt_all.find_alg(key_type) (public_key, private_key) = alg.create_keypair(key_parameters) return PrivateKey(key_type, public_key, private_key, passphrase)
def create_keypair(key_type, kwords): alg = crypt_all.find_alg(key_type) return alg.create_keypair(kwords)
def __init__(self, key_type, public_key): self.key_type = key_type self.public_key_hash = hash_public_key(key_type, public_key) self.public_key = public_key self.alg = crypt_all.find_alg(key_type)
def assert_public_key(key_type, public_key, argument): alg = crypt_all.find_alg(key_type) alg.assert_public_key(public_key, argument)
def verify_signature(key_type, public_key, data, signature): alg = crypt_all.find_alg(key_type) return alg.verify_signature(public_key, data, signature)
def decrypt(key_type, private_key, data, passphrase=None): alg = crypt_all.find_alg(key_type) return alg.decrypt(private_key, data, passphrase)
def encrypt(key_type, public_key, data): alg = crypt_all.find_alg(key_type) return alg.encrypt(public_key, data)
def assert_passphrase(key_type, private_key, passphrase): alg = crypt_all.find_alg(key_type) return alg.assert_passphrase(private_key, passphrase)