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

Issue 22992006: WebCrypto: Add exception messages for algorithm normalization failures. (Closed)

Created:
7 years, 4 months ago by eroman
Modified:
7 years, 4 months ago
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch
Visibility:
Public.

Description

WebCrypto: Add exception messages for algorithm normalization failures. ---------- Overview ---------- There are many problems that can occur during algorithm normalization, and they all have the same exception type (TypeError). Without a good exception description, it is difficult for users of the API to know what went wrong (I have been experiencing this very problem while writing layout tests) This change additionally enforces the range on numeric parameters (i.e. [EnforceRange]), which was previously a FIXME. This behavior isn't part of the WebCrypto spec yet, however it will be in a future update (https://www.w3.org/Bugs/Public/show_bug.cgi?id=23017). ---------- Examples ---------- Here are some examples of the new exception messages: (1) "Algorithm: AES-CBC: AesCbcParams: iv: Missing or not a ArrayBufferView" (Meaning: Didn't specify the iv parameter for AES-CBC. Users can see what is expected by looking at the "AesCbcParams" dictionary in the specification) (2) "Algorithm: HMAC: HmacParams: hash: Missing or not a dictionary." (Meaning: Didn't specify the hash attribute for an HMAC Algorithm. Users can see what is expected by looking at the HmacParams dictionary in the specification) (3) "Algorithm: HMAC: HmacParams: hash: Algorithm: name: Missing or not a string." (Meaning: Didn't specify "hash.name" for an HMAC Algorithm) (4) "Algorithm: HMAC: HmacParams: hash: Algorithm: Unrecognized algorithm name." (Meaning: specified hash.name, however it didn't identify a registered algorithm). (5) "Algorithm: HMAC: HmacParams: hash: Algorithm: AES-CBC: Unsupported operation." (Meaning: the "hash" specified for HMAC was AES-CBC, which is NOT a valid digest. This error message would be better if it said: "Does not support digest". I will re-visit that in a follow-up CL, since it requires some extra work) ---------- Implementation ---------- The implementation works by keeping a stack of string literals which describe the context of the error. A stack works better than an individual string, since algorithm identifiers can be nested and property names alone are ambiguous. There is very little overhead to keeping track of the context while parsing algorithm identifiers, since string literals are cheap to push into a stack (no extra allocations). A final string is constructed only on failure by joining all the literals in the stack with ": ". BUG=245025 R=abarth@chromium.org Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=156533

Patch Set 1 : #

Patch Set 2 : Add a comment to explain inline size of Vector #

Total comments: 2

Patch Set 3 : Remove unnecessary comments #

Patch Set 4 : rebase onto master #

Patch Set 5 : Replace INFINITY with std::isinf() an NAN with std::isnan() to make it work on windows #

Patch Set 6 : Use trunc() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+272 lines, -113 lines) Patch
M LayoutTests/crypto/digest-expected.txt View 1 chunk +3 lines, -3 lines 0 comments Download
M LayoutTests/crypto/encrypt-decrypt-expected.txt View 1 chunk +3 lines, -3 lines 0 comments Download
M LayoutTests/crypto/generateKey-expected.txt View 1 chunk +17 lines, -17 lines 0 comments Download
M LayoutTests/crypto/importKey-expected.txt View 1 chunk +2 lines, -2 lines 0 comments Download
M LayoutTests/crypto/sign-verify-expected.txt View 1 chunk +13 lines, -13 lines 0 comments Download
M Source/modules/crypto/NormalizeAlgorithm.cpp View 1 2 3 4 5 2 chunks +234 lines, -75 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
eroman
7 years, 4 months ago (2013-08-21 18:50:39 UTC) #1
abarth-chromium
LGTM. +mkwst who might be interested in doing similar things elsewhere in the code. If ...
7 years, 4 months ago (2013-08-21 19:17:12 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/22992006/9001
7 years, 4 months ago (2013-08-21 21:09:03 UTC) #3
commit-bot: I haz the power
Retried try job too often on win_blink_rel for step(s) webkit_lint, webkit_python_tests, webkit_tests, webkit_unit_tests, weborigin_unittests, wtf_unittests ...
7 years, 4 months ago (2013-08-21 21:58:14 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/22992006/22001
7 years, 4 months ago (2013-08-22 00:36:27 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/22992006/20001
7 years, 4 months ago (2013-08-22 00:48:27 UTC) #6
eroman
Adam: (FYI) I have made a minor modification since you last reviewed to address a ...
7 years, 4 months ago (2013-08-22 00:52:56 UTC) #7
commit-bot: I haz the power
Step "update" is always a major failure. Look at the try server FAQ for more ...
7 years, 4 months ago (2013-08-22 01:19:06 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/22992006/20001
7 years, 4 months ago (2013-08-22 01:39:33 UTC) #9
commit-bot: I haz the power
Step "update" is always a major failure. Look at the try server FAQ for more ...
7 years, 4 months ago (2013-08-22 01:59:49 UTC) #10
eroman
7 years, 4 months ago (2013-08-22 03:06:51 UTC) #11
Message was sent while issue was closed.
Committed patchset #6 manually as r156533 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698