Ejemplo n.º 1
0
def gen_dh_params(bits):
    dh = _lib.DH_new()
    _lib.DH_generate_parameters_ex(dh, bits, 2L, _ffi.NULL)

    bio = _new_mem_buf()
    _lib.PEM_write_bio_DHparams(bio, dh)
    return _bio_to_string(bio)
Ejemplo n.º 2
0
def gen_dh_params(bits):
    dh = _lib.DH_new()  # pylint: disable=no-member
    _lib.DH_generate_parameters_ex(dh, bits, 2, _ffi.NULL)  # pylint: disable=no-member

    bio = _new_mem_buf()
    _lib.PEM_write_bio_DHparams(bio, dh)  # pylint: disable=no-member
    return _bio_to_string(bio)
Ejemplo n.º 3
0
    def _generate_dh_params(output_path: str, bits: int) -> None:
        # pylint: disable=no-member
        logger.info("Generating DH key exchange params: %r", output_path)

        dh = lib.DH_new()
        lib.DH_generate_parameters_ex(dh, bits, 2, ffi.NULL)
        with open(output_path, 'w') as output_file:
            lib.DHparams_print_fp(output_file, dh)
        lib.DH_free(dh)