本文整理汇总了Python中M2Crypto.DSA.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python DSA.set_params方法的具体用法?Python DSA.set_params怎么用?Python DSA.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类M2Crypto.DSA
的用法示例。
在下文中一共展示了DSA.set_params方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_genparam_setparam_genkey
# 需要导入模块: from M2Crypto import DSA [as 别名]
# 或者: from M2Crypto.DSA import set_params [as 别名]
def test_genparam_setparam_genkey(self):
dsa = DSA.gen_params(1024, self.callback)
assert len(dsa) == 1024
p = dsa.p
q = dsa.q
g = dsa.g
dsa2 = DSA.set_params(p,q,g)
assert not dsa2.check_key()
dsa2.gen_key()
assert dsa2.check_key()
r,s = dsa2.sign(self.data)
assert dsa2.verify(self.data, r, s)
示例2: convert
# 需要导入模块: from M2Crypto import DSA [as 别名]
# 或者: from M2Crypto.DSA import set_params [as 别名]
def convert(fin, fout):
key = decode_key(fin)
ret = read_key(key)
key_type = ret[0]
if key_type == "ssh-rsa":
e, n = ret[1:]
rsa = rsa_new_pub_key((e, n))
rsa.save_pem(fout)
elif key_type == "ssh-dss":
p, q, g, y = ret[1:]
dsa = DSA.set_params(p, q, g)
dsa.gen_key()
dsa.save_pub_key(fout)
# FIXME: This is wrong.
# M2Crypto doesn't allow us to set the public key parameter
raise Exception("DSA keys are not supported yet: M2Crypto doesn't allow us to set the public key parameter")
示例3: from_string
# 需要导入模块: from M2Crypto import DSA [as 别名]
# 或者: from M2Crypto.DSA import set_params [as 别名]
def from_string(cls, key):
"""
Loads an RFC 4716 formatted public key.
"""
pubkey = cls()
if key.startswith('ssh-'):
pubkey.hashed = key.split()[1]
else:
pubkey.hashed = key
pubkey.key_type, remainder = unpack_string(pubkey.blob)
if pubkey.key_type == 'ssh-rsa':
e, n = get_packed_mp_ints(remainder, 2)
pubkey.instance = RSA.new_pub_key((e, n))
elif pubkey.key_type == 'ssh-dss':
p, q, g, y = get_packed_mp_ints(remainder, 4)
pubkey.instance = DSA.set_params(p, q, g)
return pubkey