Bug 170636

Summary: [WebCrypto] Support HKDF
Product: WebKit Reporter: Jiewen Tan <jiewen_tan>
Component: WebCore Misc.Assignee: Jiewen Tan <jiewen_tan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, buildbot, commit-queue, jiewen_tan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=170907
Bug Depends on:    
Bug Blocks: 166746    
Attachments:
Description Flags
Patch none

Description Jiewen Tan 2017-04-07 19:27:47 PDT
WebCrypto should support HKDF as being specified in: https://www.w3.org/TR/WebCryptoAPI/#hkdf.
Comment 1 Jiewen Tan 2017-04-07 19:28:18 PDT
<rdar://problem/23539827>
Comment 2 Jiewen Tan 2017-04-07 19:37:13 PDT
Created attachment 306563 [details]
Patch
Comment 3 Jiewen Tan 2017-04-07 19:37:44 PDT
(In reply to Jiewen Tan from comment #2)
> Created attachment 306563 [details]
> Patch

The patch is huge because of W3C tests rebasing.
Comment 4 Build Bot 2017-04-07 19:40:05 PDT
Attachment 306563 [details] did not pass style-queue:


ERROR: Source/WebCore/crypto/CryptoAlgorithmIdentifier.h:53:  enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums.  [readability/enum_casing] [4]
ERROR: Source/WebCore/bindings/js/SerializedScriptValue.cpp:241:  enum members should use InterCaps with an initial capital letter or initial 'k' for C-style enums.  [readability/enum_casing] [4]
Total errors found: 2 in 46 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Brent Fulgham 2017-04-12 21:19:35 PDT
Comment on attachment 306563 [details]
Patch

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

Looks good. Can you please confirm the failure are expected? Are they dependent on other unfinished work?

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:5
> +FAIL Derived key of type name: AES-CBC length: 128  using short derivedKey, normal salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Is this expected?

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:9
> +FAIL Derived key of type name: AES-CBC length: 192  using short derivedKey, normal salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Ditto all the other instances of these...

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:623
> +FAIL Derived key of type name: AES-CBC length: 128  using short derivedKey, empty salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Ditto...

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:1241
> +FAIL Derived key of type name: AES-CBC length: 128  using long derivedKey, normal salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Ditto ...

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:1859
> +FAIL Derived key of type name: AES-CBC length: 128  using long derivedKey, empty salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Ditto...

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:2477
> +FAIL Derived key of type name: AES-CBC length: 128  using empty derivedKey, normal salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"

Ditto...

> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:3092
> +FAIL empty derivedKey, empty salt, SHA-384, with normal info assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code

Ditto...
Comment 6 Jiewen Tan 2017-04-14 16:46:10 PDT
Comment on attachment 306563 [details]
Patch

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

Thanks Brent for r+ my patch.

>> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:5
>> +FAIL Derived key of type name: AES-CBC length: 128  using short derivedKey, normal salt, SHA-384, with normal info with bad hash name SHA384 assert_equals: deriveKey with bad hash name correctly threw NotSupportedError: Member HkdfParams.info is required and must be an instance of BufferSource expected "NotSupportedError" but got "TypeError"
> 
> Is this expected?

Yes. Since we detect the TypeError before the NotSupportedError, we return early. The problem with these tests is that they don't have the required dictionary member info. Therefore, we can't convert the supplied dictionaries into HkdfParams.

>> LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:3092
>> +FAIL empty derivedKey, empty salt, SHA-384, with normal info assert_unreached: deriveBits failed with error OperationError: The operation failed for an operation-specific reason Reached unreachable code
> 
> Ditto...

Not sure what this test case expects. OperationError is expected for this case.
Comment 7 WebKit Commit Bot 2017-04-14 17:17:26 PDT
Comment on attachment 306563 [details]
Patch

Clearing flags on attachment: 306563

Committed r215382: <http://trac.webkit.org/changeset/215382>
Comment 8 WebKit Commit Bot 2017-04-14 17:17:27 PDT
All reviewed patches have been landed.  Closing bug.