OLD | NEW |
---|---|
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 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 #include "config.h" | 31 #include "config.h" |
32 #include "modules/crypto/SubtleCrypto.h" | 32 #include "modules/crypto/SubtleCrypto.h" |
33 | 33 |
34 #include "bindings/v8/Dictionary.h" | 34 #include "bindings/v8/Dictionary.h" |
35 #include "bindings/v8/ScriptPromiseResolverWithContext.h" | |
36 #include "core/dom/DOMException.h" | |
35 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
36 #include "modules/crypto/CryptoResultImpl.h" | 38 #include "modules/crypto/CrossThreadCryptoResult.h" |
37 #include "modules/crypto/Key.h" | 39 #include "modules/crypto/Key.h" |
40 #include "modules/crypto/KeyPair.h" | |
38 #include "modules/crypto/NormalizeAlgorithm.h" | 41 #include "modules/crypto/NormalizeAlgorithm.h" |
39 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
43 #include "public/platform/WebArrayBuffer.h" | |
40 #include "public/platform/WebCrypto.h" | 44 #include "public/platform/WebCrypto.h" |
41 #include "public/platform/WebCryptoAlgorithm.h" | 45 #include "public/platform/WebCryptoAlgorithm.h" |
42 #include "wtf/ArrayBufferView.h" | 46 #include "wtf/ArrayBufferView.h" |
43 | 47 |
44 namespace WebCore { | 48 namespace WebCore { |
45 | 49 |
50 class SubtleCrypto::PendingResult : public GarbageCollectedFinalized<PendingResu lt>, public CryptoResultBase { | |
51 public: | |
52 PendingResult(ScriptState* scriptState, RawPtr<SubtleCrypto> crypto) | |
haraken
2014/06/13 14:23:31
RawPtr<SubtleCrypto> => SubtleCrypto*
| |
53 : m_resolver(ScriptPromiseResolverWithContext::create(scriptState)) | |
54 , m_crypto(crypto) | |
55 , m_factory(this) | |
56 { | |
57 m_resolver->keepObjectWhilePending(crypto); | |
58 m_crypto->m_pendingResults.add(this); | |
59 } | |
60 | |
61 virtual ~PendingResult() { } | |
62 | |
63 virtual void completeWithError(blink::WebCryptoErrorType errorType, const bl ink::WebString& errorDetails) OVERRIDE | |
64 { | |
65 m_resolver->reject(DOMException::create(webCryptoErrorToExceptionCode(er rorType), errorDetails)); | |
66 unregisterThis(); | |
67 } | |
68 | |
69 virtual void completeWithBuffer(const blink::WebArrayBuffer& buffer) OVERRID E | |
70 { | |
71 m_resolver->resolve(PassRefPtr<ArrayBuffer>(buffer)); | |
72 unregisterThis(); | |
73 } | |
74 | |
75 virtual void completeWithBoolean(bool b) OVERRIDE | |
76 { | |
77 m_resolver->resolve(b); | |
78 unregisterThis(); | |
79 } | |
80 | |
81 virtual void completeWithKey(const blink::WebCryptoKey& key) OVERRIDE | |
82 { | |
83 m_resolver->resolve(Key::create(key)); | |
84 unregisterThis(); | |
85 } | |
86 | |
87 virtual void completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) OVERRIDE | |
88 { | |
89 m_resolver->resolve(KeyPair::create(publicKey, privateKey)); | |
90 unregisterThis(); | |
91 } | |
92 | |
93 ScriptPromise promise() { return m_resolver->promise(); } | |
94 | |
95 WeakPtr<PendingResult> createWeakPtr() { return m_factory.createWeakPtr(); } | |
96 | |
97 void trace(Visitor* visitor) { visitor->trace(m_crypto); } | |
98 | |
99 private: | |
100 void unregisterThis() | |
101 { | |
102 m_crypto->m_pendingResults.remove(this); | |
103 } | |
104 | |
105 RefPtr<ScriptPromiseResolverWithContext> m_resolver; | |
106 Member<SubtleCrypto> m_crypto; | |
107 WeakPtrFactory<PendingResult> m_factory; | |
108 }; | |
109 | |
46 // Seems like the generated bindings should take care of these however it | 110 // Seems like the generated bindings should take care of these however it |
47 // currently doesn't. See also http://crbug.com/264520 | 111 // currently doesn't. See also http://crbug.com/264520 |
48 static bool ensureNotNull(const ArrayPiece& x, const char* paramName, CryptoResu lt* result) | 112 static bool ensureNotNull(const ArrayPiece& x, const char* paramName, CryptoResu lt* result) |
49 { | 113 { |
50 if (x.isNull()) { | 114 if (x.isNull()) { |
51 String message = String("Invalid ") + paramName + String(" argument"); | 115 String message = String("Invalid ") + paramName + String(" argument"); |
52 result->completeWithError(blink::WebCryptoErrorTypeType, blink::WebStrin g(message)); | 116 result->completeWithError(blink::WebCryptoErrorTypeType, blink::WebStrin g(message)); |
53 return false; | 117 return false; |
54 } | 118 } |
55 return true; | 119 return true; |
(...skipping 22 matching lines...) Expand all Loading... | |
78 { | 142 { |
79 const SecurityOrigin* origin = scriptState->executionContext()->securityOrig in(); | 143 const SecurityOrigin* origin = scriptState->executionContext()->securityOrig in(); |
80 if (!origin->canAccessFeatureRequiringSecureOrigin()) { | 144 if (!origin->canAccessFeatureRequiringSecureOrigin()) { |
81 result->completeWithError(blink::WebCryptoErrorTypeNotSupported, "WebCry pto is only supported over secure origins. See http://crbug.com/373032"); | 145 result->completeWithError(blink::WebCryptoErrorTypeNotSupported, "WebCry pto is only supported over secure origins. See http://crbug.com/373032"); |
82 return false; | 146 return false; |
83 } | 147 } |
84 | 148 |
85 return true; | 149 return true; |
86 } | 150 } |
87 | 151 |
88 static ScriptPromise startCryptoOperation(ScriptState* scriptState, const Dictio nary& rawAlgorithm, Key* key, blink::WebCryptoOperation operationType, const Arr ayPiece& signature, const ArrayPiece& dataBuffer) | 152 ScriptPromise SubtleCrypto::startCryptoOperation(ScriptState* scriptState, const Dictionary& rawAlgorithm, Key* key, blink::WebCryptoOperation operationType, co nst ArrayPiece& signature, const ArrayPiece& dataBuffer) |
89 { | 153 { |
90 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 154 ScriptPromise promise; |
91 ScriptPromise promise = result->promise(); | 155 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
92 | 156 |
93 if (!canAccessWebCrypto(scriptState, result.get())) | 157 if (!canAccessWebCrypto(scriptState, result.get())) |
94 return promise; | 158 return promise; |
95 | 159 |
96 bool requiresKey = operationType != blink::WebCryptoOperationDigest; | 160 bool requiresKey = operationType != blink::WebCryptoOperationDigest; |
97 | 161 |
98 if (requiresKey && !ensureNotNull(key, "key", result.get())) | 162 if (requiresKey && !ensureNotNull(key, "key", result.get())) |
99 return promise; | 163 return promise; |
100 if (operationType == blink::WebCryptoOperationVerify && !ensureNotNull(signa ture, "signature", result.get())) | 164 if (operationType == blink::WebCryptoOperationVerify && !ensureNotNull(signa ture, "signature", result.get())) |
101 return promise; | 165 return promise; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 } | 198 } |
135 | 199 |
136 return promise; | 200 return promise; |
137 } | 201 } |
138 | 202 |
139 SubtleCrypto::SubtleCrypto() | 203 SubtleCrypto::SubtleCrypto() |
140 { | 204 { |
141 ScriptWrappable::init(this); | 205 ScriptWrappable::init(this); |
142 } | 206 } |
143 | 207 |
208 SubtleCrypto::~SubtleCrypto() | |
209 { | |
210 } | |
211 | |
144 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, Key* key, const ArrayPiece& data) | 212 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, Key* key, const ArrayPiece& data) |
145 { | 213 { |
146 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationEncrypt, ArrayPiece(), data); | 214 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationEncrypt, ArrayPiece(), data); |
147 } | 215 } |
148 | 216 |
149 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, Key* key, const ArrayPiece& data) | 217 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, Key* key, const ArrayPiece& data) |
150 { | 218 { |
151 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationDecrypt, ArrayPiece(), data); | 219 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationDecrypt, ArrayPiece(), data); |
152 } | 220 } |
153 | 221 |
154 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const Dictionary& raw Algorithm, Key* key, const ArrayPiece& data) | 222 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const Dictionary& raw Algorithm, Key* key, const ArrayPiece& data) |
155 { | 223 { |
156 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationSign, ArrayPiece(), data); | 224 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationSign, ArrayPiece(), data); |
157 } | 225 } |
158 | 226 |
159 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Dict ionary& rawAlgorithm, Key* key, const ArrayPiece& signature, const ArrayPiece& d ata) | 227 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Dict ionary& rawAlgorithm, Key* key, const ArrayPiece& signature, const ArrayPiece& d ata) |
160 { | 228 { |
161 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationVerify, signature, data); | 229 return startCryptoOperation(scriptState, rawAlgorithm, key, blink::WebCrypto OperationVerify, signature, data); |
162 } | 230 } |
163 | 231 |
164 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const Dictionary& r awAlgorithm, const ArrayPiece& data) | 232 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const Dictionary& r awAlgorithm, const ArrayPiece& data) |
165 { | 233 { |
166 return startCryptoOperation(scriptState, rawAlgorithm, 0, blink::WebCryptoOp erationDigest, ArrayPiece(), data); | 234 return startCryptoOperation(scriptState, rawAlgorithm, 0, blink::WebCryptoOp erationDigest, ArrayPiece(), data); |
167 } | 235 } |
168 | 236 |
169 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Dictiona ry& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) | 237 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Dictiona ry& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) |
170 { | 238 { |
171 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 239 ScriptPromise promise; |
172 ScriptPromise promise = result->promise(); | 240 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
173 | 241 |
174 if (!canAccessWebCrypto(scriptState, result.get())) | 242 if (!canAccessWebCrypto(scriptState, result.get())) |
175 return promise; | 243 return promise; |
176 | 244 |
177 blink::WebCryptoKeyUsageMask keyUsages; | 245 blink::WebCryptoKeyUsageMask keyUsages; |
178 if (!Key::parseUsageMask(rawKeyUsages, keyUsages, result.get())) | 246 if (!Key::parseUsageMask(rawKeyUsages, keyUsages, result.get())) |
179 return promise; | 247 return promise; |
180 | 248 |
181 blink::WebCryptoAlgorithm algorithm; | 249 blink::WebCryptoAlgorithm algorithm; |
182 if (!parseAlgorithm(rawAlgorithm, blink::WebCryptoOperationGenerateKey, algo rithm, result.get())) | 250 if (!parseAlgorithm(rawAlgorithm, blink::WebCryptoOperationGenerateKey, algo rithm, result.get())) |
183 return promise; | 251 return promise; |
184 | 252 |
185 blink::Platform::current()->crypto()->generateKey(algorithm, extractable, ke yUsages, result->result()); | 253 blink::Platform::current()->crypto()->generateKey(algorithm, extractable, ke yUsages, result->result()); |
186 return promise; | 254 return promise; |
187 } | 255 } |
188 | 256 |
189 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& keyData, const Dictionary& rawAlgorithm, bool extract able, const Vector<String>& rawKeyUsages) | 257 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& keyData, const Dictionary& rawAlgorithm, bool extract able, const Vector<String>& rawKeyUsages) |
190 { | 258 { |
191 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 259 ScriptPromise promise; |
192 ScriptPromise promise = result->promise(); | 260 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
193 | 261 |
194 if (!canAccessWebCrypto(scriptState, result.get())) | 262 if (!canAccessWebCrypto(scriptState, result.get())) |
195 return promise; | 263 return promise; |
196 | 264 |
197 if (!ensureNotNull(keyData, "keyData", result.get())) | 265 if (!ensureNotNull(keyData, "keyData", result.get())) |
198 return promise; | 266 return promise; |
199 | 267 |
200 blink::WebCryptoKeyFormat format; | 268 blink::WebCryptoKeyFormat format; |
201 if (!Key::parseFormat(rawFormat, format, result.get())) | 269 if (!Key::parseFormat(rawFormat, format, result.get())) |
202 return promise; | 270 return promise; |
203 | 271 |
204 blink::WebCryptoKeyUsageMask keyUsages; | 272 blink::WebCryptoKeyUsageMask keyUsages; |
205 if (!Key::parseUsageMask(rawKeyUsages, keyUsages, result.get())) | 273 if (!Key::parseUsageMask(rawKeyUsages, keyUsages, result.get())) |
206 return promise; | 274 return promise; |
207 | 275 |
208 blink::WebCryptoAlgorithm algorithm; | 276 blink::WebCryptoAlgorithm algorithm; |
209 if (!parseAlgorithm(rawAlgorithm, blink::WebCryptoOperationImportKey, algori thm, result.get())) | 277 if (!parseAlgorithm(rawAlgorithm, blink::WebCryptoOperationImportKey, algori thm, result.get())) |
210 return promise; | 278 return promise; |
211 | 279 |
212 blink::Platform::current()->crypto()->importKey(format, keyData.bytes(), key Data.byteLength(), algorithm, extractable, keyUsages, result->result()); | 280 blink::Platform::current()->crypto()->importKey(format, keyData.bytes(), key Data.byteLength(), algorithm, extractable, keyUsages, result->result()); |
213 return promise; | 281 return promise; |
214 } | 282 } |
215 | 283 |
216 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, const String& ra wFormat, Key* key) | 284 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, const String& ra wFormat, Key* key) |
217 { | 285 { |
218 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 286 ScriptPromise promise; |
219 ScriptPromise promise = result->promise(); | 287 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
220 | 288 |
221 if (!canAccessWebCrypto(scriptState, result.get())) | 289 if (!canAccessWebCrypto(scriptState, result.get())) |
222 return promise; | 290 return promise; |
223 | 291 |
224 if (!ensureNotNull(key, "key", result.get())) | 292 if (!ensureNotNull(key, "key", result.get())) |
225 return promise; | 293 return promise; |
226 | 294 |
227 blink::WebCryptoKeyFormat format; | 295 blink::WebCryptoKeyFormat format; |
228 if (!Key::parseFormat(rawFormat, format, result.get())) | 296 if (!Key::parseFormat(rawFormat, format, result.get())) |
229 return promise; | 297 return promise; |
230 | 298 |
231 if (!key->extractable()) { | 299 if (!key->extractable()) { |
232 result->completeWithError(blink::WebCryptoErrorTypeInvalidAccess, "key i s not extractable"); | 300 result->completeWithError(blink::WebCryptoErrorTypeInvalidAccess, "key i s not extractable"); |
233 return promise; | 301 return promise; |
234 } | 302 } |
235 | 303 |
236 blink::Platform::current()->crypto()->exportKey(format, key->key(), result-> result()); | 304 blink::Platform::current()->crypto()->exportKey(format, key->key(), result-> result()); |
237 return promise; | 305 return promise; |
238 } | 306 } |
239 | 307 |
240 ScriptPromise SubtleCrypto::wrapKey(ScriptState* scriptState, const String& rawF ormat, Key* key, Key* wrappingKey, const Dictionary& rawWrapAlgorithm) | 308 ScriptPromise SubtleCrypto::wrapKey(ScriptState* scriptState, const String& rawF ormat, Key* key, Key* wrappingKey, const Dictionary& rawWrapAlgorithm) |
241 { | 309 { |
242 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 310 ScriptPromise promise; |
243 ScriptPromise promise = result->promise(); | 311 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
244 | 312 |
245 if (!canAccessWebCrypto(scriptState, result.get())) | 313 if (!canAccessWebCrypto(scriptState, result.get())) |
246 return promise; | 314 return promise; |
247 | 315 |
248 if (!ensureNotNull(key, "key", result.get())) | 316 if (!ensureNotNull(key, "key", result.get())) |
249 return promise; | 317 return promise; |
250 | 318 |
251 if (!ensureNotNull(wrappingKey, "wrappingKey", result.get())) | 319 if (!ensureNotNull(wrappingKey, "wrappingKey", result.get())) |
252 return promise; | 320 return promise; |
253 | 321 |
(...skipping 12 matching lines...) Expand all Loading... | |
266 | 334 |
267 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, blink::WebCryptoOpera tionWrapKey, result.get())) | 335 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, blink::WebCryptoOpera tionWrapKey, result.get())) |
268 return promise; | 336 return promise; |
269 | 337 |
270 blink::Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKe y->key(), wrapAlgorithm, result->result()); | 338 blink::Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKe y->key(), wrapAlgorithm, result->result()); |
271 return promise; | 339 return promise; |
272 } | 340 } |
273 | 341 |
274 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& wrappedKey, Key* unwrappingKey, const Dictionary& raw UnwrapAlgorithm, const Dictionary& rawUnwrappedKeyAlgorithm, bool extractable, c onst Vector<String>& rawKeyUsages) | 342 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& wrappedKey, Key* unwrappingKey, const Dictionary& raw UnwrapAlgorithm, const Dictionary& rawUnwrappedKeyAlgorithm, bool extractable, c onst Vector<String>& rawKeyUsages) |
275 { | 343 { |
276 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 344 ScriptPromise promise; |
277 ScriptPromise promise = result->promise(); | 345 RefPtr<CrossThreadCryptoResult<PendingResult> > result = createCrossThreadCr yptoResult(scriptState, &promise); |
278 | 346 |
279 if (!canAccessWebCrypto(scriptState, result.get())) | 347 if (!canAccessWebCrypto(scriptState, result.get())) |
280 return promise; | 348 return promise; |
281 | 349 |
282 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get())) | 350 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get())) |
283 return promise; | 351 return promise; |
284 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get())) | 352 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get())) |
285 return promise; | 353 return promise; |
286 | 354 |
287 blink::WebCryptoKeyFormat format; | 355 blink::WebCryptoKeyFormat format; |
(...skipping 12 matching lines...) Expand all Loading... | |
300 if (!parseAlgorithm(rawUnwrappedKeyAlgorithm, blink::WebCryptoOperationImpor tKey, unwrappedKeyAlgorithm, result.get())) | 368 if (!parseAlgorithm(rawUnwrappedKeyAlgorithm, blink::WebCryptoOperationImpor tKey, unwrappedKeyAlgorithm, result.get())) |
301 return promise; | 369 return promise; |
302 | 370 |
303 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, blink::WebCryptoO perationUnwrapKey, result.get())) | 371 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, blink::WebCryptoO perationUnwrapKey, result.get())) |
304 return promise; | 372 return promise; |
305 | 373 |
306 blink::Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrappedKey.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgo rithm, extractable, keyUsages, result->result()); | 374 blink::Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrappedKey.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgo rithm, extractable, keyUsages, result->result()); |
307 return promise; | 375 return promise; |
308 } | 376 } |
309 | 377 |
378 PassRefPtr<CrossThreadCryptoResult<SubtleCrypto::PendingResult> > SubtleCrypto:: createCrossThreadCryptoResult(ScriptState* scriptState, ScriptPromise* promise) | |
379 { | |
380 RawPtr<PendingResult> pending = new PendingResult(scriptState, this); | |
haraken
2014/06/13 14:23:31
RawPtr<PendingResult> => PendingResult*
| |
381 RefPtr<CrossThreadCryptoResult<PendingResult> > result = CrossThreadCryptoRe sult<PendingResult>::create(pending->createWeakPtr()); | |
382 *promise = pending->promise(); | |
383 return result.release(); | |
384 } | |
385 | |
386 void SubtleCrypto::trace(Visitor* visitor) | |
387 { | |
388 visitor->trace(m_pendingResults); | |
389 } | |
390 | |
310 } // namespace WebCore | 391 } // namespace WebCore |
OLD | NEW |