def create_key_pair(self, bits=4096, type=crypto.TYPE_RSA):
"""
Create a key pair for use in PKI
Arguments: bits - the number of bits to use in the private key
type - the type of key (currently only crypto.TYPE_RSA supported)
"""
if bits % 1024 != 0 or bits < 2048 != 0:
raise ValueError("This implementation requires a key size evenly divisible by 1024 and larger than 2048.")
k = crypto.PKey()
k.generate_key(crypto.TYPE_RSA, bits)
return k
评论列表
文章目录