OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/chromeos/cros/cert_library.h" | 5 #include "chrome/browser/chromeos/cros/cert_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 CertList server_certs_; | 592 CertList server_certs_; |
593 CertList server_ca_certs_; | 593 CertList server_ca_certs_; |
594 | 594 |
595 base::WeakPtrFactory<CertLibraryImpl> weak_ptr_factory_; | 595 base::WeakPtrFactory<CertLibraryImpl> weak_ptr_factory_; |
596 | 596 |
597 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl); | 597 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl); |
598 }; | 598 }; |
599 | 599 |
600 ////////////////////////////////////////////////////////////////////////////// | 600 ////////////////////////////////////////////////////////////////////////////// |
601 | 601 |
602 class CertLibraryImplStub : public CertLibrary { | |
603 public: | |
604 CertLibraryImplStub() | |
605 : token_name_("StubToken"), | |
606 ALLOW_THIS_IN_INITIALIZER_LIST(cert_list_(this)) { | |
607 } | |
608 virtual ~CertLibraryImplStub() {} | |
609 | |
610 virtual void AddObserver(Observer* observer) {} | |
611 virtual void RemoveObserver(Observer* observer) {} | |
612 virtual void LoadKeyStore() {} | |
613 virtual bool CertificatesLoading() const { | |
614 return false; | |
615 } | |
616 virtual bool CertificatesLoaded() const { | |
617 return true; | |
618 } | |
619 virtual bool IsHardwareBacked() const { | |
620 return false; | |
621 } | |
622 virtual const std::string& GetTpmTokenName() const { | |
623 return token_name_; | |
624 } | |
625 virtual const CertList& GetCertificates() const { | |
626 return cert_list_; | |
627 } | |
628 virtual const CertList& GetUserCertificates() const { | |
629 return cert_list_; | |
630 } | |
631 virtual const CertList& GetServerCertificates() const { | |
632 return cert_list_; | |
633 } | |
634 virtual const CertList& GetCACertificates() const { | |
635 return cert_list_; | |
636 } | |
637 virtual std::string EncryptWithSystemSalt(const std::string& token) { | |
638 return token; | |
639 } | |
640 virtual std::string DecryptWithSystemSalt( | |
641 const std::string& encrypted_token_hex) { | |
642 return encrypted_token_hex; | |
643 } | |
644 virtual std::string EncryptWithUserKey(const std::string& token) { | |
645 return token; | |
Greg Spencer (Chromium)
2013/04/01 19:37:18
I'd almost like to see rot13 or something implemen
stevenjb
2013/04/01 20:34:48
At some point I agree, along with some actual test
| |
646 } | |
647 virtual std::string DecryptWithUserKey( | |
648 const std::string& encrypted_token_hex) { | |
649 return encrypted_token_hex; | |
650 } | |
651 | |
652 private: | |
653 std::string token_name_; | |
654 CertList cert_list_; | |
655 | |
656 DISALLOW_COPY_AND_ASSIGN(CertLibraryImplStub); | |
657 }; | |
658 | |
659 ////////////////////////////////////////////////////////////////////////////// | |
660 | |
602 CertLibrary::~CertLibrary() { | 661 CertLibrary::~CertLibrary() { |
603 } | 662 } |
604 | 663 |
605 // static | 664 // static |
606 CertLibrary* CertLibrary::GetImpl(bool stub) { | 665 CertLibrary* CertLibrary::GetImpl(bool stub) { |
607 // |stub| is ignored since we have no stub of CertLibrary. | |
608 // TODO(stevenjb): Disassociate CertLibrary from CrosLibrary entirely. | 666 // TODO(stevenjb): Disassociate CertLibrary from CrosLibrary entirely. |
609 // crbug.com/133752 | 667 // crbug.com/133752 |
668 if (stub) | |
669 return new CertLibraryImplStub(); | |
610 return new CertLibraryImpl(); | 670 return new CertLibraryImpl(); |
611 } | 671 } |
612 | 672 |
613 ////////////////////////////////////////////////////////////////////////////// | 673 ////////////////////////////////////////////////////////////////////////////// |
614 | 674 |
615 CertLibrary::CertList::CertList(CertLibrary* library) | 675 CertLibrary::CertList::CertList(CertLibrary* library) |
616 : cert_library_(library) { | 676 : cert_library_(library) { |
617 } | 677 } |
618 | 678 |
619 CertLibrary::CertList::~CertList() {} | 679 CertLibrary::CertList::~CertList() {} |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 net::X509Certificate* cert = GetCertificateAt(index); | 727 net::X509Certificate* cert = GetCertificateAt(index); |
668 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); | 728 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); |
669 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle); | 729 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle); |
670 if (id == pkcs11_id) | 730 if (id == pkcs11_id) |
671 return index; | 731 return index; |
672 } | 732 } |
673 return -1; // Not found. | 733 return -1; // Not found. |
674 } | 734 } |
675 | 735 |
676 } // chromeos | 736 } // chromeos |
OLD | NEW |