tree: 838e0acc038ec9bf7ab3cd4cfcc488713dcb0e3b [path history] [tgz]
  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. crypto_export.h
  17. DEPS
  18. DIR_METADATA
  19. evp.cc
  20. evp.h
  21. evp_unittest.cc
  22. features.cc
  23. features.gni
  24. features.h
  25. hash.cc
  26. hash.h
  27. hash_unittest.cc
  28. hkdf.cc
  29. hkdf.h
  30. hmac.cc
  31. hmac.h
  32. hmac_unittest.cc
  33. kdf.cc
  34. kdf.h
  35. kdf_unittest.cc
  36. kex.cc
  37. kex.h
  38. kex_unittest.cc
  39. keypair.cc
  40. keypair.h
  41. keypair_unittest.cc
  42. nss_crypto_module_delegate.h
  43. nss_key_util.cc
  44. nss_key_util.h
  45. nss_key_util_unittest.cc
  46. nss_util.cc
  47. nss_util.h
  48. nss_util_chromeos.cc
  49. nss_util_internal.h
  50. nss_util_unittest.cc
  51. openssl_util.cc
  52. openssl_util.h
  53. OWNERS
  54. pem.cc
  55. pem.h
  56. pem_unittest.cc
  57. PLAN.md
  58. process_bound_string.cc
  59. process_bound_string.h
  60. process_bound_string_unittest.cc
  61. random.cc
  62. random.h
  63. random_unittest.cc
  64. README.md
  65. scoped_capi_types.h
  66. scoped_cng_types.h
  67. scoped_fake_unexportable_key_provider.cc
  68. scoped_fake_unexportable_key_provider.h
  69. scoped_fake_user_verifying_key_provider.cc
  70. scoped_fake_user_verifying_key_provider.h
  71. scoped_nss_types.h
  72. scoped_test_nss_chromeos_user.cc
  73. scoped_test_nss_chromeos_user.h
  74. scoped_test_nss_db.cc
  75. scoped_test_nss_db.h
  76. scoped_test_system_nss_key_slot.cc
  77. scoped_test_system_nss_key_slot.h
  78. secure_hash.cc
  79. secure_hash.h
  80. secure_hash_unittest.cc
  81. secure_util.cc
  82. secure_util.h
  83. sha2.cc
  84. sha2.h
  85. sha2_unittest.cc
  86. sign.cc
  87. sign.h
  88. sign_unittest.cc
  89. signature_verifier.cc
  90. signature_verifier.h
  91. signature_verifier_unittest.cc
  92. subtle_passkey.cc
  93. subtle_passkey.h
  94. test_support.cc
  95. test_support.h
  96. unexportable_key.cc
  97. unexportable_key.h
  98. unexportable_key_mac.h
  99. unexportable_key_mac.mm
  100. unexportable_key_mac_unittest.mm
  101. unexportable_key_metrics.cc
  102. unexportable_key_metrics.h
  103. unexportable_key_metrics_unittest.cc
  104. unexportable_key_software_unsecure.cc
  105. unexportable_key_unittest.cc
  106. unexportable_key_win.cc
  107. unexportable_key_win.h
  108. user_verifying_key.cc
  109. user_verifying_key.h
  110. user_verifying_key_mac.mm
  111. user_verifying_key_mac_unittest.mm
  112. 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.