Backport DH_check from OpenSSL 1.1.0. (#3375)

* Backport DH_check from OpenSSL 1.1.0.

OpenSSL 1.0.2's DH_check considers the q parameter, allowing it
validate more generators and primes; however, OpenSSL 1.1.0's DH_check
includes code to handle errors in BN functions, so it's preferred.

* Wrap DH_Check when using OpenSSL 1.1.0 or higher.

* Adding DH_CHECK_* values missing from older OpenSSLs

* Defensively guard DH_CHECK_* definitions with ifndef.

This will prevent duplicate definitions when LibreSSL supports a
version of DH_check that can return these.

* Document the OpenSSL of origin for the DH_check code
2 files changed