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

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

Issue 141413003: [webcrypto] Match the error handling defined by the spec. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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/Key.h ('k') | Source/modules/crypto/NormalizeAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/Key.cpp
diff --git a/Source/modules/crypto/Key.cpp b/Source/modules/crypto/Key.cpp
index d6e5cc40f01a4d6df2df218b01600a259be17560..8207c53b005e27d3fecfd4cb8d5c0948acbdbd2f 100644
--- a/Source/modules/crypto/Key.cpp
+++ b/Source/modules/crypto/Key.cpp
@@ -175,27 +175,28 @@ Vector<String> Key::usages() const
return result;
}
-bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, AlgorithmOperation op, ExceptionState& exceptionState) const
+bool Key::canBeUsedForAlgorithm(const blink::WebCryptoAlgorithm& algorithm, AlgorithmOperation op, String& errorDetails) const
{
if (!(m_key.usages() & toKeyUsage(op))) {
- exceptionState.throwDOMException(NotSupportedError, "key.usages does not permit this operation");
+ errorDetails = "key.usages does not permit this operation";
return false;
}
if (m_key.algorithm().id() != algorithm.id()) {
- exceptionState.throwDOMException(NotSupportedError, "key.algorithm does not match that of operation");
+ errorDetails = "key.algorithm does not match that of operation";
return false;
}
// Verify that the algorithm-specific parameters for the key conform to the
// algorithm.
- // FIXME: Verify that this is complete.
+ // 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) {
- exceptionState.throwDOMException(NotSupportedError, "key.algorithm does not match that of operation (HMAC's hash differs)");
+ errorDetails = "key.algorithm does not match that of operation (HMAC's hash differs)";
return false;
}
}
« no previous file with comments | « Source/modules/crypto/Key.h ('k') | Source/modules/crypto/NormalizeAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698