I have heard that the implementation of OpenSSL's cryptographic algorithms is very messy and consequentially they should be treated as not secure since people can hardly read it.
I heard that too, and you heard it from me:
i believe you are referring to usage of OpenSSL library in early versions of bitcoin core by Satoshi. i wouldn't call replacing that with a self written code "reinventing the wheel". in fact using OpenSSL is the source of some of the mess we have in bitcoin's code for example involving signatures and their encoding, the implementation both prevents bugs coming from that library and improves speed.
right.
From what I have read, using the OpenSSL library is a risky proposition for software that actually requires a high standard of cryptographic security, as the code is incredibly difficult to review. I am a little surprised that less was made of the multiple serious vulnerabilities found in OpenSSL throughout the mid 2010's (I've replaced it with LibreSSL where I can easily do so)
I'm fairly well convinced these days that where cryptography is well specified/defined, and the new code has good reviewers, that re-implementing some algorithms to replace known-bad implementations is better than using those known-bad implementations.
but I also made it more explicit in next reply that I haven't read the OpenSSL code to confirm this:
review of the OpenSSL codebase hasn't always been easy (apparently, I have not tried to read the code myself).
gmaxwell's reply was definitely useful, he has way, way more experience/aptitude with making judgements about these things.
To clarify further, I'm using LibreSSL in place of OpenSSL where that option is easy for me (on Gentoo linux). But I have other computers running either Debian and Fedora, where OpenSSL is installed.