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

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

Issue 179353002: [webcrypto] Add the KeyAlgorithm interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/Key.cpp
diff --git a/Source/modules/crypto/Key.cpp b/Source/modules/crypto/Key.cpp
index dbc2fdc8eafc6a289dce96caafb6a86aaebec810..33245e294cf320c588c825ae4710412c6ab57fcb 100644
--- a/Source/modules/crypto/Key.cpp
+++ b/Source/modules/crypto/Key.cpp
@@ -33,7 +33,7 @@
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
-#include "modules/crypto/Algorithm.h"
+#include "modules/crypto/KeyAlgorithm.h"
#include "platform/CryptoResult.h"
#include "public/platform/WebCryptoAlgorithmParams.h"
#include "public/platform/WebString.h"
@@ -122,19 +122,6 @@ blink::WebCryptoKeyUsageMask toKeyUsage(AlgorithmOperation operation)
return 0;
}
-bool getHmacHashId(const blink::WebCryptoAlgorithm& algorithm, blink::WebCryptoAlgorithmId& hashId)
-{
- if (algorithm.hmacParams()) {
- hashId = algorithm.hmacParams()->hash().id();
- return true;
- }
- if (algorithm.hmacKeyParams()) {
- hashId = algorithm.hmacKeyParams()->hash().id();
- return true;
- }
- return false;
-}
-
} // namespace
Key::~Key()
@@ -157,10 +144,10 @@ bool Key::extractable() const
return m_key.extractable();
}
-Algorithm* Key::algorithm()
+KeyAlgorithm* Key::algorithm()
{
if (!m_algorithm)
- m_algorithm = Algorithm::create(m_key.algorithm());
+ m_algorithm = KeyAlgorithm::create(m_key.algorithm());
return m_algorithm.get();
}
@@ -191,20 +178,6 @@ bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, Algo
return false;
}
- // Verify that the algorithm-specific parameters for the key conform to the
- // algorithm.
- // FIXME: This is incomplete and not future proof. Operational parameters
- // should be enumerated when defining new parameters.
-
- if (m_key.algorithm().id() == blink::WebCryptoAlgorithmIdHmac) {
- blink::WebCryptoAlgorithmId keyHash;
- blink::WebCryptoAlgorithmId algorithmHash;
- if (!getHmacHashId(m_key.algorithm(), keyHash) || !getHmacHashId(algorithm, algorithmHash) || keyHash != algorithmHash) {
- result->completeWithError("key.algorithm does not match that of operation (HMAC's hash differs)");
- return false;
- }
- }
-
return true;
}

Powered by Google App Engine
This is Rietveld 408576698