Bug 233704 - support importing compressed EC keys in webcrypto
Summary: support importing compressed EC keys in webcrypto
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Other
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 244005 244083 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-12-01 08:12 PST by Filip Skokan
Modified: 2022-08-18 18:02 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Skokan 2021-12-01 08:12:29 PST
Steps to reproduce:

// SPKI representation of a P-384 EC key in a compressed form.
const spki = new Uint8Array([48, 70, 48, 16, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 5, 43, 129, 4, 0, 34, 3, 50, 0, 2, 251, 203, 124, 105, 238, 28, 96, 87, 155, 231, 163, 52, 19, 72, 120, 217, 197, 197, 191, 53, 213, 82, 218, 182, 60, 1, 64, 57, 126, 209, 76, 239, 99, 125, 119, 32, 146, 92, 68, 105, 158, 163, 14, 114, 135, 76, 114, 251])

crypto.subtle.importKey('spki', spki, { name: 'ECDSA', namedCurve: 'P-384' }, false, ['verify'])

Actual result:

importKey is rejected with DataError: Data provided to an operation does not meet requirements

Expected result:

compressed EC public key SPKI should import as in other browsers (we expect interoperability in this regard)
Comment 1 Filip Skokan 2021-12-01 08:14:10 PST
Likewise, same issue, when using the raw keyFormat

const pub = new Uint8Array([2, 251, 203, 124, 105, 238, 28, 96, 87, 155, 231, 163, 52, 19, 72, 120, 217, 197, 197, 191, 53, 213, 82, 218, 182, 60, 1, 64, 57, 126, 209, 76, 239, 99, 125, 119, 32, 146, 92, 68, 105, 158, 163, 14, 114, 135, 76, 114, 251])
await crypto.subtle.importKey('raw', pub, { name: 'ECDSA', namedCurve: 'P-384' }, false, ['verify'])

importKey is rejected with DataError: Data provided to an operation does not meet requirements
Comment 2 Radar WebKit Bug Importer 2021-12-08 08:13:22 PST
<rdar://problem/86211772>
Comment 3 Angela 2022-08-17 12:06:53 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3406
Comment 4 Alexey Proskuryakov 2022-08-17 18:44:03 PDT
*** Bug 244005 has been marked as a duplicate of this bug. ***
Comment 5 Alexey Proskuryakov 2022-08-17 18:44:06 PDT
*** Bug 244032 has been marked as a duplicate of this bug. ***
Comment 6 Alexey Proskuryakov 2022-08-18 18:02:30 PDT
*** Bug 244083 has been marked as a duplicate of this bug. ***