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