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 <algorithm> | 33 #include <algorithm> |
34 #include <memory> | 34 #include <memory> |
35 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" | 35 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" |
36 #include "bindings/core/v8/Dictionary.h" | 36 #include "bindings/core/v8/Dictionary.h" |
37 #include "bindings/core/v8/V8ArrayBuffer.h" | 37 #include "bindings/core/v8/V8ArrayBuffer.h" |
38 #include "bindings/core/v8/V8ArrayBufferView.h" | 38 #include "bindings/core/v8/V8ArrayBufferView.h" |
39 #include "bindings/modules/v8/V8CryptoKey.h" | 39 #include "bindings/modules/v8/V8CryptoKey.h" |
40 #include "core/dom/DOMArrayPiece.h" | 40 #include "core/dom/DOMArrayPiece.h" |
41 #include "core/dom/DOMTypedArray.h" | 41 #include "core/dom/DOMTypedArray.h" |
| 42 #include "modules/crypto/CryptoUtilities.h" |
42 #include "platform/wtf/MathExtras.h" | 43 #include "platform/wtf/MathExtras.h" |
43 #include "platform/wtf/PtrUtil.h" | 44 #include "platform/wtf/PtrUtil.h" |
44 #include "platform/wtf/Vector.h" | 45 #include "platform/wtf/Vector.h" |
45 #include "platform/wtf/text/StringBuilder.h" | 46 #include "platform/wtf/text/StringBuilder.h" |
46 #include "public/platform/WebCryptoAlgorithmParams.h" | 47 #include "public/platform/WebCryptoAlgorithmParams.h" |
47 #include "public/platform/WebString.h" | 48 #include "public/platform/WebString.h" |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
53 typedef ArrayBufferOrArrayBufferView BufferSource; | |
54 | |
55 struct AlgorithmNameMapping { | 54 struct AlgorithmNameMapping { |
56 // Must be an upper case ASCII string. | 55 // Must be an upper case ASCII string. |
57 const char* const algorithm_name; | 56 const char* const algorithm_name; |
58 // Must be strlen(algorithmName). | 57 // Must be strlen(algorithmName). |
59 unsigned char algorithm_name_length; | 58 unsigned char algorithm_name_length; |
60 WebCryptoAlgorithmId algorithm_id; | 59 WebCryptoAlgorithmId algorithm_id; |
61 | 60 |
62 #if DCHECK_IS_ON() | 61 #if DCHECK_IS_ON() |
63 bool operator<(const AlgorithmNameMapping&) const; | 62 bool operator<(const AlgorithmNameMapping&) const; |
64 #endif | 63 #endif |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 stack.Add(message2); | 256 stack.Add(message2); |
258 return stack.ToString(); | 257 return stack.ToString(); |
259 } | 258 } |
260 | 259 |
261 private: | 260 private: |
262 // This inline size is large enough to avoid having to grow the Vector in | 261 // This inline size is large enough to avoid having to grow the Vector in |
263 // the majority of cases (up to 1 nested algorithm identifier). | 262 // the majority of cases (up to 1 nested algorithm identifier). |
264 Vector<const char*, 10> messages_; | 263 Vector<const char*, 10> messages_; |
265 }; | 264 }; |
266 | 265 |
267 static WebVector<uint8_t> CopyBytes(const DOMArrayPiece& source) { | |
268 return WebVector<uint8_t>(static_cast<const uint8_t*>(source.Data()), | |
269 source.ByteLength()); | |
270 } | |
271 | |
272 // Defined by the WebCrypto spec as: | 266 // Defined by the WebCrypto spec as: |
273 // | 267 // |
274 // typedef (ArrayBuffer or ArrayBufferView) BufferSource; | 268 // typedef (ArrayBuffer or ArrayBufferView) BufferSource; |
275 // | 269 // |
276 bool GetOptionalBufferSource(const Dictionary& raw, | 270 bool GetOptionalBufferSource(const Dictionary& raw, |
277 const char* property_name, | 271 const char* property_name, |
278 bool& has_property, | 272 bool& has_property, |
279 WebVector<uint8_t>& bytes, | 273 WebVector<uint8_t>& bytes, |
280 const ErrorContext& context, | 274 const ErrorContext& context, |
281 AlgorithmError* error) { | 275 AlgorithmError* error) { |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } // namespace | 1089 } // namespace |
1096 | 1090 |
1097 bool NormalizeAlgorithm(const AlgorithmIdentifier& raw, | 1091 bool NormalizeAlgorithm(const AlgorithmIdentifier& raw, |
1098 WebCryptoOperation op, | 1092 WebCryptoOperation op, |
1099 WebCryptoAlgorithm& algorithm, | 1093 WebCryptoAlgorithm& algorithm, |
1100 AlgorithmError* error) { | 1094 AlgorithmError* error) { |
1101 return ParseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); | 1095 return ParseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); |
1102 } | 1096 } |
1103 | 1097 |
1104 } // namespace blink | 1098 } // namespace blink |
OLD | NEW |