def getPublicKey(self):
"""
Gets a public key.
Return value:
str; the public key data.
Exceptions:
Exception: getting the key failed
"""
if not self.hasPublicKey:
raise Exception("Public key unknown")
size = libssl.i2o_ECPublicKey(self.keyData, None)
if not size:
raise Exception("i2o_ECPublicKey failed")
b = ctypes.create_string_buffer(size)
if libssl.i2o_ECPublicKey(self.keyData, ctypes.byref(ctypes.pointer(b))) != size:
raise Exception("i2o_ECPublicKey returned unexpected size")
return ''.join(c for c in b)
评论列表
文章目录