(num_bits=1024, pair_name=None)
Generate a primitive root for a big prime number is really slow!
        Notice the fact that:
        1. we don't need the generator to be a primitive element of the group
        but the one generates a large prime order.
        2. There is no security issue with Diffie-Hellman if you reuse previously generated 𝑝 and 𝑔.

        We simply use key pairs from RFC 5114 and RFC 2409
        @:param pair_name: one of "additional_group_1024_160", "additional_group_2048_224",
        "additional_group_2048_256", "oakley_group_768_768", "oakley_group_1024_1024"
        use additional_group_1024_160 as default
        @:param num_bits: specify size of p
        @:return p, g, where p is a prime number, g is a generator
Generate a primitive root for a big prime number is really slow!
        Notice the fact that:
        1. we don't need the generator to be a primitive element of the group
        but the one generates a large prime order.
        2. There is no security issue with Diffie-Hellman if you reuse previously generated 𝑝 and 𝑔.
Generate a primitive root for a big prime number is really slow! Notice the fact that : 1 . we don t need the generator to be a primitive element of the group but the one generates a large prime order . 2 . There is no security issue with Diffie - Hellman if you reuse previously generated 𝑝 and 𝑔 .
def key_pair(num_bits=1024, pair_name=None):
        """
        Generate a primitive root for a big prime number is really slow!
        Notice the fact that:
        1. we don't need the generator to be a primitive element of the group
        but the one generates a large prime order.
        2. There is no security issue with Diffie-Hellman if you reuse previously generated 𝑝 and 𝑔.

        We simply use key pairs from RFC 5114 and RFC 2409
        @:param pair_name: one of "additional_group_1024_160", "additional_group_2048_224",
        "additional_group_2048_256", "oakley_group_768_768", "oakley_group_1024_1024"
        use additional_group_1024_160 as default
        @:param num_bits: specify size of p
        @:return p, g, where p is a prime number, g is a generator
        """
        if pair_name is None:
            if num_bits:
                return DiffieHellman._key_pair(num_bits)
            else:
                return DiffieHellman._additional_group_1024_160()

        assert pair_name in {
            "additional_group_1024_160", "additional_group_2048_224", "additional_group_2048_256",
            "oakley_group_768_768", "oakley_group_1024_1024"
        }, "unsupported pair name: {0}".format(pair_name)

        if pair_name == "additional_group_1024_160":
            return DiffieHellman._additional_group_1024_160()
        if pair_name == "additional_group_2048_224":
            return DiffieHellman._additional_group_2048_224()
        if pair_name == "additional_group_2048_256":
            return DiffieHellman._additional_group_2048_256()
        if pair_name == "oakley_group_768_768":
            return DiffieHellman._oakley_group_768_768()
        if pair_name == "oakley_group_1024_1024":
            return DiffieHellman._oakley_group_1024_1024()
def key_pair ( num_bits = 1024 , pair_name = None ) : if pair_name is None : if num_bits : return DiffieHellman . _key_pair ( num_bits ) else : return DiffieHellman . _additional_group_1024_160 ( ) assert pair_name in { "additional_group_1024_160" , "additional_group_2048_224" , "additional_group_2048_256" , "oakley_group_768_768" , "oakley_group_1024_1024" } , "unsupported pair name: {0}" . format ( pair_name ) if pair_name == "additional_group_1024_160" : return DiffieHellman . _additional_group_1024_160 ( ) if pair_name == "additional_group_2048_224" : return DiffieHellman . _additional_group_2048_224 ( ) if pair_name == "additional_group_2048_256" : return DiffieHellman . _additional_group_2048_256 ( ) if pair_name == "oakley_group_768_768" : return DiffieHellman . _oakley_group_768_768 ( ) if pair_name == "oakley_group_1024_1024" : return DiffieHellman . _oakley_group_1024_1024 ( )