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