The biggest source of vulnerabilities in cryptographic libraries is memory safety bugs, not cryptography bugs
An empirical study of vulnerabilities in cryptographic libraries has drawn some very interesting conclusions:
While cryptographic issues are the largest individual category, comprising 25.8% of CWEs, memory-related errors are the most common overall type, producing 37.1% of CWEs when combining memory buffer issues and resource management errors. A further 27.9% of CWEs arise from various smaller sub-categories, including exposure of sensitive information, improper input validation, and numeric errors (i.e. errors in numerical calculation or conversion).
and
Of the most severe CVEs, just 3.57% were cryptographic, a substan-
tially lower percentage compared to 27.24% of all CVEs.
They've also found that having more lines of code is strongly correlated with having more CVEs.
This makes a surprisingly strong case for the approach taken by libraries such as rustls, which are written in Rust and are dramatically smaller in size than most of the alternatives.