Changeset 213560 in webkit


Ignore:
Timestamp:
Mar 7, 2017 6:09:38 PM (7 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebCrypto] Implement ECDH ImportKey/ExportKey operations
https://bugs.webkit.org/show_bug.cgi?id=169257
<rdar://problem/23789585>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

  • web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt:
  • web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt:

Source/WebCore:

This patch implements ECDH ImportKey/ExportKey operations according to:
https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations. Sad that we can't
support SPKI/PKCS8 formats at this moment due to lack of necessary
support in the underlying crypto library. Bug 169318 is tracking the
issue. Also, this patch fixes minor bugs while importing JWK keys for
HMAC/RSA.

Tests: crypto/subtle/ec-export-key-malformed-parameters.html

crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html
crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html
crypto/subtle/ec-import-jwk-key-export-raw-key.html
crypto/subtle/ec-import-key-malformed-parameters.html
crypto/subtle/ec-import-raw-key-export-jwk-key.html
crypto/subtle/ec-import-raw-key-export-raw-key.html
crypto/subtle/ecdh-generate-export-jwk-key-p256.html
crypto/subtle/ecdh-generate-export-jwk-key-p384.html
crypto/subtle/ecdh-generate-export-key-raw-p256.html
crypto/subtle/ecdh-generate-export-key-raw-p384.html
crypto/subtle/ecdh-import-jwk-key-minimum.html
crypto/subtle/ecdh-import-jwk-private-key-p256.html
crypto/subtle/ecdh-import-jwk-private-key-p384.html
crypto/subtle/ecdh-import-jwk-public-key-p256.html
crypto/subtle/ecdh-import-jwk-public-key-p384.html
crypto/subtle/ecdh-import-raw-key-p256.html
crypto/subtle/ecdh-import-raw-key-p384.html
crypto/workers/subtle/ec-generate-export-jwk-key.html
crypto/workers/subtle/ec-generate-export-raw-key.html
crypto/workers/subtle/ec-import-jwk-key-private.html
crypto/workers/subtle/ec-import-jwk-key-public.html
crypto/workers/subtle/ec-import-raw-key.html

  • bindings/js/JSSubtleCryptoCustom.cpp:

(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::supportExportKeyThrow):
Added EC family support.

  • crypto/CommonCryptoUtilities.h:

Added needed CommonCrypto SPIs.

  • crypto/CryptoAlgorithm.h:
  • crypto/algorithms/CryptoAlgorithmECDH.cpp:

(WebCore::CryptoAlgorithmECDH::importKey):
(WebCore::CryptoAlgorithmECDH::exportKey):

  • crypto/algorithms/CryptoAlgorithmECDH.h:
  • crypto/gnutls/CryptoKeyECGnuTLS.cpp:

(WebCore::CryptoKeyEC::keySizeInBits):
(WebCore::CryptoKeyEC::exportRaw):
(WebCore::CryptoKeyEC::platformImportRaw):
(WebCore::CryptoKeyEC::platformImportJWKPublic):
(WebCore::CryptoKeyEC::platformImportJWKPrivate):
(WebCore::CryptoKeyEC::platformAddFieldElements):
Faked implementations for GTK+.

  • crypto/keys/CryptoKeyEC.cpp:

(WebCore::toNamedCurve):
(WebCore::CryptoKeyEC::generatePair):
(WebCore::CryptoKeyEC::importRaw):
(WebCore::CryptoKeyEC::importJwk):
(WebCore::CryptoKeyEC::exportJwk):

  • crypto/keys/CryptoKeyEC.h:
  • crypto/keys/CryptoKeyHMAC.cpp:

(WebCore::CryptoKeyHMAC::importJwk):
Fixed a bug.

  • crypto/keys/CryptoKeyRSA.cpp:

(WebCore::CryptoKeyRSA::importJwk):
Fixed a bug.

  • crypto/mac/CryptoKeyECMac.cpp:

(WebCore::doesUncompressedPointMatchNamedCurve):
(WebCore::doesFieldElementMatchNamedCurve):
(WebCore::getKeySizeFromNamedCurve):
(WebCore::CryptoKeyEC::~CryptoKeyEC):
(WebCore::CryptoKeyEC::keySizeInBits):
(WebCore::CryptoKeyEC::exportRaw):
(WebCore::CryptoKeyEC::platformGeneratePair):
(WebCore::CryptoKeyEC::platformImportRaw):
(WebCore::CryptoKeyEC::platformImportJWKPublic):
(WebCore::CryptoKeyEC::platformImportJWKPrivate):
(WebCore::CryptoKeyEC::platformAddFieldElements):

