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

Side by Side Diff: content/child/webcrypto/status.h

Issue 282133002: [webcryto] Validate key usages during key creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 CONTENT_CHILD_WEBCRYPTO_STATUS_H_ 5 #ifndef CONTENT_CHILD_WEBCRYPTO_STATUS_H_
6 #define CONTENT_CHILD_WEBCRYPTO_STATUS_H_ 6 #define CONTENT_CHILD_WEBCRYPTO_STATUS_H_
7 7
8 #include <string> 8 #include <string>
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "third_party/WebKit/public/platform/WebCrypto.h" 10 #include "third_party/WebKit/public/platform/WebCrypto.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace webcrypto { 14 namespace webcrypto {
15 15
16 // Status indicates whether an operation completed successfully, or with an 16 // Status indicates whether an operation completed successfully, or with an
17 // error. The error is used for verification in unit-tests, as well as for 17 // error. The error is used for verification in unit-tests, as well as for
18 // display to the user. 18 // display to the user.
19 // 19 //
20 // As such, it is important that errors DO NOT reveal any sensitive material 20 // As such, it is important that errors DO NOT reveal any sensitive material
21 // (like key bytes). 21 // (like key bytes).
22 //
23 // Care must be taken with what errors are reported back to Blink when doing
24 // compound operations like unwrapping a JWK key. In this case, errors
25 // generated by the JWK import are not appropriate to report since the wrapped
26 // JWK is not visible to the caller.
27 class CONTENT_EXPORT Status { 22 class CONTENT_EXPORT Status {
28 public: 23 public:
29 Status() : type_(TYPE_ERROR) {} 24 Status() : type_(TYPE_ERROR) {}
30 25
31 // Returns true if the Status represents an error (any one of them). 26 // Returns true if the Status represents an error (any one of them).
32 bool IsError() const; 27 bool IsError() const;
33 28
34 // Returns true if the Status represent success. 29 // Returns true if the Status represent success.
35 bool IsSuccess() const; 30 bool IsSuccess() const;
36 31
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // The exponent bytes were empty when importing an RSA public key. 176 // The exponent bytes were empty when importing an RSA public key.
182 static Status ErrorImportRsaEmptyExponent(); 177 static Status ErrorImportRsaEmptyExponent();
183 178
184 // An unextractable key was used by an operation which exports the key data. 179 // An unextractable key was used by an operation which exports the key data.
185 static Status ErrorKeyNotExtractable(); 180 static Status ErrorKeyNotExtractable();
186 181
187 // The key length specified when generating a key was invalid. Either it was 182 // The key length specified when generating a key was invalid. Either it was
188 // zero, or it was not a multiple of 8 bits. 183 // zero, or it was not a multiple of 8 bits.
189 static Status ErrorGenerateKeyLength(); 184 static Status ErrorGenerateKeyLength();
190 185
186 // Attempted to create a key (either by importKey(), generateKey(), or
187 // unwrapKey()) however the key usages were not applicable for the key type
188 // and algorithm.
189 static Status ErrorCreateKeyBadUsages();
190
191 private: 191 private:
192 enum Type { TYPE_ERROR, TYPE_SUCCESS }; 192 enum Type { TYPE_ERROR, TYPE_SUCCESS };
193 193
194 // Constructs an error with the specified error type and message. 194 // Constructs an error with the specified error type and message.
195 Status(blink::WebCryptoErrorType error_type, 195 Status(blink::WebCryptoErrorType error_type,
196 const std::string& error_details_utf8); 196 const std::string& error_details_utf8);
197 197
198 // Constructs a success or error without any details. 198 // Constructs a success or error without any details.
199 explicit Status(Type type); 199 explicit Status(Type type);
200 200
201 Type type_; 201 Type type_;
202 blink::WebCryptoErrorType error_type_; 202 blink::WebCryptoErrorType error_type_;
203 std::string error_details_; 203 std::string error_details_;
204 }; 204 };
205 205
206 } // namespace webcrypto 206 } // namespace webcrypto
207 207
208 } // namespace content 208 } // namespace content
209 209
210 #endif // CONTENT_CHILD_WEBCRYPTO_STATUS_H_ 210 #endif // CONTENT_CHILD_WEBCRYPTO_STATUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698