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

Unified Diff: Source/platform/exported/WebCryptoAlgorithm.cpp

Issue 789733009: Implement HKDF for WebCrypto (blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: move ASSERT(), add break 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
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.cpp ('k') | Source/platform/exported/WebCryptoKeyAlgorithm.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/exported/WebCryptoAlgorithm.cpp
diff --git a/Source/platform/exported/WebCryptoAlgorithm.cpp b/Source/platform/exported/WebCryptoAlgorithm.cpp
index 35b1e0ac28a58c6093b3ce662be919c17a547d50..00e22a3b9d78fbc79647359adc24ad11278a2264 100644
--- a/Source/platform/exported/WebCryptoAlgorithm.cpp
+++ b/Source/platform/exported/WebCryptoAlgorithm.cpp
@@ -239,6 +239,20 @@ const WebCryptoAlgorithmInfo algorithmIdToInfo[] = {
WebCryptoAlgorithmParamsTypeNone, // WrapKey
WebCryptoAlgorithmParamsTypeNone // UnwrapKey
}
+ }, { // Index 14
+ "HKDF", {
+ WebCryptoAlgorithmInfo::Undefined, // Encrypt
+ WebCryptoAlgorithmInfo::Undefined, // Decrypt
+ WebCryptoAlgorithmInfo::Undefined, // Sign
+ WebCryptoAlgorithmInfo::Undefined, // Verify
+ WebCryptoAlgorithmInfo::Undefined, // Digest
+ WebCryptoAlgorithmInfo::Undefined, // GenerateKey
+ WebCryptoAlgorithmParamsTypeNone, // ImportKey
+ WebCryptoAlgorithmParamsTypeNone, // GetKeyLength
+ WebCryptoAlgorithmParamsTypeHkdfParams, // DeriveBits
+ WebCryptoAlgorithmInfo::Undefined, // WrapKey
+ WebCryptoAlgorithmInfo::Undefined // UnwrapKey
+ }
},
};
@@ -259,7 +273,8 @@ static_assert(WebCryptoAlgorithmIdAesKw == 10, "AESKW id must match");
static_assert(WebCryptoAlgorithmIdRsaPss == 11, "RSA-PSS id must match");
static_assert(WebCryptoAlgorithmIdEcdsa == 12, "ECDSA id must match");
static_assert(WebCryptoAlgorithmIdEcdh == 13, "ECDH id must match");
-static_assert(WebCryptoAlgorithmIdLast == 13, "last id must match");
+static_assert(WebCryptoAlgorithmIdHkdf == 14, "HKDF id must match");
+static_assert(WebCryptoAlgorithmIdLast == 14, "last id must match");
static_assert(10 == WebCryptoOperationLast, "the parameter mapping needs to be updated");
} // namespace
@@ -437,6 +452,14 @@ const WebCryptoAesDerivedKeyParams* WebCryptoAlgorithm::aesDerivedKeyParams() co
return 0;
}
+const WebCryptoHkdfParams* WebCryptoAlgorithm::hkdfParams() const
+{
+ ASSERT(!isNull());
+ if (paramsType() == WebCryptoAlgorithmParamsTypeHkdfParams)
+ return static_cast<WebCryptoHkdfParams*>(m_private->params.get());
+ return 0;
+}
+
bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id)
{
switch (id) {
@@ -455,6 +478,31 @@ bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id)
case WebCryptoAlgorithmIdRsaPss:
case WebCryptoAlgorithmIdEcdsa:
case WebCryptoAlgorithmIdEcdh:
+ case WebCryptoAlgorithmIdHkdf:
+ break;
+ }
+ return false;
+}
+
+bool WebCryptoAlgorithm::isKdf(WebCryptoAlgorithmId id)
+{
+ switch (id) {
+ case WebCryptoAlgorithmIdHkdf:
+ return true;
+ case WebCryptoAlgorithmIdSha1:
+ case WebCryptoAlgorithmIdSha256:
+ case WebCryptoAlgorithmIdSha384:
+ case WebCryptoAlgorithmIdSha512:
+ case WebCryptoAlgorithmIdAesCbc:
+ case WebCryptoAlgorithmIdHmac:
+ case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
+ case WebCryptoAlgorithmIdAesGcm:
+ case WebCryptoAlgorithmIdRsaOaep:
+ case WebCryptoAlgorithmIdAesCtr:
+ case WebCryptoAlgorithmIdAesKw:
+ case WebCryptoAlgorithmIdRsaPss:
+ case WebCryptoAlgorithmIdEcdsa:
+ case WebCryptoAlgorithmIdEcdh:
break;
}
return false;
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.cpp ('k') | Source/platform/exported/WebCryptoKeyAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698