LayoutTests:

  • crypto/subtle/ec-export-key-malformed-parameters-expected.txt: Added.
  • crypto/subtle/ec-export-key-malformed-parameters.html: Added.
  • crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt: Added.
  • crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html: Added.
  • crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt: Added.
  • crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html: Added.
  • crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt: Added.
  • crypto/subtle/ec-import-jwk-key-export-raw-key.html: Added.
  • crypto/subtle/ec-import-key-malformed-parameters-expected.txt: Added.
  • crypto/subtle/ec-import-key-malformed-parameters.html: Added.
  • crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt: Added.
  • crypto/subtle/ec-import-raw-key-export-jwk-key.html: Added.
  • crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt: Added.
  • crypto/subtle/ec-import-raw-key-export-raw-key.html: Added.
  • crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt: Added.
  • crypto/subtle/ecdh-generate-export-jwk-key-p256.html: Added.
  • crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt: Added.
  • crypto/subtle/ecdh-generate-export-jwk-key-p384.html: Added.
  • crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt: Added.
  • crypto/subtle/ecdh-generate-export-key-raw-p256.html: Added.
  • crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt: Added.
  • crypto/subtle/ecdh-generate-export-key-raw-p384.html: Added.
  • crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt: Added.
  • crypto/subtle/ecdh-import-jwk-key-minimum.html: Added.
  • crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt: Added.
  • crypto/subtle/ecdh-import-jwk-private-key-p256.html: Added.
  • crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt: Added.
  • crypto/subtle/ecdh-import-jwk-private-key-p384.html: Added.
  • crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt: Added.
  • crypto/subtle/ecdh-import-jwk-public-key-p256.html: Added.
  • crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt: Added.
  • crypto/subtle/ecdh-import-jwk-public-key-p384.html: Added.
  • crypto/subtle/ecdh-import-raw-key-p256-expected.txt: Added.
  • crypto/subtle/ecdh-import-raw-key-p256.html: Added.
  • crypto/subtle/ecdh-import-raw-key-p384-expected.txt: Added.
  • crypto/subtle/ecdh-import-raw-key-p384.html: Added.
  • crypto/subtle/hmac-import-key-malformed-parameters-expected.txt:
  • crypto/subtle/hmac-import-key-malformed-parameters.html:
  • crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
  • crypto/subtle/rsa-import-key-malformed-parameters.html:

Fixed some minor bugs.

  • crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt: Added.
  • crypto/workers/subtle/ec-generate-export-jwk-key.html: Added.
  • crypto/workers/subtle/ec-generate-export-raw-key-expected.txt: Added.
  • crypto/workers/subtle/ec-generate-export-raw-key.html: Added.
  • crypto/workers/subtle/ec-import-jwk-key-private-expected.txt: Added.
  • crypto/workers/subtle/ec-import-jwk-key-private.html: Added.
  • crypto/workers/subtle/ec-import-jwk-key-public-expected.txt: Added.
  • crypto/workers/subtle/ec-import-jwk-key-public.html: Added.
  • crypto/workers/subtle/ec-import-raw-key-expected.txt: Added.
  • crypto/workers/subtle/ec-import-raw-key.html: Added.
  • crypto/workers/subtle/resources/ec-generate-export-jwk-key.js: Added.
  • crypto/workers/subtle/resources/ec-generate-export-raw-key.js: Added.
  • crypto/workers/subtle/resources/ec-import-jwk-key-private.js: Added.
  • crypto/workers/subtle/resources/ec-import-jwk-key-public.js: Added.
  • crypto/workers/subtle/resources/ec-import-raw-key.js: Added.
