EC parameters support and fixup on DH parameters race condition.

Two commits for the following issues:
  * Fixup a race condition that could occur on error case with init_dh_from_file (mutex not released).
  * Add function to initialize EC parameters from curve name.