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 CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "net/cert/x509_certificate.h" | 17 #include "net/cert/x509_certificate.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class BrowserContext; | 20 class BrowserContext; |
21 } | 21 } |
22 | 22 |
23 namespace chromeos { | 23 namespace chromeos { |
24 | 24 |
25 namespace platform_keys { | 25 namespace platform_keys { |
26 | 26 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 void SignRSAPKCS1Raw(const std::string& token_id, | 95 void SignRSAPKCS1Raw(const std::string& token_id, |
96 const std::string& data, | 96 const std::string& data, |
97 const std::string& public_key, | 97 const std::string& public_key, |
98 const SignCallback& callback, | 98 const SignCallback& callback, |
99 content::BrowserContext* browser_context); | 99 content::BrowserContext* browser_context); |
100 | 100 |
101 // If the certificate request could be processed successfully, |matches| will | 101 // If the certificate request could be processed successfully, |matches| will |
102 // contain the list of matching certificates (which may be empty) and | 102 // contain the list of matching certificates (which may be empty) and |
103 // |error_message| will be empty. If an error occurred, |matches| will be null | 103 // |error_message| will be empty. If an error occurred, |matches| will be null |
104 // and |error_message| contain an error message. | 104 // and |error_message| contain an error message. |
105 typedef base::Callback<void(scoped_ptr<net::CertificateList> matches, | 105 typedef base::Callback<void(std::unique_ptr<net::CertificateList> matches, |
106 const std::string& error_message)> | 106 const std::string& error_message)> |
107 SelectCertificatesCallback; | 107 SelectCertificatesCallback; |
108 | 108 |
109 // Returns the list of all certificates that were issued by one of the | 109 // Returns the list of all certificates that were issued by one of the |
110 // |certificate_authorities|. If |certificate_authorities| is empty, all | 110 // |certificate_authorities|. If |certificate_authorities| is empty, all |
111 // certificates will be returned. |callback| will be invoked with the matches or | 111 // certificates will be returned. |callback| will be invoked with the matches or |
112 // an error message. | 112 // an error message. |
113 void SelectClientCertificates( | 113 void SelectClientCertificates( |
114 const std::vector<std::string>& certificate_authorities, | 114 const std::vector<std::string>& certificate_authorities, |
115 const SelectCertificatesCallback& callback, | 115 const SelectCertificatesCallback& callback, |
116 content::BrowserContext* browser_context); | 116 content::BrowserContext* browser_context); |
117 | 117 |
118 } // namespace subtle | 118 } // namespace subtle |
119 | 119 |
120 // Returns the DER encoding of the X.509 Subject Public Key Info of the public | 120 // Returns the DER encoding of the X.509 Subject Public Key Info of the public |
121 // key in |certificate|. | 121 // key in |certificate|. |
122 std::string GetSubjectPublicKeyInfo( | 122 std::string GetSubjectPublicKeyInfo( |
123 const scoped_refptr<net::X509Certificate>& certificate); | 123 const scoped_refptr<net::X509Certificate>& certificate); |
124 | 124 |
125 // Intersects the two certificate lists |certs1| and |certs2| and passes the | 125 // Intersects the two certificate lists |certs1| and |certs2| and passes the |
126 // intersection to |callback|. The intersction preserves the order of |certs1|. | 126 // intersection to |callback|. The intersction preserves the order of |certs1|. |
127 void IntersectCertificates( | 127 void IntersectCertificates( |
128 const net::CertificateList& certs1, | 128 const net::CertificateList& certs1, |
129 const net::CertificateList& certs2, | 129 const net::CertificateList& certs2, |
130 const base::Callback<void(scoped_ptr<net::CertificateList>)>& callback); | 130 const base::Callback<void(std::unique_ptr<net::CertificateList>)>& |
| 131 callback); |
131 | 132 |
132 // Obtains information about the public key in |certificate|. | 133 // Obtains information about the public key in |certificate|. |
133 // If |certificate| contains an RSA key, sets |key_size_bits| to the modulus | 134 // If |certificate| contains an RSA key, sets |key_size_bits| to the modulus |
134 // length, and |key_type| to type RSA and returns true. | 135 // length, and |key_type| to type RSA and returns true. |
135 // If |certificate| contains any other key type, or if the public exponent of | 136 // If |certificate| contains any other key type, or if the public exponent of |
136 // the RSA key in |certificate| is not F4, returns false and does not update any | 137 // the RSA key in |certificate| is not F4, returns false and does not update any |
137 // of the output parameters. | 138 // of the output parameters. |
138 // All pointer arguments must not be null. | 139 // All pointer arguments must not be null. |
139 bool GetPublicKey(const scoped_refptr<net::X509Certificate>& certificate, | 140 bool GetPublicKey(const scoped_refptr<net::X509Certificate>& certificate, |
140 net::X509Certificate::PublicKeyType* key_type, | 141 net::X509Certificate::PublicKeyType* key_type, |
141 size_t* key_size_bits); | 142 size_t* key_size_bits); |
142 | 143 |
143 // If the list of certificates could be successfully retrieved, |certs| will | 144 // If the list of certificates could be successfully retrieved, |certs| will |
144 // contain the list of available certificates (maybe empty) and |error_message| | 145 // contain the list of available certificates (maybe empty) and |error_message| |
145 // will be empty. If an error occurred, |certs| will be empty and | 146 // will be empty. If an error occurred, |certs| will be empty and |
146 // |error_message| contain an error message. | 147 // |error_message| contain an error message. |
147 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, | 148 typedef base::Callback<void(std::unique_ptr<net::CertificateList> certs, |
148 const std::string& error_message)> | 149 const std::string& error_message)> |
149 GetCertificatesCallback; | 150 GetCertificatesCallback; |
150 | 151 |
151 // Returns the list of all certificates with stored private key available from | 152 // Returns the list of all certificates with stored private key available from |
152 // the given token. |token_id| is currently ignored, instead the user token | 153 // the given token. |token_id| is currently ignored, instead the user token |
153 // associated with |browser_context| is always used. |callback| will be invoked | 154 // associated with |browser_context| is always used. |callback| will be invoked |
154 // with the list of available certificates or an error message. | 155 // with the list of available certificates or an error message. |
155 void GetCertificates(const std::string& token_id, | 156 void GetCertificates(const std::string& token_id, |
156 const GetCertificatesCallback& callback, | 157 const GetCertificatesCallback& callback, |
157 content::BrowserContext* browser_context); | 158 content::BrowserContext* browser_context); |
(...skipping 23 matching lines...) Expand all Loading... |
181 // user token associated with |browser_context| is always used. |callback| will | 182 // user token associated with |browser_context| is always used. |callback| will |
182 // be invoked when the removal is finished, possibly with an error message. | 183 // be invoked when the removal is finished, possibly with an error message. |
183 void RemoveCertificate(const std::string& token_id, | 184 void RemoveCertificate(const std::string& token_id, |
184 const scoped_refptr<net::X509Certificate>& certificate, | 185 const scoped_refptr<net::X509Certificate>& certificate, |
185 const RemoveCertificateCallback& callback, | 186 const RemoveCertificateCallback& callback, |
186 content::BrowserContext* browser_context); | 187 content::BrowserContext* browser_context); |
187 | 188 |
188 // If the list of available tokens could be successfully retrieved, |token_ids| | 189 // If the list of available tokens could be successfully retrieved, |token_ids| |
189 // will contain the token ids. If an error occurs, |token_ids| will be NULL and | 190 // will contain the token ids. If an error occurs, |token_ids| will be NULL and |
190 // |error_message| will be set to an error message. | 191 // |error_message| will be set to an error message. |
191 typedef base::Callback<void(scoped_ptr<std::vector<std::string> > token_ids, | 192 typedef base::Callback<void(std::unique_ptr<std::vector<std::string>> token_ids, |
192 const std::string& error_message)> | 193 const std::string& error_message)> |
193 GetTokensCallback; | 194 GetTokensCallback; |
194 | 195 |
195 // Gets the list of available tokens. |callback| will be invoked when the list | 196 // Gets the list of available tokens. |callback| will be invoked when the list |
196 // of available tokens is determined, possibly with an error message. | 197 // of available tokens is determined, possibly with an error message. |
197 // Must be called and calls |callback| on the UI thread. | 198 // Must be called and calls |callback| on the UI thread. |
198 void GetTokens(const GetTokensCallback& callback, | 199 void GetTokens(const GetTokensCallback& callback, |
199 content::BrowserContext* browser_context); | 200 content::BrowserContext* browser_context); |
200 | 201 |
201 } // namespace platform_keys | 202 } // namespace platform_keys |
202 | 203 |
203 } // namespace chromeos | 204 } // namespace chromeos |
204 | 205 |
205 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 206 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
OLD | NEW |