OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef WebCrypto_h | 31 #ifndef WebCrypto_h |
32 #define WebCrypto_h | 32 #define WebCrypto_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
35 #include "WebCryptoAlgorithm.h" | 35 #include "WebCryptoAlgorithm.h" |
36 #include "WebCryptoKey.h" | 36 #include "WebCryptoKey.h" |
37 #include "WebPrivateOwnPtr.h" | |
eroman
2014/03/25 23:28:09
This is unused, delete it.
jww
2014/03/25 23:39:46
Yikes, good catch!
| |
37 #include "WebPrivatePtr.h" | 38 #include "WebPrivatePtr.h" |
38 #include "WebVector.h" | 39 #include "WebVector.h" |
39 | 40 |
40 namespace WebCore { class CryptoResult; } | 41 namespace WebCore { class CryptoResult; } |
41 | 42 |
42 #if INSIDE_BLINK | 43 #if INSIDE_BLINK |
43 namespace WTF { template <typename T> class PassRefPtr; } | 44 namespace WTF { template <typename T> class PassRefPtr; } |
44 #endif | 45 #endif |
45 | 46 |
46 namespace blink { | 47 namespace blink { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore ::CryptoResult>&); | 89 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore ::CryptoResult>&); |
89 #endif | 90 #endif |
90 | 91 |
91 private: | 92 private: |
92 BLINK_PLATFORM_EXPORT void reset(); | 93 BLINK_PLATFORM_EXPORT void reset(); |
93 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); | 94 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); |
94 | 95 |
95 WebPrivatePtr<WebCore::CryptoResult> m_impl; | 96 WebPrivatePtr<WebCore::CryptoResult> m_impl; |
96 }; | 97 }; |
97 | 98 |
99 class WebCryptoDigestor { | |
100 public: | |
101 virtual ~WebCryptoDigestor() { } | |
102 | |
103 // consume() will return |true| on the successful addition of data to the | |
104 // partially generated digest. It will return |false| when that fails. After | |
105 // a return of |false|, consume() should not be called again (nor should | |
106 // finish() be called). | |
107 virtual bool consume(const unsigned char* data, unsigned dataSize) { return false; } | |
108 | |
109 // finish() will return |true| if the digest has been successfully computed | |
110 // and put into the result buffer, otherwise it will return |false|. In | |
111 // either case, neither finish() nor consume() should be called again after | |
112 // a call to finish(). resultData is valid until the WebCrytpoDigestor | |
113 // object is destroyed. | |
114 virtual bool finish(unsigned char*& resultData, unsigned& resultDataSize) { return false; } | |
abarth-chromium
2014/03/25 21:06:36
How long is the returned char* valid? Until the W
jww
2014/03/25 21:12:07
Yes, until the WebCryptoDigestor is destroyed. I t
abarth-chromium
2014/03/25 21:16:31
So you did!
| |
115 | |
116 protected: | |
117 WebCryptoDigestor() { } | |
118 }; | |
119 | |
98 class WebCrypto { | 120 class WebCrypto { |
99 public: | 121 public: |
100 // WebCrypto is the interface for starting one-shot cryptographic | 122 // WebCrypto is the interface for starting one-shot cryptographic |
101 // operations. | 123 // operations. |
102 // | 124 // |
103 // ----------------------- | 125 // ----------------------- |
104 // Completing the request | 126 // Completing the request |
105 // ----------------------- | 127 // ----------------------- |
106 // | 128 // |
107 // Implementations signal completion by calling one of the methods on | 129 // Implementations signal completion by calling one of the methods on |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); } | 191 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete WithError(); } |
170 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit hError(); } | 192 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit hError(); } |
171 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } | 193 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } |
172 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); } | 194 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); } |
173 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } | 195 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
174 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); } | 196 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); } |
175 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); } | 197 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); } |
176 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } | 198 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } |
177 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } | 199 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
178 | 200 |
179 // This is the one exception to the "Completing the request" guarantees | 201 // This is the exception to the "Completing the request" guarantees |
180 // outlined above. digestSynchronous must provide the result into result | 202 // outlined above. This is useful for Blink internal crypto and is not part |
181 // synchronously. It must return |true| on successful calculation of the | 203 // of the WebCrypto standard. digestSynchronous returns |true| if the |
182 // digest and |false| otherwise. This is useful for Blink internal crypto | 204 // digest was successfully computed and put into result. Otherwise, returns |
183 // and is not part of the WebCrypto standard. | 205 // |false|. It must compute the digest or fail synchronously. |
206 // createDigestor must provide the result via the WebCryptoDigestor object | |
207 // synchronously. createDigestor may return 0 if it fails to create a | |
208 // WebCryptoDigestor. If it succeeds, the WebCryptoDigestor returned by | |
209 // createDigestor must be freed by the caller. | |
184 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } | 210 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } |
211 virtual WebCryptoDigestor* createDigestor(WebCryptoAlgorithmId algorithmId) { return 0; } | |
185 | 212 |
186 // ----------------------- | 213 // ----------------------- |
187 // Structured clone | 214 // Structured clone |
188 // ----------------------- | 215 // ----------------------- |
189 // | 216 // |
190 // deserializeKeyForClone() and serializeKeyForClone() are used for | 217 // deserializeKeyForClone() and serializeKeyForClone() are used for |
191 // implementing structured cloning of WebCryptoKey. | 218 // implementing structured cloning of WebCryptoKey. |
192 // | 219 // |
193 // Blink is responsible for saving and restoring all of the attributes of | 220 // Blink is responsible for saving and restoring all of the attributes of |
194 // WebCryptoKey EXCEPT for the actual key data: | 221 // WebCryptoKey EXCEPT for the actual key data: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 // Returns true on success. | 258 // Returns true on success. |
232 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&) { return false; } | 259 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&) { return false; } |
233 | 260 |
234 protected: | 261 protected: |
235 virtual ~WebCrypto() { } | 262 virtual ~WebCrypto() { } |
236 }; | 263 }; |
237 | 264 |
238 } // namespace blink | 265 } // namespace blink |
239 | 266 |
240 #endif | 267 #endif |
OLD | NEW |