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

Side by Side Diff: third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp

Issue 2815313002: Reland of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Created 3 years, 8 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 AlgorithmError error; 54 AlgorithmError error;
55 bool success = NormalizeAlgorithm(raw, op, algorithm, &error); 55 bool success = NormalizeAlgorithm(raw, op, algorithm, &error);
56 if (!success) 56 if (!success)
57 result->CompleteWithError(error.error_type, error.error_details); 57 result->CompleteWithError(error.error_type, error.error_details);
58 return success; 58 return success;
59 } 59 }
60 60
61 static bool CanAccessWebCrypto(ScriptState* script_state, 61 static bool CanAccessWebCrypto(ScriptState* script_state,
62 CryptoResult* result) { 62 CryptoResult* result) {
63 String error_message; 63 String error_message;
64 if (!script_state->GetExecutionContext()->IsSecureContext( 64 if (!ExecutionContext::From(script_state)
65 error_message, ExecutionContext::kWebCryptoSecureContextCheck)) { 65 ->IsSecureContext(error_message,
66 ExecutionContext::kWebCryptoSecureContextCheck)) {
66 result->CompleteWithError(kWebCryptoErrorTypeNotSupported, error_message); 67 result->CompleteWithError(kWebCryptoErrorTypeNotSupported, error_message);
67 return false; 68 return false;
68 } 69 }
69 70
70 if (!script_state->GetExecutionContext()->IsSecureContext()) { 71 if (!ExecutionContext::From(script_state)->IsSecureContext()) {
71 Deprecation::CountDeprecation( 72 Deprecation::CountDeprecation(
72 script_state->GetExecutionContext(), 73 ExecutionContext::From(script_state),
73 UseCounter::kSubtleCryptoOnlyStrictSecureContextCheckFailed); 74 UseCounter::kSubtleCryptoOnlyStrictSecureContextCheckFailed);
74 } 75 }
75 76
76 return true; 77 return true;
77 } 78 }
78 79
79 static bool CopyStringProperty(const char* property, 80 static bool CopyStringProperty(const char* property,
80 const Dictionary& source, 81 const Dictionary& source,
81 JSONObject* destination) { 82 JSONObject* destination) {
82 String value; 83 String value;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // 14.3.1.8: If the name member of normalizedAlgorithm is not equal to the 207 // 14.3.1.8: If the name member of normalizedAlgorithm is not equal to the
207 // name attribute of the [[algorithm]] internal slot of key then 208 // name attribute of the [[algorithm]] internal slot of key then
208 // throw an InvalidAccessError. 209 // throw an InvalidAccessError.
209 // 210 //
210 // 14.3.1.9: If the [[usages]] internal slot of key does not contain an 211 // 14.3.1.9: If the [[usages]] internal slot of key does not contain an
211 // entry that is "encrypt", then throw an InvalidAccessError. 212 // entry that is "encrypt", then throw an InvalidAccessError.
212 if (!key->CanBeUsedForAlgorithm(normalized_algorithm, 213 if (!key->CanBeUsedForAlgorithm(normalized_algorithm,
213 kWebCryptoKeyUsageEncrypt, result)) 214 kWebCryptoKeyUsageEncrypt, result))
214 return promise; 215 return promise;
215 216
216 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 217 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
217 normalized_algorithm, key->Key()); 218 normalized_algorithm, key->Key());
218 Platform::Current()->Crypto()->Encrypt(normalized_algorithm, key->Key(), 219 Platform::Current()->Crypto()->Encrypt(normalized_algorithm, key->Key(),
219 std::move(data), result->Result()); 220 std::move(data), result->Result());
220 return promise; 221 return promise;
221 } 222 }
222 223
223 ScriptPromise SubtleCrypto::decrypt(ScriptState* script_state, 224 ScriptPromise SubtleCrypto::decrypt(ScriptState* script_state,
224 const AlgorithmIdentifier& raw_algorithm, 225 const AlgorithmIdentifier& raw_algorithm,
225 CryptoKey* key, 226 CryptoKey* key,
226 const BufferSource& raw_data) { 227 const BufferSource& raw_data) {
(...skipping 20 matching lines...) Expand all
247 // 14.3.2.8: If the name member of normalizedAlgorithm is not equal to the 248 // 14.3.2.8: If the name member of normalizedAlgorithm is not equal to the
248 // name attribute of the [[algorithm]] internal slot of key then 249 // name attribute of the [[algorithm]] internal slot of key then
249 // throw an InvalidAccessError. 250 // throw an InvalidAccessError.
250 // 251 //
251 // 14.3.2.9: If the [[usages]] internal slot of key does not contain an 252 // 14.3.2.9: If the [[usages]] internal slot of key does not contain an
252 // entry that is "decrypt", then throw an InvalidAccessError. 253 // entry that is "decrypt", then throw an InvalidAccessError.
253 if (!key->CanBeUsedForAlgorithm(normalized_algorithm, 254 if (!key->CanBeUsedForAlgorithm(normalized_algorithm,
254 kWebCryptoKeyUsageDecrypt, result)) 255 kWebCryptoKeyUsageDecrypt, result))
255 return promise; 256 return promise;
256 257
257 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 258 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
258 normalized_algorithm, key->Key()); 259 normalized_algorithm, key->Key());
259 Platform::Current()->Crypto()->Decrypt(normalized_algorithm, key->Key(), 260 Platform::Current()->Crypto()->Decrypt(normalized_algorithm, key->Key(),
260 std::move(data), result->Result()); 261 std::move(data), result->Result());
261 return promise; 262 return promise;
262 } 263 }
263 264
264 ScriptPromise SubtleCrypto::sign(ScriptState* script_state, 265 ScriptPromise SubtleCrypto::sign(ScriptState* script_state,
265 const AlgorithmIdentifier& raw_algorithm, 266 const AlgorithmIdentifier& raw_algorithm,
266 CryptoKey* key, 267 CryptoKey* key,
267 const BufferSource& raw_data) { 268 const BufferSource& raw_data) {
(...skipping 20 matching lines...) Expand all
288 // 14.3.3.8: If the name member of normalizedAlgorithm is not equal to the 289 // 14.3.3.8: If the name member of normalizedAlgorithm is not equal to the
289 // name attribute of the [[algorithm]] internal slot of key then 290 // name attribute of the [[algorithm]] internal slot of key then
290 // throw an InvalidAccessError. 291 // throw an InvalidAccessError.
291 // 292 //
292 // 14.3.3.9: If the [[usages]] internal slot of key does not contain an 293 // 14.3.3.9: If the [[usages]] internal slot of key does not contain an
293 // entry that is "sign", then throw an InvalidAccessError. 294 // entry that is "sign", then throw an InvalidAccessError.
294 if (!key->CanBeUsedForAlgorithm(normalized_algorithm, kWebCryptoKeyUsageSign, 295 if (!key->CanBeUsedForAlgorithm(normalized_algorithm, kWebCryptoKeyUsageSign,
295 result)) 296 result))
296 return promise; 297 return promise;
297 298
298 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 299 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
299 normalized_algorithm, key->Key()); 300 normalized_algorithm, key->Key());
300 Platform::Current()->Crypto()->Sign(normalized_algorithm, key->Key(), 301 Platform::Current()->Crypto()->Sign(normalized_algorithm, key->Key(),
301 std::move(data), result->Result()); 302 std::move(data), result->Result());
302 return promise; 303 return promise;
303 } 304 }
304 305
305 ScriptPromise SubtleCrypto::verifySignature( 306 ScriptPromise SubtleCrypto::verifySignature(
306 ScriptState* script_state, 307 ScriptState* script_state,
307 const AlgorithmIdentifier& raw_algorithm, 308 const AlgorithmIdentifier& raw_algorithm,
308 CryptoKey* key, 309 CryptoKey* key,
(...skipping 26 matching lines...) Expand all
335 // 14.3.4.9: If the name member of normalizedAlgorithm is not equal to the 336 // 14.3.4.9: If the name member of normalizedAlgorithm is not equal to the
336 // name attribute of the [[algorithm]] internal slot of key then 337 // name attribute of the [[algorithm]] internal slot of key then
337 // throw an InvalidAccessError. 338 // throw an InvalidAccessError.
338 // 339 //
339 // 14.3.4.10: If the [[usages]] internal slot of key does not contain an 340 // 14.3.4.10: If the [[usages]] internal slot of key does not contain an
340 // entry that is "verify", then throw an InvalidAccessError. 341 // entry that is "verify", then throw an InvalidAccessError.
341 if (!key->CanBeUsedForAlgorithm(normalized_algorithm, 342 if (!key->CanBeUsedForAlgorithm(normalized_algorithm,
342 kWebCryptoKeyUsageVerify, result)) 343 kWebCryptoKeyUsageVerify, result))
343 return promise; 344 return promise;
344 345
345 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 346 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
346 normalized_algorithm, key->Key()); 347 normalized_algorithm, key->Key());
347 Platform::Current()->Crypto()->VerifySignature( 348 Platform::Current()->Crypto()->VerifySignature(
348 normalized_algorithm, key->Key(), std::move(signature), std::move(data), 349 normalized_algorithm, key->Key(), std::move(signature), std::move(data),
349 result->Result()); 350 result->Result());
350 return promise; 351 return promise;
351 } 352 }
352 353
353 ScriptPromise SubtleCrypto::digest(ScriptState* script_state, 354 ScriptPromise SubtleCrypto::digest(ScriptState* script_state,
354 const AlgorithmIdentifier& raw_algorithm, 355 const AlgorithmIdentifier& raw_algorithm,
355 const BufferSource& raw_data) { 356 const BufferSource& raw_data) {
(...skipping 10 matching lines...) Expand all
366 // by the data parameter passed to the digest method. 367 // by the data parameter passed to the digest method.
367 WebVector<uint8_t> data = CopyBytes(raw_data); 368 WebVector<uint8_t> data = CopyBytes(raw_data);
368 369
369 // 14.3.5.3: Let normalizedAlgorithm be the result of normalizing an 370 // 14.3.5.3: Let normalizedAlgorithm be the result of normalizing an
370 // algorithm, with alg set to algorithm and op set to "digest". 371 // algorithm, with alg set to algorithm and op set to "digest".
371 WebCryptoAlgorithm normalized_algorithm; 372 WebCryptoAlgorithm normalized_algorithm;
372 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationDigest, 373 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationDigest,
373 normalized_algorithm, result)) 374 normalized_algorithm, result))
374 return promise; 375 return promise;
375 376
376 HistogramAlgorithm(script_state->GetExecutionContext(), normalized_algorithm); 377 HistogramAlgorithm(ExecutionContext::From(script_state),
378 normalized_algorithm);
377 Platform::Current()->Crypto()->Digest(normalized_algorithm, std::move(data), 379 Platform::Current()->Crypto()->Digest(normalized_algorithm, std::move(data),
378 result->Result()); 380 result->Result());
379 return promise; 381 return promise;
380 } 382 }
381 383
382 ScriptPromise SubtleCrypto::generateKey( 384 ScriptPromise SubtleCrypto::generateKey(
383 ScriptState* script_state, 385 ScriptState* script_state,
384 const AlgorithmIdentifier& raw_algorithm, 386 const AlgorithmIdentifier& raw_algorithm,
385 bool extractable, 387 bool extractable,
386 const Vector<String>& raw_key_usages) { 388 const Vector<String>& raw_key_usages) {
(...skipping 15 matching lines...) Expand all
402 // "generateKey". 404 // "generateKey".
403 WebCryptoAlgorithm normalized_algorithm; 405 WebCryptoAlgorithm normalized_algorithm;
404 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationGenerateKey, 406 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationGenerateKey,
405 normalized_algorithm, result)) 407 normalized_algorithm, result))
406 return promise; 408 return promise;
407 409
408 // NOTE: Steps (8) and (9) disallow empty usages on secret and private 410 // NOTE: Steps (8) and (9) disallow empty usages on secret and private
409 // keys. This normative requirement is enforced by the platform 411 // keys. This normative requirement is enforced by the platform
410 // implementation in the call below. 412 // implementation in the call below.
411 413
412 HistogramAlgorithm(script_state->GetExecutionContext(), normalized_algorithm); 414 HistogramAlgorithm(ExecutionContext::From(script_state),
415 normalized_algorithm);
413 Platform::Current()->Crypto()->GenerateKey(normalized_algorithm, extractable, 416 Platform::Current()->Crypto()->GenerateKey(normalized_algorithm, extractable,
414 key_usages, result->Result()); 417 key_usages, result->Result());
415 return promise; 418 return promise;
416 } 419 }
417 420
418 ScriptPromise SubtleCrypto::importKey( 421 ScriptPromise SubtleCrypto::importKey(
419 ScriptState* script_state, 422 ScriptState* script_state,
420 const String& raw_format, 423 const String& raw_format,
421 const ArrayBufferOrArrayBufferViewOrDictionary& raw_key_data, 424 const ArrayBufferOrArrayBufferViewOrDictionary& raw_key_data,
422 const AlgorithmIdentifier& raw_algorithm, 425 const AlgorithmIdentifier& raw_algorithm,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 491 }
489 492
490 // 14.3.9.3: Let normalizedAlgorithm be the result of normalizing an 493 // 14.3.9.3: Let normalizedAlgorithm be the result of normalizing an
491 // algorithm, with alg set to algorithm and op set to 494 // algorithm, with alg set to algorithm and op set to
492 // "importKey". 495 // "importKey".
493 WebCryptoAlgorithm normalized_algorithm; 496 WebCryptoAlgorithm normalized_algorithm;
494 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationImportKey, 497 if (!ParseAlgorithm(raw_algorithm, kWebCryptoOperationImportKey,
495 normalized_algorithm, result)) 498 normalized_algorithm, result))
496 return promise; 499 return promise;
497 500
498 HistogramAlgorithm(script_state->GetExecutionContext(), normalized_algorithm); 501 HistogramAlgorithm(ExecutionContext::From(script_state),
502 normalized_algorithm);
499 Platform::Current()->Crypto()->ImportKey(format, std::move(key_data), 503 Platform::Current()->Crypto()->ImportKey(format, std::move(key_data),
500 normalized_algorithm, extractable, 504 normalized_algorithm, extractable,
501 key_usages, result->Result()); 505 key_usages, result->Result());
502 return promise; 506 return promise;
503 } 507 }
504 508
505 ScriptPromise SubtleCrypto::exportKey(ScriptState* script_state, 509 ScriptPromise SubtleCrypto::exportKey(ScriptState* script_state,
506 const String& raw_format, 510 const String& raw_format,
507 CryptoKey* key) { 511 CryptoKey* key) {
508 // Method described by: 512 // Method described by:
(...skipping 10 matching lines...) Expand all
519 return promise; 523 return promise;
520 524
521 // 14.3.10.6: If the [[extractable]] internal slot of key is false, then 525 // 14.3.10.6: If the [[extractable]] internal slot of key is false, then
522 // throw an InvalidAccessError. 526 // throw an InvalidAccessError.
523 if (!key->extractable()) { 527 if (!key->extractable()) {
524 result->CompleteWithError(kWebCryptoErrorTypeInvalidAccess, 528 result->CompleteWithError(kWebCryptoErrorTypeInvalidAccess,
525 "key is not extractable"); 529 "key is not extractable");
526 return promise; 530 return promise;
527 } 531 }
528 532
529 HistogramKey(script_state->GetExecutionContext(), key->Key()); 533 HistogramKey(ExecutionContext::From(script_state), key->Key());
530 Platform::Current()->Crypto()->ExportKey(format, key->Key(), 534 Platform::Current()->Crypto()->ExportKey(format, key->Key(),
531 result->Result()); 535 result->Result());
532 return promise; 536 return promise;
533 } 537 }
534 538
535 ScriptPromise SubtleCrypto::wrapKey( 539 ScriptPromise SubtleCrypto::wrapKey(
536 ScriptState* script_state, 540 ScriptState* script_state,
537 const String& raw_format, 541 const String& raw_format,
538 CryptoKey* key, 542 CryptoKey* key,
539 CryptoKey* wrapping_key, 543 CryptoKey* wrapping_key,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // the spec order. 582 // the spec order.
579 583
580 // 14.3.11.12: If the [[extractable]] internal slot of key is false, then 584 // 14.3.11.12: If the [[extractable]] internal slot of key is false, then
581 // throw an InvalidAccessError. 585 // throw an InvalidAccessError.
582 if (!key->extractable()) { 586 if (!key->extractable()) {
583 result->CompleteWithError(kWebCryptoErrorTypeInvalidAccess, 587 result->CompleteWithError(kWebCryptoErrorTypeInvalidAccess,
584 "key is not extractable"); 588 "key is not extractable");
585 return promise; 589 return promise;
586 } 590 }
587 591
588 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 592 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
589 normalized_algorithm, wrapping_key->Key()); 593 normalized_algorithm, wrapping_key->Key());
590 HistogramKey(script_state->GetExecutionContext(), key->Key()); 594 HistogramKey(ExecutionContext::From(script_state), key->Key());
591 Platform::Current()->Crypto()->WrapKey( 595 Platform::Current()->Crypto()->WrapKey(
592 format, key->Key(), wrapping_key->Key(), normalized_algorithm, 596 format, key->Key(), wrapping_key->Key(), normalized_algorithm,
593 result->Result()); 597 result->Result());
594 return promise; 598 return promise;
595 } 599 }
596 600
597 ScriptPromise SubtleCrypto::unwrapKey( 601 ScriptPromise SubtleCrypto::unwrapKey(
598 ScriptState* script_state, 602 ScriptState* script_state,
599 const String& raw_format, 603 const String& raw_format,
600 const BufferSource& raw_wrapped_key, 604 const BufferSource& raw_wrapped_key,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // contain an entry that is "unwrapKey", then throw an 657 // contain an entry that is "unwrapKey", then throw an
654 // InvalidAccessError. 658 // InvalidAccessError.
655 if (!unwrapping_key->CanBeUsedForAlgorithm( 659 if (!unwrapping_key->CanBeUsedForAlgorithm(
656 normalized_algorithm, kWebCryptoKeyUsageUnwrapKey, result)) 660 normalized_algorithm, kWebCryptoKeyUsageUnwrapKey, result))
657 return promise; 661 return promise;
658 662
659 // NOTE: Step (16) disallows empty usages on secret and private keys. This 663 // NOTE: Step (16) disallows empty usages on secret and private keys. This
660 // normative requirement is enforced by the platform implementation in the 664 // normative requirement is enforced by the platform implementation in the
661 // call below. 665 // call below.
662 666
663 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 667 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
664 normalized_algorithm, unwrapping_key->Key()); 668 normalized_algorithm, unwrapping_key->Key());
665 HistogramAlgorithm(script_state->GetExecutionContext(), 669 HistogramAlgorithm(ExecutionContext::From(script_state),
666 normalized_key_algorithm); 670 normalized_key_algorithm);
667 Platform::Current()->Crypto()->UnwrapKey( 671 Platform::Current()->Crypto()->UnwrapKey(
668 format, std::move(wrapped_key), unwrapping_key->Key(), 672 format, std::move(wrapped_key), unwrapping_key->Key(),
669 normalized_algorithm, normalized_key_algorithm, extractable, key_usages, 673 normalized_algorithm, normalized_key_algorithm, extractable, key_usages,
670 result->Result()); 674 result->Result());
671 return promise; 675 return promise;
672 } 676 }
673 677
674 ScriptPromise SubtleCrypto::deriveBits(ScriptState* script_state, 678 ScriptPromise SubtleCrypto::deriveBits(ScriptState* script_state,
675 const AlgorithmIdentifier& raw_algorithm, 679 const AlgorithmIdentifier& raw_algorithm,
(...skipping 19 matching lines...) Expand all
695 // 14.3.8.7: If the name member of normalizedAlgorithm is not equal to the 699 // 14.3.8.7: If the name member of normalizedAlgorithm is not equal to the
696 // name attribute of the [[algorithm]] internal slot of baseKey 700 // name attribute of the [[algorithm]] internal slot of baseKey
697 // then throw an InvalidAccessError. 701 // then throw an InvalidAccessError.
698 // 702 //
699 // 14.3.8.8: If the [[usages]] internal slot of baseKey does not contain an 703 // 14.3.8.8: If the [[usages]] internal slot of baseKey does not contain an
700 // entry that is "deriveBits", then throw an InvalidAccessError. 704 // entry that is "deriveBits", then throw an InvalidAccessError.
701 if (!base_key->CanBeUsedForAlgorithm(normalized_algorithm, 705 if (!base_key->CanBeUsedForAlgorithm(normalized_algorithm,
702 kWebCryptoKeyUsageDeriveBits, result)) 706 kWebCryptoKeyUsageDeriveBits, result))
703 return promise; 707 return promise;
704 708
705 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 709 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
706 normalized_algorithm, base_key->Key()); 710 normalized_algorithm, base_key->Key());
707 Platform::Current()->Crypto()->DeriveBits( 711 Platform::Current()->Crypto()->DeriveBits(
708 normalized_algorithm, base_key->Key(), length_bits, result->Result()); 712 normalized_algorithm, base_key->Key(), length_bits, result->Result());
709 return promise; 713 return promise;
710 } 714 }
711 715
712 ScriptPromise SubtleCrypto::deriveKey( 716 ScriptPromise SubtleCrypto::deriveKey(
713 ScriptState* script_state, 717 ScriptState* script_state,
714 const AlgorithmIdentifier& raw_algorithm, 718 const AlgorithmIdentifier& raw_algorithm,
715 CryptoKey* base_key, 719 CryptoKey* base_key,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 // 14.3.7.12: If the [[usages]] internal slot of baseKey does not contain 769 // 14.3.7.12: If the [[usages]] internal slot of baseKey does not contain
766 // an entry that is "deriveKey", then throw an InvalidAccessError. 770 // an entry that is "deriveKey", then throw an InvalidAccessError.
767 if (!base_key->CanBeUsedForAlgorithm(normalized_algorithm, 771 if (!base_key->CanBeUsedForAlgorithm(normalized_algorithm,
768 kWebCryptoKeyUsageDeriveKey, result)) 772 kWebCryptoKeyUsageDeriveKey, result))
769 return promise; 773 return promise;
770 774
771 // NOTE: Step (16) disallows empty usages on secret and private keys. This 775 // NOTE: Step (16) disallows empty usages on secret and private keys. This
772 // normative requirement is enforced by the platform implementation in the 776 // normative requirement is enforced by the platform implementation in the
773 // call below. 777 // call below.
774 778
775 HistogramAlgorithmAndKey(script_state->GetExecutionContext(), 779 HistogramAlgorithmAndKey(ExecutionContext::From(script_state),
776 normalized_algorithm, base_key->Key()); 780 normalized_algorithm, base_key->Key());
777 HistogramAlgorithm(script_state->GetExecutionContext(), 781 HistogramAlgorithm(ExecutionContext::From(script_state),
778 normalized_derived_key_algorithm); 782 normalized_derived_key_algorithm);
779 Platform::Current()->Crypto()->DeriveKey( 783 Platform::Current()->Crypto()->DeriveKey(
780 normalized_algorithm, base_key->Key(), normalized_derived_key_algorithm, 784 normalized_algorithm, base_key->Key(), normalized_derived_key_algorithm,
781 key_length_algorithm, extractable, key_usages, result->Result()); 785 key_length_algorithm, extractable, key_usages, result->Result());
782 return promise; 786 return promise;
783 } 787 }
784 788
785 } // namespace blink 789 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698