Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
def create_keypair(key_type, kwords):

    alg = crypt_all.find_alg(key_type)

    return alg.create_keypair(kwords)
Esempio n. 4
0
 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)
Esempio n. 5
0
def assert_public_key(key_type, public_key, argument):

    alg = crypt_all.find_alg(key_type)

    alg.assert_public_key(public_key, argument)
Esempio n. 6
0
def verify_signature(key_type, public_key, data, signature):

    alg = crypt_all.find_alg(key_type)

    return alg.verify_signature(public_key, data, signature)
Esempio n. 7
0
def decrypt(key_type, private_key, data, passphrase=None):

    alg = crypt_all.find_alg(key_type)

    return alg.decrypt(private_key, data, passphrase)
Esempio n. 8
0
def encrypt(key_type, public_key, data):

    alg = crypt_all.find_alg(key_type)

    return alg.encrypt(public_key, data)
Esempio n. 9
0
def assert_passphrase(key_type, private_key, passphrase):

    alg = crypt_all.find_alg(key_type)

    return alg.assert_passphrase(private_key, passphrase)