tree: 1a5e89f4ebb2bba1abffa92e089e1cf30a08bc96 [path history] [tgz]
  1. obsolete/
  2. aead.cc
  3. aead.h
  4. aead_unittest.cc
  5. aes_cbc.cc
  6. aes_cbc.h
  7. aes_cbc_unittest.cc
  8. aes_ctr.cc
  9. aes_ctr.h
  10. aes_ctr_unittest.cc
  11. apple_keychain.cc
  12. apple_keychain.h
  13. apple_keychain_secitem.h
  14. apple_keychain_secitem.mm
  15. apple_keychain_seckeychain.cc
  16. apple_keychain_seckeychain.h
  17. apple_keychain_util.h
  18. apple_keychain_util.mm
  19. apple_keychain_util_unittest.mm
  20. apple_keychain_v2.h
  21. apple_keychain_v2.mm
  22. BUILD.gn
  23. chaps_support.cc
  24. chaps_support.h
  25. crypto_export.h
  26. DEPS
  27. DIR_METADATA
  28. ec_private_key.cc
  29. ec_private_key.h
  30. ec_private_key_unittest.cc
  31. evp.cc
  32. evp.h
  33. evp_unittest.cc
  34. fake_apple_keychain_v2.h
  35. fake_apple_keychain_v2.mm
  36. features.cc
  37. features.gni
  38. features.h
  39. hash.cc
  40. hash.h
  41. hash_unittest.cc
  42. hkdf.cc
  43. hkdf.h
  44. hmac.cc
  45. hmac.h
  46. hmac_unittest.cc
  47. kdf.cc
  48. kdf.h
  49. kdf_unittest.cc
  50. keypair.cc
  51. keypair.h
  52. keypair_unittest.cc
  53. mac_security_services_lock.cc
  54. mac_security_services_lock.h
  55. mock_apple_keychain.cc
  56. mock_apple_keychain.h
  57. mock_apple_keychain_unittest.cc
  58. nss_crypto_module_delegate.h
  59. nss_key_util.cc
  60. nss_key_util.h
  61. nss_key_util_unittest.cc
  62. nss_util.cc
  63. nss_util.h
  64. nss_util_chromeos.cc
  65. nss_util_internal.h
  66. nss_util_unittest.cc
  67. openssl_util.cc
  68. openssl_util.h
  69. OWNERS
  70. PLAN.md
  71. process_bound_string.cc
  72. process_bound_string.h
  73. process_bound_string_unittest.cc
  74. random.cc
  75. random.h
  76. random_unittest.cc
  77. README.md
  78. rsa_private_key.cc
  79. rsa_private_key.h
  80. rsa_private_key_unittest.cc
  81. scoped_capi_types.h
  82. scoped_cng_types.h
  83. scoped_fake_apple_keychain_v2.h
  84. scoped_fake_apple_keychain_v2.mm
  85. scoped_fake_unexportable_key_provider.cc
  86. scoped_fake_unexportable_key_provider.h
  87. scoped_fake_user_verifying_key_provider.cc
  88. scoped_fake_user_verifying_key_provider.h
  89. scoped_lacontext.h
  90. scoped_lacontext.mm
  91. scoped_nss_types.h
  92. scoped_test_nss_chromeos_user.cc
  93. scoped_test_nss_chromeos_user.h
  94. scoped_test_nss_db.cc
  95. scoped_test_nss_db.h
  96. scoped_test_system_nss_key_slot.cc
  97. scoped_test_system_nss_key_slot.h
  98. secure_hash.cc
  99. secure_hash.h
  100. secure_hash_unittest.cc
  101. secure_util.cc
  102. secure_util.h
  103. sha2.cc
  104. sha2.h
  105. sha2_unittest.cc
  106. sign.cc
  107. sign.h
  108. sign_unittest.cc
  109. signature_verifier.cc
  110. signature_verifier.h
  111. signature_verifier_unittest.cc
  112. subtle_passkey.cc
  113. subtle_passkey.h
  114. test_support.cc
  115. test_support.h
  116. unexportable_key.cc
  117. unexportable_key.h
  118. unexportable_key_mac.h
  119. unexportable_key_mac.mm
  120. unexportable_key_mac_unittest.mm
  121. unexportable_key_metrics.cc
  122. unexportable_key_metrics.h
  123. unexportable_key_metrics_unittest.cc
  124. unexportable_key_software_unsecure.cc
  125. unexportable_key_unittest.cc
  126. unexportable_key_win.cc
  127. unexportable_key_win.h
  128. user_verifying_key.cc
  129. user_verifying_key.h
  130. user_verifying_key_mac.mm
  131. user_verifying_key_mac_unittest.mm
  132. 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.