mount, homedirs: Add support for multiple vault keysets

The original design of cryptohome supported multiple
"master" keys stored as:
  master.0
  master.1
  ...
  master.n
It was used initially for atomic migrations to protect against data loss
on power down.  That behavior was not maintained over time and support
for multiple key sets faded into the past.

This change refactors keyset (and another vestigial component, user salt)
support to support multiple files again.  Subsequent CLs will enable
keys to be added or removed, and move migration over to this model.

An outstanding issues will be to ensure enforcement of TPM-backed keys
in the cases where it could be possible to have a mix of scrypt and tpm.

The remaining work (next CL) is to add DBus accessors (e.g., AddKey)
and add unittests around multi-key management. Additionally, unifying
vault keyset parsing via the vault_keyset.cc code and moving key migration
over to multi-key helpers needs to happen.

BUG=chromium:220243
TEST=unittest; Remainder need to be redone as this was rebased onto
     the FreeDiskSpace change test CL:
     normal sign-in, sign-out, re-signin. Manual multi-sign-in/out.

Change-Id: I4e253976c758f574dbb59af9670f3b36010e950e
Reviewed-on: https://gerrit.chromium.org/gerrit/58786
Commit-Queue: Will Drewry <wad@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
12 files changed
tree: 8e66a49e803edf3ed9b414e442d60a11b30aef64
  1. etc/
  2. share/
  3. attestation.cc
  4. attestation.h
  5. attestation.proto
  6. attestation_task.cc
  7. attestation_task.h
  8. attestation_unittest.cc
  9. common.mk
  10. credentials.h
  11. crypto.cc
  12. crypto.h
  13. crypto_unittest.cc
  14. cryptohome-path.cc
  15. cryptohome.cc
  16. cryptohome.xml
  17. cryptohome_common.h
  18. cryptohome_event_source.cc
  19. cryptohome_event_source.h
  20. cryptohome_event_source_unittest.cc
  21. cryptohome_testrunner.cc
  22. cryptohomed.cc
  23. cryptolib.cc
  24. cryptolib.h
  25. email_to_image
  26. homedirs.cc
  27. homedirs.h
  28. homedirs_unittest.cc
  29. inherit-review-settings-ok
  30. install_attributes.cc
  31. install_attributes.h
  32. install_attributes.proto
  33. install_attributes_unittest.cc
  34. interface.cc
  35. interface.h
  36. keystore.h
  37. LICENSE
  38. lockbox-cache-main.cc
  39. lockbox-cache-tpm.cc
  40. lockbox-cache-tpm.h
  41. lockbox-cache.cc
  42. lockbox-cache.h
  43. lockbox.cc
  44. lockbox.h
  45. lockbox_unittest.cc
  46. make_tests.cc
  47. make_tests.h
  48. make_tests.sh
  49. Makefile
  50. marshal.list
  51. mock_homedirs.cc
  52. mock_homedirs.h
  53. mock_install_attributes.cc
  54. mock_install_attributes.h
  55. mock_keystore.cc
  56. mock_keystore.h
  57. mock_lockbox.cc
  58. mock_lockbox.h
  59. mock_mount.cc
  60. mock_mount.h
  61. mock_mount_factory.h
  62. mock_platform.cc
  63. mock_platform.h
  64. mock_service.cc
  65. mock_service.h
  66. mock_tpm.cc
  67. mock_tpm.h
  68. mock_user_oldest_activity_timestamp_cache.cc
  69. mock_user_oldest_activity_timestamp_cache.h
  70. mock_user_session.cc
  71. mock_user_session.h
  72. mock_vault_keyset.cc
  73. mock_vault_keyset.h
  74. mock_vault_keyset_factory.h
  75. mount-encrypted.c
  76. mount-encrypted.h
  77. mount-helpers.c
  78. mount-helpers.h
  79. mount.cc
  80. mount.h
  81. mount_factory.cc
  82. mount_factory.h
  83. mount_stack.cc
  84. mount_stack.h
  85. mount_stack_unittest.cc
  86. mount_task.cc
  87. mount_task.h
  88. mount_task_unittest.cc
  89. mount_unittest.cc
  90. OWNERS
  91. pam_mount.conf.xml
  92. pkcs11_init.cc
  93. pkcs11_init.h
  94. pkcs11_keystore.cc
  95. pkcs11_keystore.h
  96. pkcs11_keystore_unittest.cc
  97. platform.cc
  98. platform.h
  99. README
  100. README.dbus
  101. README.homedirs
  102. README.lockbox
  103. README.tpm
  104. service.cc
  105. service.h
  106. service_unittest.cc
  107. stateful_recovery.cc
  108. stateful_recovery.h
  109. stateful_recovery_unittest.cc
  110. stub_tpm.h
  111. tpm.cc
  112. tpm.h
  113. tpm_init.cc
  114. tpm_init.h
  115. tpm_status.proto
  116. user_oldest_activity_timestamp_cache.cc
  117. user_oldest_activity_timestamp_cache.h
  118. user_oldest_activity_timestamp_cache_unittest.cc
  119. user_session.cc
  120. user_session.h
  121. user_session_unittest.cc
  122. username_passkey.cc
  123. username_passkey.h
  124. username_passkey_unittest.cc
  125. vault_keyset.cc
  126. vault_keyset.h
  127. vault_keyset.proto
  128. vault_keyset_factory.cc
  129. vault_keyset_factory.h
  130. vault_keyset_unittest.cc
  131. WATCHLISTS