crypto: allow custom generator for DiffieHellman

Fixes #7075.