Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1748)

Unified Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 820523003: [webcrypto] Implement PBKDF2 (blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nit Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/crypto/NormalizeAlgorithm.cpp
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
index cd540a563040a4e438fedb95f935847395295ee2..0690eb7a85d3015e98f5eb9c0f6260529ac57658 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},
@@ -761,6 +762,32 @@ bool parseEcdhKeyDeriveParams(const Dictionary& raw, OwnPtr<WebCryptoAlgorithmPa
// Defined by the WebCrypto spec as:
//
+// dictionary Pbkdf2Params : Algorithm {
+// 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:
+//
// dictionary AesDerivedKeyParams : Algorithm {
// [EnforceRange] required unsigned short length;
// };
@@ -858,6 +885,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;
« no previous file with comments | « Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp ('k') | Source/platform/exported/WebCryptoAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698