Bug 169319 - [WebCrypto] Implement ECDH DeriveBits operation
Summary: [WebCrypto] Implement ECDH DeriveBits operation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jiewen Tan
URL:
Keywords: InRadar
Depends on:
Blocks: 166746
  Show dependency treegraph
 
Reported: 2017-03-07 16:58 PST by Jiewen Tan
Modified: 2017-03-08 21:00 PST (History)
4 users (show)

See Also:


Attachments
Patch (62.79 KB, patch)
2017-03-08 14:08 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (68.30 KB, patch)
2017-03-08 14:24 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (63.61 KB, patch)
2017-03-08 15:03 PST, Jiewen Tan
bfulgham: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiewen Tan 2017-03-07 16:58:31 PST
Implement ECDH DeriveKey/DeriveBits operations according to the spec: https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations.
Comment 1 Jiewen Tan 2017-03-07 16:59:00 PST
<rdar://problem/23789585>
Comment 2 Jiewen Tan 2017-03-08 14:08:59 PST
Created attachment 303839 [details]
Patch
Comment 3 Jiewen Tan 2017-03-08 14:10:28 PST
This bug only implements ECDH DeriveBits for now. The DeriveKey operation will be tracked on another bug.
Comment 4 Jiewen Tan 2017-03-08 14:24:12 PST
Created attachment 303842 [details]
Patch
Comment 5 Brent Fulgham 2017-03-08 14:38:17 PST
Comment on attachment 303842 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=303842&action=review

Looks good. Does this not cause any W3C test cases to start passing? Maybe you need the DeriveKey part, too.

> Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp:-63
> -    DeriveKey,

Should we leave this in as a "NotSupportedError" case until your second patch?

> Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp:-162
> -        case Operations::DeriveKey:

Ditto here? Just handle "NotSupported" for now, rather than remove it completely?
Comment 6 Jiewen Tan 2017-03-08 14:45:09 PST
Comment on attachment 303842 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=303842&action=review

Thanks Brent for r+ my patch.
Sadly, all the w3c test cases use SPKI/PKCS as the de facto formats for importing EC keys. Therefore, the test won't run on WebKit until we support SPKI/PKCS.
Good news though Firefox doesn't support SPKI/PKCS as well. So the tests don't run on Firefox too.

>> Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp:-63
>> -    DeriveKey,
> 
> Should we leave this in as a "NotSupportedError" case until your second patch?

Sure.

>> Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp:-162
>> -        case Operations::DeriveKey:
> 
> Ditto here? Just handle "NotSupported" for now, rather than remove it completely?

Fixed.
Comment 7 Jiewen Tan 2017-03-08 15:03:58 PST
Created attachment 303850 [details]
Patch
Comment 8 Brent Fulgham 2017-03-08 15:09:03 PST
Comment on attachment 303850 [details]
Patch

r=me.
Comment 9 WebKit Commit Bot 2017-03-08 18:17:12 PST
Comment on attachment 303850 [details]
Patch

Rejecting attachment 303850 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 303850, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
ilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc ...
Currently at 213615 = 4ca78b286ae45bc70b983c531c3b927abd5f921f
r213616 = f89f40e92bc59b44ebaf3e209362eaf1c89dfbf2
r213617 = 196c89ab01ab2d2311a910cb5fb43773dff9e9f2
Done rebuilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/origin/master.
Total errors found: 0 in 1 files

Full output: http://webkit-queues.webkit.org/results/3273373
Comment 10 Jiewen Tan 2017-03-08 20:04:42 PST
Committed r213624: <http://trac.webkit.org/changeset/213624>
Comment 11 Joseph Pecoraro 2017-03-08 20:45:11 PST
Comment on attachment 303850 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=303850&action=review

> Source/WebCore/crypto/keys/CryptoKeyEC.h:88
> +    PlatformECKey platformKey() { return m_platformKey; }

const?
Comment 12 Jiewen Tan 2017-03-08 21:00:51 PST
(In reply to comment #11)
> Comment on attachment 303850 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=303850&action=review
> 
> > Source/WebCore/crypto/keys/CryptoKeyEC.h:88
> > +    PlatformECKey platformKey() { return m_platformKey; }
> 
> const?

PlatformECKey is a opaque C structure from CommonCrypto. Therefore, const will make it impossible to pass to CommonCrypto APIs.