| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 5 #ifndef CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
| 6 #define CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 6 #define CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 | 13 |
| 14 namespace cryptohome { | 14 namespace cryptohome { |
| 15 | 15 |
| 16 enum AuthKeyPrivileges { | 16 enum AuthKeyPrivileges { |
| 17 PRIV_MOUNT = 1 << 0, // Can mount with this key. | 17 PRIV_MOUNT = 1 << 0, // Can mount with this key. |
| 18 PRIV_ADD = 1 << 1, // Can add new keys. | 18 PRIV_ADD = 1 << 1, // Can add new keys. |
| 19 PRIV_REMOVE = 1 << 2, // Can remove other keys. | 19 PRIV_REMOVE = 1 << 2, // Can remove other keys. |
| 20 PRIV_MIGRATE = 1 << 3, // Destroy all keys and replace with new. | 20 PRIV_MIGRATE = 1 << 3, // Destroy all keys and replace with new. |
| 21 PRIV_AUTHORIZED_UPDATE = 1 << 4, // Key can be updated in place. | 21 PRIV_AUTHORIZED_UPDATE = 1 << 4, // Key can be updated in place. |
| 22 PRIV_DEFAULT = PRIV_MOUNT | PRIV_ADD | PRIV_REMOVE | PRIV_MIGRATE | 22 PRIV_DEFAULT = PRIV_MOUNT | PRIV_ADD | PRIV_REMOVE | PRIV_MIGRATE |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 // Identification of the user calling cryptohome method. | 25 // Identification of the user calling cryptohome method. |
| 26 struct CHROMEOS_EXPORT Identification { | 26 struct CHROMEOS_EXPORT Identification { |
| 27 explicit Identification(const std::string& user_id) : user_id(user_id) {} | 27 explicit Identification(const std::string& user_id); |
| 28 |
| 29 bool operator==(const Identification& other) const; |
| 30 |
| 28 std::string user_id; | 31 std::string user_id; |
| 29 }; | 32 }; |
| 30 | 33 |
| 31 // Definition of the key (e.g. password) for the cryptohome. | 34 // Definition of the key (e.g. password) for the cryptohome. |
| 32 // It contains authorization data along with extra parameters like perimissions | 35 // It contains authorization data along with extra parameters like perimissions |
| 33 // associated with this key. | 36 // associated with this key. |
| 34 struct CHROMEOS_EXPORT KeyDefinition { | 37 struct CHROMEOS_EXPORT KeyDefinition { |
| 35 KeyDefinition(const std::string& key, | 38 KeyDefinition(const std::string& key, |
| 36 const std::string& label, | 39 const std::string& label, |
| 37 int /*AuthKeyPrivileges*/ privileges); | 40 int /*AuthKeyPrivileges*/ privileges); |
| 38 ~KeyDefinition(); | 41 ~KeyDefinition(); |
| 42 |
| 43 bool operator==(const KeyDefinition& other) const; |
| 44 |
| 39 std::string label; | 45 std::string label; |
| 40 | 46 |
| 41 int revision; | 47 int revision; |
| 42 std::string key; | 48 std::string key; |
| 43 | 49 |
| 44 std::string encryption_key; | 50 std::string encryption_key; |
| 45 std::string signature_key; | 51 std::string signature_key; |
| 46 // Privileges associated with key. Combination of |AuthKeyPrivileges| values. | 52 // Privileges associated with key. Combination of |AuthKeyPrivileges| values. |
| 47 int privileges; | 53 int privileges; |
| 48 }; | 54 }; |
| 49 | 55 |
| 50 // Authorization attempt data for user. | 56 // Authorization attempt data for user. |
| 51 struct CHROMEOS_EXPORT Authorization { | 57 struct CHROMEOS_EXPORT Authorization { |
| 52 Authorization(const std::string& key, const std::string& label); | 58 Authorization(const std::string& key, const std::string& label); |
| 53 explicit Authorization(const KeyDefinition& key); | 59 explicit Authorization(const KeyDefinition& key); |
| 60 |
| 61 bool operator==(const Authorization& other) const; |
| 62 |
| 54 std::string key; | 63 std::string key; |
| 55 std::string label; | 64 std::string label; |
| 56 }; | 65 }; |
| 57 | 66 |
| 58 // Parameters for Mount call. | 67 // Parameters for Mount call. |
| 59 class CHROMEOS_EXPORT MountParameters { | 68 class CHROMEOS_EXPORT MountParameters { |
| 60 public: | 69 public: |
| 61 explicit MountParameters(bool ephemeral); | 70 explicit MountParameters(bool ephemeral); |
| 62 ~MountParameters(); | 71 ~MountParameters(); |
| 63 | 72 |
| 73 bool operator==(const MountParameters& other) const; |
| 74 |
| 64 // If |true|, the mounted home dir will be backed by tmpfs. If |false|, the | 75 // If |true|, the mounted home dir will be backed by tmpfs. If |false|, the |
| 65 // ephemeral users policy decides whether tmpfs or an encrypted directory is | 76 // ephemeral users policy decides whether tmpfs or an encrypted directory is |
| 66 // used as the backend. | 77 // used as the backend. |
| 67 bool ephemeral; | 78 bool ephemeral; |
| 68 | 79 |
| 69 // If not empty, home dir will be created with these keys if it exist. | 80 // If not empty, home dir will be created with these keys if it exist. |
| 70 std::vector<KeyDefinition> create_keys; | 81 std::vector<KeyDefinition> create_keys; |
| 71 }; | 82 }; |
| 72 | 83 |
| 73 } // namespace cryptohome | 84 } // namespace cryptohome |
| 74 | 85 |
| 75 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ | 86 #endif // CHROMEOS_CRYPTOHOME_CRYPTOHOME_PARAMETERS_H_ |
| OLD | NEW |