Example #1
0
File: jwt.py Project: almet/PyVEP
 def __init__(self, data):
     self.p = p = long(data["p"], 16)
     self.q = q = long(data["q"], 16)
     self.g = g = long(data["g"], 16)
     self.y = y = long(data["y"], 16)
     if "x" not in data:
         self.x = None
         self.dsa = _DSA.load_pub_key_params(int2mpint(p), int2mpint(q),
                                             int2mpint(g), int2mpint(y))
     else:
         self.x = x = long(data["x"], 16)
         self.dsa = _DSA.load_key_params(int2mpint(p), int2mpint(q),
                                         int2mpint(g), int2mpint(y),
                                         int2mpint(x))
Example #2
0
 def __init__(self, data):
     self.p = p = long(data["p"], 16)
     self.q = q = long(data["q"], 16)
     self.g = g = long(data["g"], 16)
     self.y = y = long(data["y"], 16)
     if "x" not in data:
         self.x = None
         self.dsa = _DSA.load_pub_key_params(int2mpint(p), int2mpint(q),
                                             int2mpint(g), int2mpint(y))
     else:
         self.x = x = long(data["x"], 16)
         self.dsa = _DSA.load_key_params(int2mpint(p), int2mpint(q),
                                         int2mpint(g), int2mpint(y),
                                         int2mpint(x))
Example #3
0
def get_crypto_obj(algo, filename=None, key=None):
    if filename is None and key is None:
        raise ValueError('you need to specify either filename or key')

    if key is not None:
        bio = BIO.MemoryBuffer(str(key))
    else:
        bio = BIO.openfile(filename)

    # we can know what's the algorithm used thanks to the filename
    if algo.startswith('RS'):
        obj = _RSA.load_pub_key_bio(bio)
    elif algo.startswith('DS'):
        obj = _DSA.load_pub_key_bio(bio)
    else:
        raise ValueError('unknown algorithm')
    return obj