| 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 #include "net/ssl/ssl_client_cert_type.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 class BrowserContext; | 18 class BrowserContext; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 class X509Certificate; | 22 class X509Certificate; |
| 22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 23 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 23 } | 24 } |
| 24 | 25 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 extern const char kTokenIdSystem[]; | 37 extern const char kTokenIdSystem[]; |
| 37 | 38 |
| 38 // Supported hash algorithms. | 39 // Supported hash algorithms. |
| 39 enum HashAlgorithm { | 40 enum HashAlgorithm { |
| 40 HASH_ALGORITHM_SHA1, | 41 HASH_ALGORITHM_SHA1, |
| 41 HASH_ALGORITHM_SHA256, | 42 HASH_ALGORITHM_SHA256, |
| 42 HASH_ALGORITHM_SHA384, | 43 HASH_ALGORITHM_SHA384, |
| 43 HASH_ALGORITHM_SHA512 | 44 HASH_ALGORITHM_SHA512 |
| 44 }; | 45 }; |
| 45 | 46 |
| 47 struct ClientCertificateRequest { |
| 48 ClientCertificateRequest(); |
| 49 ~ClientCertificateRequest(); |
| 50 |
| 51 // The list of the types of certificates requested, sorted in order of the |
| 52 // server's preference. |
| 53 std::vector<net::SSLClientCertType> certificate_key_types; |
| 54 |
| 55 // List of distinguished names of certificate authorities allowed by the |
| 56 // server. Each entry must be a DER-encoded X.509 DistinguishedName. |
| 57 std::vector<std::string> certificate_authorities; |
| 58 }; |
| 59 |
| 46 namespace subtle { | 60 namespace subtle { |
| 47 // Functions of this namespace shouldn't be called directly from the context of | 61 // Functions of this namespace shouldn't be called directly from the context of |
| 48 // an extension. Instead use PlatformKeysService which enforces restrictions | 62 // an extension. Instead use PlatformKeysService which enforces restrictions |
| 49 // upon extensions. | 63 // upon extensions. |
| 50 | 64 |
| 51 typedef base::Callback<void(const std::string& public_key_spki_der, | 65 typedef base::Callback<void(const std::string& public_key_spki_der, |
| 52 const std::string& error_message)> | 66 const std::string& error_message)> |
| 53 GenerateKeyCallback; | 67 GenerateKeyCallback; |
| 54 | 68 |
| 55 // Generates a RSA key pair with |modulus_length_bits|. |token_id| is currently | 69 // Generates a RSA key pair with |modulus_length_bits|. |token_id| is currently |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 // SubjectPublicKeyInfo. |callback| will be invoked with the signature or an | 84 // SubjectPublicKeyInfo. |callback| will be invoked with the signature or an |
| 71 // error message. | 85 // error message. |
| 72 // Currently supports RSA keys only. | 86 // Currently supports RSA keys only. |
| 73 void Sign(const std::string& token_id, | 87 void Sign(const std::string& token_id, |
| 74 const std::string& public_key, | 88 const std::string& public_key, |
| 75 HashAlgorithm hash_algorithm, | 89 HashAlgorithm hash_algorithm, |
| 76 const std::string& data, | 90 const std::string& data, |
| 77 const SignCallback& callback, | 91 const SignCallback& callback, |
| 78 content::BrowserContext* browser_context); | 92 content::BrowserContext* browser_context); |
| 79 | 93 |
| 94 // If the certificate request could be processed successfully, |matches| will |
| 95 // contain the list of matching certificates (which may be empty) and |
| 96 // |error_message| will be empty. If an error occurred, |matches| will be null |
| 97 // and |error_message| contain an error message. |
| 98 typedef base::Callback<void(scoped_ptr<net::CertificateList> matches, |
| 99 const std::string& error_message)> |
| 100 SelectCertificatesCallback; |
| 101 |
| 102 // Returns the list of all certificates that match |request|. |callback| will be |
| 103 // invoked with these matches or an error message. |
| 104 void SelectClientCertificates(const ClientCertificateRequest& request, |
| 105 const SelectCertificatesCallback& callback, |
| 106 content::BrowserContext* browser_context); |
| 107 |
| 80 } // namespace subtle | 108 } // namespace subtle |
| 81 | 109 |
| 82 // If the list of certificates could be successfully retrieved, |certs| will | 110 // If the list of certificates could be successfully retrieved, |certs| will |
| 83 // contain the list of available certificates (maybe empty) and |error_message| | 111 // contain the list of available certificates (maybe empty) and |error_message| |
| 84 // will be empty. If an error occurred, |certs| will be empty and | 112 // will be empty. If an error occurred, |certs| will be empty and |
| 85 // |error_message| contain an error message. | 113 // |error_message| contain an error message. |
| 86 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, | 114 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, |
| 87 const std::string& error_message)> | 115 const std::string& error_message)> |
| 88 GetCertificatesCallback; | 116 GetCertificatesCallback; |
| 89 | 117 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // of available tokens is determined, possibly with an error message. | 163 // of available tokens is determined, possibly with an error message. |
| 136 // Must be called and calls |callback| on the UI thread. | 164 // Must be called and calls |callback| on the UI thread. |
| 137 void GetTokens(const GetTokensCallback& callback, | 165 void GetTokens(const GetTokensCallback& callback, |
| 138 content::BrowserContext* browser_context); | 166 content::BrowserContext* browser_context); |
| 139 | 167 |
| 140 } // namespace platform_keys | 168 } // namespace platform_keys |
| 141 | 169 |
| 142 } // namespace chromeos | 170 } // namespace chromeos |
| 143 | 171 |
| 144 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 172 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
| OLD | NEW |