crypto.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Trusted-Platform-Module-nova 作者: BU-NU-CLOUD-SP16 项目源码 文件源码
def generate_key(bits):
    """Generate a paramiko RSAKey"""
    # NOTE(dims): pycryptodome has changed the signature of the RSA.generate
    # call. specifically progress_func has been dropped. paramiko still uses
    # pycrypto. However some projects like latest pysaml2 have switched from
    # pycrypto to pycryptodome as pycrypto seems to have been abandoned.
    # paramiko project has started transition to pycryptodome as well but
    # there is no release yet with that support. So at the moment depending on
    # which version of pysaml2 is installed, Nova is likely to break. So we
    # call "RSA.generate(bits)" which works on both pycrypto and pycryptodome
    # and then wrap it into a paramiko.RSAKey
    rsa = RSA.generate(bits)
    key = paramiko.RSAKey(vals=(rsa.e, rsa.n))
    key.d = rsa.d
    key.p = rsa.p
    key.q = rsa.q
    return key
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号