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

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: 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 // FIXME: Remove this once chromium side is updated. 40 // FIXME: Remove this once chromium side is updated.
40 #define WEBCRYPTO_HMAC_BITS 1 41 #define WEBCRYPTO_HMAC_BITS 1
41 42
42 namespace WebCore { class CryptoResult; } 43 namespace WebCore { class CryptoResult; }
43 44
44 #if INSIDE_BLINK 45 #if INSIDE_BLINK
45 namespace WTF { template <typename T> class PassRefPtr; } 46 namespace WTF { template <typename T> class PassRefPtr; }
46 #endif 47 #endif
47 48
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // It is possible that unwrappedKeyAlgorithm.isNull() 183 // It is possible that unwrappedKeyAlgorithm.isNull()
183 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(); } 184 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(); }
184 185
185 // This is the one exception to the "Completing the request" guarantees 186 // This is the one exception to the "Completing the request" guarantees
186 // outlined above. digestSynchronous must provide the result into result 187 // outlined above. digestSynchronous must provide the result into result
187 // synchronously. It must return |true| on successful calculation of the 188 // synchronously. It must return |true| on successful calculation of the
188 // digest and |false| otherwise. This is useful for Blink internal crypto 189 // digest and |false| otherwise. This is useful for Blink internal crypto
189 // and is not part of the WebCrypto standard. 190 // and is not part of the WebCrypto standard.
190 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; } 191 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false; }
191 192
193 // -----------------------
194 // Structured clone
195 // -----------------------
196 //
197 // deserializeKeyForClone() and serializeKeyForClone() are used for
198 // implementing structured cloning of WebCryptoKey.
199 //
200 // Blink is responsible for saving and restoring all of the attributes of
201 // WebCryptoKey EXCEPT for the actual key data:
202 //
203 // In other words, blink takes care of serializing:
Ryan Sleevi 2014/03/12 22:54:35 s/blink/Blink/
204 // * Key usages
205 // * Key extractability
206 // * Key algorithm
207 // * Key type (public, private, secret)
208 //
209 // The embedder is responsible for saving the key data itself.
210 //
211 // For instance, an implementation might implement
212 // serializing/deserializing of the key data by reusing
213 // exportKey()/importKey() with an appropriate key format (raw, spki,
214 // pkcs8)
215 //
216 // Visibility of the serialized key data:
217 //
218 // The serialized key data will NOT be visible to web pages. So if the
219 // serialized format were to include key bytes as plain text, this wouldn't
220 // make it available to web pages. However, the serialized key data is
221 // visible to anyone with access to the user account (for instance by
222 // serializing to indexed DB). An implementation that wants to hide the
Ryan Sleevi 2014/03/12 22:54:35 s/indexed DB/IndexedDB/
223 // key data could encrypt it.
Ryan Sleevi 2014/03/12 22:54:35 I'd delete the remainder, starting with "However,
224 //
225 // Longevity of the key data:
226 //
227 // The serialized key data is intended to be long lived (years) and MUST
228 // be using a stable format. For instance a key might be persisted to
229 // indexed db and should be able to be deserialized correctly in the
230 // future.
Ryan Sleevi 2014/03/12 22:54:35 s/indexed db/IndexedDB/
231 //
232 // Error handling and asynchronous completion:
233 //
234 // Serialization/deserialization must complete synchronously, and will
235 // block the javascript thread.
Ryan Sleevi 2014/03/12 22:54:35 s/javascript/JavaScript/
236 //
237 // The only reasons for failing serialization/deserialization should be:
238 // * Key serialization not yet implemented
239 // * The bytes to deserialize were corrupted
240
241 // Creates a new key given key data which was written using
242 // serializeKeyForClone(). Returns true on success.
243 virtual bool deserializeKeyForClone(const WebCryptoKeyAlgorithm&, WebCryptoK eyType, bool extractable, WebCryptoKeyUsageMask, const unsigned char* keyData, u nsigned keyDataSize, WebCryptoKey&)
244 {
245 return false;
246 }
247
248 // Writes the key data into the given WebVector.
249 // Returns true on success.
250 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&)
251 {
252 return false;
253 }
254
192 protected: 255 protected:
193 virtual ~WebCrypto() { } 256 virtual ~WebCrypto() { }
194 }; 257 };
195 258
196 } // namespace blink 259 } // namespace blink
197 260
198 #endif 261 #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