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