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 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" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 // The key length specified when generating a key was invalid. Either it was | 207 // The key length specified when generating a key was invalid. Either it was |
208 // zero, or it was not a multiple of 8 bits. | 208 // zero, or it was not a multiple of 8 bits. |
209 static Status ErrorGenerateKeyLength(); | 209 static Status ErrorGenerateKeyLength(); |
210 | 210 |
211 // Attempted to create a key (either by importKey(), generateKey(), or | 211 // Attempted to create a key (either by importKey(), generateKey(), or |
212 // unwrapKey()) however the key usages were not applicable for the key type | 212 // unwrapKey()) however the key usages were not applicable for the key type |
213 // and algorithm. | 213 // and algorithm. |
214 static Status ErrorCreateKeyBadUsages(); | 214 static Status ErrorCreateKeyBadUsages(); |
215 | 215 |
| 216 // An EC key imported using SPKI/PKCS8 format had the wrong curve specified in |
| 217 // the key. |
| 218 static Status ErrorImportedEcKeyIncorrectCurve(); |
| 219 |
| 220 // The "crv" member for a JWK did not match the expectations from importKey() |
| 221 static Status ErrorJwkIncorrectCrv(); |
| 222 |
| 223 // The EC key failed validation (coordinates don't lie on curve, out of range, |
| 224 // etc.) |
| 225 static Status ErrorEcKeyInvalid(); |
| 226 |
| 227 // The octet string |member_name| was expected to be |expected_length| bytes |
| 228 // long, but was instead |actual_length| bytes long. |
| 229 static Status JwkOctetStringWrongLength(const std::string& member_name, |
| 230 size_t expected_length, |
| 231 size_t actual_length); |
| 232 |
216 private: | 233 private: |
217 enum Type { TYPE_ERROR, TYPE_SUCCESS }; | 234 enum Type { TYPE_ERROR, TYPE_SUCCESS }; |
218 | 235 |
219 // Constructs an error with the specified error type and message. | 236 // Constructs an error with the specified error type and message. |
220 Status(blink::WebCryptoErrorType error_type, | 237 Status(blink::WebCryptoErrorType error_type, |
221 const std::string& error_details_utf8); | 238 const std::string& error_details_utf8); |
222 | 239 |
223 // Constructs a success or error without any details. | 240 // Constructs a success or error without any details. |
224 explicit Status(Type type); | 241 explicit Status(Type type); |
225 | 242 |
226 Type type_; | 243 Type type_; |
227 blink::WebCryptoErrorType error_type_; | 244 blink::WebCryptoErrorType error_type_; |
228 std::string error_details_; | 245 std::string error_details_; |
229 }; | 246 }; |
230 | 247 |
231 } // namespace webcrypto | 248 } // namespace webcrypto |
232 | 249 |
233 } // namespace content | 250 } // namespace content |
234 | 251 |
235 #endif // CONTENT_CHILD_WEBCRYPTO_STATUS_H_ | 252 #endif // CONTENT_CHILD_WEBCRYPTO_STATUS_H_ |
OLD | NEW |