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

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: 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 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:
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.
221 //
222 // Longevity of the key data:
223 //
224 // The serialized key data is intended to be long lived (years) and MUST
225 // be using a stable format. For instance a key might be persisted to
226 // IndexedDB and should be able to be deserialized correctly in the
227 // future.
228 //
229 // Error handling and asynchronous completion:
230 //
231 // Serialization/deserialization must complete synchronously, and will
232 // block the JavaScript thread.
233 //
234 // The only reasons for failing serialization/deserialization should be:
235 // * Key serialization not yet implemented
236 // * The bytes to deserialize were corrupted
237
238 // Creates a new key given key data which was written using
239 // serializeKeyForClone(). Returns true on success.
240 virtual bool deserializeKeyForClone(const WebCryptoKeyAlgorithm&, WebCryptoK eyType, bool extractable, WebCryptoKeyUsageMask, const unsigned char* keyData, u nsigned keyDataSize, WebCryptoKey&)
241 {
242 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
243 }
244
245 // Writes the key data into the given WebVector.
246 // Returns true on success.
247 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch ar>&)
248 {
249 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.
250 }
251
192 protected: 252 protected:
193 virtual ~WebCrypto() { } 253 virtual ~WebCrypto() { }
194 }; 254 };
195 255
196 } // namespace blink 256 } // namespace blink
197 257
198 #endif 258 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698