OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 5 #ifndef COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ |
6 #define COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 6 #define COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/stl_util.h" | |
16 #include "components/ownership/ownership_export.h" | 15 #include "components/ownership/ownership_export.h" |
17 #include "crypto/scoped_nss_types.h" | 16 #include "crypto/scoped_nss_types.h" |
18 | 17 |
19 struct PK11SlotInfoStr; | 18 struct PK11SlotInfoStr; |
20 typedef struct PK11SlotInfoStr PK11SlotInfo; | 19 typedef struct PK11SlotInfoStr PK11SlotInfo; |
21 | 20 |
22 namespace ownership { | 21 namespace ownership { |
23 | 22 |
24 class OwnerKeyUtilTest; | 23 class OwnerKeyUtilTest; |
25 | 24 |
26 // This class is a ref-counted wrapper around a plain public key. | 25 // This class is a ref-counted wrapper around a plain public key. |
27 class OWNERSHIP_EXPORT PublicKey | 26 class OWNERSHIP_EXPORT PublicKey |
28 : public base::RefCountedThreadSafe<PublicKey> { | 27 : public base::RefCountedThreadSafe<PublicKey> { |
29 public: | 28 public: |
30 PublicKey(); | 29 PublicKey(); |
31 | 30 |
32 std::vector<uint8>& data() { return data_; } | 31 std::vector<uint8>& data() { return data_; } |
33 | 32 |
34 bool is_loaded() const { return !data_.empty(); } | 33 bool is_loaded() const { return !data_.empty(); } |
35 | 34 |
36 std::string as_string() { | 35 std::string as_string() { |
37 return std::string(reinterpret_cast<const char*>(vector_as_array(&data_)), | 36 return std::string(reinterpret_cast<const char*>(data_.data()), |
38 data_.size()); | 37 data_.size()); |
39 } | 38 } |
40 | 39 |
41 private: | 40 private: |
42 friend class base::RefCountedThreadSafe<PublicKey>; | 41 friend class base::RefCountedThreadSafe<PublicKey>; |
43 | 42 |
44 virtual ~PublicKey(); | 43 virtual ~PublicKey(); |
45 | 44 |
46 std::vector<uint8> data_; | 45 std::vector<uint8> data_; |
47 | 46 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 protected: | 88 protected: |
90 virtual ~OwnerKeyUtil() {} | 89 virtual ~OwnerKeyUtil() {} |
91 | 90 |
92 private: | 91 private: |
93 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; | 92 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; |
94 }; | 93 }; |
95 | 94 |
96 } // namespace ownership | 95 } // namespace ownership |
97 | 96 |
98 #endif // COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 97 #endif // COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ |
OLD | NEW |