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

Issue 777403004: [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey (Closed)

Created:
6 years ago by Habib Virji
Modified:
6 years ago
Reviewers:
eroman
CC:
chromium-reviews, darin-cc_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

[WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey Throws SyntaxError when KeyUsage is empty. Have fixes in unit test, which was using empty key usage. BUG=425646 R=eroman TEST=Added unit test in HMAC and AES-CBC. Committed: https://crrev.com/f4aa92ee7b9c7fe3ba28d04cc46d352bc5b4f98b Cr-Commit-Position: refs/heads/master@{#309175}

Patch Set 1 #

Total comments: 4

Patch Set 2 : Support for throwing error if usage is empty in HMAC and AES #

Total comments: 1

Patch Set 3 : Moved import key empty usage to CheckKeyCreationUsages #

Total comments: 6

Patch Set 4 : #

Total comments: 26

Patch Set 5 : Updated code to adapt to new changes + code review comments #

Total comments: 8

Patch Set 6 : Updated as per code review comments #

Total comments: 10

Patch Set 7 : Updated issues in ecdh tests and other review comments. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+156 lines, -65 lines) Patch
M content/child/webcrypto/nss/aes_key_nss.cc View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M content/child/webcrypto/nss/hmac_nss.cc View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M content/child/webcrypto/nss/rsa_key_nss.cc View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M content/child/webcrypto/nss/sym_key_nss.cc View 1 2 3 4 1 chunk +0 lines, -3 lines 0 comments Download
M content/child/webcrypto/openssl/aes_key_openssl.cc View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M content/child/webcrypto/openssl/ec_key_openssl.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/child/webcrypto/openssl/hmac_openssl.cc View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M content/child/webcrypto/openssl/rsa_key_openssl.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/child/webcrypto/openssl/sym_key_openssl.cc View 1 2 3 4 1 chunk +0 lines, -3 lines 0 comments Download
M content/child/webcrypto/status.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M content/child/webcrypto/test/aes_cbc_unittest.cc View 1 2 3 4 5 6 3 chunks +12 lines, -10 lines 0 comments Download
M content/child/webcrypto/test/aes_kw_unittest.cc View 1 2 3 4 5 2 chunks +11 lines, -2 lines 0 comments Download
M content/child/webcrypto/test/ecdh_unittest.cc View 1 2 3 4 5 6 1 chunk +34 lines, -0 lines 0 comments Download
M content/child/webcrypto/test/hmac_unittest.cc View 1 2 3 4 5 2 chunks +12 lines, -5 lines 0 comments Download
M content/child/webcrypto/test/rsa_ssa_unittest.cc View 1 2 3 4 5 6 1 chunk +60 lines, -0 lines 0 comments Download
M content/child/webcrypto/webcrypto_util.h View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M content/child/webcrypto/webcrypto_util.cc View 1 2 3 4 5 3 chunks +12 lines, -6 lines 0 comments Download
M content/test/data/webcrypto/ecdh.json View 1 2 3 4 5 6 1 chunk +0 lines, -22 lines 2 comments Download

Messages

Total messages: 32 (6 generated)
Habib Virji
Changes to throw syntax error if key usage is empty.
6 years ago (2014-12-05 18:26:54 UTC) #1
eroman
Please take a similar approach to http://crbug.com/425645 -- do the checks on a per-algorithm basis ...
6 years ago (2014-12-05 20:45:51 UTC) #2
Habib Virji
Updated to check usages only for AES and HMAC. Did not find in spec mentioning ...
6 years ago (2014-12-08 15:05:21 UTC) #3
eroman
The spec says that RSA and EC algorithms must throw if the usages are empty ...
6 years ago (2014-12-08 18:46:33 UTC) #4
Habib Virji
I was looking in section 18 in specific of each algorithm, that's why probably missed ...
6 years ago (2014-12-08 19:07:56 UTC) #5
Habib Virji
Sorry forget to ask question, so should make changes in checkKeyCreationsUsages() or VerifyKeyUsagesBeforeImportKey?
6 years ago (2014-12-08 19:09:28 UTC) #6
eroman
GenerateKey() could be refactored to something like: blink::WebCryptoKeyUsageMask public_usages; blink::WebCryptoKeyUsageMask private_usages; status = GetGenerateAsymmetricKeyUsages(combined_usages, all_public_usages, ...
6 years ago (2014-12-08 19:15:47 UTC) #7
eroman
I can propose that latter refactor separately.
6 years ago (2014-12-08 19:16:56 UTC) #8
Habib Virji
Changes as per your suggestion in CheckKeyCreationUsages. It has extra parameter which is set in ...
6 years ago (2014-12-09 10:21:53 UTC) #9
eroman
not lgtm https://codereview.chromium.org/777403004/diff/40001/content/child/webcrypto/nss/aes_key_nss.cc File content/child/webcrypto/nss/aes_key_nss.cc (right): https://codereview.chromium.org/777403004/diff/40001/content/child/webcrypto/nss/aes_key_nss.cc#newcode62 content/child/webcrypto/nss/aes_key_nss.cc:62: bool checkEmptyUsage = true; Incorrect naming style, ...
6 years ago (2014-12-09 17:42:56 UTC) #10
Habib Virji
I have corrected issue as highlighted in previous review. Have given a last try, please ...
6 years ago (2014-12-09 19:31:51 UTC) #11
eroman
Thanks this is better, we are almost there. I hope to commit two refactors before ...
6 years ago (2014-12-09 21:04:47 UTC) #12
Habib Virji
Sorry for delay in updating. Updated with your suggestions. https://codereview.chromium.org/777403004/diff/60001/content/child/webcrypto/nss/aes_key_nss.cc File content/child/webcrypto/nss/aes_key_nss.cc (right): https://codereview.chromium.org/777403004/diff/60001/content/child/webcrypto/nss/aes_key_nss.cc#newcode45 content/child/webcrypto/nss/aes_key_nss.cc:45: ...
6 years ago (2014-12-15 18:48:56 UTC) #13
eroman
https://codereview.chromium.org/777403004/diff/80001/content/child/webcrypto/status.cc File content/child/webcrypto/status.cc (right): https://codereview.chromium.org/777403004/diff/80001/content/child/webcrypto/status.cc#newcode271 content/child/webcrypto/status.cc:271: Status Status::ErrorKeyEmptyUsages() { Several issues here: (1) The header ...
6 years ago (2014-12-16 01:26:46 UTC) #14
Habib Virji
Updated with correct value for allow_empty_usages. https://codereview.chromium.org/777403004/diff/80001/content/child/webcrypto/status.cc File content/child/webcrypto/status.cc (right): https://codereview.chromium.org/777403004/diff/80001/content/child/webcrypto/status.cc#newcode271 content/child/webcrypto/status.cc:271: Status Status::ErrorKeyEmptyUsages() { ...
6 years ago (2014-12-16 09:59:42 UTC) #15
eroman
https://codereview.chromium.org/777403004/diff/100001/content/child/webcrypto/openssl/ec_key_openssl.cc File content/child/webcrypto/openssl/ec_key_openssl.cc (right): https://codereview.chromium.org/777403004/diff/100001/content/child/webcrypto/openssl/ec_key_openssl.cc#newcode377 content/child/webcrypto/openssl/ec_key_openssl.cc:377: usages, true); I don't believe this is correct. Shouldn't ...
6 years ago (2014-12-17 01:23:51 UTC) #16
Habib Virji
Updated with suggested changes. https://codereview.chromium.org/777403004/diff/100001/content/child/webcrypto/openssl/ec_key_openssl.cc File content/child/webcrypto/openssl/ec_key_openssl.cc (right): https://codereview.chromium.org/777403004/diff/100001/content/child/webcrypto/openssl/ec_key_openssl.cc#newcode377 content/child/webcrypto/openssl/ec_key_openssl.cc:377: usages, true); Sorry I missed ...
6 years ago (2014-12-17 15:41:54 UTC) #17
eroman
https://codereview.chromium.org/777403004/diff/120001/content/test/data/webcrypto/ecdh.json File content/test/data/webcrypto/ecdh.json (left): https://codereview.chromium.org/777403004/diff/120001/content/test/data/webcrypto/ecdh.json#oldcode350 content/test/data/webcrypto/ecdh.json:350: // The public key parameter is in fact a ...
6 years ago (2014-12-17 21:17:42 UTC) #18
eroman
https://codereview.chromium.org/777403004/diff/120001/content/test/data/webcrypto/ecdh.json File content/test/data/webcrypto/ecdh.json (left): https://codereview.chromium.org/777403004/diff/120001/content/test/data/webcrypto/ecdh.json#oldcode350 content/test/data/webcrypto/ecdh.json:350: // The public key parameter is in fact a ...
6 years ago (2014-12-17 21:21:03 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/777403004/120001
6 years ago (2014-12-17 21:22:34 UTC) #21
eroman
(The LayoutTest changes need to land first, so cancelling commit queue)
6 years ago (2014-12-17 21:24:59 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/777403004/120001
6 years ago (2014-12-18 20:02:01 UTC) #25
eroman
Nope, the LayoutTests still don't pass with this change, aborting the commit.
6 years ago (2014-12-18 20:02:52 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/777403004/120001
6 years ago (2014-12-19 10:04:10 UTC) #30
commit-bot: I haz the power
Committed patchset #7 (id:120001)
6 years ago (2014-12-19 10:05:05 UTC) #31
commit-bot: I haz the power
6 years ago (2014-12-19 10:05:48 UTC) #32
Message was sent while issue was closed.
Patchset 7 (id:??) landed as
https://crrev.com/f4aa92ee7b9c7fe3ba28d04cc46d352bc5b4f98b
Cr-Commit-Position: refs/heads/master@{#309175}

Powered by Google App Engine
This is Rietveld 408576698