| Index: Source/modules/crypto/NormalizeAlgorithm.cpp
|
| diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| index 823989554d1830bcbaa42b07280068057277d59b..cd540a563040a4e438fedb95f935847395295ee2 100644
|
| --- a/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| +++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| @@ -67,6 +67,7 @@ struct AlgorithmNameMapping {
|
| // Also all names must be upper case ASCII.
|
| const AlgorithmNameMapping algorithmNameMappings[] = {
|
| {"HMAC", 4, WebCryptoAlgorithmIdHmac},
|
| + {"HKDF", 4, WebCryptoAlgorithmIdHkdf},
|
| {"ECDH", 4, WebCryptoAlgorithmIdEcdh},
|
| {"SHA-1", 5, WebCryptoAlgorithmIdSha1},
|
| {"ECDSA", 5, WebCryptoAlgorithmIdEcdsa},
|
| @@ -773,6 +774,37 @@ bool parseAesDerivedKeyParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmPa
|
| return true;
|
| }
|
|
|
| +// FIXME: once the spec has been updated, check that the implementation is
|
| +// still correct and update this comment. http://crbug.com/399095
|
| +//
|
| +// The WebCrypto spec hasn't been updated yet to define HKDF
|
| +// (https://www.w3.org/Bugs/Public/show_bug.cgi?id=27425). The assumed
|
| +// parameters are:
|
| +//
|
| +// dictionary HkdfParams : Algorithm {
|
| +// required HashAlgorithmIdentifier hash;
|
| +// required BufferSource salt;
|
| +// required BufferSource info;
|
| +// };
|
| +bool parseHkdfParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error)
|
| +{
|
| + WebCryptoAlgorithm hash;
|
| + if (!parseHash(raw, hash, context, error))
|
| + return false;
|
| + BufferSource saltBufferSource;
|
| + if (!getBufferSource(raw, "salt", saltBufferSource, context, error))
|
| + return false;
|
| + BufferSource infoBufferSource;
|
| + if (!getBufferSource(raw, "info", infoBufferSource, context, error))
|
| + return false;
|
| +
|
| + DOMArrayPiece salt(saltBufferSource);
|
| + DOMArrayPiece info(infoBufferSource);
|
| +
|
| + params = adoptPtr(new WebCryptoHkdfParams(hash, salt.bytes(), salt.byteLength(), info.bytes(), info.byteLength()));
|
| + return true;
|
| +}
|
| +
|
| bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType type, OwnPtr<WebCryptoAlgorithmParams>& params, ErrorContext& context, AlgorithmError* error)
|
| {
|
| switch (type) {
|
| @@ -823,6 +855,9 @@ bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty
|
| case WebCryptoAlgorithmParamsTypeAesDerivedKeyParams:
|
| context.add("AesDerivedKeyParams");
|
| return parseAesDerivedKeyParams(raw, params, context, error);
|
| + case WebCryptoAlgorithmParamsTypeHkdfParams:
|
| + context.add("HkdfParams");
|
| + return parseHkdfParams(raw, params, context, error);
|
| }
|
| ASSERT_NOT_REACHED();
|
| return false;
|
|
|