fixes for new crypto_early_init() separation

part of crypto_global_init was separated into crypto_early_init.
this commit ensures proper locking and initialization of that
function.

the changes were made in Tor commit:
d3fb846d8c98c13d349762682e714e8312f20270