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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return WebVector<uint8_t>(static_cast<uint8_t*>(source.data()), | 168 return WebVector<uint8_t>(static_cast<uint8_t*>(source.data()), |
169 source.byteLength()); | 169 source.byteLength()); |
170 } | 170 } |
171 | 171 |
172 SubtleCrypto::SubtleCrypto() {} | 172 SubtleCrypto::SubtleCrypto() {} |
173 | 173 |
174 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, | 174 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, |
175 const AlgorithmIdentifier& rawAlgorithm, | 175 const AlgorithmIdentifier& rawAlgorithm, |
176 CryptoKey* key, | 176 CryptoKey* key, |
177 const BufferSource& rawData) { | 177 const BufferSource& rawData) { |
178 // Method described by: https://w3c.github.io/webcrypto/Overview.html#dfn-Subt
leCrypto-method-encrypt | 178 // Method described by: |
| 179 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-encry
pt |
179 | 180 |
180 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 181 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
181 ScriptPromise promise = result->promise(); | 182 ScriptPromise promise = result->promise(); |
182 | 183 |
183 if (!canAccessWebCrypto(scriptState, result)) | 184 if (!canAccessWebCrypto(scriptState, result)) |
184 return promise; | 185 return promise; |
185 | 186 |
186 // 14.3.1.2: Let data be the result of getting a copy of the bytes held by | 187 // 14.3.1.2: Let data be the result of getting a copy of the bytes held by |
187 // the data parameter passed to the encrypt method. | 188 // the data parameter passed to the encrypt method. |
188 WebVector<uint8_t> data = copyBytes(rawData); | 189 WebVector<uint8_t> data = copyBytes(rawData); |
(...skipping 19 matching lines...) Expand all Loading... |
208 normalizedAlgorithm, key->key()); | 209 normalizedAlgorithm, key->key()); |
209 Platform::current()->crypto()->encrypt(normalizedAlgorithm, key->key(), | 210 Platform::current()->crypto()->encrypt(normalizedAlgorithm, key->key(), |
210 std::move(data), result->result()); | 211 std::move(data), result->result()); |
211 return promise; | 212 return promise; |
212 } | 213 } |
213 | 214 |
214 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, | 215 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, |
215 const AlgorithmIdentifier& rawAlgorithm, | 216 const AlgorithmIdentifier& rawAlgorithm, |
216 CryptoKey* key, | 217 CryptoKey* key, |
217 const BufferSource& rawData) { | 218 const BufferSource& rawData) { |
218 // Method described by: https://w3c.github.io/webcrypto/Overview.html#dfn-Subt
leCrypto-method-decrypt | 219 // Method described by: |
| 220 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-decry
pt |
219 | 221 |
220 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 222 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
221 ScriptPromise promise = result->promise(); | 223 ScriptPromise promise = result->promise(); |
222 | 224 |
223 if (!canAccessWebCrypto(scriptState, result)) | 225 if (!canAccessWebCrypto(scriptState, result)) |
224 return promise; | 226 return promise; |
225 | 227 |
226 // 14.3.2.2: Let data be the result of getting a copy of the bytes held by | 228 // 14.3.2.2: Let data be the result of getting a copy of the bytes held by |
227 // the data parameter passed to the decrypt method. | 229 // the data parameter passed to the decrypt method. |
228 WebVector<uint8_t> data = copyBytes(rawData); | 230 WebVector<uint8_t> data = copyBytes(rawData); |
(...skipping 19 matching lines...) Expand all Loading... |
248 normalizedAlgorithm, key->key()); | 250 normalizedAlgorithm, key->key()); |
249 Platform::current()->crypto()->decrypt(normalizedAlgorithm, key->key(), | 251 Platform::current()->crypto()->decrypt(normalizedAlgorithm, key->key(), |
250 std::move(data), result->result()); | 252 std::move(data), result->result()); |
251 return promise; | 253 return promise; |
252 } | 254 } |
253 | 255 |
254 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, | 256 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, |
255 const AlgorithmIdentifier& rawAlgorithm, | 257 const AlgorithmIdentifier& rawAlgorithm, |
256 CryptoKey* key, | 258 CryptoKey* key, |
257 const BufferSource& rawData) { | 259 const BufferSource& rawData) { |
258 // Method described by: https://w3c.github.io/webcrypto/Overview.html#dfn-Subt
leCrypto-method-sign | 260 // Method described by: |
| 261 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-sign |
259 | 262 |
260 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 263 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
261 ScriptPromise promise = result->promise(); | 264 ScriptPromise promise = result->promise(); |
262 | 265 |
263 if (!canAccessWebCrypto(scriptState, result)) | 266 if (!canAccessWebCrypto(scriptState, result)) |
264 return promise; | 267 return promise; |
265 | 268 |
266 // 14.3.3.2: Let data be the result of getting a copy of the bytes held by | 269 // 14.3.3.2: Let data be the result of getting a copy of the bytes held by |
267 // the data parameter passed to the sign method. | 270 // the data parameter passed to the sign method. |
268 WebVector<uint8_t> data = copyBytes(rawData); | 271 WebVector<uint8_t> data = copyBytes(rawData); |
(...skipping 21 matching lines...) Expand all Loading... |
290 std::move(data), result->result()); | 293 std::move(data), result->result()); |
291 return promise; | 294 return promise; |
292 } | 295 } |
293 | 296 |
294 ScriptPromise SubtleCrypto::verifySignature( | 297 ScriptPromise SubtleCrypto::verifySignature( |
295 ScriptState* scriptState, | 298 ScriptState* scriptState, |
296 const AlgorithmIdentifier& rawAlgorithm, | 299 const AlgorithmIdentifier& rawAlgorithm, |
297 CryptoKey* key, | 300 CryptoKey* key, |
298 const BufferSource& rawSignature, | 301 const BufferSource& rawSignature, |
299 const BufferSource& rawData) { | 302 const BufferSource& rawData) { |
300 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-verify | 303 // Method described by: |
| 304 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-verify |
301 | 305 |
302 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 306 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
303 ScriptPromise promise = result->promise(); | 307 ScriptPromise promise = result->promise(); |
304 | 308 |
305 if (!canAccessWebCrypto(scriptState, result)) | 309 if (!canAccessWebCrypto(scriptState, result)) |
306 return promise; | 310 return promise; |
307 | 311 |
308 // 14.3.4.2: Let signature be the result of getting a copy of the bytes | 312 // 14.3.4.2: Let signature be the result of getting a copy of the bytes |
309 // held by the signature parameter passed to the verify method. | 313 // held by the signature parameter passed to the verify method. |
310 WebVector<uint8_t> signature = copyBytes(rawSignature); | 314 WebVector<uint8_t> signature = copyBytes(rawSignature); |
311 | 315 |
312 // 14.3.4.3: Let data be the result of getting a copy of the bytes held by | 316 // 14.3.4.3: Let data be the result of getting a copy of the bytes held by |
313 // the data parameter passed to the verify method. | 317 // the data parameter passed to the verify method. |
314 WebVector<uint8_t> data = copyBytes(rawData); | 318 WebVector<uint8_t> data = copyBytes(rawData); |
315 | 319 |
316 // 14.3.4.4: Let normalizedAlgorithm be the result of normalizing an | 320 // 14.3.4.4: Let normalizedAlgorithm be the result of normalizing an |
317 // algorithm, with alg set to algorithm and op set to "verify". | 321 // algorithm, with alg set to algorithm and op set to "verify". |
318 WebCryptoAlgorithm normalizedAlgorithm; | 322 WebCryptoAlgorithm normalizedAlgorithm; |
319 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationVerify, | 323 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationVerify, |
320 normalizedAlgorithm, result)) | 324 normalizedAlgorithm, result)) |
321 return promise; | 325 return promise; |
322 | 326 |
323 // 14.3.4.9: If the name member of normalizedAlgorithm is not equal to the | 327 // 14.3.4.9: If the name member of normalizedAlgorithm is not equal to the |
324 // name attribute of the [[algorithm]] internal slot of key then thr
ow an | 328 // name attribute of the [[algorithm]] internal slot of key then |
325 // InvalidAccessError. | 329 // throw an InvalidAccessError. |
326 // | 330 // |
327 // 14.3.4.10: If the [[usages]] internal slot of key does not contain an | 331 // 14.3.4.10: If the [[usages]] internal slot of key does not contain an |
328 // entry that is "verify", then throw an InvalidAccessError. | 332 // entry that is "verify", then throw an InvalidAccessError. |
329 if (!key->canBeUsedForAlgorithm(normalizedAlgorithm, WebCryptoKeyUsageVerify, | 333 if (!key->canBeUsedForAlgorithm(normalizedAlgorithm, WebCryptoKeyUsageVerify, |
330 result)) | 334 result)) |
331 return promise; | 335 return promise; |
332 | 336 |
333 histogramAlgorithmAndKey(scriptState->getExecutionContext(), | 337 histogramAlgorithmAndKey(scriptState->getExecutionContext(), |
334 normalizedAlgorithm, key->key()); | 338 normalizedAlgorithm, key->key()); |
335 Platform::current()->crypto()->verifySignature( | 339 Platform::current()->crypto()->verifySignature( |
336 normalizedAlgorithm, key->key(), std::move(signature), std::move(data), | 340 normalizedAlgorithm, key->key(), std::move(signature), std::move(data), |
337 result->result()); | 341 result->result()); |
338 return promise; | 342 return promise; |
339 } | 343 } |
340 | 344 |
341 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, | 345 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, |
342 const AlgorithmIdentifier& rawAlgorithm, | 346 const AlgorithmIdentifier& rawAlgorithm, |
343 const BufferSource& rawData) { | 347 const BufferSource& rawData) { |
344 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-digest | 348 // Method described by: |
| 349 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-digest |
345 | 350 |
346 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 351 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
347 ScriptPromise promise = result->promise(); | 352 ScriptPromise promise = result->promise(); |
348 | 353 |
349 if (!canAccessWebCrypto(scriptState, result)) | 354 if (!canAccessWebCrypto(scriptState, result)) |
350 return promise; | 355 return promise; |
351 | 356 |
352 // 14.3.5.2: Let data be the result of getting a copy of the bytes held | 357 // 14.3.5.2: Let data be the result of getting a copy of the bytes held |
353 // by the data parameter passed to the digest method. | 358 // by the data parameter passed to the digest method. |
354 WebVector<uint8_t> data = copyBytes(rawData); | 359 WebVector<uint8_t> data = copyBytes(rawData); |
355 | 360 |
356 // 14.3.5.3: Let normalizedAlgorithm be the result of normalizing an | 361 // 14.3.5.3: Let normalizedAlgorithm be the result of normalizing an |
357 // algorithm, with alg set to algorithm and op set to "digest". | 362 // algorithm, with alg set to algorithm and op set to "digest". |
358 WebCryptoAlgorithm normalizedAlgorithm; | 363 WebCryptoAlgorithm normalizedAlgorithm; |
359 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDigest, | 364 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDigest, |
360 normalizedAlgorithm, result)) | 365 normalizedAlgorithm, result)) |
361 return promise; | 366 return promise; |
362 | 367 |
363 histogramAlgorithm(scriptState->getExecutionContext(), normalizedAlgorithm); | 368 histogramAlgorithm(scriptState->getExecutionContext(), normalizedAlgorithm); |
364 Platform::current()->crypto()->digest(normalizedAlgorithm, std::move(data), | 369 Platform::current()->crypto()->digest(normalizedAlgorithm, std::move(data), |
365 result->result()); | 370 result->result()); |
366 return promise; | 371 return promise; |
367 } | 372 } |
368 | 373 |
369 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, | 374 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, |
370 const AlgorithmIdentifier& rawAlgorithm, | 375 const AlgorithmIdentifier& rawAlgorithm, |
371 bool extractable, | 376 bool extractable, |
372 const Vector<String>& rawKeyUsages) { | 377 const Vector<String>& rawKeyUsages) { |
373 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-generateKey | 378 // Method described by: |
| 379 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-generateK
ey |
374 | 380 |
375 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 381 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
376 ScriptPromise promise = result->promise(); | 382 ScriptPromise promise = result->promise(); |
377 | 383 |
378 if (!canAccessWebCrypto(scriptState, result)) | 384 if (!canAccessWebCrypto(scriptState, result)) |
379 return promise; | 385 return promise; |
380 | 386 |
381 WebCryptoKeyUsageMask keyUsages; | 387 WebCryptoKeyUsageMask keyUsages; |
382 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result)) | 388 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result)) |
383 return promise; | 389 return promise; |
(...skipping 16 matching lines...) Expand all Loading... |
400 return promise; | 406 return promise; |
401 } | 407 } |
402 | 408 |
403 ScriptPromise SubtleCrypto::importKey( | 409 ScriptPromise SubtleCrypto::importKey( |
404 ScriptState* scriptState, | 410 ScriptState* scriptState, |
405 const String& rawFormat, | 411 const String& rawFormat, |
406 const ArrayBufferOrArrayBufferViewOrDictionary& rawKeyData, | 412 const ArrayBufferOrArrayBufferViewOrDictionary& rawKeyData, |
407 const AlgorithmIdentifier& rawAlgorithm, | 413 const AlgorithmIdentifier& rawAlgorithm, |
408 bool extractable, | 414 bool extractable, |
409 const Vector<String>& rawKeyUsages) { | 415 const Vector<String>& rawKeyUsages) { |
410 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-importKey | 416 // Method described by: |
| 417 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-importKey |
411 | 418 |
412 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 419 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
413 ScriptPromise promise = result->promise(); | 420 ScriptPromise promise = result->promise(); |
414 | 421 |
415 if (!canAccessWebCrypto(scriptState, result)) | 422 if (!canAccessWebCrypto(scriptState, result)) |
416 return promise; | 423 return promise; |
417 | 424 |
418 WebCryptoKeyFormat format; | 425 WebCryptoKeyFormat format; |
419 if (!CryptoKey::parseFormat(rawFormat, format, result)) | 426 if (!CryptoKey::parseFormat(rawFormat, format, result)) |
420 return promise; | 427 return promise; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 histogramAlgorithm(scriptState->getExecutionContext(), normalizedAlgorithm); | 489 histogramAlgorithm(scriptState->getExecutionContext(), normalizedAlgorithm); |
483 Platform::current()->crypto()->importKey(format, std::move(keyData), | 490 Platform::current()->crypto()->importKey(format, std::move(keyData), |
484 normalizedAlgorithm, extractable, | 491 normalizedAlgorithm, extractable, |
485 keyUsages, result->result()); | 492 keyUsages, result->result()); |
486 return promise; | 493 return promise; |
487 } | 494 } |
488 | 495 |
489 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, | 496 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, |
490 const String& rawFormat, | 497 const String& rawFormat, |
491 CryptoKey* key) { | 498 CryptoKey* key) { |
492 // Method described by: https://w3c.github.io/webcrypto/Overview.html#dfn-Subt
leCrypto-method-exportKey | 499 // Method described by: |
| 500 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-expor
tKey |
493 | 501 |
494 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 502 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
495 ScriptPromise promise = result->promise(); | 503 ScriptPromise promise = result->promise(); |
496 | 504 |
497 if (!canAccessWebCrypto(scriptState, result)) | 505 if (!canAccessWebCrypto(scriptState, result)) |
498 return promise; | 506 return promise; |
499 | 507 |
500 WebCryptoKeyFormat format; | 508 WebCryptoKeyFormat format; |
501 if (!CryptoKey::parseFormat(rawFormat, format, result)) | 509 if (!CryptoKey::parseFormat(rawFormat, format, result)) |
502 return promise; | 510 return promise; |
(...skipping 11 matching lines...) Expand all Loading... |
514 result->result()); | 522 result->result()); |
515 return promise; | 523 return promise; |
516 } | 524 } |
517 | 525 |
518 ScriptPromise SubtleCrypto::wrapKey( | 526 ScriptPromise SubtleCrypto::wrapKey( |
519 ScriptState* scriptState, | 527 ScriptState* scriptState, |
520 const String& rawFormat, | 528 const String& rawFormat, |
521 CryptoKey* key, | 529 CryptoKey* key, |
522 CryptoKey* wrappingKey, | 530 CryptoKey* wrappingKey, |
523 const AlgorithmIdentifier& rawWrapAlgorithm) { | 531 const AlgorithmIdentifier& rawWrapAlgorithm) { |
524 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-wrapKey | 532 // Method described by: |
| 533 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-wrapKey |
525 | 534 |
526 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 535 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
527 ScriptPromise promise = result->promise(); | 536 ScriptPromise promise = result->promise(); |
528 | 537 |
529 if (!canAccessWebCrypto(scriptState, result)) | 538 if (!canAccessWebCrypto(scriptState, result)) |
530 return promise; | 539 return promise; |
531 | 540 |
532 WebCryptoKeyFormat format; | 541 WebCryptoKeyFormat format; |
533 if (!CryptoKey::parseFormat(rawFormat, format, result)) | 542 if (!CryptoKey::parseFormat(rawFormat, format, result)) |
534 return promise; | 543 return promise; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 586 |
578 ScriptPromise SubtleCrypto::unwrapKey( | 587 ScriptPromise SubtleCrypto::unwrapKey( |
579 ScriptState* scriptState, | 588 ScriptState* scriptState, |
580 const String& rawFormat, | 589 const String& rawFormat, |
581 const BufferSource& rawWrappedKey, | 590 const BufferSource& rawWrappedKey, |
582 CryptoKey* unwrappingKey, | 591 CryptoKey* unwrappingKey, |
583 const AlgorithmIdentifier& rawUnwrapAlgorithm, | 592 const AlgorithmIdentifier& rawUnwrapAlgorithm, |
584 const AlgorithmIdentifier& rawUnwrappedKeyAlgorithm, | 593 const AlgorithmIdentifier& rawUnwrappedKeyAlgorithm, |
585 bool extractable, | 594 bool extractable, |
586 const Vector<String>& rawKeyUsages) { | 595 const Vector<String>& rawKeyUsages) { |
587 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-unwrapKey | 596 // Method described by: |
| 597 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-unwrapKey |
588 | 598 |
589 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 599 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
590 ScriptPromise promise = result->promise(); | 600 ScriptPromise promise = result->promise(); |
591 | 601 |
592 if (!canAccessWebCrypto(scriptState, result)) | 602 if (!canAccessWebCrypto(scriptState, result)) |
593 return promise; | 603 return promise; |
594 | 604 |
595 WebCryptoKeyFormat format; | 605 WebCryptoKeyFormat format; |
596 if (!CryptoKey::parseFormat(rawFormat, format, result)) | 606 if (!CryptoKey::parseFormat(rawFormat, format, result)) |
597 return promise; | 607 return promise; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 Platform::current()->crypto()->unwrapKey( | 657 Platform::current()->crypto()->unwrapKey( |
648 format, std::move(wrappedKey), unwrappingKey->key(), normalizedAlgorithm, | 658 format, std::move(wrappedKey), unwrappingKey->key(), normalizedAlgorithm, |
649 normalizedKeyAlgorithm, extractable, keyUsages, result->result()); | 659 normalizedKeyAlgorithm, extractable, keyUsages, result->result()); |
650 return promise; | 660 return promise; |
651 } | 661 } |
652 | 662 |
653 ScriptPromise SubtleCrypto::deriveBits(ScriptState* scriptState, | 663 ScriptPromise SubtleCrypto::deriveBits(ScriptState* scriptState, |
654 const AlgorithmIdentifier& rawAlgorithm, | 664 const AlgorithmIdentifier& rawAlgorithm, |
655 CryptoKey* baseKey, | 665 CryptoKey* baseKey, |
656 unsigned lengthBits) { | 666 unsigned lengthBits) { |
657 // Method described by: https://w3c.github.io/webcrypto/Overview.html#dfn-Subt
leCrypto-method-deriveBits | 667 // Method described by: |
| 668 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-deriv
eBits |
658 | 669 |
659 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 670 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
660 ScriptPromise promise = result->promise(); | 671 ScriptPromise promise = result->promise(); |
661 | 672 |
662 if (!canAccessWebCrypto(scriptState, result)) | 673 if (!canAccessWebCrypto(scriptState, result)) |
663 return promise; | 674 return promise; |
664 | 675 |
665 // 14.3.8.2: Let normalizedAlgorithm be the result of normalizing an | 676 // 14.3.8.2: Let normalizedAlgorithm be the result of normalizing an |
666 // algorithm, with alg set to algorithm and op set to | 677 // algorithm, with alg set to algorithm and op set to |
667 // "deriveBits". | 678 // "deriveBits". |
(...skipping 19 matching lines...) Expand all Loading... |
687 return promise; | 698 return promise; |
688 } | 699 } |
689 | 700 |
690 ScriptPromise SubtleCrypto::deriveKey( | 701 ScriptPromise SubtleCrypto::deriveKey( |
691 ScriptState* scriptState, | 702 ScriptState* scriptState, |
692 const AlgorithmIdentifier& rawAlgorithm, | 703 const AlgorithmIdentifier& rawAlgorithm, |
693 CryptoKey* baseKey, | 704 CryptoKey* baseKey, |
694 const AlgorithmIdentifier& rawDerivedKeyType, | 705 const AlgorithmIdentifier& rawDerivedKeyType, |
695 bool extractable, | 706 bool extractable, |
696 const Vector<String>& rawKeyUsages) { | 707 const Vector<String>& rawKeyUsages) { |
697 // Method described by: https://w3c.github.io/webcrypto/Overview.html#SubtleCr
ypto-method-deriveKey | 708 // Method described by: |
| 709 // https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey |
698 | 710 |
699 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); | 711 CryptoResultImpl* result = CryptoResultImpl::create(scriptState); |
700 ScriptPromise promise = result->promise(); | 712 ScriptPromise promise = result->promise(); |
701 | 713 |
702 if (!canAccessWebCrypto(scriptState, result)) | 714 if (!canAccessWebCrypto(scriptState, result)) |
703 return promise; | 715 return promise; |
704 | 716 |
705 WebCryptoKeyUsageMask keyUsages; | 717 WebCryptoKeyUsageMask keyUsages; |
706 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result)) | 718 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result)) |
707 return promise; | 719 return promise; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 normalizedAlgorithm, baseKey->key()); | 765 normalizedAlgorithm, baseKey->key()); |
754 histogramAlgorithm(scriptState->getExecutionContext(), | 766 histogramAlgorithm(scriptState->getExecutionContext(), |
755 normalizedDerivedKeyAlgorithm); | 767 normalizedDerivedKeyAlgorithm); |
756 Platform::current()->crypto()->deriveKey( | 768 Platform::current()->crypto()->deriveKey( |
757 normalizedAlgorithm, baseKey->key(), normalizedDerivedKeyAlgorithm, | 769 normalizedAlgorithm, baseKey->key(), normalizedDerivedKeyAlgorithm, |
758 keyLengthAlgorithm, extractable, keyUsages, result->result()); | 770 keyLengthAlgorithm, extractable, keyUsages, result->result()); |
759 return promise; | 771 return promise; |
760 } | 772 } |
761 | 773 |
762 } // namespace blink | 774 } // namespace blink |
OLD | NEW |