| Index: third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| diff --git a/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp b/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| index d09a7b0f0f7fc89a2a87814d0a4e568affd4efd1..caf063811aec299c0ac76e1e1354fd885ea10057 100644
|
| --- a/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| +++ b/third_party/WebKit/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| @@ -40,11 +40,9 @@
|
| #include "public/platform/WebCryptoAlgorithmParams.h"
|
| #include "public/platform/WebString.h"
|
| #include "wtf/MathExtras.h"
|
| -#include "wtf/PtrUtil.h"
|
| #include "wtf/Vector.h"
|
| #include "wtf/text/StringBuilder.h"
|
| #include <algorithm>
|
| -#include <memory>
|
|
|
| namespace blink {
|
|
|
| @@ -449,7 +447,7 @@ bool getAlgorithmIdentifier(const Dictionary& raw, const char* propertyName, Alg
|
| // dictionary AesCbcParams : Algorithm {
|
| // required BufferSource iv;
|
| // };
|
| -bool parseAesCbcParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseAesCbcParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| BufferSource ivBufferSource;
|
| if (!getBufferSource(raw, "iv", ivBufferSource, context, error))
|
| @@ -457,7 +455,7 @@ bool parseAesCbcParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
|
|
| DOMArrayPiece iv(ivBufferSource);
|
|
|
| - params = wrapUnique(new WebCryptoAesCbcParams(iv.bytes(), iv.byteLength()));
|
| + params = adoptPtr(new WebCryptoAesCbcParams(iv.bytes(), iv.byteLength()));
|
| return true;
|
| }
|
|
|
| @@ -466,13 +464,13 @@ bool parseAesCbcParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| // dictionary AesKeyGenParams : Algorithm {
|
| // [EnforceRange] required unsigned short length;
|
| // };
|
| -bool parseAesKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseAesKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| uint16_t length;
|
| if (!getUint16(raw, "length", length, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoAesKeyGenParams(length));
|
| + params = adoptPtr(new WebCryptoAesKeyGenParams(length));
|
| return true;
|
| }
|
|
|
| @@ -498,7 +496,7 @@ bool parseHash(const Dictionary& raw, WebCryptoAlgorithm& hash, ErrorContext con
|
| // FIXME: http://crbug.com/438475: The current implementation differs from the
|
| // spec in that the "hash" parameter is required. This seems more sensible, and
|
| // is being proposed as a change to the spec. (https://www.w3.org/Bugs/Public/show_bug.cgi?id=27448).
|
| -bool parseHmacImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseHmacImportParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| @@ -509,7 +507,7 @@ bool parseHmacImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgor
|
| if (!getOptionalUint32(raw, "length", hasLength, length, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoHmacImportParams(hash, hasLength, length));
|
| + params = adoptPtr(new WebCryptoHmacImportParams(hash, hasLength, length));
|
| return true;
|
| }
|
|
|
| @@ -519,7 +517,7 @@ bool parseHmacImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgor
|
| // required HashAlgorithmIdentifier hash;
|
| // [EnforceRange] unsigned long length;
|
| // };
|
| -bool parseHmacKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseHmacKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| @@ -530,7 +528,7 @@ bool parseHmacKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgor
|
| if (!getOptionalUint32(raw, "length", hasLength, length, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoHmacKeyGenParams(hash, hasLength, length));
|
| + params = adoptPtr(new WebCryptoHmacKeyGenParams(hash, hasLength, length));
|
| return true;
|
| }
|
|
|
| @@ -539,13 +537,13 @@ bool parseHmacKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgor
|
| // dictionary RsaHashedImportParams : Algorithm {
|
| // required HashAlgorithmIdentifier hash;
|
| // };
|
| -bool parseRsaHashedImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseRsaHashedImportParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoRsaHashedImportParams(hash));
|
| + params = adoptPtr(new WebCryptoRsaHashedImportParams(hash));
|
| return true;
|
| }
|
|
|
| @@ -559,7 +557,7 @@ bool parseRsaHashedImportParams(const Dictionary& raw, std::unique_ptr<WebCrypto
|
| // dictionary RsaHashedKeyGenParams : RsaKeyGenParams {
|
| // required HashAlgorithmIdentifier hash;
|
| // };
|
| -bool parseRsaHashedKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseRsaHashedKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| uint32_t modulusLength;
|
| if (!getUint32(raw, "modulusLength", modulusLength, context, error))
|
| @@ -573,7 +571,7 @@ bool parseRsaHashedKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCrypto
|
| if (!parseHash(raw, hash, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoRsaHashedKeyGenParams(hash, modulusLength, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteLength()));
|
| + params = adoptPtr(new WebCryptoRsaHashedKeyGenParams(hash, modulusLength, static_cast<const unsigned char*>(publicExponent->baseAddress()), publicExponent->byteLength()));
|
| return true;
|
| }
|
|
|
| @@ -583,7 +581,7 @@ bool parseRsaHashedKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCrypto
|
| // required BufferSource counter;
|
| // [EnforceRange] required octet length;
|
| // };
|
| -bool parseAesCtrParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseAesCtrParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| BufferSource counterBufferSource;
|
| if (!getBufferSource(raw, "counter", counterBufferSource, context, error))
|
| @@ -594,7 +592,7 @@ bool parseAesCtrParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| if (!getUint8(raw, "length", length, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoAesCtrParams(length, counter.bytes(), counter.byteLength()));
|
| + params = adoptPtr(new WebCryptoAesCtrParams(length, counter.bytes(), counter.byteLength()));
|
| return true;
|
| }
|
|
|
| @@ -605,7 +603,7 @@ bool parseAesCtrParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| // BufferSource additionalData;
|
| // [EnforceRange] octet tagLength;
|
| // }
|
| -bool parseAesGcmParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseAesGcmParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| BufferSource ivBufferSource;
|
| if (!getBufferSource(raw, "iv", ivBufferSource, context, error))
|
| @@ -624,7 +622,7 @@ bool parseAesGcmParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| DOMArrayPiece iv(ivBufferSource);
|
| DOMArrayPiece additionalData(additionalDataBufferSource, DOMArrayPiece::AllowNullPointToNullWithZeroSize);
|
|
|
| - params = wrapUnique(new WebCryptoAesGcmParams(iv.bytes(), iv.byteLength(), hasAdditionalData, additionalData.bytes(), additionalData.byteLength(), hasTagLength, tagLength));
|
| + params = adoptPtr(new WebCryptoAesGcmParams(iv.bytes(), iv.byteLength(), hasAdditionalData, additionalData.bytes(), additionalData.byteLength(), hasTagLength, tagLength));
|
| return true;
|
| }
|
|
|
| @@ -633,7 +631,7 @@ bool parseAesGcmParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| // dictionary RsaOaepParams : Algorithm {
|
| // BufferSource label;
|
| // };
|
| -bool parseRsaOaepParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseRsaOaepParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| bool hasLabel;
|
| BufferSource labelBufferSource;
|
| @@ -641,7 +639,7 @@ bool parseRsaOaepParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorith
|
| return false;
|
|
|
| DOMArrayPiece label(labelBufferSource, DOMArrayPiece::AllowNullPointToNullWithZeroSize);
|
| - params = wrapUnique(new WebCryptoRsaOaepParams(hasLabel, label.bytes(), label.byteLength()));
|
| + params = adoptPtr(new WebCryptoRsaOaepParams(hasLabel, label.bytes(), label.byteLength()));
|
| return true;
|
| }
|
|
|
| @@ -650,13 +648,13 @@ bool parseRsaOaepParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorith
|
| // dictionary RsaPssParams : Algorithm {
|
| // [EnforceRange] required unsigned long saltLength;
|
| // };
|
| -bool parseRsaPssParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseRsaPssParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| uint32_t saltLengthBytes;
|
| if (!getUint32(raw, "saltLength", saltLengthBytes, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoRsaPssParams(saltLengthBytes));
|
| + params = adoptPtr(new WebCryptoRsaPssParams(saltLengthBytes));
|
| return true;
|
| }
|
|
|
| @@ -665,13 +663,13 @@ bool parseRsaPssParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| // dictionary EcdsaParams : Algorithm {
|
| // required HashAlgorithmIdentifier hash;
|
| // };
|
| -bool parseEcdsaParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseEcdsaParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoEcdsaParams(hash));
|
| + params = adoptPtr(new WebCryptoEcdsaParams(hash));
|
| return true;
|
| }
|
|
|
| @@ -713,13 +711,13 @@ bool parseNamedCurve(const Dictionary& raw, WebCryptoNamedCurve& namedCurve, Err
|
| // dictionary EcKeyGenParams : Algorithm {
|
| // required NamedCurve namedCurve;
|
| // };
|
| -bool parseEcKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseEcKeyGenParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoNamedCurve namedCurve;
|
| if (!parseNamedCurve(raw, namedCurve, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoEcKeyGenParams(namedCurve));
|
| + params = adoptPtr(new WebCryptoEcKeyGenParams(namedCurve));
|
| return true;
|
| }
|
|
|
| @@ -728,13 +726,13 @@ bool parseEcKeyGenParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorit
|
| // dictionary EcKeyImportParams : Algorithm {
|
| // required NamedCurve namedCurve;
|
| // };
|
| -bool parseEcKeyImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseEcKeyImportParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoNamedCurve namedCurve;
|
| if (!parseNamedCurve(raw, namedCurve, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoEcKeyImportParams(namedCurve));
|
| + params = adoptPtr(new WebCryptoEcKeyImportParams(namedCurve));
|
| return true;
|
| }
|
|
|
| @@ -743,7 +741,7 @@ bool parseEcKeyImportParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgo
|
| // dictionary EcdhKeyDeriveParams : Algorithm {
|
| // required CryptoKey public;
|
| // };
|
| -bool parseEcdhKeyDeriveParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseEcdhKeyDeriveParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| v8::Local<v8::Value> v8Value;
|
| if (!raw.get("public", v8Value)) {
|
| @@ -757,7 +755,7 @@ bool parseEcdhKeyDeriveParams(const Dictionary& raw, std::unique_ptr<WebCryptoAl
|
| return false;
|
| }
|
|
|
| - params = wrapUnique(new WebCryptoEcdhKeyDeriveParams(cryptoKey->key()));
|
| + params = adoptPtr(new WebCryptoEcdhKeyDeriveParams(cryptoKey->key()));
|
| return true;
|
| }
|
|
|
| @@ -768,7 +766,7 @@ bool parseEcdhKeyDeriveParams(const Dictionary& raw, std::unique_ptr<WebCryptoAl
|
| // [EnforceRange] required unsigned long iterations;
|
| // required HashAlgorithmIdentifier hash;
|
| // };
|
| -bool parsePbkdf2Params(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parsePbkdf2Params(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| BufferSource saltBufferSource;
|
| if (!getBufferSource(raw, "salt", saltBufferSource, context, error))
|
| @@ -783,7 +781,7 @@ bool parsePbkdf2Params(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| return false;
|
| - params = wrapUnique(new WebCryptoPbkdf2Params(hash, salt.bytes(), salt.byteLength(), iterations));
|
| + params = adoptPtr(new WebCryptoPbkdf2Params(hash, salt.bytes(), salt.byteLength(), iterations));
|
| return true;
|
| }
|
|
|
| @@ -792,13 +790,13 @@ bool parsePbkdf2Params(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithm
|
| // dictionary AesDerivedKeyParams : Algorithm {
|
| // [EnforceRange] required unsigned short length;
|
| // };
|
| -bool parseAesDerivedKeyParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseAesDerivedKeyParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| uint16_t length;
|
| if (!getUint16(raw, "length", length, context, error))
|
| return false;
|
|
|
| - params = wrapUnique(new WebCryptoAesDerivedKeyParams(length));
|
| + params = adoptPtr(new WebCryptoAesDerivedKeyParams(length));
|
| return true;
|
| }
|
|
|
| @@ -814,7 +812,7 @@ bool parseAesDerivedKeyParams(const Dictionary& raw, std::unique_ptr<WebCryptoAl
|
| // required BufferSource salt;
|
| // required BufferSource info;
|
| // };
|
| -bool parseHkdfParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +bool parseHkdfParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| {
|
| WebCryptoAlgorithm hash;
|
| if (!parseHash(raw, hash, context, error))
|
| @@ -829,11 +827,11 @@ bool parseHkdfParams(const Dictionary& raw, std::unique_ptr<WebCryptoAlgorithmPa
|
| DOMArrayPiece salt(saltBufferSource);
|
| DOMArrayPiece info(infoBufferSource);
|
|
|
| - params = wrapUnique(new WebCryptoHkdfParams(hash, salt.bytes(), salt.byteLength(), info.bytes(), info.byteLength()));
|
| + params = adoptPtr(new WebCryptoHkdfParams(hash, salt.bytes(), salt.byteLength(), info.bytes(), info.byteLength()));
|
| return true;
|
| }
|
|
|
| -bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType type, std::unique_ptr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmError* error)
|
| +bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType type, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmError* error)
|
| {
|
| switch (type) {
|
| case WebCryptoAlgorithmParamsTypeNone:
|
| @@ -944,7 +942,7 @@ bool parseAlgorithmDictionary(const String& algorithmName, const Dictionary& raw
|
|
|
| WebCryptoAlgorithmParamsType paramsType = static_cast<WebCryptoAlgorithmParamsType>(algorithmInfo->operationToParamsType[op]);
|
|
|
| - std::unique_ptr<WebCryptoAlgorithmParams> params;
|
| + OwnPtr<WebCryptoAlgorithmParams> params;
|
| if (!parseAlgorithmParams(raw, paramsType, params, context, error))
|
| return false;
|
|
|
|
|