OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS 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 #include "service.h" | 5 #include "service.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include <base/file_util.h> | 10 #include <base/file_util.h> |
11 #include <base/logging.h> | 11 #include <base/logging.h> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }; | 74 }; |
75 | 75 |
76 Service::Service() | 76 Service::Service() |
77 : loop_(NULL), | 77 : loop_(NULL), |
78 cryptohome_(NULL), | 78 cryptohome_(NULL), |
79 system_salt_(), | 79 system_salt_(), |
80 default_mount_(new cryptohome::Mount()), | 80 default_mount_(new cryptohome::Mount()), |
81 mount_(default_mount_.get()), | 81 mount_(default_mount_.get()), |
82 default_tpm_init_(new TpmInit()), | 82 default_tpm_init_(new TpmInit()), |
83 tpm_init_(default_tpm_init_.get()), | 83 tpm_init_(default_tpm_init_.get()), |
| 84 default_pkcs11_init_(new Pkcs11Init()), |
| 85 pkcs11_init_(default_pkcs11_init_.get()), |
84 initialize_tpm_(true), | 86 initialize_tpm_(true), |
85 mount_thread_(kMountThreadName), | 87 mount_thread_(kMountThreadName), |
86 async_complete_signal_(-1), | 88 async_complete_signal_(-1), |
87 tpm_init_signal_(-1), | 89 tpm_init_signal_(-1), |
88 event_source_(), | 90 event_source_(), |
89 auto_cleanup_period_(kAutoCleanupPeriodMS) { | 91 auto_cleanup_period_(kAutoCleanupPeriodMS) { |
90 } | 92 } |
91 | 93 |
92 Service::~Service() { | 94 Service::~Service() { |
93 if (loop_) | 95 if (loop_) |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 tpm_init_->StartInitializeTpm(); | 562 tpm_init_->StartInitializeTpm(); |
561 } | 563 } |
562 return TRUE; | 564 return TRUE; |
563 } | 565 } |
564 | 566 |
565 gboolean Service::TpmClearStoredPassword(GError** error) { | 567 gboolean Service::TpmClearStoredPassword(GError** error) { |
566 tpm_init_->ClearStoredTpmPassword(); | 568 tpm_init_->ClearStoredTpmPassword(); |
567 return TRUE; | 569 return TRUE; |
568 } | 570 } |
569 | 571 |
| 572 gboolean Service::Pkcs11IsTpmTokenReady(gboolean* OUT_ready, GError** error) { |
| 573 // TODO(kmixter/gauravsh): Base this on PKCS#11 really being initialized. |
| 574 *OUT_ready = TRUE; |
| 575 return TRUE; |
| 576 } |
| 577 |
| 578 gboolean Service::Pkcs11GetTpmTokenInfo(gchar** OUT_label, |
| 579 gchar** OUT_user_pin, |
| 580 GError** error) { |
| 581 pkcs11_init_->GetTpmTokenInfo(OUT_label, |
| 582 OUT_user_pin); |
| 583 return TRUE; |
| 584 } |
| 585 |
570 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) { | 586 gboolean Service::GetStatusString(gchar** OUT_status, GError** error) { |
571 Tpm::TpmStatusInfo tpm_status; | 587 Tpm::TpmStatusInfo tpm_status; |
572 mount_->get_crypto()->EnsureTpm(false); | 588 mount_->get_crypto()->EnsureTpm(false); |
573 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); | 589 Tpm* tpm = const_cast<Tpm*>(mount_->get_crypto()->get_tpm()); |
574 | 590 |
575 if (tpm) { | 591 if (tpm) { |
576 tpm->GetStatus(true, &tpm_status); | 592 tpm->GetStatus(true, &tpm_status); |
577 } else { | 593 } else { |
578 Tpm::GetSingleton()->GetStatus(true, &tpm_status); | 594 Tpm::GetSingleton()->GetStatus(true, &tpm_status); |
579 } | 595 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), | 688 FROM_HERE, NewRunnableMethod(this, &Service::AutoCleanupCallback), |
673 auto_cleanup_period_); | 689 auto_cleanup_period_); |
674 } | 690 } |
675 | 691 |
676 } // namespace cryptohome | 692 } // namespace cryptohome |
677 | 693 |
678 // We do not want AutoCleanupCallback() to refer the class and make it | 694 // We do not want AutoCleanupCallback() to refer the class and make it |
679 // wait for its execution. If Mount thread terminates, it will delete | 695 // wait for its execution. If Mount thread terminates, it will delete |
680 // our pending task or wait for it to finish. | 696 // our pending task or wait for it to finish. |
681 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service); | 697 DISABLE_RUNNABLE_METHOD_REFCOUNT(cryptohome::Service); |
OLD | NEW |