WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
171070
[GCrypt] ECDH bit derivation support
https://bugs.webkit.org/show_bug.cgi?id=171070
Summary
[GCrypt] ECDH bit derivation support
Zan Dobersek
Reported
2017-04-20 13:01:30 PDT
[GCrypt] ECDH support
Attachments
Patch
(7.11 KB, patch)
2017-04-20 13:26 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
Patch
(7.13 KB, patch)
2017-04-21 07:41 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
Patch
(10.01 KB, patch)
2017-04-23 04:29 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews122 for ios-simulator-wk2
(5.51 MB, application/zip)
2017-04-23 08:38 PDT
,
Build Bot
no flags
Details
Patch
(16.06 KB, patch)
2017-04-27 08:26 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews100 for mac-elcapitan
(945.83 KB, application/zip)
2017-04-27 09:32 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews107 for mac-elcapitan-wk2
(870.71 KB, application/zip)
2017-04-27 09:35 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews112 for mac-elcapitan
(1.72 MB, application/zip)
2017-04-27 09:47 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews121 for ios-simulator-wk2
(907.25 KB, application/zip)
2017-04-27 10:01 PDT
,
Build Bot
no flags
Details
Patch
(16.09 KB, patch)
2017-04-28 12:36 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Zan Dobersek
Comment 1
2017-04-20 13:26:13 PDT
Created
attachment 307627
[details]
Patch
Michael Catanzaro
Comment 2
2017-04-20 14:29:06 PDT
I don't understand it, but rs=me if Jiewen says it looks good.
Jiewen Tan
Comment 3
2017-04-20 15:30:12 PDT
Comment on
attachment 307627
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=307627&action=review
> Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:64 > + PAL::GCrypt::Handle<gcry_sexp_t> cipherSexp;
A little bit confused about this step. Why do we need this encryption? Is it equivalent to adding the public key d times?
> Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:109 > + error = gcry_mpi_print(GCRYMPI_FMT_USG, output.data(), output.size(), nullptr, xMPI);
Why doing gcry_mpi_print twice here? What's the usage of the first gcry_mpi_print?
Zan Dobersek
Comment 4
2017-04-21 01:21:02 PDT
Comment on
attachment 307627
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=307627&action=review
>> Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:64 >> + PAL::GCrypt::Handle<gcry_sexp_t> cipherSexp; > > A little bit confused about this step. Why do we need this encryption? Is it equivalent to adding the public key d times?
It performs the complete ECDH operation, but yes, the public key is added d times which yields the EC point from which the x-coordinate is extracted and returned. The extraction steps are done below. What's missing is using the specified length to validate and clip the coordinate data. I'll upload a new patch.
>> Source/WebCore/crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp:109 >> + error = gcry_mpi_print(GCRYMPI_FMT_USG, output.data(), output.size(), nullptr, xMPI); > > Why doing gcry_mpi_print twice here? What's the usage of the first gcry_mpi_print?
The first one only retrieves the required buffer size. That's then used to allocate a large-enough Vector into which the data is printed out.
Zan Dobersek
Comment 5
2017-04-21 07:37:00 PDT
(In reply to Zan Dobersek from
comment #4
)
> The extraction steps are done below. What's missing is using the specified > length to validate and clip the coordinate data. I'll upload a new patch. >
This is actually already done in CryptoAlgorithmECDH::deriveBits(), so we don't have to do it ourselves. So this patch is still valid. The EWS failure was due to missing 1.7.0 version of libgcrypt on the bot. I'll add the SUBTLE_CRYPTO dependency on 1.7.0 in a separate patch.
Zan Dobersek
Comment 6
2017-04-21 07:41:08 PDT
Created
attachment 307727
[details]
Patch
Jiewen Tan
Comment 7
2017-04-21 13:00:13 PDT
Comment on
attachment 307727
[details]
Patch Looks good. However, I suggest you should at least add some false tests for gcrypt specific implementations as they are more complicated than my CommonCrypto ones. I believe I didn't add that many false tests to cover all the cases there.
Zan Dobersek
Comment 8
2017-04-23 04:29:32 PDT
Created
attachment 307930
[details]
Patch
Zan Dobersek
Comment 9
2017-04-23 07:14:04 PDT
(In reply to Jiewen Tan from
comment #7
)
> Comment on
attachment 307727
[details]
> Patch > > Looks good. However, I suggest you should at least add some false tests for > gcrypt specific implementations as they are more complicated than my > CommonCrypto ones. I believe I didn't add that many false tests to cover all > the cases there.
Similar question as the one in
bug #171074
-- should the additional tests focus on anything else apart from the requested length? I'm assuming all these tests should be layout tests. But on top of that we could also move the libgcrypt-specific code down to PAL and write C++ unit tests for that.
Build Bot
Comment 10
2017-04-23 08:38:42 PDT
Comment on
attachment 307930
[details]
Patch
Attachment 307930
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/3589570
New failing tests: fast/loader/form-submission-after-beforeunload-cancel.html
Build Bot
Comment 11
2017-04-23 08:38:43 PDT
Created
attachment 307936
[details]
Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Jiewen Tan
Comment 12
2017-04-24 11:36:44 PDT
(In reply to Zan Dobersek from
comment #9
)
> (In reply to Jiewen Tan from
comment #7
) > > Comment on
attachment 307727
[details]
> > Patch > > > > Looks good. However, I suggest you should at least add some false tests for > > gcrypt specific implementations as they are more complicated than my > > CommonCrypto ones. I believe I didn't add that many false tests to cover all > > the cases there. > > Similar question as the one in
bug #171074
-- should the additional tests > focus on anything else apart from the requested length? > > I'm assuming all these tests should be layout tests. But on top of that we > could also move the libgcrypt-specific code down to PAL and write C++ unit > tests for that.
Well, I think layout tests should be enough. You might be able to manipulate parameters to force some of the gcrypt apis to fail. That would help to ensure that the exception callback is implemented correctly.
Zan Dobersek
Comment 13
2017-04-27 08:26:47 PDT
Created
attachment 308392
[details]
Patch
Zan Dobersek
Comment 14
2017-04-27 08:51:49 PDT
(In reply to Zan Dobersek from
comment #13
)
> Created
attachment 308392
[details]
> Patch
This adds a layout test that tests specific length when deriving from EC keys, making sure a properly-sized result is returned for valid lengths, and that the operation fails if the requested length is larger than the key size. (In reply to Jiewen Tan from
comment #12
)
> (In reply to Zan Dobersek from
comment #9
) > > (In reply to Jiewen Tan from
comment #7
) > > > Comment on
attachment 307727
[details]
> > > Patch > > > > > > Looks good. However, I suggest you should at least add some false tests for > > > gcrypt specific implementations as they are more complicated than my > > > CommonCrypto ones. I believe I didn't add that many false tests to cover all > > > the cases there. > > > > Similar question as the one in
bug #171074
-- should the additional tests > > focus on anything else apart from the requested length? > > > > I'm assuming all these tests should be layout tests. But on top of that we > > could also move the libgcrypt-specific code down to PAL and write C++ unit > > tests for that. > > Well, I think layout tests should be enough. You might be able to manipulate > parameters to force some of the gcrypt apis to fail. That would help to > ensure that the exception callback is implemented correctly.
This one isn't that simple, and it's not immediately related to the deriveBits operation. The GCrypt-specific implementation would fail if the provided public and private keys are somehow invalid when the deriveBits operation is invoked. The import and generation steps ensure to some degree that it doesn't come to that, but I won't guarantee that the current implementations are flawless. So I would argue that the GCrypt-specific bits of the deriveBits() implementations should expect to work on valid keys. If an error occurs, I would presume it's because of some external factor that we don't have effect on. Again, this is presuming we have bulletproof key import and generation implementations and that the keys are properly validated at that point.
Build Bot
Comment 15
2017-04-27 09:32:54 PDT
Comment on
attachment 308392
[details]
Patch
Attachment 308392
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.webkit.org/results/3620199
New failing tests: crypto/subtle/ecdh-derive-bits-length-limits.html
Build Bot
Comment 16
2017-04-27 09:32:55 PDT
Created
attachment 308400
[details]
Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 17
2017-04-27 09:35:51 PDT
Comment on
attachment 308392
[details]
Patch
Attachment 308392
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/3620205
New failing tests: crypto/subtle/ecdh-derive-bits-length-limits.html
Build Bot
Comment 18
2017-04-27 09:35:52 PDT
Created
attachment 308401
[details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 19
2017-04-27 09:47:02 PDT
Comment on
attachment 308392
[details]
Patch
Attachment 308392
[details]
did not pass mac-debug-ews (mac): Output:
http://webkit-queues.webkit.org/results/3620213
New failing tests: crypto/subtle/ecdh-derive-bits-length-limits.html
Build Bot
Comment 20
2017-04-27 09:47:03 PDT
Created
attachment 308402
[details]
Archive of layout-test-results from ews112 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 21
2017-04-27 10:01:35 PDT
Comment on
attachment 308392
[details]
Patch
Attachment 308392
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/3620223
New failing tests: crypto/subtle/ecdh-derive-bits-length-limits.html
Build Bot
Comment 22
2017-04-27 10:01:36 PDT
Created
attachment 308403
[details]
Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.11.6
Jiewen Tan
Comment 23
2017-04-27 14:30:42 PDT
Comment on
attachment 308392
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=308392&action=review
> LayoutTests/crypto/subtle/ecdh-derive-bits-length-limits.html:1 > +<!DOCTYPE html>
Can you fix the test? I can't run it on Safari, Chrome and Firefox.
Zan Dobersek
Comment 24
2017-04-28 12:36:15 PDT
Created
attachment 308574
[details]
Patch
Zan Dobersek
Comment 25
2017-05-01 23:34:05 PDT
Comment on
attachment 308574
[details]
Patch Clearing flags on attachment: 308574 Committed
r216060
: <
http://trac.webkit.org/changeset/216060
>
Zan Dobersek
Comment 26
2017-05-01 23:34:10 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug