Chromium Code Reviews| Index: Source/modules/crypto/NormalizeAlgorithm.cpp |
| diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp |
| index 823989554d1830bcbaa42b07280068057277d59b..e8580e5631ffa04ef24a1bdac7106170043acaba 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,36 @@ 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. I am assuming a |
|
eroman
2015/01/07 00:40:31
Leave out things like "we" and "I" as it is unclea
nharper
2015/01/08 00:58:39
Done.
|
| +// definition along the lines of: |
| +// |
| +// 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 +854,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; |