From 14172c8f5b57c8ec6da296c7f1b305cb1946dd12 Mon Sep 17 00:00:00 2001 From: "hashimoto@chromium.org" Date: Tue, 28 Feb 2012 10:34:21 +0000 Subject: Convert blocking chromeos::CryptohomeClient::Pkcs11* methods to async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CryptohomeLibrary::Pkcs11* methods are removed. crypto::EnsureTPMTokenReady (renamed to InitializeTPMToken) and TPMTokenInfoDelegate::IsTokenReady are also converted to async. BUG=chromium-os:16552 TEST=Login as a user, open chrome://cryptohome and see "token_name" is displayed correctly, open chrome://settings/certificates and see "Import and Bind to Deviceā€¦" button is enabled (can be pushed). Review URL: http://codereview.chromium.org/9421045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123956 0039d316-1c4b-4281-b951-d872f2087c98 --- crypto/nss_util.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'crypto/nss_util.h') diff --git a/crypto/nss_util.h b/crypto/nss_util.h index 9cfdf0b..fb5049b 100644 --- a/crypto/nss_util.h +++ b/crypto/nss_util.h @@ -8,6 +8,7 @@ #include #include "base/basictypes.h" +#include "base/callback.h" #include "crypto/crypto_export.h" #if defined(USE_NSS) @@ -26,6 +27,9 @@ namespace crypto { class SymmetricKey; +// A callback to handle the result of InitializeTPMToken. +typedef base::Callback InitializeTPMTokenCallback; + #if defined(USE_NSS) // EarlySetupForNSSInit performs lightweight setup which must occur before the // process goes multithreaded. This does not initialise NSS. For test, see @@ -93,16 +97,22 @@ CRYPTO_EXPORT void OpenPersistentNSSDB(); // communication with cryptohomed and the TPM. class CRYPTO_EXPORT TPMTokenInfoDelegate { public: + // A callback to handle the result of RequestIsTokenReady. + typedef base::Callback RequestIsTokenReadyCallback; + TPMTokenInfoDelegate(); virtual ~TPMTokenInfoDelegate(); // Returns true if the hardware supports a TPM Token and the TPM is enabled. virtual bool IsTokenAvailable() const = 0; - // Returns true if the TPM and PKCS#11 token slot is ready to be used. - // If IsTokenAvailable() is false this should return false. - // If IsTokenAvailable() is true, this should eventually return true. - virtual bool IsTokenReady() const = 0; + // Runs |callback| with true if the TPM and PKCS#11 token slot is ready to be + // used. + // If IsTokenAvailable() is false this should run |callback| with false. + // If IsTokenAvailable() is true, this should eventually run |callback| with + // true. + virtual void RequestIsTokenReady(RequestIsTokenReadyCallback callback) const + = 0; // Fetches token properties. TODO(stevenjb): make this interface asynchronous // so that the implementation does not have to be blocking. @@ -132,9 +142,8 @@ CRYPTO_EXPORT bool IsTPMTokenAvailable(); // loaded into NSS. CRYPTO_EXPORT bool IsTPMTokenReady(); -// Same as IsTPMTokenReady() except this attempts to initialize the token -// if necessary. -CRYPTO_EXPORT bool EnsureTPMTokenReady(); +// Initialize the TPM token. Does nothing if it is already initialized. +CRYPTO_EXPORT void InitializeTPMToken(InitializeTPMTokenCallback callback); // Gets supplemental user key. Creates one in NSS database if it does not exist. // The supplemental user key is used for AES encryption of user data that is -- cgit v1.1