Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1093)

Unified Diff: public/platform/WebCrypto.h

Issue 195543002: [webcrypto] Implement structured clone of keys (blink-side). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update serialized-script-value.html for version bump Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/exported/WebCryptoKeyAlgorithm.cpp ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/platform/WebCrypto.h
diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h
index a14fad6e2405fd6f20170b31103e148de88cca94..0e3828117ecd463083850c7269d4a65bb2ebb0f3 100644
--- a/public/platform/WebCrypto.h
+++ b/public/platform/WebCrypto.h
@@ -35,6 +35,7 @@
#include "WebCryptoAlgorithm.h"
#include "WebCryptoKey.h"
#include "WebPrivatePtr.h"
+#include "WebVector.h"
namespace WebCore { class CryptoResult; }
@@ -182,6 +183,54 @@ public:
// and is not part of the WebCrypto standard.
virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; }
+ // -----------------------
+ // Structured clone
+ // -----------------------
+ //
+ // deserializeKeyForClone() and serializeKeyForClone() are used for
+ // implementing structured cloning of WebCryptoKey.
+ //
+ // Blink is responsible for saving and restoring all of the attributes of
+ // WebCryptoKey EXCEPT for the actual key data:
+ //
+ // In other words, Blink takes care of serializing:
+ // * Key usages
+ // * Key extractability
+ // * Key algorithm
+ // * Key type (public, private, secret)
+ //
+ // The embedder is responsible for saving the key data itself.
+ //
+ // Visibility of the serialized key data:
+ //
+ // The serialized key data will NOT be visible to web pages. So if the
+ // serialized format were to include key bytes as plain text, this wouldn't
+ // make it available to web pages.
+ //
+ // Longevity of the key data:
+ //
+ // The serialized key data is intended to be long lived (years) and MUST
+ // be using a stable format. For instance a key might be persisted to
+ // IndexedDB and should be able to be deserialized correctly in the
+ // future.
+ //
+ // Error handling and asynchronous completion:
+ //
+ // Serialization/deserialization must complete synchronously, and will
+ // block the JavaScript thread.
+ //
+ // The only reasons to fail serialization/deserialization are:
+ // * Key serialization not yet implemented
+ // * The bytes to deserialize were corrupted
+
+ // Creates a new key given key data which was written using
+ // serializeKeyForClone(). Returns true on success.
+ virtual bool deserializeKeyForClone(const WebCryptoKeyAlgorithm&, WebCryptoKeyType, bool extractable, WebCryptoKeyUsageMask, const unsigned char* keyData, unsigned keyDataSize, WebCryptoKey&) { return false; }
+
+ // Writes the key data into the given WebVector.
+ // Returns true on success.
+ virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned char>&) { return false; }
+
protected:
virtual ~WebCrypto() { }
};
« no previous file with comments | « Source/platform/exported/WebCryptoKeyAlgorithm.cpp ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698