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

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: fix another comment 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
Index: public/platform/WebCrypto.h
diff --git a/public/platform/WebCrypto.h b/public/platform/WebCrypto.h
index 7b56f4ef7bfd391eb1f6af186fb6449b04f3d94d..bbc594a29cceab1d79f4b8541e3559116acf7801 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"
// FIXME: Remove this once chromium side is updated.
#define WEBCRYPTO_HMAC_BITS 1
@@ -189,6 +190,65 @@ 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.
+ //
+ // For instance, an implementation might implement
+ // serializing/deserializing of the key data by reusing
+ // exportKey()/importKey() with an appropriate key format (raw, spki,
+ // pkcs8)
+ //
+ // 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 for failing serialization/deserialization should be:
+ // * 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;
jsbell 2014/03/13 20:16:07 This default impl. can all be on one (very long) l
eroman 2014/03/14 05:24:33 Done (am using clang-format and it put it on a new
+ }
+
+ // Writes the key data into the given WebVector.
+ // Returns true on success.
+ virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned char>&)
+ {
+ return false;
jsbell 2014/03/13 20:16:07 This default impl. can all be on one (very long) l
eroman 2014/03/14 05:24:33 Done.
+ }
+
protected:
virtual ~WebCrypto() { }
};

Powered by Google App Engine
This is Rietveld 408576698