Chromium Code Reviews| 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 WebCryptoDigestor(blink::WebCryptoAlgorithmId algorithmId) { } | |
|
eroman
2014/03/19 19:06:21
Remove this constructor
jww
2014/03/20 23:02:50
This is actually the constructor that the implemen
eroman
2014/03/20 23:14:02
This is just an interface class, there doesn't nee
| |
| 104 virtual ~WebCryptoDigestor() { } | |
| 105 | |
| 106 virtual bool consume(const unsigned char* data, unsigned dataSize) { return false; } | |
|
eroman
2014/03/19 19:06:21
I think it is worth describing what the return val
jww
2014/03/20 23:02:50
Done.
| |
| 107 virtual bool finish(WebArrayBuffer& result) { return false; } | |
|
eroman
2014/03/19 19:06:21
I actually think that rather than filling a WebArr
jww
2014/03/20 23:02:50
In my new version, I've implemented it pretty much
| |
| 108 | |
| 109 private: | |
| 110 WebCryptoDigestor() { } | |
| 111 }; | |
| 112 | |
| 100 class WebCrypto { | 113 class WebCrypto { |
| 101 public: | 114 public: |
| 102 // WebCrypto is the interface for starting one-shot cryptographic | 115 // WebCrypto is the interface for starting one-shot cryptographic |
| 103 // operations. | 116 // operations. |
| 104 // | 117 // |
| 105 // ----------------------- | 118 // ----------------------- |
| 106 // Completing the request | 119 // Completing the request |
| 107 // ----------------------- | 120 // ----------------------- |
| 108 // | 121 // |
| 109 // Implementations signal completion by calling one of the methods on | 122 // 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(); } | 188 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(); } | 189 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(); } | 190 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
| 178 // It is possible for the WebCryptoAlgorithm to be "isNull()" | 191 // 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(); } | 192 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(); } | 193 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(); } | 194 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() | 195 // 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(); } | 196 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 | 197 |
| 185 // This is the one exception to the "Completing the request" guarantees | 198 // These are the exceptions to the "Completing the request" guarantees |
| 186 // outlined above. digestSynchronous must provide the result into result | 199 // outlined above. digestSynchronous must provide the result into result |
| 187 // synchronously. It must return |true| on successful calculation of the | 200 // synchronously. It must return |true| on successful calculation of the |
| 188 // digest and |false| otherwise. This is useful for Blink internal crypto | 201 // digest and |false| otherwise. This is useful for Blink internal crypto |
| 189 // and is not part of the WebCrypto standard. | 202 // and is not part of the WebCrypto standard. digestorSynchronous returns a |
| 203 // WebCryptoDigestor object that consumes chunks synchronously and returns | |
| 204 // a result synchronously. | |
| 190 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } | 205 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } |
|
eroman
2014/03/19 19:06:21
Is this version already in use, or can it be delet
jww
2014/03/20 23:02:50
This is in use. Of course, it's not that hard to r
| |
| 206 virtual WebCryptoDigestor* digestorSynchronous(const WebCryptoAlgorithmId al gorithmId) { return 0; } | |
|
eroman
2014/03/19 19:06:21
I would say drop the const.
jww
2014/03/20 23:02:50
Done.
| |
| 191 | 207 |
| 192 protected: | 208 protected: |
| 193 virtual ~WebCrypto() { } | 209 virtual ~WebCrypto() { } |
| 194 }; | 210 }; |
| 195 | 211 |
| 196 } // namespace blink | 212 } // namespace blink |
| 197 | 213 |
| 198 #endif | 214 #endif |
| OLD | NEW |