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

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

Issue 884073002: Implement chrome.platformKeys.getKeyPair(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_impl2
Patch Set: Reupload Created 5 years, 10 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
OLDNEW
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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // be used for signing at most once. 42 // be used for signing at most once.
43 // The format written to |state_store| is: 43 // The format written to |state_store| is:
44 // kStateStorePlatformKeys maps to a list of strings. 44 // kStateStorePlatformKeys maps to a list of strings.
45 // Each string is the base64 encoding of the DER representation of a public 45 // Each string is the base64 encoding of the DER representation of a public
46 // key's SPKI. 46 // key's SPKI.
47 explicit PlatformKeysService(content::BrowserContext* browser_context, 47 explicit PlatformKeysService(content::BrowserContext* browser_context,
48 extensions::StateStore* state_store); 48 extensions::StateStore* state_store);
49 ~PlatformKeysService() override; 49 ~PlatformKeysService() override;
50 50
51 // Disables the checks whether an extension is allowed to read client 51 // Disables the checks whether an extension is allowed to read client
52 // certificates. 52 // certificates or allowed to use the signing function of a key.
53 // TODO(pneubeck): Remove this once a permissions are implemented. 53 // TODO(pneubeck): Remove this once a permissions are implemented.
54 void DisablePermissionCheckForTesting(); 54 void DisablePermissionCheckForTesting();
55 55
56 // If the generation was successful, |public_key_spki_der| will contain the 56 // If the generation was successful, |public_key_spki_der| will contain the
57 // DER encoding of the SubjectPublicKeyInfo of the generated key and 57 // DER encoding of the SubjectPublicKeyInfo of the generated key and
58 // |error_message| will be empty. If it failed, |public_key_spki_der| will be 58 // |error_message| will be empty. If it failed, |public_key_spki_der| will be
59 // empty and |error_message| contain an error message. 59 // empty and |error_message| contain an error message.
60 typedef base::Callback<void(const std::string& public_key_spki_der, 60 typedef base::Callback<void(const std::string& public_key_spki_der,
61 const std::string& error_message)> 61 const std::string& error_message)>
62 GenerateKeyCallback; 62 GenerateKeyCallback;
63 63
64 // Generates a RSA key pair with |modulus_length_bits| and registers the key 64 // Generates a RSA key pair with |modulus_length_bits| and registers the key
65 // to allow a single sign operation by the given extension. |token_id| is 65 // to allow a single sign operation by the given extension. |token_id| is
66 // currently ignored, instead the user token associated with |browser_context| 66 // currently ignored, instead the user token associated with |browser_context|
67 // is always used. |callback| will be invoked with the resulting public key or 67 // is always used. |callback| will be invoked with the resulting public key or
68 // an error. 68 // an error.
69 // Will only call back during the lifetime of this object. 69 // Will only call back during the lifetime of this object.
70 void GenerateRSAKey(const std::string& token_id, 70 void GenerateRSAKey(const std::string& token_id,
71 unsigned int modulus_length_bits, 71 unsigned int modulus_length_bits,
72 const std::string& extension_id, 72 const std::string& extension_id,
73 const GenerateKeyCallback& callback); 73 const GenerateKeyCallback& callback);
74 74
75 // If signing was successful, |signature| will be contain the signature and 75 // If signing was successful, |signature| will be contain the signature and
76 // |error_message| will be empty. If it failed, |signature| will be empty and 76 // |error_message| will be empty. If it failed, |signature| will be empty and
77 // |error_message| contain an error message. 77 // |error_message| contain an error message.
78 typedef base::Callback<void(const std::string& signature, 78 typedef base::Callback<void(const std::string& signature,
79 const std::string& error_message)> SignCallback; 79 const std::string& error_message)> SignCallback;
80 80
81 // Digests |data| with |hash_algorithm| and afterwards signs the digest with 81 // Optionally digests |data|, applies PKCS1 padding and afterwards signs the
82 // the private key matching |public_key_spki_der|, if that key is stored in 82 // data with the private key matching |params.public_key|. If a non empty
83 // the given token and wasn't used for signing before. 83 // token id is provided and the key is not found in that token, the operation
84 // Unregisters the key so that every future attempt to sign data with this key 84 // aborts.
85 // is rejected. |token_id| is currently ignored, instead the user token 85 // If the extension does not have permissions for signing with this key, the
86 // associated with |browser_context| is always used. |public_key_spki_der| 86 // operation aborts. In case of a one time permission (granted after
87 // must be the DER encoding of a SubjectPublicKeyInfo. |callback| will be 87 // generating the key), this function also removes the permission to prevent
88 // invoked with the signature or an error message. Currently supports RSA keys 88 // future signing attempts.
89 // only. 89 // |callback| will be invoked with the signature or an error message.
90 // Will only call back during the lifetime of this object. 90 // Will only call back during the lifetime of this object.
91 void Sign(const std::string& token_id, 91 void SignRSA(const std::string& token_id,
92 const std::string& public_key_spki_der, 92 scoped_ptr<platform_keys::SignRSAParams> params,
93 platform_keys::HashAlgorithm hash_algorithm, 93 const std::string& extension_id,
94 const std::string& data, 94 const SignCallback& callback);
95 const std::string& extension_id,
96 const SignCallback& callback);
97 95
98 // If the certificate request could be processed successfully, |matches| will 96 // If the certificate request could be processed successfully, |matches| will
99 // contain the list of matching certificates (maybe empty) and |error_message| 97 // contain the list of matching certificates (maybe empty) and |error_message|
100 // will be empty. If an error occurred, |matches| will be null and 98 // will be empty. If an error occurred, |matches| will be null and
101 // |error_message| contain an error message. 99 // |error_message| contain an error message.
102 typedef base::Callback<void(scoped_ptr<net::CertificateList> matches, 100 typedef base::Callback<void(scoped_ptr<net::CertificateList> matches,
103 const std::string& error_message)> 101 const std::string& error_message)>
104 SelectCertificatesCallback; 102 SelectCertificatesCallback;
105 103
106 // Returns the list of all certificates that match |request|. |callback| will 104 // Returns the list of all certificates that match |request|. |callback| will
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 extensions::StateStore* state_store_; 191 extensions::StateStore* state_store_;
194 bool permission_check_enabled_ = true; 192 bool permission_check_enabled_ = true;
195 base::WeakPtrFactory<PlatformKeysService> weak_factory_; 193 base::WeakPtrFactory<PlatformKeysService> weak_factory_;
196 194
197 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService); 195 DISALLOW_COPY_AND_ASSIGN(PlatformKeysService);
198 }; 196 };
199 197
200 } // namespace chromeos 198 } // namespace chromeos
201 199
202 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_ 200 #endif // CHROME_BROWSER_CHROMEOS_PLATFORM_KEYS_PLATFORM_KEYS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698