Location:
trunk
Files:
51 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r213554 r213560  
     12017-03-07  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
     4        https://bugs.webkit.org/show_bug.cgi?id=169257
     5        <rdar://problem/23789585>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * crypto/subtle/ec-export-key-malformed-parameters-expected.txt: Added.
     10        * crypto/subtle/ec-export-key-malformed-parameters.html: Added.
     11        * crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt: Added.
     12        * crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html: Added.
     13        * crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt: Added.
     14        * crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html: Added.
     15        * crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt: Added.
     16        * crypto/subtle/ec-import-jwk-key-export-raw-key.html: Added.
     17        * crypto/subtle/ec-import-key-malformed-parameters-expected.txt: Added.
     18        * crypto/subtle/ec-import-key-malformed-parameters.html: Added.
     19        * crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt: Added.
     20        * crypto/subtle/ec-import-raw-key-export-jwk-key.html: Added.
     21        * crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt: Added.
     22        * crypto/subtle/ec-import-raw-key-export-raw-key.html: Added.
     23        * crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt: Added.
     24        * crypto/subtle/ecdh-generate-export-jwk-key-p256.html: Added.
     25        * crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt: Added.
     26        * crypto/subtle/ecdh-generate-export-jwk-key-p384.html: Added.
     27        * crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt: Added.
     28        * crypto/subtle/ecdh-generate-export-key-raw-p256.html: Added.
     29        * crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt: Added.
     30        * crypto/subtle/ecdh-generate-export-key-raw-p384.html: Added.
     31        * crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt: Added.
     32        * crypto/subtle/ecdh-import-jwk-key-minimum.html: Added.
     33        * crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt: Added.
     34        * crypto/subtle/ecdh-import-jwk-private-key-p256.html: Added.
     35        * crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt: Added.
     36        * crypto/subtle/ecdh-import-jwk-private-key-p384.html: Added.
     37        * crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt: Added.
     38        * crypto/subtle/ecdh-import-jwk-public-key-p256.html: Added.
     39        * crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt: Added.
     40        * crypto/subtle/ecdh-import-jwk-public-key-p384.html: Added.
     41        * crypto/subtle/ecdh-import-raw-key-p256-expected.txt: Added.
     42        * crypto/subtle/ecdh-import-raw-key-p256.html: Added.
     43        * crypto/subtle/ecdh-import-raw-key-p384-expected.txt: Added.
     44        * crypto/subtle/ecdh-import-raw-key-p384.html: Added.
     45        * crypto/subtle/hmac-import-key-malformed-parameters-expected.txt:
     46        * crypto/subtle/hmac-import-key-malformed-parameters.html:
     47        * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
     48        * crypto/subtle/rsa-import-key-malformed-parameters.html:
     49        Fixed some minor bugs.
     50        * crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt: Added.
     51        * crypto/workers/subtle/ec-generate-export-jwk-key.html: Added.
     52        * crypto/workers/subtle/ec-generate-export-raw-key-expected.txt: Added.
     53        * crypto/workers/subtle/ec-generate-export-raw-key.html: Added.
     54        * crypto/workers/subtle/ec-import-jwk-key-private-expected.txt: Added.
     55        * crypto/workers/subtle/ec-import-jwk-key-private.html: Added.
     56        * crypto/workers/subtle/ec-import-jwk-key-public-expected.txt: Added.
     57        * crypto/workers/subtle/ec-import-jwk-key-public.html: Added.
     58        * crypto/workers/subtle/ec-import-raw-key-expected.txt: Added.
     59        * crypto/workers/subtle/ec-import-raw-key.html: Added.
     60        * crypto/workers/subtle/resources/ec-generate-export-jwk-key.js: Added.
     61        * crypto/workers/subtle/resources/ec-generate-export-raw-key.js: Added.
     62        * crypto/workers/subtle/resources/ec-import-jwk-key-private.js: Added.
     63        * crypto/workers/subtle/resources/ec-import-jwk-key-public.js: Added.
     64        * crypto/workers/subtle/resources/ec-import-raw-key.js: Added.
     65
    1662017-03-07  Ryan Haddad  <ryanhaddad@apple.com>
    267
  • trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt

    r212465 r213560  
    2424PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: ""}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2525PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: ["sign"]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     26PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: [ ]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2627PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", ext: false}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2728PASS successfullyParsed is true
  • trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html

    r212465 r213560  
    4444// Jwk: wrong key_ops
    4545shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: ["sign"]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
     46shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: [ ]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
    4647// Jwk: wrong ext
    4748shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", ext: false}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
  • trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt

    r212465 r213560  
    4343PASS crypto.subtle.importKey("jwk", {kty: "oct", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    4444PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: ["sign", "verify"]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     45PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: [ ]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    4546PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, ext: false}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    4647PASS crypto.subtle.importKey("jwk", {kty: "RSA"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
  • trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html

    r212465 r213560  
    7777// Jwk: Wrong key_ops
    7878shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: ["sign", "verify"]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
     79shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, key_ops: [ ]}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
    7980// Jwk: Wrong ext
    8081shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, ext: false}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r213546 r213560  
     12017-03-07  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
     4        https://bugs.webkit.org/show_bug.cgi?id=169257
     5        <rdar://problem/23789585>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt:
     10        * web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt:
     11
    1122017-03-07  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt

    r212124 r213560  
    2424FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    2525FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    26 FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    27 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    28 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    29 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    30 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    31 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    32 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    33 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    34 FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    35 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    36 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    37 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    38 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    39 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    40 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    41 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    42 FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    43 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    44 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    45 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    46 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    47 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    48 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    49 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    50 FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    51 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    52 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    53 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    54 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    55 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    56 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    57 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    58 FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    59 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    60 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    61 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    62 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    63 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    64 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    65 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    66 FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    67 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    68 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    69 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    70 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    71 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    72 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    73 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
     26FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     27PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, [])
     28FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     29PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey])
     30FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     31PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey])
     32FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     33PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits])
     34FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     35PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, [])
     36FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     37PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey])
     38FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     39PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey])
     40FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     41PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits])
     42FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     43PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, [])
     44FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     45PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey])
     46FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     47PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey])
     48FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     49PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits])
     50FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     51PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, [])
     52FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     53PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey])
     54FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     55PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey])
     56FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     57PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits])
     58FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     59FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     60FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     61FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     62FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     63FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     64FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     65FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     66FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     67FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     68FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     69FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     70FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     71FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     72FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     73FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
    7474
  • trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt

    r212124 r213560  
    2424FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    2525FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    26 FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    27 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    28 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    29 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    30 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    31 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    32 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    33 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    34 FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    35 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    36 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    37 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    38 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    39 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    40 FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    41 FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    42 FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    43 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    44 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    45 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    46 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    47 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    48 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    49 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    50 FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    51 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    52 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    53 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    54 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    55 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    56 FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    57 FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    58 FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    59 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    60 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    61 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    62 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    63 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    64 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    65 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    66 FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    67 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    68 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    69 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    70 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    71 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    72 FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
    73 FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
     26FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     27PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, [])
     28FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     29PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey])
     30FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     31PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey])
     32FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     33PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits])
     34FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     35PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, [])
     36FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     37PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey])
     38FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     39PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey])
     40FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     41PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits])
     42FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     43PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, [])
     44FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     45PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey])
     46FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     47PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey])
     48FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     49PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits])
     50FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     51PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, [])
     52FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     53PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey])
     54FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     55PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey])
     56FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     57PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits])
     58FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     59FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     60FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     61FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     62FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     63FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     64FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     65FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     66FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     67FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     68FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     69FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     70FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     71FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
     72FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
     73FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
    7474
  • trunk/Source/WebCore/ChangeLog

    r213558 r213560  
     12017-03-07  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
     4        https://bugs.webkit.org/show_bug.cgi?id=169257
     5        <rdar://problem/23789585>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch implements ECDH ImportKey/ExportKey operations according to:
     10        https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations. Sad that we can't
     11        support SPKI/PKCS8 formats at this moment due to lack of necessary
     12        support in the underlying crypto library. Bug 169318 is tracking the
     13        issue. Also, this patch fixes minor bugs while importing JWK keys for
     14        HMAC/RSA.
     15
     16        Tests: crypto/subtle/ec-export-key-malformed-parameters.html
     17               crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html
     18               crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html
     19               crypto/subtle/ec-import-jwk-key-export-raw-key.html
     20               crypto/subtle/ec-import-key-malformed-parameters.html
     21               crypto/subtle/ec-import-raw-key-export-jwk-key.html
     22               crypto/subtle/ec-import-raw-key-export-raw-key.html
     23               crypto/subtle/ecdh-generate-export-jwk-key-p256.html
     24               crypto/subtle/ecdh-generate-export-jwk-key-p384.html
     25               crypto/subtle/ecdh-generate-export-key-raw-p256.html
     26               crypto/subtle/ecdh-generate-export-key-raw-p384.html
     27               crypto/subtle/ecdh-import-jwk-key-minimum.html
     28               crypto/subtle/ecdh-import-jwk-private-key-p256.html
     29               crypto/subtle/ecdh-import-jwk-private-key-p384.html
     30               crypto/subtle/ecdh-import-jwk-public-key-p256.html
     31               crypto/subtle/ecdh-import-jwk-public-key-p384.html
     32               crypto/subtle/ecdh-import-raw-key-p256.html
     33               crypto/subtle/ecdh-import-raw-key-p384.html
     34               crypto/workers/subtle/ec-generate-export-jwk-key.html
     35               crypto/workers/subtle/ec-generate-export-raw-key.html
     36               crypto/workers/subtle/ec-import-jwk-key-private.html
     37               crypto/workers/subtle/ec-import-jwk-key-public.html
     38               crypto/workers/subtle/ec-import-raw-key.html
     39
     40        * bindings/js/JSSubtleCryptoCustom.cpp:
     41        (WebCore::normalizeCryptoAlgorithmParameters):
     42        (WebCore::supportExportKeyThrow):
     43        Added EC family support.
     44        * crypto/CommonCryptoUtilities.h:
     45        Added needed CommonCrypto SPIs.
     46        * crypto/CryptoAlgorithm.h:
     47        * crypto/algorithms/CryptoAlgorithmECDH.cpp:
     48        (WebCore::CryptoAlgorithmECDH::importKey):
     49        (WebCore::CryptoAlgorithmECDH::exportKey):
     50        * crypto/algorithms/CryptoAlgorithmECDH.h:
     51        * crypto/gnutls/CryptoKeyECGnuTLS.cpp:
     52        (WebCore::CryptoKeyEC::keySizeInBits):
     53        (WebCore::CryptoKeyEC::exportRaw):
     54        (WebCore::CryptoKeyEC::platformImportRaw):
     55        (WebCore::CryptoKeyEC::platformImportJWKPublic):
     56        (WebCore::CryptoKeyEC::platformImportJWKPrivate):
     57        (WebCore::CryptoKeyEC::platformAddFieldElements):
     58        Faked implementations for GTK+.
     59        * crypto/keys/CryptoKeyEC.cpp:
     60        (WebCore::toNamedCurve):
     61        (WebCore::CryptoKeyEC::generatePair):
     62        (WebCore::CryptoKeyEC::importRaw):
     63        (WebCore::CryptoKeyEC::importJwk):
     64        (WebCore::CryptoKeyEC::exportJwk):
     65        * crypto/keys/CryptoKeyEC.h:
     66        * crypto/keys/CryptoKeyHMAC.cpp:
     67        (WebCore::CryptoKeyHMAC::importJwk):
     68        Fixed a bug.
     69        * crypto/keys/CryptoKeyRSA.cpp:
     70        (WebCore::CryptoKeyRSA::importJwk):
     71        Fixed a bug.
     72        * crypto/mac/CryptoKeyECMac.cpp:
     73        (WebCore::doesUncompressedPointMatchNamedCurve):
     74        (WebCore::doesFieldElementMatchNamedCurve):
     75        (WebCore::getKeySizeFromNamedCurve):
     76        (WebCore::CryptoKeyEC::~CryptoKeyEC):
     77        (WebCore::CryptoKeyEC::keySizeInBits):
     78        (WebCore::CryptoKeyEC::exportRaw):
     79        (WebCore::CryptoKeyEC::platformGeneratePair):
     80        (WebCore::CryptoKeyEC::platformImportRaw):
     81        (WebCore::CryptoKeyEC::platformImportJWKPublic):
     82        (WebCore::CryptoKeyEC::platformImportJWKPrivate):
     83        (WebCore::CryptoKeyEC::platformAddFieldElements):
     84
    1852017-03-07  Youenn Fablet  <youenn@apple.com>
    286
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r213489 r213560  
    244244                break;
    245245            }
     246            case CryptoAlgorithmIdentifier::ECDSA:
     247            case CryptoAlgorithmIdentifier::ECDH: {
     248                auto params = convertDictionary<CryptoAlgorithmEcKeyParams>(state, value);
     249                RETURN_IF_EXCEPTION(scope, nullptr);
     250                result = std::make_unique<CryptoAlgorithmEcKeyParams>(params);
     251                break;
     252            }
    246253            default:
    247254                throwNotSupportedError(state, scope);
     
    416423    case CryptoAlgorithmIdentifier::AES_KW:
    417424    case CryptoAlgorithmIdentifier::HMAC:
     425    case CryptoAlgorithmIdentifier::ECDSA:
     426    case CryptoAlgorithmIdentifier::ECDH:
    418427        return;
    419428    default:
  • trunk/Source/WebCore/crypto/CommonCryptoUtilities.h

    r213489 r213560  
    8787extern "C" CCCryptorStatus CCRSACryptorExport(CCRSACryptorRef key, void *out, size_t *outLen);
    8888
     89#ifndef _CC_ECCRYPTOR_H_
     90enum {
     91    ccECKeyPublic = 0,
     92    ccECKeyPrivate = 1,
     93};
     94typedef uint32_t CCECKeyType;
     95
     96enum {
     97    kCCImportKeyBinary = 0,
     98};
     99typedef uint32_t CCECKeyExternalFormat;
     100#endif
     101
    89102typedef struct _CCECCryptor *CCECCryptorRef;
    90103extern "C" CCCryptorStatus CCECCryptorGeneratePair(size_t keysize, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey);
    91104extern "C" void CCECCryptorRelease(CCECCryptorRef key);
     105extern "C" CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key);
     106extern "C" CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key);
     107extern "C" int CCECGetKeySize(CCECCryptorRef key);
     108extern "C" CCCryptorStatus CCECCryptorCreateFromData(size_t keySize, uint8_t *qX, size_t qXLength, uint8_t *qY, size_t qYLength, CCECCryptorRef *ref);
     109extern "C" CCCryptorStatus CCECCryptorGetKeyComponents(CCECCryptorRef ecKey, size_t *keySize, uint8_t *qX, size_t *qXLength, uint8_t *qY, size_t *qYLength, uint8_t *d, size_t *dLength);
     110
    92111
    93112#if !USE(APPLE_INTERNAL_SDK)
  • trunk/Source/WebCore/crypto/CryptoAlgorithm.h

    r212736 r213560  
    7373    virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
    7474    virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
     75    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169262
    7576    virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
    7677    virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp

    r213489 r213560  
    6666}
    6767
     68void CryptoAlgorithmECDH::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
     69{
     70    ASSERT(parameters);
     71    const auto& ecParameters = downcast<CryptoAlgorithmEcKeyParams>(*parameters);
     72
     73    RefPtr<CryptoKeyEC> result;
     74    switch (format) {
     75    case SubtleCrypto::KeyFormat::Jwk: {
     76        JsonWebKey key = WTFMove(WTF::get<JsonWebKey>(data));
     77
     78        bool isUsagesAllowed = false;
     79        if (!key.d.isNull()) {
     80            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageDeriveKey);
     81            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageDeriveBits);
     82            isUsagesAllowed = isUsagesAllowed || !(usages ^ (CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits));
     83        }
     84        isUsagesAllowed = isUsagesAllowed || !usages;
     85        if (!isUsagesAllowed) {
     86            exceptionCallback(SYNTAX_ERR);
     87            return;
     88        }
     89
     90        if (usages && !key.use.isNull() && key.use != "enc") {
     91            exceptionCallback(DataError);
     92            return;
     93        }
     94
     95        result = CryptoKeyEC::importJwk(ecParameters.identifier, ecParameters.namedCurve, WTFMove(key), extractable, usages);
     96        break;
     97    }
     98    case SubtleCrypto::KeyFormat::Raw:
     99        if (usages) {
     100            exceptionCallback(SYNTAX_ERR);
     101            return;
     102        }
     103        result = CryptoKeyEC::importRaw(ecParameters.identifier, ecParameters.namedCurve, WTFMove(WTF::get<Vector<uint8_t>>(data)), extractable, usages);
     104        break;
     105    default:
     106        exceptionCallback(NOT_SUPPORTED_ERR);
     107        return;
     108    }
     109    if (!result) {
     110        exceptionCallback(DataError);
     111        return;
     112    }
     113
     114    callback(*result);
     115}
     116
     117void CryptoAlgorithmECDH::exportKey(SubtleCrypto::KeyFormat format, Ref<CryptoKey>&& key, KeyDataCallback&& callback, ExceptionCallback&& exceptionCallback)
     118{
     119    const auto& ecKey = downcast<CryptoKeyEC>(key.get());
     120
     121    if (!ecKey.keySizeInBits()) {
     122        exceptionCallback(OperationError);
     123        return;
     124    }
     125
     126    KeyData result;
     127    switch (format) {
     128    case SubtleCrypto::KeyFormat::Jwk: {
     129        result = ecKey.exportJwk();
     130        break;
     131    }
     132    case SubtleCrypto::KeyFormat::Raw: {
     133        if (ecKey.type() != CryptoKey::Type::Public) {
     134            exceptionCallback(INVALID_ACCESS_ERR);
     135            return;
     136        }
     137        result = ecKey.exportRaw();
     138        break;
     139    }
     140    default:
     141        exceptionCallback(NOT_SUPPORTED_ERR);
     142        return;
     143    }
     144
     145    callback(format, WTFMove(result));
     146}
     147
    68148} // namespace WebCore
    69149
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h

    r213489 r213560  
    4343
    4444    void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
     45    void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
     46    void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
    4547};
    4648
  • trunk/Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp

    r213489 r213560  
    4242}
    4343
     44size_t CryptoKeyEC::keySizeInBits() const
     45{
     46    notImplemented();
     47
     48    return 0;
     49}
     50
     51Vector<uint8_t> CryptoKeyEC::exportRaw() const
     52{
     53    notImplemented();
     54
     55    return { };
     56}
     57
    4458std::optional<CryptoKeyPair> CryptoKeyEC::platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool, CryptoKeyUsageBitmap)
    4559{
     
    4963}
    5064
     65RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&&, bool, CryptoKeyUsageBitmap)
     66{
     67    notImplemented();
     68
     69    return nullptr;
     70}
     71
     72RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportJWKPublic(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&&, Vector<uint8_t>&&, bool, CryptoKeyUsageBitmap)
     73{
     74    notImplemented();
     75
     76    return nullptr;
     77}
     78
     79RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportJWKPrivate(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, bool, CryptoKeyUsageBitmap)
     80{
     81    notImplemented();
     82
     83    return nullptr;
     84}
     85
     86void CryptoKeyEC::platformAddFieldElements(JsonWebKey&) const
     87{
     88    notImplemented();
     89}
     90
    5191} // namespace WebCore
    5292
  • trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp

    r213489 r213560  
    3232#include "CryptoKeyData.h"
    3333#include "ExceptionCode.h"
     34#include "JsonWebKey.h"
     35#include <wtf/text/Base64.h>
    3436
    3537namespace WebCore {
     
    3739static const char* const P256 = "P-256";
    3840static const char* const P384 = "P-384";
     41
     42static std::optional<CryptoKeyEC::NamedCurve> toNamedCurve(const String& curve)
     43{
     44    if (curve == P256)
     45        return CryptoKeyEC::NamedCurve::P256;
     46    if (curve == P384)
     47        return CryptoKeyEC::NamedCurve::P384;
     48
     49    return std::nullopt;
     50}
    3951
    4052CryptoKeyEC::CryptoKeyEC(CryptoAlgorithmIdentifier identifier, NamedCurve curve, CryptoKeyType type, PlatformECKey platformKey, bool extractable, CryptoKeyUsageBitmap usages)
     
    4557}
    4658
    47 ExceptionOr<CryptoKeyPair> CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier identifier, const String& namedCurve, bool extractable, CryptoKeyUsageBitmap usages)
     59ExceptionOr<CryptoKeyPair> CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier identifier, const String& curve, bool extractable, CryptoKeyUsageBitmap usages)
    4860{
    49     NamedCurve curve;
    50     if (namedCurve == P256)
    51         curve = NamedCurve::P256;
    52     else if (namedCurve == P384)
    53         curve = NamedCurve::P384;
    54     else
     61    auto namedCurve = toNamedCurve(curve);
     62    if (!namedCurve)
    5563        return Exception { NOT_SUPPORTED_ERR };
    5664
    57     auto result = platformGeneratePair(identifier, curve, extractable, usages);
     65    auto result = platformGeneratePair(identifier, *namedCurve, extractable, usages);
    5866    if (!result)
    5967        return Exception { OperationError };
    6068
    6169    return WTFMove(*result);
     70}
     71
     72RefPtr<CryptoKeyEC> CryptoKeyEC::importRaw(CryptoAlgorithmIdentifier identifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap usages)
     73{
     74    auto namedCurve = toNamedCurve(curve);
     75    if (!namedCurve)
     76        return nullptr;
     77
     78    return platformImportRaw(identifier, *namedCurve, WTFMove(keyData), extractable, usages);
     79}
     80
     81RefPtr<CryptoKeyEC> CryptoKeyEC::importJwk(CryptoAlgorithmIdentifier identifier, const String& curve, JsonWebKey&& keyData, bool extractable, CryptoKeyUsageBitmap usages)
     82{
     83    if (keyData.kty != "EC")
     84        return nullptr;
     85    if (keyData.key_ops && ((keyData.usages & usages) != usages))
     86        return nullptr;
     87    if (keyData.ext && !keyData.ext.value() && extractable)
     88        return nullptr;
     89
     90    if (keyData.crv.isNull() || curve != keyData.crv)
     91        return nullptr;
     92    auto namedCurve = toNamedCurve(keyData.crv);
     93    if (!namedCurve)
     94        return nullptr;
     95
     96    if (keyData.x.isNull() || keyData.y.isNull())
     97        return nullptr;
     98    Vector<uint8_t> x;
     99    if (!WTF::base64URLDecode(keyData.x, x))
     100        return nullptr;
     101    Vector<uint8_t> y;
     102    if (!WTF::base64URLDecode(keyData.y, y))
     103        return nullptr;
     104    if (keyData.d.isNull()) {
     105        // import public key
     106        return platformImportJWKPublic(identifier, *namedCurve, WTFMove(x), WTFMove(y), extractable, usages);
     107    }
     108
     109    Vector<uint8_t> d;
     110    if (!WTF::base64URLDecode(keyData.d, d))
     111        return nullptr;
     112    // import private key
     113    return platformImportJWKPrivate(identifier, *namedCurve, WTFMove(x), WTFMove(y), WTFMove(d), extractable, usages);
     114}
     115
     116JsonWebKey CryptoKeyEC::exportJwk() const
     117{
     118    JsonWebKey result;
     119    result.kty = "EC";
     120    switch (m_curve) {
     121    case NamedCurve::P256:
     122        result.crv = P256;
     123        break;
     124    case NamedCurve::P384:
     125        result.crv = P384;
     126        break;
     127    }
     128    result.key_ops = usages();
     129    result.ext = extractable();
     130    platformAddFieldElements(result);
     131    return result;
    62132}
    63133
  • trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h

    r213489 r213560  
    4545namespace WebCore {
    4646
     47struct JsonWebKey;
     48
    4749class EcKeyAlgorithm : public KeyAlgorithm {
    4850public:
     
    7577    virtual ~CryptoKeyEC();
    7678
    77     static ExceptionOr<CryptoKeyPair> generatePair(CryptoAlgorithmIdentifier, const String&, bool extractable, CryptoKeyUsageBitmap);
     79    static ExceptionOr<CryptoKeyPair> generatePair(CryptoAlgorithmIdentifier, const String& curve, bool extractable, CryptoKeyUsageBitmap);
     80    static RefPtr<CryptoKeyEC> importRaw(CryptoAlgorithmIdentifier, const String& curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
     81    static RefPtr<CryptoKeyEC> importJwk(CryptoAlgorithmIdentifier, const String& curve, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap);
     82
     83    Vector<uint8_t> exportRaw() const;
     84    JsonWebKey exportJwk() const;
     85
     86    size_t keySizeInBits() const;
    7887
    7988private:
     
    8695
    8796    static std::optional<CryptoKeyPair> platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool extractable, CryptoKeyUsageBitmap);
     97    static RefPtr<CryptoKeyEC> platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
     98    static RefPtr<CryptoKeyEC> platformImportJWKPublic(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&& x, Vector<uint8_t>&& y, bool extractable, CryptoKeyUsageBitmap);
     99    static RefPtr<CryptoKeyEC> platformImportJWKPrivate(CryptoAlgorithmIdentifier, NamedCurve, Vector<uint8_t>&& x, Vector<uint8_t>&& y, Vector<uint8_t>&& d, bool extractable, CryptoKeyUsageBitmap);
     100    void platformAddFieldElements(JsonWebKey&) const;
    88101
    89102    PlatformECKey m_platformKey;
  • trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp

    r212465 r213560  
    107107    if (usages && !keyData.use.isNull() && keyData.use != "sig")
    108108        return nullptr;
    109     if (keyData.usages && ((keyData.usages & usages) != usages))
     109    if (keyData.key_ops && ((keyData.usages & usages) != usages))
    110110        return nullptr;
    111111    if (keyData.ext && !keyData.ext.value() && extractable)
  • trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp

    r212465 r213560  
    3939    if (keyData.kty != "RSA")
    4040        return nullptr;
    41     if (keyData.usages && ((keyData.usages & usages) != usages))
     41    if (keyData.key_ops && ((keyData.usages & usages) != usages))
    4242        return nullptr;
    4343    if (keyData.ext && !keyData.ext.value() && extractable)
  • trunk/Source/WebCore/crypto/mac/CryptoKeyECMac.cpp

    r213489 r213560  
    3030
    3131#include "CommonCryptoUtilities.h"
     32#include "JsonWebKey.h"
     33#include <wtf/text/Base64.h>
    3234
    3335namespace WebCore {
     36
     37static unsigned char InitialOctet = 0x04; // Per Section 2.3.3 of http://www.secg.org/sec1-v2.pdf
     38
     39// Per Section 2.3.4 of http://www.secg.org/sec1-v2.pdf
     40// We only support uncompressed point format.
     41static bool doesUncompressedPointMatchNamedCurve(CryptoKeyEC::NamedCurve curve, size_t size)
     42{
     43    switch (curve) {
     44    case CryptoKeyEC::NamedCurve::P256:
     45        return size == 65;
     46    case CryptoKeyEC::NamedCurve::P384:
     47        return size == 97;
     48    }
     49
     50    ASSERT_NOT_REACHED();
     51    return false;
     52}
     53
     54// Per Section 2.3.5 of http://www.secg.org/sec1-v2.pdf
     55static bool doesFieldElementMatchNamedCurve(CryptoKeyEC::NamedCurve curve, size_t size)
     56{
     57    switch (curve) {
     58    case CryptoKeyEC::NamedCurve::P256:
     59        return size == 32;
     60    case CryptoKeyEC::NamedCurve::P384:
     61        return size == 48;
     62    }
     63
     64    ASSERT_NOT_REACHED();
     65    return false;
     66}
     67
     68static size_t getKeySizeFromNamedCurve(CryptoKeyEC::NamedCurve curve)
     69{
     70    switch (curve) {
     71    case CryptoKeyEC::NamedCurve::P256:
     72        return 256;
     73    case CryptoKeyEC::NamedCurve::P384:
     74        return 384;
     75    }
     76
     77    ASSERT_NOT_REACHED();
     78    return 0;
     79}
    3480
    3581CryptoKeyEC::~CryptoKeyEC()
     
    3884}
    3985
     86size_t CryptoKeyEC::keySizeInBits() const
     87{
     88    int result = CCECGetKeySize(m_platformKey);
     89    return result ? result : 0;
     90}
     91
     92Vector<uint8_t> CryptoKeyEC::exportRaw() const
     93{
     94    Vector<uint8_t> result(keySizeInBits() / 4 + 1); // Per Section 2.3.4 of http://www.secg.org/sec1-v2.pdf
     95    size_t size = result.size();
     96    CCECCryptorExportKey(kCCImportKeyBinary, result.data(), &size, ccECKeyPublic, m_platformKey);
     97    return result;
     98}
     99
    40100std::optional<CryptoKeyPair> CryptoKeyEC::platformGeneratePair(CryptoAlgorithmIdentifier identifier, NamedCurve curve, bool extractable, CryptoKeyUsageBitmap usages)
    41101{
    42     size_t size;
    43     switch (curve) {
    44     case NamedCurve::P256:
    45         size = 256;
    46         break;
    47     case NamedCurve::P384:
    48         size = 384;
    49         break;
    50     }
    51 
     102    size_t size = getKeySizeFromNamedCurve(curve);
    52103    CCECCryptorRef ccPublicKey;
    53104    CCECCryptorRef ccPrivateKey;
    54     CCCryptorStatus status = CCECCryptorGeneratePair(size, &ccPublicKey, &ccPrivateKey);
    55     if (status)
     105    if (CCECCryptorGeneratePair(size, &ccPublicKey, &ccPrivateKey))
    56106        return std::nullopt;
    57107
     
    61111}
    62112
     113RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportRaw(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap usages)
     114{
     115    if (!doesUncompressedPointMatchNamedCurve(curve, keyData.size()))
     116        return nullptr;
     117
     118    CCECCryptorRef ccPublicKey;
     119    if (CCECCryptorImportKey(kCCImportKeyBinary, keyData.data(), keyData.size(), ccECKeyPublic, &ccPublicKey))
     120        return nullptr;
     121
     122    return create(identifier, curve, CryptoKeyType::Public, ccPublicKey, extractable, usages);
     123}
     124
     125RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportJWKPublic(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector<uint8_t>&& x, Vector<uint8_t>&& y, bool extractable, CryptoKeyUsageBitmap usages)
     126{
     127    if (!doesFieldElementMatchNamedCurve(curve, x.size()) || !doesFieldElementMatchNamedCurve(curve, y.size()))
     128        return nullptr;
     129
     130    size_t size = getKeySizeFromNamedCurve(curve);
     131    CCECCryptorRef ccPublicKey;
     132    if (CCECCryptorCreateFromData(size, x.data(), x.size(), y.data(), y.size(), &ccPublicKey))
     133        return nullptr;
     134
     135    return create(identifier, curve, CryptoKeyType::Public, ccPublicKey, extractable, usages);
     136}
     137
     138RefPtr<CryptoKeyEC> CryptoKeyEC::platformImportJWKPrivate(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector<uint8_t>&& x, Vector<uint8_t>&& y, Vector<uint8_t>&& d, bool extractable, CryptoKeyUsageBitmap usages)
     139{
     140    if (!doesFieldElementMatchNamedCurve(curve, x.size()) || !doesFieldElementMatchNamedCurve(curve, y.size()) || !doesFieldElementMatchNamedCurve(curve, d.size()))
     141        return nullptr;
     142
     143    // A hack to CommonCrypto since it doesn't provide API for creating private keys directly from x, y, d.
     144    // BinaryInput = InitialOctet + X + Y + D
     145    Vector<uint8_t> binaryInput;
     146    binaryInput.append(InitialOctet);
     147    binaryInput.appendVector(x);
     148    binaryInput.appendVector(y);
     149    binaryInput.appendVector(d);
     150
     151    CCECCryptorRef ccPrivateKey;
     152    if (CCECCryptorImportKey(kCCImportKeyBinary, binaryInput.data(), binaryInput.size(), ccECKeyPrivate, &ccPrivateKey))
     153        return nullptr;
     154
     155    return create(identifier, curve, CryptoKeyType::Private, ccPrivateKey, extractable, usages);
     156}
     157
     158void CryptoKeyEC::platformAddFieldElements(JsonWebKey& jwk) const
     159{
     160    size_t size = getKeySizeFromNamedCurve(m_curve);
     161    size_t sizeInBytes = size / 8;
     162    Vector<uint8_t> x(sizeInBytes);
     163    size_t xSize = x.size();
     164    Vector<uint8_t> y(sizeInBytes);
     165    size_t ySize = y.size();
     166    Vector<uint8_t> d(sizeInBytes);
     167    size_t dSize = d.size();
     168
     169    CCECCryptorGetKeyComponents(m_platformKey, &size, x.data(), &xSize, y.data(), &ySize, d.data(), &dSize);
     170    jwk.x = base64URLEncode(x);
     171    jwk.y = base64URLEncode(y);
     172    if (type() == Type::Private)
     173        jwk.d = base64URLEncode(d);
     174}
     175
    63176} // namespace WebCore
    64177
Note: See TracChangeset for help on using the changeset viewer.