this is the original code from openssl-1.0.1e