Index: public/platform/WebCrypto.h |
diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h |
index 0e3828117ecd463083850c7269d4a65bb2ebb0f3..fd67ad9835d11a893ee8ea7cddb95fc1c22c620b 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" |
eroman
2014/03/25 23:28:09
This is unused, delete it.
jww
2014/03/25 23:39:46
Yikes, good catch!
|
#include "WebPrivatePtr.h" |
#include "WebVector.h" |
@@ -95,6 +96,27 @@ 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 |
+ // 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 |
+ // 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; } |
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!
|
+ |
+protected: |
+ WebCryptoDigestor() { } |
+}; |
+ |
class WebCrypto { |
public: |
// WebCrypto is the interface for starting one-shot cryptographic |
@@ -176,12 +198,17 @@ public: |
virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebCryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { result.completeWithError(); } |
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 |
- // and is not part of the WebCrypto standard. |
+ // This is the exception to the "Completing the request" guarantees |
+ // outlined above. This is useful for Blink internal crypto and is not part |
+ // of the WebCrypto standard. digestSynchronous returns |true| if the |
+ // digest was successfully computed and put into result. Otherwise, returns |
+ // |false|. It must compute the digest or fail synchronously. |
+ // createDigestor must provide the result via the WebCryptoDigestor object |
+ // synchronously. createDigestor may return 0 if it fails to create a |
+ // WebCryptoDigestor. If it succeeds, the WebCryptoDigestor returned by |
+ // createDigestor must be freed by the caller. |
virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } |
+ virtual WebCryptoDigestor* createDigestor(WebCryptoAlgorithmId algorithmId) { return 0; } |
// ----------------------- |
// Structured clone |