Remove crypto::GetTPMTokenInfo which is no longer necessary.
BUG=none Review URL: https://codereview.chromium.org/83833003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237150 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser
resources
chromeos
ui
chromeos
crypto
@@ -43,14 +43,6 @@
|
|||||||
<td>IsTPMTokenReady</td>
|
<td>IsTPMTokenReady</td>
|
||||||
<td id="is-tpm-token-ready"></td>
|
<td id="is-tpm-token-ready"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>token_name</td>
|
|
||||||
<td id="token-name"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>user_pin</td>
|
|
||||||
<td id="user-pin"></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -14,24 +14,6 @@
|
|||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace {
|
|
||||||
void GetNSSUtilInfoOnIOThread(const base::Callback<
|
|
||||||
void(bool, const std::string&, const std::string&)>& ui_callback) {
|
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
||||||
|
|
||||||
bool is_tpm_ready = crypto::IsTPMTokenReady();
|
|
||||||
std::string token_name;
|
|
||||||
std::string user_pin;
|
|
||||||
if (is_tpm_ready)
|
|
||||||
crypto::GetTPMTokenInfo(&token_name, &user_pin);
|
|
||||||
|
|
||||||
BrowserThread::PostTask(
|
|
||||||
BrowserThread::UI,
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(ui_callback, is_tpm_ready, token_name, user_pin));
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace chromeos {
|
namespace chromeos {
|
||||||
|
|
||||||
CryptohomeWebUIHandler::CryptohomeWebUIHandler() : weak_ptr_factory_(this) {}
|
CryptohomeWebUIHandler::CryptohomeWebUIHandler() : weak_ptr_factory_(this) {}
|
||||||
@@ -58,31 +40,20 @@ void CryptohomeWebUIHandler::OnPageLoaded(const base::ListValue* args) {
|
|||||||
cryptohome_client->Pkcs11IsTpmTokenReady(
|
cryptohome_client->Pkcs11IsTpmTokenReady(
|
||||||
GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready"));
|
GetCryptohomeBoolCallback("pkcs11-is-tpm-token-ready"));
|
||||||
|
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTaskAndReplyWithResult(
|
||||||
BrowserThread::IO,
|
BrowserThread::IO,
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(
|
base::Bind(&crypto::IsTPMTokenReady),
|
||||||
&GetNSSUtilInfoOnIOThread,
|
base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
|
||||||
base::Bind(&CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread,
|
weak_ptr_factory_.GetWeakPtr()));
|
||||||
weak_ptr_factory_.GetWeakPtr())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread(
|
void CryptohomeWebUIHandler::DidGetNSSUtilInfoOnUIThread(
|
||||||
bool is_tpm_token_ready,
|
bool is_tpm_token_ready) {
|
||||||
const std::string& token_name,
|
|
||||||
const std::string& user_pin) {
|
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||||
|
|
||||||
base::FundamentalValue is_tpm_token_ready_value(is_tpm_token_ready);
|
base::FundamentalValue is_tpm_token_ready_value(is_tpm_token_ready);
|
||||||
SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value);
|
SetCryptohomeProperty("is-tpm-token-ready", is_tpm_token_ready_value);
|
||||||
|
|
||||||
if (is_tpm_token_ready) {
|
|
||||||
base::StringValue token_name_value(token_name);
|
|
||||||
SetCryptohomeProperty("token-name", token_name_value);
|
|
||||||
// Hide user_pin.
|
|
||||||
base::StringValue user_pin_value(std::string(user_pin.length(), '*'));
|
|
||||||
SetCryptohomeProperty("user-pin", user_pin_value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback(
|
BoolDBusMethodCallback CryptohomeWebUIHandler::GetCryptohomeBoolCallback(
|
||||||
|
@@ -34,9 +34,7 @@ class CryptohomeWebUIHandler : public content::WebUIMessageHandler {
|
|||||||
// This method is called from JavaScript.
|
// This method is called from JavaScript.
|
||||||
void OnPageLoaded(const base::ListValue* args);
|
void OnPageLoaded(const base::ListValue* args);
|
||||||
|
|
||||||
void DidGetNSSUtilInfoOnUIThread(bool is_tpm_token_ready,
|
void DidGetNSSUtilInfoOnUIThread(bool is_tpm_token_ready);
|
||||||
const std::string& token_name,
|
|
||||||
const std::string& user_pin);
|
|
||||||
|
|
||||||
// Returns a callback to handle Cryptohome property values.
|
// Returns a callback to handle Cryptohome property values.
|
||||||
BoolDBusMethodCallback GetCryptohomeBoolCallback(
|
BoolDBusMethodCallback GetCryptohomeBoolCallback(
|
||||||
|
@@ -212,10 +212,7 @@ void CertLoader::InitializeTokenAndLoadCertificates() {
|
|||||||
base::PostTaskAndReplyWithResult(
|
base::PostTaskAndReplyWithResult(
|
||||||
crypto_task_runner_.get(),
|
crypto_task_runner_.get(),
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&crypto::InitializeTPMToken,
|
base::Bind(&crypto::InitializeTPMToken, tpm_token_slot_id_),
|
||||||
tpm_token_name_,
|
|
||||||
tpm_token_slot_id_,
|
|
||||||
tpm_user_pin_),
|
|
||||||
base::Bind(&CertLoader::OnTPMTokenInitialized,
|
base::Bind(&CertLoader::OnTPMTokenInitialized,
|
||||||
initialize_token_factory_.GetWeakPtr()));
|
initialize_token_factory_.GetWeakPtr()));
|
||||||
return;
|
return;
|
||||||
|
@@ -234,9 +234,7 @@ class NSSInitSingleton {
|
|||||||
tpm_token_enabled_for_nss_ = true;
|
tpm_token_enabled_for_nss_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitializeTPMToken(const std::string& token_name,
|
bool InitializeTPMToken(int token_slot_id) {
|
||||||
int token_slot_id,
|
|
||||||
const std::string& user_pin) {
|
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
|
|
||||||
// If EnableTPMTokenForNSS hasn't been called, return false.
|
// If EnableTPMTokenForNSS hasn't been called, return false.
|
||||||
@@ -247,9 +245,6 @@ class NSSInitSingleton {
|
|||||||
if (chaps_module_ && tpm_slot_)
|
if (chaps_module_ && tpm_slot_)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
tpm_token_name_ = token_name;
|
|
||||||
tpm_user_pin_ = user_pin;
|
|
||||||
|
|
||||||
// This tries to load the Chaps module so NSS can talk to the hardware
|
// This tries to load the Chaps module so NSS can talk to the hardware
|
||||||
// TPM.
|
// TPM.
|
||||||
if (!chaps_module_) {
|
if (!chaps_module_) {
|
||||||
@@ -277,18 +272,6 @@ class NSSInitSingleton {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTPMTokenInfo(std::string* token_name, std::string* user_pin) {
|
|
||||||
DCHECK(thread_checker_.CalledOnValidThread());
|
|
||||||
if (!tpm_token_enabled_for_nss_) {
|
|
||||||
LOG(ERROR) << "GetTPMTokenInfo called before TPM Token is ready.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (token_name)
|
|
||||||
*token_name = tpm_token_name_;
|
|
||||||
if (user_pin)
|
|
||||||
*user_pin = tpm_user_pin_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsTPMTokenReady() {
|
bool IsTPMTokenReady() {
|
||||||
// TODO(mattm): Change to DCHECK when callers have been fixed.
|
// TODO(mattm): Change to DCHECK when callers have been fixed.
|
||||||
if (!thread_checker_.CalledOnValidThread()) {
|
if (!thread_checker_.CalledOnValidThread()) {
|
||||||
@@ -629,8 +612,6 @@ class NSSInitSingleton {
|
|||||||
static bool force_nodb_init_;
|
static bool force_nodb_init_;
|
||||||
|
|
||||||
bool tpm_token_enabled_for_nss_;
|
bool tpm_token_enabled_for_nss_;
|
||||||
std::string tpm_token_name_;
|
|
||||||
std::string tpm_user_pin_;
|
|
||||||
SECMODModule* chaps_module_;
|
SECMODModule* chaps_module_;
|
||||||
PK11SlotInfo* software_slot_;
|
PK11SlotInfo* software_slot_;
|
||||||
PK11SlotInfo* test_slot_;
|
PK11SlotInfo* test_slot_;
|
||||||
@@ -800,19 +781,12 @@ void EnableTPMTokenForNSS() {
|
|||||||
g_nss_singleton.Get().EnableTPMTokenForNSS();
|
g_nss_singleton.Get().EnableTPMTokenForNSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTPMTokenInfo(std::string* token_name, std::string* user_pin) {
|
|
||||||
g_nss_singleton.Get().GetTPMTokenInfo(token_name, user_pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsTPMTokenReady() {
|
bool IsTPMTokenReady() {
|
||||||
return g_nss_singleton.Get().IsTPMTokenReady();
|
return g_nss_singleton.Get().IsTPMTokenReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitializeTPMToken(const std::string& token_name,
|
bool InitializeTPMToken(int token_slot_id) {
|
||||||
int token_slot_id,
|
return g_nss_singleton.Get().InitializeTPMToken(token_slot_id);
|
||||||
const std::string& user_pin) {
|
|
||||||
return g_nss_singleton.Get().InitializeTPMToken(
|
|
||||||
token_name, token_slot_id, user_pin);
|
|
||||||
}
|
}
|
||||||
#endif // defined(OS_CHROMEOS)
|
#endif // defined(OS_CHROMEOS)
|
||||||
|
|
||||||
|
@@ -102,12 +102,6 @@ CRYPTO_EXPORT void OpenPersistentNSSDB();
|
|||||||
// GetPrivateNSSKeySlot() will return the TPM slot if one was found.
|
// GetPrivateNSSKeySlot() will return the TPM slot if one was found.
|
||||||
CRYPTO_EXPORT void EnableTPMTokenForNSS();
|
CRYPTO_EXPORT void EnableTPMTokenForNSS();
|
||||||
|
|
||||||
// Get name and user PIN for the built-in TPM token on ChromeOS.
|
|
||||||
// Either one can safely be NULL. Should only be called after
|
|
||||||
// EnableTPMTokenForNSS has been called with a non-null delegate.
|
|
||||||
CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name,
|
|
||||||
std::string* user_pin);
|
|
||||||
|
|
||||||
// Returns true if the TPM is owned and PKCS#11 initialized with the
|
// Returns true if the TPM is owned and PKCS#11 initialized with the
|
||||||
// user and security officer PINs, and has been enabled in NSS by
|
// user and security officer PINs, and has been enabled in NSS by
|
||||||
// calling EnableTPMForNSS, and Chaps has been successfully
|
// calling EnableTPMForNSS, and Chaps has been successfully
|
||||||
@@ -115,9 +109,7 @@ CRYPTO_EXPORT void GetTPMTokenInfo(std::string* token_name,
|
|||||||
CRYPTO_EXPORT bool IsTPMTokenReady();
|
CRYPTO_EXPORT bool IsTPMTokenReady();
|
||||||
|
|
||||||
// Initialize the TPM token. Does nothing if it is already initialized.
|
// Initialize the TPM token. Does nothing if it is already initialized.
|
||||||
CRYPTO_EXPORT bool InitializeTPMToken(const std::string& token_name,
|
CRYPTO_EXPORT bool InitializeTPMToken(int token_slot_id);
|
||||||
int token_slot_id,
|
|
||||||
const std::string& user_pin);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Convert a NSS PRTime value into a base::Time object.
|
// Convert a NSS PRTime value into a base::Time object.
|
||||||
|
Reference in New Issue
Block a user