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" | |
37 #include "WebPrivatePtr.h" | 38 #include "WebPrivatePtr.h" |
38 | 39 |
39 // FIXME: Remove this once chromium side is updated. | 40 // FIXME: Remove this once chromium side is updated. |
40 #define WEBCRYPTO_HMAC_BITS 1 | 41 #define WEBCRYPTO_HMAC_BITS 1 |
41 | 42 |
42 namespace WebCore { class CryptoResult; } | 43 namespace WebCore { class CryptoResult; } |
43 | 44 |
44 #if INSIDE_BLINK | 45 #if INSIDE_BLINK |
45 namespace WTF { template <typename T> class PassRefPtr; } | 46 namespace WTF { template <typename T> class PassRefPtr; } |
46 #endif | 47 #endif |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore ::CryptoResult>&); | 91 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore ::CryptoResult>&); |
91 #endif | 92 #endif |
92 | 93 |
93 private: | 94 private: |
94 BLINK_PLATFORM_EXPORT void reset(); | 95 BLINK_PLATFORM_EXPORT void reset(); |
95 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); | 96 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); |
96 | 97 |
97 WebPrivatePtr<WebCore::CryptoResult> m_impl; | 98 WebPrivatePtr<WebCore::CryptoResult> m_impl; |
98 }; | 99 }; |
99 | 100 |
101 class WebCryptoDigestor { | |
102 public: | |
103 virtual ~WebCryptoDigestor() { } | |
104 | |
105 // consume() will return |true| on the successful addition of data to the | |
106 // partially generated digest. It will return |false when that fails. After | |
eroman
2014/03/25 17:37:02
missing "|false" --> "|false|"
jww
2014/03/25 20:18:19
Done.
| |
107 // a return of |false|, consume() should not be called again (nor should | |
108 // finish() be called). | |
109 virtual bool consume(const unsigned char* data, unsigned dataSize) { return false; } | |
110 // finish() will return |true| if the digest has been successfully computed | |
eroman
2014/03/25 17:37:02
nit: add a newline
jww
2014/03/25 20:18:19
Done.
| |
111 // and put into the result buffer, otherwise it will return |false|. In | |
112 // either case, neither finish() nor consume() should be called again after | |
113 // a call to finish(). resultData is valid until the WebCrytpoDigestor | |
114 // object is destroyed. | |
115 virtual bool finish(unsigned char*& resultData, unsigned& resultDataSize) { return false; } | |
116 | |
117 protected: | |
118 WebCryptoDigestor() { } | |
119 }; | |
120 | |
100 class WebCrypto { | 121 class WebCrypto { |
101 public: | 122 public: |
102 // WebCrypto is the interface for starting one-shot cryptographic | 123 // WebCrypto is the interface for starting one-shot cryptographic |
103 // operations. | 124 // operations. |
104 // | 125 // |
105 // ----------------------- | 126 // ----------------------- |
106 // Completing the request | 127 // Completing the request |
107 // ----------------------- | 128 // ----------------------- |
108 // | 129 // |
109 // Implementations signal completion by calling one of the methods on | 130 // Implementations signal completion by calling one of the methods on |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } | 196 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, unsigned signatureSize, const unsigned char* da ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } |
176 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); } | 197 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un signed dataSize, WebCryptoResult result) { result.completeWithError(); } |
177 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } | 198 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
178 // It is possible for the WebCryptoAlgorithm to be "isNull()" | 199 // It is possible for the WebCryptoAlgorithm to be "isNull()" |
179 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); } | 200 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag eMask, WebCryptoResult result) { result.completeWithError(); } |
180 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); } | 201 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes ult result) { result.completeWithError(); } |
181 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } | 202 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } |
182 // It is possible that unwrappedKeyAlgorithm.isNull() | 203 // It is possible that unwrappedKeyAlgorithm.isNull() |
183 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(); } | 204 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(); } |
184 | 205 |
185 // This is the one exception to the "Completing the request" guarantees | 206 // This is the exception to the "Completing the request" guarantees |
186 // outlined above. digestSynchronous must provide the result into result | 207 // outlined above. digestorSynchronous must provide the result via the WebCr yptoDigestor object synchronously. |
eroman
2014/03/25 17:37:02
Please also mention that 0 can be returned on fail
jww
2014/03/25 20:18:19
Done.
| |
187 // synchronously. It must return |true| on successful calculation of the | 208 // This is useful for Blink internal crypto |
188 // digest and |false| otherwise. This is useful for Blink internal crypto | |
189 // and is not part of the WebCrypto standard. | 209 // and is not part of the WebCrypto standard. |
190 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* digestorSynchronous(WebCryptoAlgorithmId algorith mId) { return 0; } | |
eroman
2014/03/25 17:37:02
I propose calling this "createDigestor()". And lea
jww
2014/03/25 20:18:19
Done.
| |
191 | 212 |
192 protected: | 213 protected: |
193 virtual ~WebCrypto() { } | 214 virtual ~WebCrypto() { } |
194 }; | 215 }; |
195 | 216 |
196 } // namespace blink | 217 } // namespace blink |
197 | 218 |
198 #endif | 219 #endif |
OLD | NEW |