Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | |
| 18 namespace net { | |
| 19 class X509Certificate; | |
| 20 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | |
| 21 } | |
| 22 | |
| 23 namespace chromeos { | |
| 24 | |
| 25 namespace platform_keys { | |
| 26 | |
| 27 // If the generation was successful, |public_key_str| will contain the DER | |
|
Ryan Sleevi
2014/05/15 19:57:13
naming: public_key_str -> public_key_der or public
pneubeck (no reviews)
2014/05/16 12:30:16
Done.
| |
| 28 // encoding of the SubjectPublicKeyInfo of the generated key and |error_message| | |
| 29 // will be empty. If it failed, |public_key_str| will be empty and | |
| 30 // |error_message| contain an error message. | |
| 31 typedef base::Callback< | |
| 32 void(const std::string& public_key_str, const std::string& error_message)> | |
| 33 GenerateKeyCallback; | |
| 34 | |
| 35 // Generates a RSA key with |modulus_length|. |token_id| is currently ignored, | |
| 36 // instead always the user token associated to |profile| is used. |callback| | |
| 37 // will be called back with the resulting public key or an error. | |
| 38 void GenerateRSAKey(const std::string& token_id, | |
| 39 int modulus_length, | |
|
Ryan Sleevi
2014/05/15 19:57:13
Should be unsigned. What does it mean to generate
pneubeck (no reviews)
2014/05/16 12:30:16
Done.
| |
| 40 const GenerateKeyCallback& callback, | |
| 41 Profile* profile); | |
| 42 | |
| 43 // If signing was successful, |signature| will be contain the signature and | |
| 44 // |error_message| will be empty. If it failed, |signature| will be empty and | |
| 45 // |error_message| contain an error message. | |
| 46 typedef base::Callback<void(const std::string& signature, | |
| 47 const std::string& error_message)> SignCallback; | |
| 48 | |
| 49 // Signs |data| with the private key matching |public_key|, if that key is | |
| 50 // stored in the given token. |token_id| is currently ignored, instead always | |
| 51 // the user token associated to |profile| is used. |public_key| must be the DER | |
| 52 // encoding of a SubjectPublicKeyInfo. |callback| will be called back with the | |
| 53 // signature or an error message. | |
| 54 // Currently supports RSA keys only. | |
| 55 void Sign(const std::string& token_id, | |
| 56 const std::string& public_key, | |
| 57 const std::string& data, | |
| 58 const SignCallback& callback, | |
| 59 Profile* profile); | |
| 60 | |
| 61 // If the list of certificates could be successfully retrieved, |certs| will | |
| 62 // contain the list of available certificates (maybe empty) and |error_message| | |
| 63 // will be empty. If an error occurred, |certs| will be empty and | |
| 64 // |error_message| contain an error message. | |
| 65 typedef base::Callback<void(scoped_ptr<net::CertificateList> certs, | |
| 66 const std::string& error_message)> | |
| 67 GetCertificatesCallback; | |
| 68 | |
| 69 // Returns the list of all certificates with stored private key available from | |
| 70 // the given token. |token_id| is currently ignored, instead always the user | |
| 71 // token associated to |profile| is used. |callback| will be called back with | |
| 72 // the list of available certificates or an error message. | |
| 73 void GetCertificates(const std::string& token_id, | |
| 74 const GetCertificatesCallback& callback, | |
| 75 Profile* profile); | |
| 76 | |
| 77 // If an error occurred during import, |error_message| will be set to an error | |
| 78 // message. | |
| 79 typedef base::Callback<void(const std::string& error_message)> | |
| 80 ImportCertificateCallback; | |
| 81 | |
| 82 // Imports |certificate| to the given token if the certified key is already | |
| 83 // stored in this token. |token_id| is currently ignored, instead always the | |
| 84 // user token associated to |profile| is used. |callback| will be called back | |
| 85 // when the import is finished, possibly with an error message. | |
| 86 void ImportCertificate(const std::string& token_id, | |
| 87 scoped_refptr<net::X509Certificate> certificate, | |
|
Ryan Sleevi
2014/05/15 19:57:13
where do the intermediates in |certificate| go?
pneubeck (no reviews)
2014/05/16 12:30:16
documented that they're ignored.
| |
| 88 const ImportCertificateCallback& callback, | |
| 89 Profile* profile); | |
| 90 | |
| 91 // If an error occurred during removal, |error_message| will be set to an error | |
| 92 // message. | |
| 93 typedef base::Callback<void(const std::string& error_message)> | |
| 94 RemoveCertificateCallback; | |
| 95 | |
| 96 // Removes |certificate| from the given token if present. |token_id| is | |
| 97 // currently ignored, instead always the user token associated to |profile| is | |
| 98 // used. |callback| will be called back when the removal is finished, possibly | |
| 99 // with an error message. | |
| 100 void RemoveCertificate(const std::string& token_id, | |
| 101 scoped_refptr<net::X509Certificate> certificate, | |
|
Ryan Sleevi
2014/05/15 19:57:13
ditto intermediates (just need to document)
pneubeck (no reviews)
2014/05/16 12:30:16
documented that they're ignored.
| |
| 102 const RemoveCertificateCallback& callback, | |
| 103 Profile* profile); | |
| 104 | |
| 105 } // namespace platform_keys | |
|
mattm
2014/05/16 20:27:12
extraneous space
pneubeck (no reviews)
2014/05/19 19:17:19
Done.
| |
| 106 | |
| 107 } // namespace chromeos | |
| 108 | |
| 109 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_ | |
| OLD | NEW |