This reverts commit d65791e26c. Conflict with the patch which was originally written and lacks the BN_clear_free() and the NULL check.
d65791e26c