A cryptographic library is reusable software that exposes cryptographic algorithms and protocols through programming interfaces. It turns a standardized construction into support that applications can use, but its interface can also create opportunities for dangerous misuse. section 1.7 section 16.4
Figure 1.16 The ideal life cycle for a cryptographic algorithm starts when cryptographers instantiate a concept in a white paper. For example, AES is an instantiation of the concept of symmetric encryption (there are many more symmetric encryption algorithms out there). A construction can then be standardized: everybody agrees to implement it a certain way to maximize interoperability. Then support is created by implementing the standard in different languages.
The ideal lifecycle connects a cryptographic concept to a construction, standardization, and implementations in different programming languages. section 1.7
Use a cryptographic library conservatively:
- Prefer a well-respected implementation that supports the primitive or protocol and its standard. section 16.3
- Seek community advice, inspect the library’s authors, and consider expert code review when language or protocol support is weak. section 16.3
- Avoid implementing cryptography yourself when a suitable library exists; use test vectors such as Wycheproof when implementation is unavoidable. section 16.3
- Read the fine print and favor misuse-resistant interfaces that constrain hazardous choices. section 16.4
A safer interface
Google’s Tink prevents callers from choosing the AES-GCM nonce or IV, reducing accidental nonce reuse. Libsodium similarly limits users to a fixed set of primitives to reduce complexity. section 16.4
