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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 310 |
311 // Defined by the WebCrypto spec as: | 311 // Defined by the WebCrypto spec as: |
312 // | 312 // |
313 // typedef Uint8Array BigInteger; | 313 // typedef Uint8Array BigInteger; |
314 bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<Uint8
Array>& array, const ErrorContext& context, AlgorithmError* error) | 314 bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<Uint8
Array>& array, const ErrorContext& context, AlgorithmError* error) |
315 { | 315 { |
316 if (!getUint8Array(raw, propertyName, array, context, error)) | 316 if (!getUint8Array(raw, propertyName, array, context, error)) |
317 return false; | 317 return false; |
318 | 318 |
319 if (!array->byteLength()) { | 319 if (!array->byteLength()) { |
320 setSyntaxError(context.toString(propertyName, "BigInteger should not be
empty"), error); | 320 // Empty BigIntegers represent 0 according to the spec |
321 return false; | 321 array = Uint8Array::create(1); |
322 } | 322 } |
323 | 323 |
324 if (!DictionaryHelper::get(raw, propertyName, array) || !array) { | |
325 setSyntaxError(context.toString(propertyName, "Missing or not a Uint8Arr
ay"), error); | |
326 return false; | |
327 } | |
328 return true; | 324 return true; |
329 } | 325 } |
330 | 326 |
331 // Gets an integer according to WebIDL's [EnforceRange]. | 327 // Gets an integer according to WebIDL's [EnforceRange]. |
332 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h
asProperty, double& value, double minValue, double maxValue, const ErrorContext&
context, AlgorithmError* error) | 328 bool getOptionalInteger(const Dictionary& raw, const char* propertyName, bool& h
asProperty, double& value, double minValue, double maxValue, const ErrorContext&
context, AlgorithmError* error) |
333 { | 329 { |
334 double number; | 330 double number; |
335 bool ok = DictionaryHelper::get(raw, propertyName, number, hasProperty); | 331 bool ok = DictionaryHelper::get(raw, propertyName, number, hasProperty); |
336 | 332 |
337 if (!hasProperty) | 333 if (!hasProperty) |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 734 } |
739 | 735 |
740 } // namespace | 736 } // namespace |
741 | 737 |
742 bool normalizeAlgorithm(const Dictionary& raw, WebCryptoOperation op, WebCryptoA
lgorithm& algorithm, AlgorithmError* error) | 738 bool normalizeAlgorithm(const Dictionary& raw, WebCryptoOperation op, WebCryptoA
lgorithm& algorithm, AlgorithmError* error) |
743 { | 739 { |
744 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error); | 740 return parseAlgorithm(raw, op, algorithm, ErrorContext(), error); |
745 } | 741 } |
746 | 742 |
747 } // namespace blink | 743 } // namespace blink |
OLD | NEW |