cryptographically_secure_generators.py 文件源码

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

项目:py-prng 作者: czechnology 项目源码 文件源码
def _verify_params(self):
        phi = (self.p - 1) * (self.q - 1)

        if self.p == self.q:
            raise ValueError("p and q cannot be identical")
        # verify that p and q are far enough apart - https://crypto.stackexchange.com/a/35096
        if self.n >= 1024 and abs(self.p - self.q).bit_length() <= (self.n.bit_length() // 2 - 100):
            raise ValueError("p and q are too close together")
        if not is_prime(self.p):
            raise ValueError("p must be a prime (probabilistic)")
        if not is_prime(self.q):
            raise ValueError("q must be a prime (probabilistic)")
        if not (1 < self.e < phi):
            raise ValueError("e must be between 1 and (p-1)(q-1)")
        if gcd(self.e, phi) != 1:
            raise ValueError("e must be co-prime to (p-1)(q-1)")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号