Chromium Code Reviews| Index: public/platform/WebCrypto.h |
| diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h |
| index 7b56f4ef7bfd391eb1f6af186fb6449b04f3d94d..abea0f4bbd83726cc15f0e448ade186ffac565c0 100644 |
| --- a/public/platform/WebCrypto.h |
| +++ b/public/platform/WebCrypto.h |
| @@ -34,6 +34,7 @@ |
| #include "WebCommon.h" |
| #include "WebCryptoAlgorithm.h" |
| #include "WebCryptoKey.h" |
| +#include "WebPrivateOwnPtr.h" |
| #include "WebPrivatePtr.h" |
| // FIXME: Remove this once chromium side is updated. |
| @@ -97,6 +98,26 @@ private: |
| WebPrivatePtr<WebCore::CryptoResult> m_impl; |
| }; |
| +class WebCryptoDigestor { |
| +public: |
| + virtual ~WebCryptoDigestor() { } |
| + |
| + // consume() will return |true| on the successful addition of data to the |
| + // 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.
|
| + // a return of |false|, consume() should not be called again (nor should |
| + // finish() be called). |
| + virtual bool consume(const unsigned char* data, unsigned dataSize) { return false; } |
| + // 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.
|
| + // and put into the result buffer, otherwise it will return |false|. In |
| + // either case, neither finish() nor consume() should be called again after |
| + // a call to finish(). resultData is valid until the WebCrytpoDigestor |
| + // object is destroyed. |
| + virtual bool finish(unsigned char*& resultData, unsigned& resultDataSize) { return false; } |
| + |
| +protected: |
| + WebCryptoDigestor() { } |
| +}; |
| + |
| class WebCrypto { |
| public: |
| // WebCrypto is the interface for starting one-shot cryptographic |
| @@ -182,12 +203,12 @@ public: |
| // It is possible that unwrappedKeyAlgorithm.isNull() |
| virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAlgorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebCryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
| - // This is the one exception to the "Completing the request" guarantees |
| - // outlined above. digestSynchronous must provide the result into result |
| - // synchronously. It must return |true| on successful calculation of the |
| - // digest and |false| otherwise. This is useful for Blink internal crypto |
| + // This is the exception to the "Completing the request" guarantees |
| + // outlined above. digestorSynchronous must provide the result via the WebCryptoDigestor 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.
|
| + // This is useful for Blink internal crypto |
| // and is not part of the WebCrypto standard. |
| virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } |
| + virtual WebCryptoDigestor* digestorSynchronous(WebCryptoAlgorithmId algorithmId) { return 0; } |
|
eroman
2014/03/25 17:37:02
I propose calling this "createDigestor()". And lea
jww
2014/03/25 20:18:19
Done.
|
| protected: |
| virtual ~WebCrypto() { } |