| 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 // Supported hash algorithms. |
| 30 enum HashAlgorithm { |
| 31 HASH_ALGORITHM_SHA1, |
| 32 HASH_ALGORITHM_SHA256, |
| 33 HASH_ALGORITHM_SHA384, |
| 34 HASH_ALGORITHM_SHA512 |
| 35 }; |
| 36 |
| 29 // If the generation was successful, |public_key_spki_der| will contain the DER | 37 // If the generation was successful, |public_key_spki_der| will contain the DER |
| 30 // encoding of the SubjectPublicKeyInfo of the generated key and |error_message| | 38 // encoding of the SubjectPublicKeyInfo of the generated key and |error_message| |
| 31 // will be empty. If it failed, |public_key_spki_der| will be empty and | 39 // will be empty. If it failed, |public_key_spki_der| will be empty and |
| 32 // |error_message| contain an error message. | 40 // |error_message| contain an error message. |
| 33 typedef base::Callback<void(const std::string& public_key_spki_der, | 41 typedef base::Callback<void(const std::string& public_key_spki_der, |
| 34 const std::string& error_message)> | 42 const std::string& error_message)> |
| 35 GenerateKeyCallback; | 43 GenerateKeyCallback; |
| 36 | 44 |
| 37 // Generates a RSA key with |modulus_length|. |token_id| is currently ignored, | 45 // Generates a RSA key with |modulus_length|. |token_id| is currently ignored, |
| 38 // instead the user token associated with |browser_context| is always used. | 46 // instead the user token associated with |browser_context| is always used. |
| 39 // |callback| will be invoked with the resulting public key or an error. | 47 // |callback| will be invoked with the resulting public key or an error. |
| 40 void GenerateRSAKey(const std::string& token_id, | 48 void GenerateRSAKey(const std::string& token_id, |
| 41 unsigned int modulus_length, | 49 unsigned int modulus_length, |
| 42 const GenerateKeyCallback& callback, | 50 const GenerateKeyCallback& callback, |
| 43 content::BrowserContext* browser_context); | 51 content::BrowserContext* browser_context); |
| 44 | 52 |
| 45 // If signing was successful, |signature| will be contain the signature and | 53 // 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 | 54 // |error_message| will be empty. If it failed, |signature| will be empty and |
| 47 // |error_message| contain an error message. | 55 // |error_message| contain an error message. |
| 48 typedef base::Callback<void(const std::string& signature, | 56 typedef base::Callback<void(const std::string& signature, |
| 49 const std::string& error_message)> SignCallback; | 57 const std::string& error_message)> SignCallback; |
| 50 | 58 |
| 51 // Signs |data| with the private key matching |public_key|, if that key is | 59 // Digests |data| with |hash_algorithm| and afterwards signs the digest with the |
| 52 // stored in the given token. |token_id| is currently ignored, instead the user | 60 // private key matching |public_key|, if that key is stored in the given token. |
| 53 // token associated with |browser_context| is always used. |public_key| must be | 61 // |token_id| is currently ignored, instead the user token associated with |
| 54 // the DER encoding of a SubjectPublicKeyInfo. |callback| will be invoked with | 62 // |browser_context| is always used. |public_key| must be the DER encoding of a |
| 55 // the signature or an error message. | 63 // SubjectPublicKeyInfo. |callback| will be invoked with the signature or an |
| 64 // error message. |
| 56 // Currently supports RSA keys only. | 65 // Currently supports RSA keys only. |
| 57 void Sign(const std::string& token_id, | 66 void Sign(const std::string& token_id, |
| 58 const std::string& public_key, | 67 const std::string& public_key, |
| 68 HashAlgorithm hash_algorithm, |
| 59 const std::string& data, | 69 const std::string& data, |
| 60 const SignCallback& callback, | 70 const SignCallback& callback, |
| 61 content::BrowserContext* browser_context); | 71 content::BrowserContext* browser_context); |
| 62 | 72 |
| 63 // If the list of certificates could be successfully retrieved, |certs| will | 73 // If the list of certificates could be successfully retrieved, |certs| will |
| 64 // contain the list of available certificates (maybe empty) and |error_message| | 74 // contain the list of available certificates (maybe empty) and |error_message| |
| 65 // will be empty. If an error occurred, |certs| will be empty and | 75 // will be empty. If an error occurred, |certs| will be empty and |
| 66 // |error_message| contain an error message. | 76 // |error_message| contain an error message. |
| 67 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, | 77 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, |
| 68 const std::string& error_message)> | 78 const std::string& error_message)> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void RemoveCertificate(const std::string& token_id, | 113 void RemoveCertificate(const std::string& token_id, |
| 104 scoped_refptr<net::X509Certificate> certificate, | 114 scoped_refptr<net::X509Certificate> certificate, |
| 105 const RemoveCertificateCallback& callback, | 115 const RemoveCertificateCallback& callback, |
| 106 content::BrowserContext* browser_context); | 116 content::BrowserContext* browser_context); |
| 107 | 117 |
| 108 } // namespace platform_keys | 118 } // namespace platform_keys |
| 109 | 119 |
| 110 } // namespace chromeos | 120 } // namespace chromeos |
| 111 | 121 |
| 112 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | 122 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ |
| OLD | NEW |