| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 { | 301 { |
| 302 bool hasProperty; | 302 bool hasProperty; |
| 303 bool ok = getOptionalBufferSource(raw, propertyName, hasProperty, buffer, co
ntext, error); | 303 bool ok = getOptionalBufferSource(raw, propertyName, hasProperty, buffer, co
ntext, error); |
| 304 if (!hasProperty) { | 304 if (!hasProperty) { |
| 305 setTypeError(context.toString(propertyName, "Missing required property")
, error); | 305 setTypeError(context.toString(propertyName, "Missing required property")
, error); |
| 306 return false; | 306 return false; |
| 307 } | 307 } |
| 308 return ok; | 308 return ok; |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool getUint8Array(const Dictionary& raw, const char* propertyName, DOMUint8Arra
y*& array, const ErrorContext& context, AlgorithmError* error) | 311 bool getUint8Array(const Dictionary& raw, const char* propertyName, RefPtr<DOMUi
nt8Array>& array, const ErrorContext& context, AlgorithmError* error) |
| 312 { | 312 { |
| 313 if (!DictionaryHelper::get(raw, propertyName, array) || !array) { | 313 if (!DictionaryHelper::get(raw, propertyName, array) || !array) { |
| 314 setTypeError(context.toString(propertyName, "Missing or not a Uint8Array
"), error); | 314 setTypeError(context.toString(propertyName, "Missing or not a Uint8Array
"), error); |
| 315 return false; | 315 return false; |
| 316 } | 316 } |
| 317 return true; | 317 return true; |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Defined by the WebCrypto spec as: | 320 // Defined by the WebCrypto spec as: |
| 321 // | 321 // |
| 322 // typedef Uint8Array BigInteger; | 322 // typedef Uint8Array BigInteger; |
| 323 bool getBigInteger(const Dictionary& raw, const char* propertyName, DOMUint8Arra
y*& array, const ErrorContext& context, AlgorithmError* error) | 323 bool getBigInteger(const Dictionary& raw, const char* propertyName, RefPtr<DOMUi
nt8Array>& array, const ErrorContext& context, AlgorithmError* error) |
| 324 { | 324 { |
| 325 if (!getUint8Array(raw, propertyName, array, context, error)) | 325 if (!getUint8Array(raw, propertyName, array, context, error)) |
| 326 return false; | 326 return false; |
| 327 | 327 |
| 328 if (!array->byteLength()) { | 328 if (!array->byteLength()) { |
| 329 // Empty BigIntegers represent 0 according to the spec | 329 // Empty BigIntegers represent 0 according to the spec |
| 330 array = DOMUint8Array::create(1); | 330 array = DOMUint8Array::create(1); |
| 331 } | 331 } |
| 332 | 332 |
| 333 return true; | 333 return true; |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 // | 556 // |
| 557 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams { | 557 // dictionary RsaHashedKeyGenParams : RsaKeyGenParams { |
| 558 // required HashAlgorithmIdentifier hash; | 558 // required HashAlgorithmIdentifier hash; |
| 559 // }; | 559 // }; |
| 560 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithm
Params>& params, const ErrorContext& context, AlgorithmError* error) | 560 bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithm
Params>& params, const ErrorContext& context, AlgorithmError* error) |
| 561 { | 561 { |
| 562 uint32_t modulusLength; | 562 uint32_t modulusLength; |
| 563 if (!getUint32(raw, "modulusLength", modulusLength, context, error)) | 563 if (!getUint32(raw, "modulusLength", modulusLength, context, error)) |
| 564 return false; | 564 return false; |
| 565 | 565 |
| 566 DOMUint8Array* publicExponent = nullptr; | 566 RefPtr<DOMUint8Array> publicExponent; |
| 567 if (!getBigInteger(raw, "publicExponent", publicExponent, context, error)) | 567 if (!getBigInteger(raw, "publicExponent", publicExponent, context, error)) |
| 568 return false; | 568 return false; |
| 569 | 569 |
| 570 WebCryptoAlgorithm hash; | 570 WebCryptoAlgorithm hash; |
| 571 if (!parseHash(raw, hash, context, error)) | 571 if (!parseHash(raw, hash, context, error)) |
| 572 return false; | 572 return false; |
| 573 | 573 |
| 574 params = adoptPtr(new WebCryptoRsaHashedKeyGenParams(hash, modulusLength, st
atic_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->
byteLength())); | 574 params = adoptPtr(new WebCryptoRsaHashedKeyGenParams(hash, modulusLength, st
atic_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->
byteLength())); |
| 575 return true; | 575 return true; |
| 576 } | 576 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 } | 977 } |
| 978 | 978 |
| 979 } // namespace | 979 } // namespace |
| 980 | 980 |
| 981 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W
ebCryptoAlgorithm& algorithm, AlgorithmError* error) | 981 bool normalizeAlgorithm(const AlgorithmIdentifier& raw, WebCryptoOperation op, W
ebCryptoAlgorithm& algorithm, AlgorithmError* error) |
| 982 { | 982 { |
| 983 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); | 983 return parseAlgorithmIdentifier(raw, op, algorithm, ErrorContext(), error); |
| 984 } | 984 } |
| 985 | 985 |
| 986 } // namespace blink | 986 } // namespace blink |
| OLD | NEW |