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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WebCrypto_h 31 #ifndef WebCrypto_h
32 #define WebCrypto_h 32 #define WebCrypto_h
33 33
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 #include "WebCryptoAlgorithm.h" 35 #include "WebCryptoAlgorithm.h"
36 #include "WebCryptoKey.h" 36 #include "WebCryptoKey.h"
37 #include "WebPrivatePtr.h" 37 #include "WebPrivatePtr.h"
38 #include "WebVector.h"
38 39
39 namespace WebCore { class CryptoResult; } 40 namespace WebCore { class CryptoResult; }
40 41
41 #if INSIDE_BLINK 42 #if INSIDE_BLINK
42 namespace WTF { template <typename T> class PassRefPtr; } 43 namespace WTF { template <typename T> class PassRefPtr; }
43 #endif 44 #endif
44 45
45 namespace blink { 46 namespace blink {
46 47
47 class WebArrayBuffer; 48 class WebArrayBuffer;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); } 176 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu lt.completeWithError(); }
176 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } 177 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); }
177 178
178 // This is the one exception to the "Completing the request" guarantees 179 // This is the one exception to the "Completing the request" guarantees
179 // outlined above. digestSynchronous must provide the result into result 180 // outlined above. digestSynchronous must provide the result into result
180 // synchronously. It must return |true| on successful calculation of the 181 // synchronously. It must return |true| on successful calculation of the
181 // digest and |false| otherwise. This is useful for Blink internal crypto 182 // digest and |false| otherwise. This is useful for Blink internal crypto
182 // and is not part of the WebCrypto standard. 183 // and is not part of the WebCrypto standard.
183 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } 184 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; }
184 185
186 // -----------------------
187 // Structured clone
188 // -----------------------
189 //
190 // deserializeKeyForClone() and serializeKeyForClone() are used for
191 // implementing structured cloning of WebCryptoKey.
192 //
193 // Blink is responsible for saving and restoring all of the attributes of
194 // WebCryptoKey EXCEPT for the actual key data:
195 //
196 // In other words, Blink takes care of serializing:
197 // * Key usages
198 // * Key extractability
199 // * Key algorithm
200 // * Key type (public, private, secret)
201 //
202 // The embedder is responsible for saving the key data itself.
203 //
204 // Visibility of the serialized key data:
205 //
206 // The serialized key data will NOT be visible to web pages. So if the
207 // serialized format were to include key bytes as plain text, this wouldn't
208 // make it available to web pages.
209 //
210 // Longevity of the key data:
211 //
212 // The serialized key data is intended to be long lived (years) and MUST
213 // be using a stable format. For instance a key might be persisted to
214 // IndexedDB and should be able to be deserialized correctly in the
215 // future.
216 //
217 // Error handling and asynchronous completion:
218 //
219 // Serialization/deserialization must complete synchronously, and will
220 // block the JavaScript thread.
221 //
222 // The only reasons to fail serialization/deserialization are:
223 // * Key serialization not yet implemented
224 // * The bytes to deserialize were corrupted
225
226 // Creates a new key given key data which was written using
227 // serializeKeyForClone(). Returns true on success.
228 virtual bool deserializeKeyForClone(const WebCryptoKeyAlgorithm&, WebCryptoK eyType, bool extractable, WebCryptoKeyUsageMask, const unsigned char* keyData, u nsigned keyDataSize, WebCryptoKey&) { return false; }
229
230 // Writes the key data into the given WebVector.
231 // Returns true on success.
232 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&) { return false; }
233
185 protected: 234 protected:
186 virtual ~WebCrypto() { } 235 virtual ~WebCrypto() { }
187 }; 236 };
188 237
189 } // namespace blink 238 } // namespace blink
190 239
191 #endif 240 #endif
OLDNEW
« 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