Index: public/platform/WebCrypto.h |
diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h |
index 5428e9f20df3fcbe46a94ad550d990ce0512a4cc..3a03349286e0664369bd0d1042a6ad670ed86d8d 100644 |
--- a/public/platform/WebCrypto.h |
+++ b/public/platform/WebCrypto.h |
@@ -38,222 +38,81 @@ |
namespace WebKit { |
class WebArrayBuffer; |
-class WebCryptoKeyOperation; |
-class WebCryptoKeyOperationResult; |
class WebCryptoOperation; |
-class WebCryptoOperationResult; |
-class WebCrypto { |
+class WebCryptoResultPrivate { |
public: |
- // FIXME: Deprecated, delete once chromium side is updated. |
- virtual WebCryptoOperation* digest(const WebCryptoAlgorithm&) { WEBKIT_ASSERT_NOT_REACHED(); return 0; } |
- |
- // The following methods begin an asynchronous multi-part cryptographic |
- // operation. |
- // |
- // Let the WebCryptoOperationResult& be called "result". |
- // |
- // Before returning, implementations can either: |
- // |
- // * Synchronously fail initialization by calling: |
- // result.initializationFailed(errorDetails) |
- // |
- // OR |
- // |
- // * Create a new WebCryptoOperation* and return it by calling: |
- // result.initializationSucceeded(cryptoOperation) |
- // |
- // If initialization succeeds, then Blink will subsequently call |
- // methods on cryptoOperation: |
- // |
- // - cryptoOperation->process() to feed it data |
- // - cryptoOperation->finish() to indicate there is no more data |
- // - cryptoOperation->abort() to cancel. |
- // |
- // The embedder may call result.completeWithXXX() at any time while the |
- // cryptoOperation is "in progress" (can copy the initial "result" object). |
- // Typically completion is set once cryptoOperation->finish() is called, |
- // however it can also be called during cryptoOperation->process() (for |
- // instance to set an error). |
- // |
- // The cryptoOperation pointer MUST remain valid while it is "in progress". |
- // The cryptoOperation is said to be "in progress" from the time after |
- // result->initializationSucceded() has been called, up until either: |
- // |
- // - Blink calls cryptoOperation->abort() |
- // OR |
- // - Embedder calls result.completeWithXXX() |
- // |
- // Once the cryptoOperation is no longer "in progress" the embedder is |
- // responsible for freeing the cryptoOperation. |
- virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, WebCryptoOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, WebCryptoOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, WebCryptoOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, size_t, WebCryptoOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- virtual void digest(const WebCryptoAlgorithm&, WebCryptoOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- |
- // The following methods begin an asynchronous single-part key operation. |
- // |
- // Let the WebCryptoKeyOperationResult& be called "result". |
- // |
- // Before returning, implementations can either: |
- // |
- // (a) Synchronously fail initialization by calling: |
- // result.initializationFailed(errorDetails) |
- // (this results in throwing a Javascript exception) |
- // |
- // (b) Synchronously complete the request (success or error) by calling: |
- // result.completeWithXXX() |
- // |
- // (c) Defer completion by calling |
- // result.initializationSucceeded(keyOperation) |
- // |
- // If asynchronous completion (c) was chosen, then the embedder can notify |
- // completion after returning by calling result.completeWithXXX() (can make |
- // a copy of "result"). |
- // |
- // The keyOperation pointer MUST remain valid while it is "in progress". |
- // The keyOperation is said to be "in progress" from the time after |
- // result->initializationSucceded() has been called, up until either: |
- // |
- // - Blink calls keyOperation->abort() |
- // OR |
- // - Embedder calls result.completeWithXXX() |
- // |
- // Once the keyOperation is no longer "in progress" the embedder is |
- // responsible for freeing the cryptoOperation. |
- virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoKeyOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, size_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoKeyOperationResult&) { WEBKIT_ASSERT_NOT_REACHED(); } |
- |
-protected: |
- virtual ~WebCrypto() { } |
-}; |
- |
-class WebCryptoOperation { |
-public: |
- // Feeds data (bytes, size) to the operation. |
- // - |bytes| may be 0 if |size| is 0 |
- // - |bytes| is valid only until process() returns |
- // - process() will not be called after abort() or finish() |
- virtual void process(const unsigned char*, size_t) = 0; |
- |
- // Cancels the in-progress operation. |
- // * Implementations should delete |this| after aborting. |
- virtual void abort() = 0; |
- |
- // Indicates that there is no more data to receive. |
- virtual void finish() = 0; |
- |
-protected: |
- virtual ~WebCryptoOperation() { } |
-}; |
- |
-// Can be implemented by embedder for unit-testing. |
-class WebCryptoOperationResultPrivate { |
-public: |
- virtual ~WebCryptoOperationResultPrivate() { } |
+ virtual void ref() = 0; |
+ virtual void deref() = 0; |
- virtual void initializationFailed() = 0; |
- virtual void initializationSucceeded(WebCryptoOperation*) = 0; |
virtual void completeWithError() = 0; |
- virtual void completeWithArrayBuffer(const WebArrayBuffer&) = 0; |
+ virtual void completeWithBuffer(const WebArrayBuffer&) = 0; |
virtual void completeWithBoolean(bool) = 0; |
+ virtual void completeWithKey(const WebCryptoKey&) = 0; |
- virtual void ref() = 0; |
- virtual void deref() = 0; |
+protected: |
+ virtual ~WebCryptoResultPrivate() { } |
}; |
-// FIXME: Add error types. |
-class WebCryptoOperationResult { |
+class WebCryptoResult { |
public: |
- explicit WebCryptoOperationResult(WebCryptoOperationResultPrivate* impl) |
+ WebCryptoResult(WebCryptoResultPrivate* impl) |
{ |
assign(impl); |
} |
- ~WebCryptoOperationResult() { reset(); } |
- |
- WebCryptoOperationResult(const WebCryptoOperationResult& o) |
+ WebCryptoResult(const WebCryptoResult& o) |
{ |
assign(o); |
} |
- WebCryptoOperationResult& operator=(const WebCryptoOperationResult& o) |
+ ~WebCryptoResult() |
+ { |
+ reset(); |
+ } |
+ |
+ WebCryptoResult& operator=(const WebCryptoResult& o) |
{ |
assign(o); |
return *this; |
} |
- WEBKIT_EXPORT void initializationFailed(); |
- WEBKIT_EXPORT void initializationSucceeded(WebCryptoOperation*); |
WEBKIT_EXPORT void completeWithError(); |
- WEBKIT_EXPORT void completeWithArrayBuffer(const WebArrayBuffer&); |
+ WEBKIT_EXPORT void completeWithBuffer(const WebArrayBuffer&); |
+ WEBKIT_EXPORT void completeWithBuffer(const void*, size_t); |
WEBKIT_EXPORT void completeWithBoolean(bool); |
+ WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&); |
private: |
WEBKIT_EXPORT void reset(); |
- WEBKIT_EXPORT void assign(const WebCryptoOperationResult&); |
- WEBKIT_EXPORT void assign(WebCryptoOperationResultPrivate*); |
- |
- WebPrivatePtr<WebCryptoOperationResultPrivate> m_impl; |
-}; |
- |
-class WebCryptoKeyOperation { |
-public: |
- // Cancels the in-progress operation. |
- // * Implementations should delete |this| after aborting. |
- virtual void abort() = 0; |
- |
-protected: |
- virtual ~WebCryptoKeyOperation() { } |
-}; |
+ WEBKIT_EXPORT void assign(const WebCryptoResult&); |
+ WEBKIT_EXPORT void assign(WebCryptoResultPrivate*); |
-// Can be implemented by embedder for unit-testing. |
-class WebCryptoKeyOperationResultPrivate { |
-public: |
- virtual ~WebCryptoKeyOperationResultPrivate() { } |
- |
- virtual void initializationFailed() = 0; |
- virtual void initializationSucceeded(WebCryptoKeyOperation*) = 0; |
- virtual void completeWithError() = 0; |
- virtual void completeWithKey(const WebCryptoKey&) = 0; |
- |
- virtual void ref() = 0; |
- virtual void deref() = 0; |
+ WebPrivatePtr<WebCryptoResultPrivate> m_impl; |
}; |
-class WebCryptoKeyOperationResult { |
+class WebCrypto { |
public: |
- explicit WebCryptoKeyOperationResult(WebCryptoKeyOperationResultPrivate* impl) |
- { |
- assign(impl); |
- } |
- |
- ~WebCryptoKeyOperationResult() { reset(); } |
- |
- WebCryptoKeyOperationResult(const WebCryptoKeyOperationResult& o) |
- { |
- assign(o); |
- } |
- |
- WebCryptoKeyOperationResult& operator=(const WebCryptoKeyOperationResult& o) |
- { |
- assign(o); |
- return *this; |
- } |
- |
- WEBKIT_EXPORT void initializationFailed(); |
- WEBKIT_EXPORT void initializationSucceeded(WebCryptoKeyOperation*); |
- |
- WEBKIT_EXPORT void completeWithError(); |
- WEBKIT_EXPORT void completeWithKey(const WebCryptoKey&); |
+ // FIXME: Deprecated, delete once chromium side is updated. |
+ virtual WebCryptoOperation* digest(const WebCryptoAlgorithm&) { WEBKIT_ASSERT_NOT_REACHED(); return 0; } |
-private: |
- WEBKIT_EXPORT void reset(); |
- WEBKIT_EXPORT void assign(const WebCryptoKeyOperationResult&); |
- WEBKIT_EXPORT void assign(WebCryptoKeyOperationResultPrivate*); |
+ // Starts a one-shot cryptographic operation which can complete either |
+ // synchronously, or asynchronously. |
+ // |
+ // Let the WebCryptoResult be called "result". |
+ // |
+ // The result should be set exactly once, from the same thread which |
+ // initiated the operation. |
+ virtual void encrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsigned char* signature, size_t signature_size, const unsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, size_t data_size, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
+ virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, size_t keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsageMask, WebCryptoResult) { WEBKIT_ASSERT_NOT_REACHED(); } |
- WebPrivatePtr<WebCryptoKeyOperationResultPrivate> m_impl; |
+protected: |
+ virtual ~WebCrypto() { } |
}; |
} // namespace WebKit |