Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 namespace webcrypto { | 18 namespace webcrypto { |
| 19 | 19 |
| 20 // |Status| indicates whether an operation completed successfully, or with an | |
|
Ryan Sleevi
2014/01/24 01:21:50
nit: No | | - this is not a variable, it's a class
eroman
2014/01/24 03:19:21
Shrug. There are examples of both models in Chromi
Ryan Sleevi
2014/01/24 20:27:01
I didn't have strong objections, I just wanted to
| |
| 21 // error. | |
| 22 class CONTENT_EXPORT Status { | |
| 23 public: | |
| 24 bool IsError() const; | |
| 25 bool IsSuccess() const; | |
| 26 | |
| 27 // Returns a UTF-8 error message (non-localized) describing the error. | |
| 28 std::string ToString() const; | |
| 29 | |
| 30 static Status Success(); | |
| 31 static Status Error(); | |
| 32 | |
| 33 static Status ErrorEmptyKeyData(); | |
| 34 static Status ErrorEmptyData(); | |
| 35 static Status ErrorEmptySignatureData(); | |
| 36 static Status ErrorUnexpectedKeyType(); | |
| 37 | |
| 38 static Status ErrorJwkNotDictionary(); | |
| 39 static Status ErrorJwkMissingKty(); | |
| 40 static Status ErrorJwkExtractableInconsistent(); | |
| 41 static Status ErrorJwkUnrecognizedAlgorithm(); | |
| 42 static Status ErrorJwkAlgorithmInconsistent(); | |
| 43 static Status ErrorJwkAlgorithmMissing(); | |
| 44 static Status ErrorJwkUnrecognizedUsage(); | |
| 45 static Status ErrorJwkUsageInconsistent(); | |
| 46 static Status ErrorJwkDecodeK(); | |
| 47 static Status ErrorJwkDecodeN(); | |
| 48 static Status ErrorJwkDecodeE(); | |
| 49 static Status ErrorJwkRsaPrivateKeyUnsupported(); | |
| 50 static Status ErrorJwkUnrecognizedKty(); | |
| 51 | |
| 52 static Status ErrorIncorrectSizedIv(); | |
| 53 static Status ErrorDataTooBig(); | |
| 54 static Status ErrorUnsupported(); | |
| 55 static Status ErrorUnexpected(); | |
| 56 static Status ErrorInvalidAesGcmTagLength(); | |
| 57 static Status ErrorPublicExponent(); | |
| 58 static Status ErrorMissingAlgorithmRawKey(); | |
| 59 static Status ErrorEmptyModulus(); | |
| 60 static Status ErrorEmptyExponent(); | |
| 61 static Status ErrorKeyNotExtractable(); | |
| 62 static Status ErrorKeyLength(); | |
|
Ryan Sleevi
2014/01/24 20:27:01
At the risk of being a real PITA, can I ask you to
eroman
2014/01/25 00:53:10
Done. I have added comments for each of the errors
| |
| 63 | |
| 64 private: | |
| 65 // |error_details_utf8| can be NULL to indicate there was no error. | |
| 66 // Otherwise it is a UTF-8 string literal (the pointer must remain valid). | |
| 67 explicit Status(const char* error_details_utf8); | |
| 68 | |
| 69 const char* error_details_; | |
| 70 }; | |
| 71 | |
| 20 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a | 72 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a |
| 21 // convenience function for getting the pointer, and should not be used beyond | 73 // convenience function for getting the pointer, and should not be used beyond |
| 22 // the expected lifetime of |data|. | 74 // the expected lifetime of |data|. |
| 23 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); | 75 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); |
| 24 | 76 |
| 25 // Shrinks a WebArrayBuffer to a new size. | 77 // Shrinks a WebArrayBuffer to a new size. |
| 26 // TODO(eroman): This works by re-allocating a new buffer. It would be better if | 78 // TODO(eroman): This works by re-allocating a new buffer. It would be better if |
| 27 // the WebArrayBuffer could just be truncated instead. | 79 // the WebArrayBuffer could just be truncated instead. |
| 28 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); | 80 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); |
| 29 | 81 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 uint8 tag_length_bytes); | 139 uint8 tag_length_bytes); |
| 88 | 140 |
| 89 // Returns the internal block size for SHA-* | 141 // Returns the internal block size for SHA-* |
| 90 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); | 142 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); |
| 91 | 143 |
| 92 } // namespace webcrypto | 144 } // namespace webcrypto |
| 93 | 145 |
| 94 } // namespace content | 146 } // namespace content |
| 95 | 147 |
| 96 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 148 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| OLD | NEW |