1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_
6 #define CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_
11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_method_call_status.h"
19 // This class is used to get the system salt from cryptohome and cache it.
20 class CHROMEOS_EXPORT SystemSaltGetter
{
22 typedef base::Callback
<void(const std::string
& system_salt
)>
23 GetSystemSaltCallback
;
25 // Manage an explicitly initialized global instance.
26 static void Initialize();
27 static bool IsInitialized();
28 static void Shutdown();
29 static SystemSaltGetter
* Get();
31 // Converts |salt| to a hex encoded string.
32 static std::string
ConvertRawSaltToHexString(const std::vector
<uint8
>& salt
);
34 // Returns system hash in hex encoded ascii format. Note: this may return
35 // an empty string (e.g. errors in D-Bus layer)
36 void GetSystemSalt(const GetSystemSaltCallback
& callback
);
43 // Used to implement GetSystemSalt().
44 void DidWaitForServiceToBeAvailable(const GetSystemSaltCallback
& callback
,
45 bool service_is_available
);
46 void DidGetSystemSalt(const GetSystemSaltCallback
& callback
,
47 DBusMethodCallStatus call_status
,
48 const std::vector
<uint8
>& system_salt
);
50 std::string system_salt_
;
52 base::WeakPtrFactory
<SystemSaltGetter
> weak_ptr_factory_
;
54 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter
);
57 } // namespace chromeos
59 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_