I'm making a C++ back end for an application that'll heavily rely on AES-256 and DH. Should I trust third party libraries, or spend (lots of) time to learn about cryptographic implementation and write my own? Is there any reliable authority that can audit the security of a library (like Crypto++ in this case)? I hope this question doesn't come off as opinion based, but it's quite hard to find reputable data on this. I have no idea where to even start.

TL;DR: What's worse: risking vulnerabilities in a third party library, or risking novice mistakes in a custom implementation?


2 Answers 2


Rather risk vulnerabilities of third party library than implement your own. If you feel novice on this field, only implement cryptography yourself as an learning exercise.


Mistakes, lack of know-how and maintenance.

  1. It is very easy to make novice mistakes in custom implementation of cryptography. Even battle scarred veterans of the field do mistakes now and then. The amount of software quality assurance (including testing, reviews, ...) needed to ensure quality of cryptographic library is very significant.
  2. When vulnerabilities are found third party cryptographic libraries are (often) updated. The user of the software may be able to update the library to newer version and (assuming API compatibility) fix the issue. If cryptographic functionality is built inside the program, all vulnerabilities always require fixes to the program itself.
  3. Cryptographic libraries have to protect them against attacks almost no other software needs to (like timing attacks, and pretty recently, sound). New attacks are found now and then.
  4. Even when no new attacks are not found, the cryptographic practices develop (towards safer). For instance, NIST considers 1024 bit RSA modulus fairly safe to use now, but in 1.1.2014, the minimum NIST accepts will be 2048 bit. Similarly, other parties "upgrade" minimum key length requirements from time to time.
  • 1
    $\begingroup$ Good answer. Just to add, since the OP is using it in a real-world scenario, there's no need to reinvent the wheel and increase the complexity and maintenance cost of your own code. Always use a library if you can - especially for cryptography. $\endgroup$
    – rath
    Dec 29, 2013 at 11:08

The risks are much higher that there will be mistakes in a novice (or even advanced) implementation. Look at the history of OpenSSL. It was long thought secure, until someone discovered a timing side channel attack. How would you know your code is secure against all the vulnerabilities you don't know about?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.