示例#1
0
文件: util.py 项目: eek6/squeakspace
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)
示例#2
0
文件: util.py 项目: eek6/squeakspace
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)
示例#3
0
文件: util.py 项目: eek6/squeakspace
def create_keypair(key_type, kwords):

    alg = crypt_all.find_alg(key_type)

    return alg.create_keypair(kwords)
示例#4
0
文件: util.py 项目: eek6/squeakspace
 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)
示例#5
0
文件: util.py 项目: eek6/squeakspace
def assert_public_key(key_type, public_key, argument):

    alg = crypt_all.find_alg(key_type)

    alg.assert_public_key(public_key, argument)
示例#6
0
文件: util.py 项目: eek6/squeakspace
def verify_signature(key_type, public_key, data, signature):

    alg = crypt_all.find_alg(key_type)

    return alg.verify_signature(public_key, data, signature)
示例#7
0
文件: util.py 项目: eek6/squeakspace
def decrypt(key_type, private_key, data, passphrase=None):

    alg = crypt_all.find_alg(key_type)

    return alg.decrypt(private_key, data, passphrase)
示例#8
0
文件: util.py 项目: eek6/squeakspace
def encrypt(key_type, public_key, data):

    alg = crypt_all.find_alg(key_type)

    return alg.encrypt(public_key, data)
示例#9
0
文件: util.py 项目: eek6/squeakspace
def assert_passphrase(key_type, private_key, passphrase):

    alg = crypt_all.find_alg(key_type)

    return alg.assert_passphrase(private_key, passphrase)