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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.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 | 15 |
16 namespace content { | 16 namespace content { |
17 class BrowserContext; | 17 class BrowserContext; |
18 } | 18 } |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 class X509Certificate; | 21 class X509Certificate; |
22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
23 } | 23 } |
24 | 24 |
25 namespace chromeos { | 25 namespace chromeos { |
26 | 26 |
27 namespace platform_keys { | 27 namespace platform_keys { |
28 | 28 |
29 // If the generation was successful, |public_key_spki_der| will contain the DER | 29 namespace subtle { |
30 // encoding of the SubjectPublicKeyInfo of the generated key and |error_message| | 30 // Functions of this namespace shouldn't be called directly from the context of |
31 // will be empty. If it failed, |public_key_spki_der| will be empty and | 31 // an extension. Instead use PlatformKeysService which enforces restrictions |
32 // |error_message| contain an error message. | 32 // upon extensions. |
| 33 |
33 typedef base::Callback<void(const std::string& public_key_spki_der, | 34 typedef base::Callback<void(const std::string& public_key_spki_der, |
34 const std::string& error_message)> | 35 const std::string& error_message)> |
35 GenerateKeyCallback; | 36 GenerateKeyCallback; |
36 | 37 |
37 // Generates a RSA key with |modulus_length|. |token_id| is currently ignored, | 38 // Generates a RSA key pair with |modulus_length_bits|. |token_id| is currently |
38 // instead the user token associated with |browser_context| is always used. | 39 // ignored, instead the user token associated with |browser_context| is always |
39 // |callback| will be invoked with the resulting public key or an error. | 40 // used. |callback| will be invoked with the resulting public key or an error. |
40 void GenerateRSAKey(const std::string& token_id, | 41 void GenerateRSAKey(const std::string& token_id, |
41 unsigned int modulus_length, | 42 unsigned int modulus_length_bits, |
42 const GenerateKeyCallback& callback, | 43 const GenerateKeyCallback& callback, |
43 content::BrowserContext* browser_context); | 44 content::BrowserContext* browser_context); |
44 | 45 |
45 // If signing was successful, |signature| will be contain the signature and | |
46 // |error_message| will be empty. If it failed, |signature| will be empty and | |
47 // |error_message| contain an error message. | |
48 typedef base::Callback<void(const std::string& signature, | 46 typedef base::Callback<void(const std::string& signature, |
49 const std::string& error_message)> SignCallback; | 47 const std::string& error_message)> SignCallback; |
50 | 48 |
51 // Signs |data| with the private key matching |public_key|, if that key is | 49 // Signs |data| with the private key matching |public_key|, if that key is |
52 // stored in the given token. |token_id| is currently ignored, instead the user | 50 // stored in the given token. |token_id| is currently ignored, instead the user |
53 // token associated with |browser_context| is always used. |public_key| must be | 51 // token associated with |browser_context| is always used. |public_key| must be |
54 // the DER encoding of a SubjectPublicKeyInfo. |callback| will be invoked with | 52 // the DER encoding of a SubjectPublicKeyInfo. |callback| will be invoked with |
55 // the signature or an error message. | 53 // the signature or an error message. |
56 // Currently supports RSA keys only. | 54 // Currently supports RSA keys only. |
57 void Sign(const std::string& token_id, | 55 void Sign(const std::string& token_id, |
58 const std::string& public_key, | 56 const std::string& public_key, |
59 const std::string& data, | 57 const std::string& data, |
60 const SignCallback& callback, | 58 const SignCallback& callback, |
61 content::BrowserContext* browser_context); | 59 content::BrowserContext* browser_context); |
62 | 60 |
| 61 } // namespace subtle |
| 62 |
63 // If the list of certificates could be successfully retrieved, |certs| will | 63 // If the list of certificates could be successfully retrieved, |certs| will |
64 // contain the list of available certificates (maybe empty) and |error_message| | 64 // contain the list of available certificates (maybe empty) and |error_message| |
65 // will be empty. If an error occurred, |certs| will be empty and | 65 // will be empty. If an error occurred, |certs| will be empty and |
66 // |error_message| contain an error message. | 66 // |error_message| contain an error message. |
67 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, | 67 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, |
68 const std::string& error_message)> | 68 const std::string& error_message)> |
69 GetCertificatesCallback; | 69 GetCertificatesCallback; |
70 | 70 |
71 // Returns the list of all certificates with stored private key available from | 71 // Returns the list of all certificates with stored private key available from |
72 // the given token. |token_id| is currently ignored, instead the user token | 72 // the given token. |token_id| is currently ignored, instead the user token |
(...skipping 30 matching lines...) Expand all Loading... |
103 void RemoveCertificate(const std::string& token_id, | 103 void RemoveCertificate(const std::string& token_id, |
104 scoped_refptr<net::X509Certificate> certificate, | 104 scoped_refptr<net::X509Certificate> certificate, |
105 const RemoveCertificateCallback& callback, | 105 const RemoveCertificateCallback& callback, |
106 content::BrowserContext* browser_context); | 106 content::BrowserContext* browser_context); |
107 | 107 |
108 } // namespace platform_keys | 108 } // namespace platform_keys |
109 | 109 |
110 } // namespace chromeos | 110 } // namespace chromeos |
111 | 111 |
112 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 112 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
OLD | NEW |