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 21 matching lines...) Expand all Loading... |
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/Deprecation.h" | 38 #include "core/frame/Deprecation.h" |
39 #include "modules/crypto/CryptoHistograms.h" | 39 #include "modules/crypto/CryptoHistograms.h" |
40 #include "modules/crypto/CryptoKey.h" | 40 #include "modules/crypto/CryptoKey.h" |
41 #include "modules/crypto/CryptoResultImpl.h" | 41 #include "modules/crypto/CryptoResultImpl.h" |
| 42 #include "modules/crypto/CryptoUtilities.h" |
42 #include "modules/crypto/NormalizeAlgorithm.h" | 43 #include "modules/crypto/NormalizeAlgorithm.h" |
43 #include "platform/json/JSONValues.h" | 44 #include "platform/json/JSONValues.h" |
44 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
45 #include "public/platform/WebCrypto.h" | 46 #include "public/platform/WebCrypto.h" |
46 #include "public/platform/WebCryptoAlgorithm.h" | 47 #include "public/platform/WebCryptoAlgorithm.h" |
47 | 48 |
48 namespace blink { | 49 namespace blink { |
49 | 50 |
50 static bool ParseAlgorithm(const AlgorithmIdentifier& raw, | 51 static bool ParseAlgorithm(const AlgorithmIdentifier& raw, |
51 WebCryptoOperation op, | 52 WebCryptoOperation op, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 const char* const kPropertyNames[] = {"d", "n", "e", "p", "q", "dp", | 148 const char* const kPropertyNames[] = {"d", "n", "e", "p", "q", "dp", |
148 "dq", "qi", "k", "crv", "x", "y"}; | 149 "dq", "qi", "k", "crv", "x", "y"}; |
149 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(kPropertyNames); ++i) | 150 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(kPropertyNames); ++i) |
150 CopyStringProperty(kPropertyNames[i], dict, json_object.get()); | 151 CopyStringProperty(kPropertyNames[i], dict, json_object.get()); |
151 | 152 |
152 String json = json_object->ToJSONString(); | 153 String json = json_object->ToJSONString(); |
153 json_utf8 = WebVector<uint8_t>(json.Utf8().data(), json.Utf8().length()); | 154 json_utf8 = WebVector<uint8_t>(json.Utf8().data(), json.Utf8().length()); |
154 return true; | 155 return true; |
155 } | 156 } |
156 | 157 |
157 static WebVector<uint8_t> CopyBytes(const DOMArrayPiece& source) { | |
158 return WebVector<uint8_t>(static_cast<uint8_t*>(source.Data()), | |
159 source.ByteLength()); | |
160 } | |
161 | |
162 SubtleCrypto::SubtleCrypto() {} | 158 SubtleCrypto::SubtleCrypto() {} |
163 | 159 |
164 ScriptPromise SubtleCrypto::encrypt(ScriptState* script_state, | 160 ScriptPromise SubtleCrypto::encrypt(ScriptState* script_state, |
165 const AlgorithmIdentifier& raw_algorithm, | 161 const AlgorithmIdentifier& raw_algorithm, |
166 CryptoKey* key, | 162 CryptoKey* key, |
167 const BufferSource& raw_data) { | 163 const BufferSource& raw_data) { |
168 // Method described by: | 164 // Method described by: |
169 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-encry
pt | 165 // https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-encry
pt |
170 | 166 |
171 CryptoResultImpl* result = CryptoResultImpl::Create(script_state); | 167 CryptoResultImpl* result = CryptoResultImpl::Create(script_state); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 normalized_algorithm, base_key->Key()); | 721 normalized_algorithm, base_key->Key()); |
726 HistogramAlgorithm(ExecutionContext::From(script_state), | 722 HistogramAlgorithm(ExecutionContext::From(script_state), |
727 normalized_derived_key_algorithm); | 723 normalized_derived_key_algorithm); |
728 Platform::Current()->Crypto()->DeriveKey( | 724 Platform::Current()->Crypto()->DeriveKey( |
729 normalized_algorithm, base_key->Key(), normalized_derived_key_algorithm, | 725 normalized_algorithm, base_key->Key(), normalized_derived_key_algorithm, |
730 key_length_algorithm, extractable, key_usages, result->Result()); | 726 key_length_algorithm, extractable, key_usages, result->Result()); |
731 return promise; | 727 return promise; |
732 } | 728 } |
733 | 729 |
734 } // namespace blink | 730 } // namespace blink |
OLD | NEW |