OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/nss_util.h" | 5 #include "crypto/nss_util.h" |
6 #include "crypto/nss_util_internal.h" | 6 #include "crypto/nss_util_internal.h" |
7 | 7 |
8 #include <nss.h> | 8 #include <nss.h> |
9 #include <plarena.h> | 9 #include <plarena.h> |
10 #include <prerror.h> | 10 #include <prerror.h> |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 762 |
763 bool EnsureTPMTokenReady() { | 763 bool EnsureTPMTokenReady() { |
764 return g_nss_singleton.Get().EnsureTPMTokenReady(); | 764 return g_nss_singleton.Get().EnsureTPMTokenReady(); |
765 } | 765 } |
766 | 766 |
767 SymmetricKey* GetSupplementalUserKey() { | 767 SymmetricKey* GetSupplementalUserKey() { |
768 return g_nss_singleton.Get().GetSupplementalUserKey(); | 768 return g_nss_singleton.Get().GetSupplementalUserKey(); |
769 } | 769 } |
770 #endif // defined(OS_CHROMEOS) | 770 #endif // defined(OS_CHROMEOS) |
771 | 771 |
| 772 // TODO(port): Implement this more simply. We can convert by subtracting an |
| 773 // offset (the difference between NSPR's and base::Time's epochs). |
772 base::Time PRTimeToBaseTime(PRTime prtime) { | 774 base::Time PRTimeToBaseTime(PRTime prtime) { |
773 return base::Time::FromInternalValue( | 775 PRExplodedTime prxtime; |
774 prtime + base::Time::UnixEpoch().ToInternalValue()); | 776 PR_ExplodeTime(prtime, PR_GMTParameters, &prxtime); |
775 } | |
776 | 777 |
777 PRTime BaseTimeToPRTime(base::Time time) { | 778 base::Time::Exploded exploded; |
778 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); | 779 exploded.year = prxtime.tm_year; |
| 780 exploded.month = prxtime.tm_month + 1; |
| 781 exploded.day_of_week = prxtime.tm_wday; |
| 782 exploded.day_of_month = prxtime.tm_mday; |
| 783 exploded.hour = prxtime.tm_hour; |
| 784 exploded.minute = prxtime.tm_min; |
| 785 exploded.second = prxtime.tm_sec; |
| 786 exploded.millisecond = prxtime.tm_usec / 1000; |
| 787 |
| 788 return base::Time::FromUTCExploded(exploded); |
779 } | 789 } |
780 | 790 |
781 PK11SlotInfo* GetPublicNSSKeySlot() { | 791 PK11SlotInfo* GetPublicNSSKeySlot() { |
782 return g_nss_singleton.Get().GetPublicNSSKeySlot(); | 792 return g_nss_singleton.Get().GetPublicNSSKeySlot(); |
783 } | 793 } |
784 | 794 |
785 PK11SlotInfo* GetPrivateNSSKeySlot() { | 795 PK11SlotInfo* GetPrivateNSSKeySlot() { |
786 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); | 796 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); |
787 } | 797 } |
788 | 798 |
789 } // namespace crypto | 799 } // namespace crypto |
OLD | NEW |