Make DH_check_pub_key() and DH_generate_key() safer yet