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

Issue 379383002: Refactor WebCrypto code (Closed)

Created:
6 years, 5 months ago by eroman
Modified:
6 years, 5 months ago
CC:
chromium-reviews, darin-cc_chromium.org, jam
Project:
chromium
Visibility:
Public.

Description

Refactor WebCrypto code. Split up the monstrously large platform_crypto_nss.cc, platform_crypto_openssl.cc into multiple files. ----------- Overview: ----------- * algorithm_implementation.h: This defines a base class AlgorithmImplementation, which has virtual methods for synchronous encrypt/decrypt/generatekey. All of the information about an algorithm is now encapsulated by an AlgorithmImplementation. So for instance the JWK specific knowledge, key usages for each key type are pulled into this interface. * algorithm_registry.cc: Contains a mapping from WebCryptoAlgorithmID --> AlgorithmImplementation, stored by a singleton. * algorithm_dispatch.cc: Given parameters from Blink, looks up the appropriate AlgorithmImplementation in the registry and dispatches the operation. Also implements wrap/unwrap in terms of encrypt/decrypt. * structured_clone.cc: Contains the code related to structured cloning (which still needs some cleanup, and is implemented in terms of import/export). * nss/*, openssl/*: Contains the AlgorithmImplementation concrete classes for each algorithm. This reorganization also unintentionally fixes a few bugs. * ExportKey() for spki/pkcs8/raw uses the already serialized key data rather than re-exporting * Some exception codes were fixed. BUG=389325, 389342, 389327, 374912 R=jochen@chromium.org, rsleevi@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=284267

Patch Set 1 : backup #

Patch Set 2 : backup #

Patch Set 3 : backup #

Patch Set 4 : backup #

Patch Set 5 : backup #

Patch Set 6 : backup #

Patch Set 7 : #

Total comments: 11

Patch Set 8 : Rename VerifySignature -> Verify and remove AlgorithmImplementation::CreateDigestor #

Patch Set 9 : Remove <map> from algorithm_registry #

Patch Set 10 : Put JWK rsa parameters into a struct #

Patch Set 11 : Hook up OpenSSL #

Patch Set 12 : Rebase onto master #

Total comments: 26

Patch Set 13 : add #include<vector> #

Total comments: 1

Patch Set 14 : address sleevi comments #

Patch Set 15 : reorder virtuals #

Patch Set 16 : Rename algorithm.h --> algorithm_implementation.h #

Patch Set 17 : add comment about removing algorithm-specific info from jwk.cc #

Patch Set 18 : rebase onto master #

Total comments: 44

Patch Set 19 : Address rsleevi comments #

Total comments: 10

Patch Set 20 : Address more comments (all documentation improvements) #

Patch Set 21 : Fix compile on non-linux #

Patch Set 22 : rebase onto master #

Patch Set 23 : revert the revert #

Patch Set 24 : Fix bug: call InitPlatform() before digestor #

Patch Set 25 : Rebase onto master (no longer has BoringSSL) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+5865 lines, -4664 lines) Patch
M content/child/blink_platform_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +0 lines, -1 line 0 comments Download
A content/child/webcrypto/algorithm_dispatch.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +104 lines, -0 lines 0 comments Download
A content/child/webcrypto/algorithm_dispatch.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 chunk +294 lines, -0 lines 0 comments Download
A content/child/webcrypto/algorithm_implementation.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +173 lines, -0 lines 0 comments Download
A content/child/webcrypto/algorithm_implementation.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +152 lines, -0 lines 0 comments Download
A content/child/webcrypto/algorithm_registry.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +32 lines, -0 lines 0 comments Download
A content/child/webcrypto/algorithm_registry.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +81 lines, -0 lines 0 comments Download
M content/child/webcrypto/jwk.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +99 lines, -6 lines 0 comments Download
M content/child/webcrypto/jwk.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 4 chunks +297 lines, -594 lines 0 comments Download
A content/child/webcrypto/nss/aes_cbc_nss.cc View 1 2 3 4 5 6 7 8 1 chunk +126 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/aes_gcm_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +188 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/aes_key_nss.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +80 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/aes_key_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +137 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/aes_kw_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +203 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/hmac_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +234 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/key_nss.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +102 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/key_nss.cc View 1 2 3 4 5 6 7 8 1 chunk +96 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/rsa_key_nss.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +100 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/rsa_key_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +897 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/rsa_oaep_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +246 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/rsa_ssa_nss.cc View 1 2 3 4 5 6 7 8 1 chunk +144 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/sha_nss.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +159 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/sym_key_nss.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +38 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/sym_key_nss.cc View 1 2 3 4 1 chunk +91 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/util_nss.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +113 lines, -0 lines 0 comments Download
A content/child/webcrypto/nss/util_nss.cc View 1 2 3 4 5 6 7 8 1 chunk +84 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/aes_cbc_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +138 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/aes_gcm_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 22 23 24 1 chunk +139 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/aes_key_openssl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +70 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/aes_key_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +126 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/aes_kw_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +44 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/hmac_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +211 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/key_openssl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +56 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/key_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +53 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/sha_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +139 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/sym_key_openssl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +33 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/sym_key_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +58 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/util_openssl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +26 lines, -0 lines 0 comments Download
A content/child/webcrypto/openssl/util_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +48 lines, -0 lines 0 comments Download
M content/child/webcrypto/platform_crypto.h View 1 2 3 4 5 6 7 8 1 chunk +14 lines, -264 lines 0 comments Download
M content/child/webcrypto/platform_crypto_nss.cc View 1 1 chunk +0 lines, -1934 lines 0 comments Download
D content/child/webcrypto/platform_crypto_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 22 23 24 1 chunk +0 lines, -590 lines 0 comments Download
D content/child/webcrypto/shared_crypto.h View 1 chunk +0 lines, -187 lines 0 comments Download
D content/child/webcrypto/shared_crypto.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +0 lines, -944 lines 0 comments Download
M content/child/webcrypto/shared_crypto_unittest.cc View 1 2 3 4 5 6 7 21 chunks +102 lines, -83 lines 0 comments Download
M content/child/webcrypto/status.h View 1 2 3 4 5 6 3 chunks +11 lines, -7 lines 0 comments Download
M content/child/webcrypto/status.cc View 1 2 3 4 5 6 3 chunks +12 lines, -7 lines 0 comments Download
A content/child/webcrypto/structured_clone.h View 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +33 lines, -0 lines 0 comments Download
A content/child/webcrypto/structured_clone.cc View 1 2 3 4 5 6 7 8 1 chunk +136 lines, -0 lines 0 comments Download
M content/child/webcrypto/webcrypto_impl.h View 1 chunk +0 lines, -2 lines 0 comments Download
M content/child/webcrypto/webcrypto_impl.cc View 1 2 3 4 5 6 7 3 chunks +7 lines, -11 lines 0 comments Download
M content/child/webcrypto/webcrypto_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +17 lines, -4 lines 0 comments Download
M content/child/webcrypto/webcrypto_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +84 lines, -26 lines 0 comments Download
M content/content_child.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 22 23 24 2 chunks +38 lines, -4 lines 0 comments Download

Messages

Total messages: 24 (0 generated)
Ryan Sleevi
Quick scan. Very limited. https://codereview.chromium.org/379383002/diff/110001/content/child/webcrypto/algorithm.h File content/child/webcrypto/algorithm.h (right): https://codereview.chromium.org/379383002/diff/110001/content/child/webcrypto/algorithm.h#newcode37 content/child/webcrypto/algorithm.h:37: class AlgorithmImplementation { We generally ...
6 years, 5 months ago (2014-07-10 23:20:54 UTC) #1
eroman
Thanks for the initial comments. I will start work on translating OpenSSL code and ping ...
6 years, 5 months ago (2014-07-11 00:27:36 UTC) #2
eroman
This is ready for review now (added the OpenSSL bits in). I won't be splitting ...
6 years, 5 months ago (2014-07-11 23:08:40 UTC) #3
Ryan Sleevi
I tried plowing through this more, but ran out of steam midway through the /nss ...
6 years, 5 months ago (2014-07-12 00:55:28 UTC) #4
eroman
https://codereview.chromium.org/379383002/diff/200001/content/child/webcrypto/algorithm.h File content/child/webcrypto/algorithm.h (right): https://codereview.chromium.org/379383002/diff/200001/content/child/webcrypto/algorithm.h#newcode37 content/child/webcrypto/algorithm.h:37: class AlgorithmImplementation { On 2014/07/12 00:55:27, Ryan Sleevi wrote: ...
6 years, 5 months ago (2014-07-12 01:59:31 UTC) #5
eroman
Uploaded a new patchset with the fixes. https://codereview.chromium.org/379383002/diff/200001/content/child/webcrypto/jwk.cc File content/child/webcrypto/jwk.cc (right): https://codereview.chromium.org/379383002/diff/200001/content/child/webcrypto/jwk.cc#newcode437 content/child/webcrypto/jwk.cc:437: return Status::ErrorJwkAlgorithmInconsistent(); ...
6 years, 5 months ago (2014-07-14 21:56:10 UTC) #6
Ryan Sleevi
Another pass, but the monstrosity of the CL makes me confident I may have missed ...
6 years, 5 months ago (2014-07-17 00:06:55 UTC) #7
Ryan Sleevi
Oh, I should have added a more general request: You're very sparse on documentation. I ...
6 years, 5 months ago (2014-07-17 00:08:26 UTC) #8
eroman
https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/aes_gcm_nss.cc File content/child/webcrypto/nss/aes_gcm_nss.cc (right): https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/aes_gcm_nss.cc#newcode104 content/child/webcrypto/nss/aes_gcm_nss.cc:104: return Status::ErrorDataTooLarge(); On 2014/07/17 00:06:54, Ryan Sleevi wrote: > ...
6 years, 5 months ago (2014-07-17 20:37:27 UTC) #9
Ryan Sleevi
https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/sha_nss.cc File content/child/webcrypto/nss/sha_nss.cc (right): https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/sha_nss.cc#newcode39 content/child/webcrypto/nss/sha_nss.cc:39: class DigestorNSS : public blink::WebCryptoDigestor { On 2014/07/17 20:37:26, ...
6 years, 5 months ago (2014-07-17 22:42:56 UTC) #10
eroman
https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/sha_nss.cc File content/child/webcrypto/nss/sha_nss.cc (right): https://codereview.chromium.org/379383002/diff/320001/content/child/webcrypto/nss/sha_nss.cc#newcode39 content/child/webcrypto/nss/sha_nss.cc:39: class DigestorNSS : public blink::WebCryptoDigestor { On 2014/07/17 22:42:55, ...
6 years, 5 months ago (2014-07-17 23:33:24 UTC) #11
Ryan Sleevi
Last review was a LGTM, mod those nits.
6 years, 5 months ago (2014-07-17 23:38:54 UTC) #12
eroman
@jochen: Can you grant OWNERS approval for the deletion in content/child/blink_platform_impl.cc ? Thanks!
6 years, 5 months ago (2014-07-18 00:00:56 UTC) #13
jochen (gone - plz use gerrit)
lgtm
6 years, 5 months ago (2014-07-18 09:12:56 UTC) #14
eroman
The CQ bit was checked by eroman@chromium.org
6 years, 5 months ago (2014-07-18 18:10:57 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/379383002/400001
6 years, 5 months ago (2014-07-18 18:14:01 UTC) #16
commit-bot: I haz the power
Change committed as 284192
6 years, 5 months ago (2014-07-18 20:19:40 UTC) #17
eroman
Note: I reverted this in r284215, due to a failing test on one bot: DigestSampleSetsInChunks ...
6 years, 5 months ago (2014-07-18 22:25:13 UTC) #18
eroman
Will try re-landing with the call to init for digestor!
6 years, 5 months ago (2014-07-18 23:39:16 UTC) #19
eroman
The CQ bit was checked by eroman@chromium.org
6 years, 5 months ago (2014-07-18 23:39:28 UTC) #20
eroman
The CQ bit was unchecked by eroman@chromium.org
6 years, 5 months ago (2014-07-18 23:39:37 UTC) #21
eroman
The CQ bit was checked by eroman@chromium.org
6 years, 5 months ago (2014-07-18 23:39:58 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eroman@chromium.org/379383002/480001
6 years, 5 months ago (2014-07-18 23:41:50 UTC) #23
eroman
6 years, 5 months ago (2014-07-19 00:55:04 UTC) #24
Message was sent while issue was closed.
Committed patchset #25 manually as r284267 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698