| 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 17 matching lines...) Expand all Loading... |
| 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 "modules/crypto/SubtleCrypto.h" | 31 #include "modules/crypto/SubtleCrypto.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/Dictionary.h" | 33 #include "bindings/core/v8/Dictionary.h" |
| 34 #include "core/dom/DOMArrayBuffer.h" | 34 #include "core/dom/DOMArrayBuffer.h" |
| 35 #include "core/dom/DOMArrayBufferView.h" | 35 #include "core/dom/DOMArrayBufferView.h" |
| 36 #include "core/dom/DOMArrayPiece.h" | 36 #include "core/dom/DOMArrayPiece.h" |
| 37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 38 #include "core/frame/UseCounter.h" |
| 38 #include "modules/crypto/CryptoHistograms.h" | 39 #include "modules/crypto/CryptoHistograms.h" |
| 39 #include "modules/crypto/CryptoKey.h" | 40 #include "modules/crypto/CryptoKey.h" |
| 40 #include "modules/crypto/CryptoResultImpl.h" | 41 #include "modules/crypto/CryptoResultImpl.h" |
| 41 #include "modules/crypto/NormalizeAlgorithm.h" | 42 #include "modules/crypto/NormalizeAlgorithm.h" |
| 42 #include "platform/json/JSONValues.h" | 43 #include "platform/json/JSONValues.h" |
| 43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 44 #include "public/platform/WebCrypto.h" | 45 #include "public/platform/WebCrypto.h" |
| 45 #include "public/platform/WebCryptoAlgorithm.h" | 46 #include "public/platform/WebCryptoAlgorithm.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 } | 59 } |
| 59 | 60 |
| 60 static bool canAccessWebCrypto(ScriptState* scriptState, CryptoResult* result) { | 61 static bool canAccessWebCrypto(ScriptState* scriptState, CryptoResult* result) { |
| 61 String errorMessage; | 62 String errorMessage; |
| 62 if (!scriptState->getExecutionContext()->isSecureContext( | 63 if (!scriptState->getExecutionContext()->isSecureContext( |
| 63 errorMessage, ExecutionContext::WebCryptoSecureContextCheck)) { | 64 errorMessage, ExecutionContext::WebCryptoSecureContextCheck)) { |
| 64 result->completeWithError(WebCryptoErrorTypeNotSupported, errorMessage); | 65 result->completeWithError(WebCryptoErrorTypeNotSupported, errorMessage); |
| 65 return false; | 66 return false; |
| 66 } | 67 } |
| 67 | 68 |
| 69 if (!scriptState->getExecutionContext()->isSecureContext()) { |
| 70 UseCounter::count( |
| 71 scriptState->getExecutionContext(), |
| 72 UseCounter::SubtleCryptoOnlyStrictSecureContextCheckFailed); |
| 73 } |
| 74 |
| 68 return true; | 75 return true; |
| 69 } | 76 } |
| 70 | 77 |
| 71 static bool copyStringProperty(const char* property, | 78 static bool copyStringProperty(const char* property, |
| 72 const Dictionary& source, | 79 const Dictionary& source, |
| 73 JSONObject* destination) { | 80 JSONObject* destination) { |
| 74 String value; | 81 String value; |
| 75 if (!DictionaryHelper::get(source, property, value)) | 82 if (!DictionaryHelper::get(source, property, value)) |
| 76 return false; | 83 return false; |
| 77 destination->setString(property, value); | 84 destination->setString(property, value); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 normalizedAlgorithm, baseKey->key()); | 772 normalizedAlgorithm, baseKey->key()); |
| 766 histogramAlgorithm(scriptState->getExecutionContext(), | 773 histogramAlgorithm(scriptState->getExecutionContext(), |
| 767 normalizedDerivedKeyAlgorithm); | 774 normalizedDerivedKeyAlgorithm); |
| 768 Platform::current()->crypto()->deriveKey( | 775 Platform::current()->crypto()->deriveKey( |
| 769 normalizedAlgorithm, baseKey->key(), normalizedDerivedKeyAlgorithm, | 776 normalizedAlgorithm, baseKey->key(), normalizedDerivedKeyAlgorithm, |
| 770 keyLengthAlgorithm, extractable, keyUsages, result->result()); | 777 keyLengthAlgorithm, extractable, keyUsages, result->result()); |
| 771 return promise; | 778 return promise; |
| 772 } | 779 } |
| 773 | 780 |
| 774 } // namespace blink | 781 } // namespace blink |
| OLD | NEW |