This directory contains implementations of crypto primitives for use in Chromium. Most of these are either:
There is very little actual cryptographic code in //crypto - it is mostly wrappers.
This directory has recently been refactored, and as a result some of the APIs are deprecated. They are marked as such in their header files, along with notes pointing you towards their replacements.
Many interfaces in this directory are deprecated and being changed or removed; check the comment at the top of the header file before using them.
If you are designing a new protocol in Chromium using cryptography, these are our recommended primitives and constructions to use. They balance performance with security, are “post-quantum”, and have reasonably well-understood margins of safety.
vector<uint8_t>, array<uint8_t>, and span<uint8_t> rather than string and string_view.keypair::PrivateKey::ToPrivateKeyInfo(), which returns a PKCS#8 PrivateKeyInfo structure serialized as a byte vector. To unserialize keys in this format, use keypair::PrivateKey::FromPrivateKeyInfo().keypair::PublicKey::ToSubjectPublicKeyInfo() or keypair::PrivateKey::ToSubjectPublicKeyInfo(), which return a X.509 SubjectPublicKeyInfo structure serialized as a byte vector. To unserialize public keys in this format, use keypair::PublicKey::FromSubjectPublicKeyInfo().vector<uint8_t>, array<uint8_t>, or span<uint8_t> directly.