Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/chromeos/platform_keys/platform_keys.h

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NSS operations now asynchronous. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_spki_der| will contain the DER
28 // encoding of the SubjectPublicKeyInfo of the generated key and |error_message|
29 // will be empty. If it failed, |public_key_spki_der| will be empty and
30 // |error_message| contain an error message.
31 typedef base::Callback<void(const std::string& public_key_spki_der,
32 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 unsigned int modulus_length,
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. Any intermediate of |certificate| will be ignored.
84 // |token_id| is currently ignored, instead always the user token associated to
85 // |profile| is used. |callback| will be called back when the import is
86 // finished, possibly with an error message.
87 void ImportCertificate(const std::string& token_id,
88 scoped_refptr<net::X509Certificate> certificate,
89 const ImportCertificateCallback& callback,
90 Profile* profile);
91
92 // If an error occurred during removal, |error_message| will be set to an error
93 // message.
94 typedef base::Callback<void(const std::string& error_message)>
95 RemoveCertificateCallback;
96
97 // Removes |certificate| from the given token if present. Any intermediate of
98 // |certificate| will be ignored. |token_id| is currently ignored, instead
99 // always the user token associated to |profile| is used. |callback| will be
100 // called back when the removal is finished, possibly with an error message.
101 void RemoveCertificate(const std::string& token_id,
102 scoped_refptr<net::X509Certificate> certificate,
103 const RemoveCertificateCallback& callback,
104 Profile* profile);
105
106 } // namespace platform_keys
107
108 } // namespace chromeos
109
110 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698