tree: de692e082ef02471384286a773b462853dda50a2
  1. apple/
  2. obsolete/
  3. test/
  4. aead.cc
  5. aead.h
  6. aead_unittest.cc
  7. aes_cbc.cc
  8. aes_cbc.h
  9. aes_cbc_unittest.cc
  10. aes_ctr.cc
  11. aes_ctr.h
  12. aes_ctr_unittest.cc
  13. BUILD.gn
  14. chaps_support.cc
  15. chaps_support.h
  16. cose.cc
  17. cose.h
  18. cose_unittest.cc
  19. crypto_export.h
  20. DEPS
  21. DIR_METADATA
  22. ecdsa_utils.cc
  23. ecdsa_utils.h
  24. ecdsa_utils_unittest.cc
  25. encrypt.cc
  26. encrypt.h
  27. encrypt_unittest.cc
  28. evp.cc
  29. evp.h
  30. evp_unittest.cc
  31. features.cc
  32. features.gni
  33. features.h
  34. hash.cc
  35. hash.h
  36. hash_unittest.cc
  37. hmac.cc
  38. hmac.h
  39. hmac_unittest.cc
  40. hpke.cc
  41. hpke.h
  42. hpke_unittest.cc
  43. kdf.cc
  44. kdf.h
  45. kdf_unittest.cc
  46. kex.cc
  47. kex.h
  48. kex_unittest.cc
  49. keypair.cc
  50. keypair.h
  51. keypair_unittest.cc
  52. mock_unexportable_key.cc
  53. mock_unexportable_key.h
  54. mock_unexportable_key_provider.cc
  55. mock_unexportable_key_provider.h
  56. nss_crypto_module_delegate.h
  57. nss_key_util.cc
  58. nss_key_util.h
  59. nss_key_util_unittest.cc
  60. nss_util.cc
  61. nss_util.h
  62. nss_util_chromeos.cc
  63. nss_util_internal.h
  64. nss_util_unittest.cc
  65. openssl_util.cc
  66. openssl_util.h
  67. OWNERS
  68. pem.cc
  69. pem.h
  70. pem_unittest.cc
  71. PLAN.md
  72. process_bound_string.cc
  73. process_bound_string.h
  74. process_bound_string_unittest.cc
  75. random.cc
  76. random.h
  77. random_unittest.cc
  78. README.md
  79. scoped_capi_types.h
  80. scoped_cng_types.h
  81. scoped_fake_unexportable_key_provider.cc
  82. scoped_fake_unexportable_key_provider.h
  83. scoped_fake_user_verifying_key_provider.cc
  84. scoped_fake_user_verifying_key_provider.h
  85. scoped_mock_unexportable_key_provider.cc
  86. scoped_mock_unexportable_key_provider.h
  87. scoped_nss_types.h
  88. scoped_test_nss_chromeos_user.cc
  89. scoped_test_nss_chromeos_user.h
  90. scoped_test_nss_db.cc
  91. scoped_test_nss_db.h
  92. scoped_test_system_nss_key_slot.cc
  93. scoped_test_system_nss_key_slot.h
  94. secure_hash.cc
  95. secure_hash.h
  96. secure_hash_unittest.cc
  97. secure_util.cc
  98. secure_util.h
  99. sha2.cc
  100. sha2.h
  101. sha2_unittest.cc
  102. sign.cc
  103. sign.h
  104. sign_unittest.cc
  105. signature_verifier.cc
  106. signature_verifier.h
  107. signature_verifier_unittest.cc
  108. subtle_passkey.cc
  109. subtle_passkey.h
  110. test_support.cc
  111. test_support.h
  112. tpm.rs
  113. tpm_parser.cc
  114. tpm_parser.h
  115. tpm_parser_unittest.cc
  116. tpm_unittest.rs
  117. unexportable_key.cc
  118. unexportable_key.h
  119. unexportable_key_metrics.cc
  120. unexportable_key_metrics.h
  121. unexportable_key_metrics_unittest.cc
  122. unexportable_key_software_unsecure.cc
  123. unexportable_key_unittest.cc
  124. unexportable_key_win.cc
  125. unexportable_key_win.h
  126. user_verifying_key.cc
  127. user_verifying_key.h
  128. user_verifying_key_mac.mm
  129. user_verifying_key_mac_unittest.mm
  130. user_verifying_key_win.cc
crypto/README.md

//crypto README

This directory contains implementations of crypto primitives for use in Chromium. Most of these are either:

  • Wrappers around platform-specific APIs (DPAPI, libsecret, etc), so that code elsewhere in Chromium can use cross-platform abstractions, or
  • Wrappers around BoringSSL APIs that use Chromium-native types like base::span and similar

There is very little actual cryptographic code in //crypto - it is mostly wrappers.

This directory is actively being refactored as of 2025-06. See PLAN.md.

Commonly-Used Interfaces

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.

Advice For Clients

  • Ciphertext, keys, certificates, and other cryptographic material are generally sequences of bytes, not characters, so prefer using byte-oriented types to represent them: vector<uint8_t>, array<uint8_t>, and span<uint8_t> rather than string and string_view.
  • To serialize private keys, use 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().
  • To serialize public keys, use 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::FromPublicKeyInfo().
  • SubjectPublicKeyInfo and PrivateKeyInfo can represent many kinds of keys, so code that expects a specific kind of key must check the kind after deserialization.
  • To serialize symmetric keys (AEAD, HMAC, or symmetric encryption keys), use a raw sequence of bytes for the key material. Represent these keys in memory using vector<uint8_t>, array<uint8_t>, or span<uint8_t> directly.