Index: Source/modules/crypto/NormalizeAlgorithm.cpp |
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp |
index cd540a563040a4e438fedb95f935847395295ee2..6c2fc739e216d32f8013dbd33fb2490eb7894a46 100644 |
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp |
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp |
@@ -71,6 +71,7 @@ const AlgorithmNameMapping algorithmNameMappings[] = { |
{"ECDH", 4, WebCryptoAlgorithmIdEcdh}, |
{"SHA-1", 5, WebCryptoAlgorithmIdSha1}, |
{"ECDSA", 5, WebCryptoAlgorithmIdEcdsa}, |
+ {"PBKDF2", 6, WebCryptoAlgorithmIdPbkdf2}, |
{"AES-KW", 6, WebCryptoAlgorithmIdAesKw}, |
{"SHA-512", 7, WebCryptoAlgorithmIdSha512}, |
{"SHA-384", 7, WebCryptoAlgorithmIdSha384}, |
@@ -758,6 +759,29 @@ bool parseEcdhKeyDeriveParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmPa |
params = adoptPtr(new WebCryptoEcdhKeyDeriveParams(cryptoKey->key())); |
return true; |
} |
+// dictionary Pbkdf2Params : Algorithm { |
eroman
2015/01/14 21:12:22
Add a newline separating this from the previous li
xun.sun
2015/01/15 17:13:29
Done.
|
+// required BufferSource salt; |
+// [EnforceRange] required unsigned long iterations; |
+// required HashAlgorithmIdentifier hash; |
+// }; |
+bool parsePbkdf2Params(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmParams>& params, const ErrorContext& context, AlgorithmError* error) |
+{ |
+ BufferSource saltBufferSource; |
+ if (!getBufferSource(raw, "salt", saltBufferSource, context, error)) |
+ return false; |
+ |
+ DOMArrayPiece salt(saltBufferSource); |
+ |
+ uint32_t iterations; |
+ if (!getUint32(raw, "iterations", iterations, context, error)) |
+ return false; |
+ |
+ WebCryptoAlgorithm hash; |
+ if (!parseHash(raw, hash, context, error)) |
+ return false; |
+ params = adoptPtr(new WebCryptoPbkdf2Params(hash, salt.bytes(), salt.byteLength(), iterations)); |
+ return true; |
+} |
// Defined by the WebCrypto spec as: |
// |
@@ -858,6 +882,9 @@ bool parseAlgorithmParams(const Dictionary& raw, WebCryptoAlgorithmParamsType ty |
case WebCryptoAlgorithmParamsTypeHkdfParams: |
context.add("HkdfParams"); |
return parseHkdfParams(raw, params, context, error); |
+ case WebCryptoAlgorithmParamsTypePbkdf2Params: |
+ context.add("Pbkdf2Params"); |
+ return parsePbkdf2Params(raw, params, context, error); |
} |
ASSERT_NOT_REACHED(); |
return false; |