Changeset 212465 in webkit


Ignore:
Timestamp:
Feb 16, 2017 2:31:14 PM (7 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebCrypto] remove toJSValueFromJsonWebKey from custom SubtleCrypto binding codes
https://bugs.webkit.org/show_bug.cgi?id=167026

Reviewed by Chris Dumez.

Source/WebCore:

Covered by existing tests.

  • bindings/js/JSSubtleCryptoCustom.cpp:

(WebCore::jsSubtleCryptoFunctionExportKeyPromise):
(WebCore::jsSubtleCryptoFunctionWrapKeyPromise):
(WebCore::toJSValueFromJsonWebKey): Deleted.

  • crypto/JsonWebKey.h:
  • crypto/JsonWebKey.idl:
  • crypto/RsaOtherPrimesInfo.idl:

Change std::optional<String> to String in order to use toJS<IDLDictionary<JsonWebKey>>.

  • crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:

(WebCore::CryptoAlgorithmAES_CBC::importKey):

  • crypto/algorithms/CryptoAlgorithmAES_KW.cpp:

(WebCore::CryptoAlgorithmAES_KW::importKey):

  • crypto/algorithms/CryptoAlgorithmHMAC.cpp:

(WebCore::CryptoAlgorithmHMAC::importKey):

  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:

(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):

  • crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:

(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):

  • crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:

(WebCore::CryptoAlgorithmRSA_OAEP::importKey):

  • crypto/keys/CryptoKeyAES.cpp:

(WebCore::CryptoKeyAES::importJwk):
Only check if key_ops contains all of the specified usages when key_ops field of jwk is present,
as per the specification: https://www.w3.org/TR/WebCryptoAPI/#aes-cbc-operations

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

(WebCore::CryptoKeyHMAC::importJwk):

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

(WebCore::CryptoKeyRSA::importJwk):
Accommodate the change from std::optional<String> to String.

  • crypto/mac/CryptoKeyRSAMac.cpp:

(WebCore::CryptoKeyRSA::create):
Add a null check for p.

LayoutTests:

  • crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-private.html:
  • crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-public.html:

Order of attributes inside JWK is different after this patch.

  • crypto/subtle/aes-import-key-malformed-parameters-expected.txt:
  • crypto/subtle/aes-import-key-malformed-parameters.html:
  • 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:
  • crypto/workers/subtle/resources/aes-cbc-import-key-wrap-key.js:
Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r212460 r212465  
     12017-02-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] remove toJSValueFromJsonWebKey from custom SubtleCrypto binding codes
     4        https://bugs.webkit.org/show_bug.cgi?id=167026
     5
     6        Reviewed by Chris Dumez.
     7
     8        * crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-private.html:
     9        * crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-public.html:
     10        Order of attributes inside JWK is different after this patch.
     11
     12        * crypto/subtle/aes-import-key-malformed-parameters-expected.txt:
     13        * crypto/subtle/aes-import-key-malformed-parameters.html:
     14        * crypto/subtle/hmac-import-key-malformed-parameters-expected.txt:
     15        * crypto/subtle/hmac-import-key-malformed-parameters.html:
     16        * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
     17        * crypto/subtle/rsa-import-key-malformed-parameters.html:
     18        * crypto/workers/subtle/resources/aes-cbc-import-key-wrap-key.js:
     19
    1202017-02-16  Ryan Haddad  <ryanhaddad@apple.com>
    221
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-private.html

    r209155 r212465  
    3535    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
    3636}
    37 var expectWrappedKey = "848aa2f70ee18e2953520132a79cf479b03a8732a3cc73f8c51c68456d3c2557e8be9d5911b2a74267e282a87ffeed88dfbac38a22c26ba621f83915d7539420a4dc0b2329c585b442967367c1ea6c1126f98c4f13b7c8cb7402b86a5844c19420ea333dc33d908be89172f8bac59b403fe202f32c8eed19f431cedfc3383f536f3557163b1311ae42ee5486c6dafee968640d6b6999c687f37fba8d65cc662f1c84f16245665e4af41c98e8b63632cc1d19e2bece2154c7eab1905f3f6ab17b495cefec3508e9b451f2ea1422b97f275dfdc118f46af02040250d0e55d8d8d172b969bbcf7314a257f10b98d2c47c6c72a727acaf4c96340d590ebcebc61f73b7a868b490f3c1e17c59ea479a3b8db5574153de46cfdbb07cfc5e95ebcf7ad3d5fa057ba946d6da872c4bef3af6d7013e222c227650d0022c94d306cb14e203aad378d171c7c24f824c31b81fd18265e0de2f4b415584ebc4adeb5880c4eddbc88b854699f7aa74d6a10ca5df8978f27b5d1372b31ea67a9c4841ae101ea6ad78df0580b70358e6933ac92f7faee5320af329d8349a7b98690708a388737604be0affaa0669410d8d93dc4e4f57e14583253f11e5b27c89b84f1f3038bae6d9b37e3eb64b63ad1880627aef3b19e3e851cfae639ec46dd06fd131b51f530b37260b836d9013d8ad7c8640096070f96984c528ee5e20b69f3cd98a269621cd886ccb16d9c526a87cd5c458541309bb7fa4f3337305d76fc050d39ca8b1fdb0675a11a40ffde9cebb33ddc485e5dc5e7667b08c2a3e0136d063a447aee5a8f650429c5e422a706c4c240a4d11f4a9b5782f2cba2575f0c32cb477a9f0cef97fa993977104181315ff90e46f3b12b8b00f4a7611c42b1bb53d0e6021ab21ee8ae606d9f06dfedb891763007e020977c28b46d5f33bc35c12061d90ebbe02cab58783c0cac0c6f14ed735204f23d0eb6a9fe9edea2aecb1ac213f58b42d5d96374ec70ca288a31016ba02adef43250d717e9fab8982a1a180b1f3944d450c159010fd23f354d88502ec702882ae3edd567c6a6edf3cb2e34edc13f410a25d97298ab9062ddb566576fa8b6599bba205bab55aa5f3f37edaf7733cf249e69c74da975ef249ca673da749d86babebdf55410a389720ac943f1e9d921f5d69c5789636cb904fb9263744236eade9acae889a01c237ab3436101463dfa9d92f936c1b652c80f3abba76023ebe5b9bfdd54735e3a3494de18a456967f58758e546021feef3fa3e6c239981aa06f1f7ddc415d957ff9919bbec5f36af092a81ba6c14fe644d2ee98a2fcdee2ed70b87a53ffa327b25b4569c5886b15f2bd583d6f5bd7e951a915142baa08c6a9c343c200678a005fad22a337d2c5627f8c816db2525a7e121849b9da756eee68a240452849ffdb9651f998257c62e8fdcdc48dadfc3ebb18f7eb5461442008846a629ec8149c052f357bf5889095047b272bce0ff505953e7cd525b24c838ba6e9ed91922a30eeb858de8556f19f761d0287d768876346a5dcac3dbadd7a30072c9338162be5812166d961f4031f962ef668781d39d0fc69fe5f4494e31ec082d4a0140e368b69975beeba120ef9b651ead531b4d44296bd3cfe2ce7f97bb5bb4921061b12c2e1c4c10928c0980ff8d488a2282d0c056a40260167410e39664f75ff1f1249820e174eed978318a05e654b8aa6c60b70001a7a04f0aff17597dd9ab3ccc34f5ba2e352b7244dd3dccb462d7175b95ae3970ec5858e2312aac7c2c79a37b53d089f988720a4c04df6328a384004d0d51eafb9486623099a98e69be5169201c88824acc2bb0e1790889014a1797c168e98d19f0787c2935cfbc3bf24c4adad69a81e0e6adf8c21e3c4789064aa31a025dff5cc6eaba3f3e43f10a9d531f47963372120e2366b84c281ed968d9d11c1d103826c9362741e1267d1a3e8d2188761fa876b7b09617df14130c07209f1f1188ff40971b86607dee14d556a880447901c69d29cb16c027c3aae316ff00132bdfcd0e39c5e201252c9771483ccb275b0c67b3cb4dcd19198c7718634460254dfd6f8df4374b8bedee7dd20ce411b5f987cac2ce17492aa78f919c6d5e555000f47f7b8a9896d448bc4fc13e40a9e5c02258d509a7289f44d7250e89260233bf96702bb3d350451f03d802e0e37d9f01cce4c78869403493eb9890c2c09109d1f427f59cf091cd1c836e25a9bb065041407c2183f643bce2e72db1e7caeac42e2d8379f8b84df2cc7b1d055f42d6f62e0cb5771a14ae8872792350e5f770115a86564f60a785c53325c8c084afe214da3cac1783e2be9099d96ddbe9cc3ea3dd1d3ae50526b4afe24397420a3e4fa697613421";
     37var expectWrappedKey = "995a93379575a0c677a7d48dbe7d496f64a53769eafae1e6a1d0f6a57d2c7f69748cdaeeff1fe7e13eb9c6d4597458ed22d369d5c6043b6ab30c79f1e7082cb3a57e19e53e607a0b26090317f45b24266c662923bb3b8c0fd7447860c52b3052da1bddda729a8bc19c447e4acd2b7da6b13fad0c4e022f7d76cb804c8aaebaed4566e2e14b02e81689f47314bf49c599c9b3700f2e23df498816bbe3ffe139cc0ed0500e762b4f3341b159950abd362ada4158e21b8ba0ed0f01a441d6a730e6a5717fd939b2e8b418d86f632ed2f3c7fea57d1ad67914afc41e4153c5b799f91c49f4db257d06477c748f7405c1394fbc8523c0a6fd31bf8368573defb47353d55c3bd5a7adfa5d9a54412823a5cfed93e632af8bdb929f0113d5ff021c0cf40d98e0f8dbaadf2c8c3878196a616e607fb5f7db4420a587cac87771c2ee6028d7f5036e1ffcb88b7f4c72a155890e8bb99c74a02aa80d4ed22ad27d4a60e9d532ab4c461a776a16e6b88ae8365b3987eab6fd2d02f9de9febc28d6f4a5467a3ef8e92c36d4e971d8c0801526393260f11eed75b6fb70ed3822c60bf7dcc6c8d4ef21ce74449365019033dfb9b8f9793198d68d406ca5dce366fb7b515c85c4ff47f6b5b3692397632d22eb6026f05a9e39f2be3be75d8aa1876aa4bac108d3ce67914c95cba31c5c072d9ddcbbbb90e34bc16c60ce812bfbb34cb76e4e7f68c0e5d6eb7647853731cab8ef4b8e3a557c84ca2b6aae9eec06bef30edf1280ef534c8698baa265d08b75ca3a29a4fbed50afdaa48e8cfebff211e9d64e63c0e3ba077f9a9c6f77a5b865a25850334d42df4f55cb7d0e1fb59590fea96d757eac310be056427b55b10342a3dd522a712d86e589183fa278dbc3c6654c12d777e9fa2a030aba5747aa345a46e7754bda59f530e5e8dfdedfc343bb789fdfc138210d5ab587f581c006760ba3d6b5875e2a34ae16f9cbded2882f5e6ffd9904518b789123ca6d19eeda979dab4ba8437b8d660354a28dac7e917cdf061cd7748d624e0af4ab9c2a5c18389e71accc495945dc83e7ea7c7724434ab375551c6fd2b0070229ec791aa680be539799aa168cf5a955721d249e676ee434141f93d1977fd8d635e387496cac6c3509a71df4fac016ca7885ae7fa7fe601c6ed62a83d0313b7d07476501e5e8b3821a1fedfa91e842cffa3cc255db1a50091aa6b391d1014cc1e59c3f36425102a03acabf06525f44c87422a889ed78c1e78a2a4d9ab244a30155005e954111d4c3384f63153adc276861021a76289f266fb7d6eda300d39102bee7d7047e32b0ced7a90e0b27f201ad8960ecb83a8003ef1e3de97b2ddf00f5b8344f1f103c6b0c5a90804201f9ac26c544e7f3cca7d4d10a7388b2460a83dfbc9c7544b9e7ce2488907f2da06b48ec209c8e9a4688261c1a1b63c940b07c2053b60b06b20421810ffbef6a4d482d7ba7d80cb6ea04222797e4ee40564612bfb15b57b34afcab259efb03e2f7a7a1622b06df5825d6cf2fd0bf63749e2c6e89b358cfe0167f0577c571953dba4b4bb3591c922b2605ccc4ccb5a3ba1a38a8983d885d867713be90d2e796fd7cb8d465925927feaeae45ef931dc7806a6ecc94810a7a39a87c6158e85866a8c2bdd3b88522c23fc4a969f60994e3cfb1be584c3f418b1e19009ac53b38d9d015af213acd5f0e9d65ee78d59c10e94973eb08b79403483591662cc9b45ac13360e262c77bb3f71f32f0f3fa35ce75daf7ca39c4c81abbabc478d6c51ffdadee0787bc98617e3ef85d87a2447103e43f910019ee95d829a4dda87339fb1437aabf4bdc884ac470853622835e825229299b838ed75024ed28050ac858aa5ba9df18ff072e878c7f1fb2da444a8eb92de07e77fd1cf7c19e589646cdbce436de837b44b78420ee9ed1bc74b5b49d98758b1b80bf17f1a2836a2a9958990a6205bd20e969c91ed56b196b0dd64fc3545e5d9278a75f0368bd4ec1a88f396e374d19a3e622f65709a522b2b1ffc70aac843f879e4507cc675a513eb868e1116fa2c8e0215afa1ddaaa99d2698879944180a4da38873c512998a7a0c51b44c8655302b703a9251a9f3acd9465d9f3eab1b7555317fdd97ccf0305a56e32a34daa62a8a4d16f280db7fd54bff1ed916d04c3e346b5de79b833d9ba42789be91a42fdad20c239eaa51f411fde79f0d6274a055fa98fabbc583714ed4baa168660493a55a7fdf5b66dc4d6afb05224da3b3f81ca8274b1be0d31da40b80ee9f0a56448bcbc6f8142aea8ab0169764dac201c7c8733e3f9b7212be22a39c12e30cde9ed5fe3042db4a51a1b85e0d23fc7b237224473be41ef6a8db014cda53969b1acdd0b732a5";
    3838
    3939crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey"]).then(function(result) {
  • trunk/LayoutTests/crypto/subtle/aes-cbc-import-key-wrap-jwk-rsa-key-public.html

    r209155 r212465  
    2929    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
    3030}
    31 var expectWrappedKey = "848aa2f70ee18e2953520132a79cf47946e00c99362340bb690edc9ab5315757462c128278c6232e770e7437c56ed722a8e1703855f7f3e565394e1a6a0305c4ef1b30fa4c7f72d1a239cc6c6ba067898798a36a75132c66b4a2d3fb942886affd3ea3b2756b0ddc886c01e3b93107469b82124468408ef8ab548b85aa8f206c312d74ce4f2c679eb147a275cefda64d5bdc4a2b5b90a4ac9ad3eb5f2cf19f5f87653211f59b4731ba61125582a233951097dea65db05899d587d1dcfccab9ab7410ab3010b89066506dbacbc6b73e4b564792751388fa0f58d55c59c14a08c9dfb0f78100b0f5cc29d62328822636d30a6a153ec5cd4727ad5e47b419c48544565637ac5789863d43b7da78cf4383d09d66e9d458e436dbfbee75e382b2bab49eec2c7491ff93cf099fe92feaf4658e30889fd12d3ae61cd5e8c8e1e56a079b662f90cd10cdbdbb4d12eefb36d825e1a043e82f5a98f8960d655d3f9ed5af31e581fa846cc582f6cee5c25e0b3c32050534ae957ce27860d470ba26da2c7d6fa621b0faa8becad58e9e55bb2a9d984b042f25df21482529870d271cbf5508a0edfc3cb37316c11f16b342bc1f1f98aa";
     31var expectWrappedKey = "995a93379575a0c677a7d48dbe7d496fe4d8c9be49cdaf48e88398a769c2825d94396edb75683ed54e3ca0ac1f352f6b92486ef68186ef37d2b6be27ddd4bdaafbea98ec8c0dfc62353714f11219d4c69271a06507909f6dc50fd136f06265e5bfe9b2de09a704db4b4acd1d2834eefaab814484b70d77984455a1bad47e94cedc467939ea7495387087aff0eec9dfa4bf6c5baa6df37328a7068128930adc129a1874c323f315e993a27c667f1e02ffab5cc235bb7d270696875f43bb198f453cdef134ffe171c855c4641678527819dce552e4cd97fb30404075869aba085634327774cd7b71e7d0ea306f2d92d64658778897489fff205645e1a1b57832349ef1e6abef7c6780aa085b7d55c55693d69cf439497925dc8239791130d4387387188f2dea13d2825b2690456df80f6f1694351c8f33eb37bc44f2ad3f8f6d0a0e98c1510c6a5f64209288516aec0b30f85ed0b129a5ffc4840a9b5f0374c37304ad4f3d81572417813172929dd08f8a853ab57d3bc5d72eeeca932d8a05d3eb74d2ceba39b87cd7113abb30de3d05448162b50b17de8603fa4b5e7f8ab267cc6b8fdc830d76a35eb4078597b6301176";
    3232
    3333crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey"]).then(function(result) {
  • trunk/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters-expected.txt

    r208548 r212465  
    1010PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1111PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     12PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     13PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     14PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     15PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1216PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1317PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1418PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    15 PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     19PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     20PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     21PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     22PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1623PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     24PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1725PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: "sig"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     26PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1827PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: ["encrypt", "decrypt"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     28PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: [ ]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1929PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", ext: false}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2030PASS successfullyParsed is true
  • trunk/LayoutTests/crypto/subtle/aes-import-key-malformed-parameters.html

    r208548 r212465  
    2727shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
    2828shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128CBC"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     29shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     30shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     31shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     32shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
    2933shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A192KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
    3034shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: "A256KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
    3135shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: "A128KW"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
    32 shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-cbc", extractable, ["wrapKey", "unwrapKey"])');
     36shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "A72F", alg: "foo"}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
     37shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
     38shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k192, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
     39shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k256, alg: ""}, "aes-kw", extractable, ["wrapKey", "unwrapKey"])');
    3340// Jwk: wrong k format
    3441shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     42shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "", alg: "foo"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
    3543// Jwk: wrong use
    3644shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: "sig"}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     45shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", use: ""}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
    3746// Jwk: wrong key_ops
    3847shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: ["encrypt", "decrypt"]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
     48shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", key_ops: [ ]}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
    3949// Jwk: wrong ext
    4050shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k128, alg: "A128CBC", ext: false}, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])');
  • trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt

    r208737 r212465  
    1414PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS512"}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1515PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1"}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     16PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     17PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-224"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     18PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-256"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     19PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     20PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1621PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     22PASS crypto.subtle.importKey("jwk", {kty: "oct", k: "", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1723PASS crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: "enc"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     24PASS 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.
    1825PASS 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.
    1926PASS 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.
  • trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html

    r208737 r212465  
    3131shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS512"}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"])');
    3232shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1"}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"])');
     33shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
     34shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-224"}, extractable, ["sign", "verify"])');
     35shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-256"}, extractable, ["sign", "verify"])');
     36shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-384"}, extractable, ["sign", "verify"])');
     37shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: ""}, {name: "hmac", hash: "sha-512"}, extractable, ["sign", "verify"])');
    3338// Jwk: wrong k format
    3439shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "!!!", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
     40shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: "", alg: "foo"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
    3541// Jwk: wrong use
    3642shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: "enc"}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
     43shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", use: ""}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
    3744// Jwk: wrong key_ops
    3845shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", k: k, alg: "HS1", key_ops: ["sign"]}, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])');
  • trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt

    r209633 r212465  
    66PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    77PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
     8PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    89PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["sign"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    910PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
     11PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    1012PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    1113PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
     14PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    1215PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     16PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1317PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "enc"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     18PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1419PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     20PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1521PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "foo"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     22PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1623PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS224"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    1724PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS256"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     
    1926PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS512"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2027PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS1"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     28PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     29PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     30PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-256"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     31PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     32PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2133PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-224"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2234PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-256"}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     
    2436PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-512"}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2537PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP"}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     38PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     39PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     40PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-256"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     41PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     42PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    2643PASS 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.
    2744PASS 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.
     
    3754PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    3855PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     56PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: "", e: e, d: d, p: p, q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
     57PASS crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: "", q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
    3958PASS crypto.subtle.importKey("spki", spkiKey, "RSAES-PKCS1-v1_5", extractable, ["decrypt"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
    4059PASS crypto.subtle.importKey("spki", spkiKey, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["sign"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
  • trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html

    r209633 r212465  
    3636shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
    3737shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
     38shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
    3839shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["sign"])');
    3940shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
     41shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
    4042shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"])');
    4143shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
     44shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
    4245// Jwk: Wrong use
    4346shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
     47shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
    4448shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "enc"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
     49shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
    4550shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: "sig"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
     51shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, use: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
    4652// Jwk: Wrong alg
    4753shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "foo"}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
     54shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
    4855shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS224"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
    4956shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS256"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"])');
     
    5158shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS512"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"])');
    5259shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RS1"}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"])');
     60shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-1"}, extractable, ["verify"])');
     61shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-224"}, extractable, ["verify"])');
     62shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-256"}, extractable, ["verify"])');
     63shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-384"}, extractable, ["verify"])');
     64shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSASSA-PKCS1-v1_5", hash: "sha-512"}, extractable, ["verify"])');
    5365shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-224"}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
    5466shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-256"}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"])');
     
    5668shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP-512"}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"])');
    5769shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: "RSA-OAEP"}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"])');
     70shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"])');
     71shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-224"}, extractable, ["encrypt", "wrapKey"])');
     72shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-256"}, extractable, ["encrypt", "wrapKey"])');
     73shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-384"}, extractable, ["encrypt", "wrapKey"])');
     74shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, alg: ""}, {name: "RSA-OAEP", hash: "sha-512"}, extractable, ["encrypt", "wrapKey"])');
    5875// Jwk: Wrong kty
    5976shouldReject('crypto.subtle.importKey("jwk", {kty: "oct", n: n, e: e}, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
     
    7592shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
    7693shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: p, q: q, dp: dp, dq: dq}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
     94// Empty n, p
     95shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: "", e: e, d: d, p: p, q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
     96shouldReject('crypto.subtle.importKey("jwk", {kty: "RSA", n: n, e: e, d: d, p: "", q: q, dp: dp, dq: dq, qi: qi}, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
    7797// Spki: Wrong usages
    7898shouldReject('crypto.subtle.importKey("spki", spkiKey, "RSAES-PKCS1-v1_5", extractable, ["decrypt"])');
  • trunk/LayoutTests/crypto/workers/subtle/resources/aes-cbc-import-key-wrap-key.js

    r209155 r212465  
    2121    iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
    2222}
    23 var expectWrappedKey = "848aa2f70ee18e2953520132a79cf47946e00c99362340bb690edc9ab5315757462c128278c6232e770e7437c56ed722a8e1703855f7f3e565394e1a6a0305c4ef1b30fa4c7f72d1a239cc6c6ba067898798a36a75132c66b4a2d3fb942886affd3ea3b2756b0ddc886c01e3b93107469b82124468408ef8ab548b85aa8f206c312d74ce4f2c679eb147a275cefda64d5bdc4a2b5b90a4ac9ad3eb5f2cf19f5f87653211f59b4731ba61125582a233951097dea65db05899d587d1dcfccab9ab7410ab3010b89066506dbacbc6b73e4b564792751388fa0f58d55c59c14a08c9dfb0f78100b0f5cc29d62328822636d30a6a153ec5cd4727ad5e47b419c48544565637ac5789863d43b7da78cf4383d09d66e9d458e436dbfbee75e382b2bab49eec2c7491ff93cf099fe92feaf4658e30889fd12d3ae61cd5e8c8e1e56a079b662f90cd10cdbdbb4d12eefb36d825e1a043e82f5a98f8960d655d3f9ed5af31e581fa846cc582f6cee5c25e0b3c32050534ae957ce27860d470ba26da2c7d6fa621b0faa8becad58e9e55bb2a9d984b042f25df21482529870d271cbf5508a0edfc3cb37316c11f16b342bc1f1f98aa";
     23var expectWrappedKey = "995a93379575a0c677a7d48dbe7d496fe4d8c9be49cdaf48e88398a769c2825d94396edb75683ed54e3ca0ac1f352f6b92486ef68186ef37d2b6be27ddd4bdaafbea98ec8c0dfc62353714f11219d4c69271a06507909f6dc50fd136f06265e5bfe9b2de09a704db4b4acd1d2834eefaab814484b70d77984455a1bad47e94cedc467939ea7495387087aff0eec9dfa4bf6c5baa6df37328a7068128930adc129a1874c323f315e993a27c667f1e02ffab5cc235bb7d270696875f43bb198f453cdef134ffe171c855c4641678527819dce552e4cd97fb30404075869aba085634327774cd7b71e7d0ea306f2d92d64658778897489fff205645e1a1b57832349ef1e6abef7c6780aa085b7d55c55693d69cf439497925dc8239791130d4387387188f2dea13d2825b2690456df80f6f1694351c8f33eb37bc44f2ad3f8f6d0a0e98c1510c6a5f64209288516aec0b30f85ed0b129a5ffc4840a9b5f0374c37304ad4f3d81572417813172929dd08f8a853ab57d3bc5d72eeeca932d8a05d3eb74d2ceba39b87cd7113abb30de3d05448162b50b17de8603fa4b5e7f8ab267cc6b8fdc830d76a35eb4078597b6301176";
    2424
    2525crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey"]).then(function(result) {
  • trunk/Source/WebCore/ChangeLog

    r212463 r212465  
     12017-02-16  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebCrypto] remove toJSValueFromJsonWebKey from custom SubtleCrypto binding codes
     4        https://bugs.webkit.org/show_bug.cgi?id=167026
     5
     6        Reviewed by Chris Dumez.
     7
     8        Covered by existing tests.
     9
     10        * bindings/js/JSSubtleCryptoCustom.cpp:
     11        (WebCore::jsSubtleCryptoFunctionExportKeyPromise):
     12        (WebCore::jsSubtleCryptoFunctionWrapKeyPromise):
     13        (WebCore::toJSValueFromJsonWebKey): Deleted.
     14        * crypto/JsonWebKey.h:
     15        * crypto/JsonWebKey.idl:
     16        * crypto/RsaOtherPrimesInfo.idl:
     17        Change std::optional<String> to String in order to use toJS<IDLDictionary<JsonWebKey>>.
     18        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
     19        (WebCore::CryptoAlgorithmAES_CBC::importKey):
     20        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
     21        (WebCore::CryptoAlgorithmAES_KW::importKey):
     22        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
     23        (WebCore::CryptoAlgorithmHMAC::importKey):
     24        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
     25        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey):
     26        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
     27        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey):
     28        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
     29        (WebCore::CryptoAlgorithmRSA_OAEP::importKey):
     30        * crypto/keys/CryptoKeyAES.cpp:
     31        (WebCore::CryptoKeyAES::importJwk):
     32        Only check if key_ops contains all of the specified usages when key_ops field of jwk is present,
     33        as per the specification: https://www.w3.org/TR/WebCryptoAPI/#aes-cbc-operations
     34        * crypto/keys/CryptoKeyAES.h:
     35        * crypto/keys/CryptoKeyHMAC.cpp:
     36        (WebCore::CryptoKeyHMAC::importJwk):
     37        * crypto/keys/CryptoKeyHMAC.h:
     38        * crypto/keys/CryptoKeyRSA.cpp:
     39        (WebCore::CryptoKeyRSA::importJwk):
     40        Accommodate the change from std::optional<String> to String.
     41        * crypto/mac/CryptoKeyRSAMac.cpp:
     42        (WebCore::CryptoKeyRSA::create):
     43        Add a null check for p.
     44
    1452017-02-16  Antti Koivisto  <antti@apple.com>
    246
  • trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

    r212207 r212465  
    360360}
    361361
    362 // FIXME: We should get rid of this once https://bugs.webkit.org/show_bug.cgi?id=163711 is fixed.
    363 static JSValue toJSValueFromJsonWebKey(JSDOMGlobalObject& globalObject, JsonWebKey&& key)
    364 {
    365     ExecState& state = *globalObject.globalExec();
    366     VM& vm = state.vm();
    367 
    368     auto* result = constructEmptyObject(&state);
    369     result->putDirect(vm, Identifier::fromString(&vm, "kty"), toJS<IDLDOMString>(state, key.kty));
    370     if (key.use)
    371         result->putDirect(vm, Identifier::fromString(&vm, "use"), toJS<IDLDOMString>(state, key.use.value()));
    372     if (key.key_ops)
    373         result->putDirect(vm, Identifier::fromString(&vm, "key_ops"), toJS<IDLSequence<IDLEnumeration<CryptoKeyUsage>>>(state, globalObject, key.key_ops.value()));
    374     if (key.alg)
    375         result->putDirect(vm, Identifier::fromString(&vm, "alg"), toJS<IDLDOMString>(state, key.alg.value()));
    376     if (key.ext)
    377         result->putDirect(vm, Identifier::fromString(&vm, "ext"), toJS<IDLBoolean>(state, key.ext.value()));
    378     if (key.crv)
    379         result->putDirect(vm, Identifier::fromString(&vm, "crv"), toJS<IDLDOMString>(state, key.crv.value()));
    380     if (key.x)
    381         result->putDirect(vm, Identifier::fromString(&vm, "x"), toJS<IDLDOMString>(state, key.x.value()));
    382     if (key.y)
    383         result->putDirect(vm, Identifier::fromString(&vm, "y"), toJS<IDLDOMString>(state, key.y.value()));
    384     if (key.d)
    385         result->putDirect(vm, Identifier::fromString(&vm, "d"), toJS<IDLDOMString>(state, key.d.value()));
    386     if (key.n)
    387         result->putDirect(vm, Identifier::fromString(&vm, "n"), toJS<IDLDOMString>(state, key.n.value()));
    388     if (key.e)
    389         result->putDirect(vm, Identifier::fromString(&vm, "e"), toJS<IDLDOMString>(state, key.e.value()));
    390     if (key.p)
    391         result->putDirect(vm, Identifier::fromString(&vm, "p"), toJS<IDLDOMString>(state, key.p.value()));
    392     if (key.q)
    393         result->putDirect(vm, Identifier::fromString(&vm, "q"), toJS<IDLDOMString>(state, key.q.value()));
    394     if (key.dp)
    395         result->putDirect(vm, Identifier::fromString(&vm, "dp"), toJS<IDLDOMString>(state, key.dp.value()));
    396     if (key.dq)
    397         result->putDirect(vm, Identifier::fromString(&vm, "dq"), toJS<IDLDOMString>(state, key.dq.value()));
    398     if (key.qi)
    399         result->putDirect(vm, Identifier::fromString(&vm, "qi"), toJS<IDLDOMString>(state, key.qi.value()));
    400     if (key.oth) {
    401         MarkedArgumentBuffer list;
    402         for (auto& value : key.oth.value()) {
    403             auto* info = constructEmptyObject(&state);
    404             info->putDirect(vm, Identifier::fromString(&vm, "r"), toJS<IDLDOMString>(state, value.r));
    405             info->putDirect(vm, Identifier::fromString(&vm, "d"), toJS<IDLDOMString>(state, value.d));
    406             info->putDirect(vm, Identifier::fromString(&vm, "t"), toJS<IDLDOMString>(state, value.t));
    407             list.append(info);
    408         }
    409         result->putDirect(vm, Identifier::fromString(&vm, "oth"), constructArray(&state, static_cast<Structure*>(nullptr), list));
    410     }
    411     if (key.k)
    412         result->putDirect(vm, Identifier::fromString(&vm, "k"), toJS<IDLDOMString>(state, key.k.value()));
    413 
    414     return result;
    415 }
    416 
    417362static RefPtr<CryptoKey> toCryptoKey(ExecState& state, JSValue value)
    418363{
     
    866811        }
    867812        case SubtleCrypto::KeyFormat::Jwk:
    868             capturedPromise->resolve<IDLAny>(toJSValueFromJsonWebKey(*(capturedPromise->globalObject()), WTFMove(WTF::get<JsonWebKey>(key))));
     813            capturedPromise->resolve<IDLDictionary<JsonWebKey>>(WTFMove(WTF::get<JsonWebKey>(key)));
    869814            return;
    870815        }
     
    955900            break;
    956901        case SubtleCrypto::KeyFormat::Jwk: {
    957             auto jwk = toJSValueFromJsonWebKey(*(promise->globalObject()), WTFMove(WTF::get<JsonWebKey>(key)));
     902            auto jwk = toJS<IDLDictionary<JsonWebKey>>(*(promise->globalObject()->globalExec()), *(promise->globalObject()), WTFMove(WTF::get<JsonWebKey>(key)));
    958903            String jwkString = JSONStringify(promise->globalObject()->globalExec(), jwk, 0);
    959904            CString jwkUtf8String = jwkString.utf8(StrictConversion);
  • trunk/Source/WebCore/crypto/JsonWebKey.h

    r208985 r212465  
    3636struct JsonWebKey {
    3737    String kty;
    38     std::optional<String> use;
     38    String use;
    3939    // FIXME: Consider merging key_ops and usages.
    4040    std::optional<Vector<CryptoKeyUsage>> key_ops;
    4141    CryptoKeyUsageBitmap usages;
    42     std::optional<String> alg;
     42    String alg;
    4343
    4444    std::optional<bool> ext;
    4545
    46     std::optional<String> crv;
    47     std::optional<String> x;
    48     std::optional<String> y;
    49     std::optional<String> d;
    50     std::optional<String> n;
    51     std::optional<String> e;
    52     std::optional<String> p;
    53     std::optional<String> q;
    54     std::optional<String> dp;
    55     std::optional<String> dq;
    56     std::optional<String> qi;
     46    String crv;
     47    String x;
     48    String y;
     49    String d;
     50    String n;
     51    String e;
     52    String p;
     53    String q;
     54    String dp;
     55    String dq;
     56    String qi;
    5757    std::optional<Vector<RsaOtherPrimesInfo>> oth;
    58     std::optional<String> k;
     58    String k;
    5959};
    6060
  • trunk/Source/WebCore/crypto/JsonWebKey.idl

    r208602 r212465  
    2626[
    2727    Conditional=SUBTLE_CRYPTO,
     28    JSGenerateToJSObject,
    2829] dictionary JsonWebKey {
    2930    // The following fields are defined in Section 3.1 of JSON Web Key
  • trunk/Source/WebCore/crypto/RsaOtherPrimesInfo.idl

    r208548 r212465  
    2626[
    2727    Conditional=SUBTLE_CRYPTO,
     28    JSGenerateToJSObject,
    2829] dictionary RsaOtherPrimesInfo {
    2930    // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp

    r209390 r212465  
    121121        break;
    122122    case SubtleCrypto::KeyFormat::Jwk: {
    123         auto checkAlgCallback = [](size_t length, const std::optional<String>& alg) -> bool {
     123        auto checkAlgCallback = [](size_t length, const String& alg) -> bool {
    124124            switch (length) {
    125125            case CryptoKeyAES::s_length128:
    126                 return !alg || alg.value() == ALG128;
     126                return alg.isNull() || alg == ALG128;
    127127            case CryptoKeyAES::s_length192:
    128                 return !alg || alg.value() == ALG192;
     128                return alg.isNull() || alg == ALG192;
    129129            case CryptoKeyAES::s_length256:
    130                 return !alg || alg.value() == ALG256;
     130                return alg.isNull() || alg == ALG256;
    131131            }
    132132            return false;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp

    r210257 r212465  
    9595        break;
    9696    case SubtleCrypto::KeyFormat::Jwk: {
    97         result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, [](size_t length, const std::optional<String>& alg) -> bool {
     97        result = CryptoKeyAES::importJwk(parameters->identifier, WTFMove(WTF::get<JsonWebKey>(data)), extractable, usages, [](size_t length, const String& alg) -> bool {
    9898            switch (length) {
    9999            case CryptoKeyAES::s_length128:
    100                 return !alg || alg.value() == ALG128;
     100                return alg.isNull() || alg == ALG128;
    101101            case CryptoKeyAES::s_length192:
    102                 return !alg || alg.value() == ALG192;
     102                return alg.isNull() || alg == ALG192;
    103103            case CryptoKeyAES::s_length256:
    104                 return !alg || alg.value() == ALG256;
     104                return alg.isNull() || alg == ALG256;
    105105            }
    106106            return false;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp

    r210257 r212465  
    120120        break;
    121121    case SubtleCrypto::KeyFormat::Jwk: {
    122         auto checkAlgCallback = [](CryptoAlgorithmIdentifier hash, const std::optional<String>& alg) -> bool {
     122        auto checkAlgCallback = [](CryptoAlgorithmIdentifier hash, const String& alg) -> bool {
    123123            switch (hash) {
    124124            case CryptoAlgorithmIdentifier::SHA_1:
    125                 return !alg || alg.value() == ALG1;
     125                return alg.isNull() || alg == ALG1;
    126126            case CryptoAlgorithmIdentifier::SHA_224:
    127                 return !alg || alg.value() == ALG224;
     127                return alg.isNull() || alg == ALG224;
    128128            case CryptoAlgorithmIdentifier::SHA_256:
    129                 return !alg || alg.value() == ALG256;
     129                return alg.isNull() || alg == ALG256;
    130130            case CryptoAlgorithmIdentifier::SHA_384:
    131                 return !alg || alg.value() == ALG384;
     131                return alg.isNull() || alg == ALG384;
    132132            case CryptoAlgorithmIdentifier::SHA_512:
    133                 return !alg || alg.value() == ALG512;
     133                return alg.isNull() || alg == ALG512;
    134134            default:
    135135                return false;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp

    r210257 r212465  
    107107    case SubtleCrypto::KeyFormat::Jwk: {
    108108        JsonWebKey key = WTFMove(WTF::get<JsonWebKey>(data));
    109         if (usages && ((key.d && (usages ^ CryptoKeyUsageDecrypt)) || (!key.d && (usages ^ CryptoKeyUsageEncrypt)))) {
     109        if (usages && ((!key.d.isNull() && (usages ^ CryptoKeyUsageDecrypt)) || (key.d.isNull() && (usages ^ CryptoKeyUsageEncrypt)))) {
    110110            exceptionCallback(SYNTAX_ERR);
    111111            return;
    112112        }
    113         if (usages && key.use && key.use.value() != "enc") {
     113        if (usages && !key.use.isNull() && key.use != "enc") {
    114114            exceptionCallback(DataError);
    115115            return;
    116116        }
    117         if (key.alg && key.alg.value() != ALG) {
     117        if (!key.alg.isNull() && key.alg != ALG) {
    118118            exceptionCallback(DataError);
    119119            return;
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp

    r210257 r212465  
    118118        JsonWebKey key = WTFMove(WTF::get<JsonWebKey>(data));
    119119
    120         if (usages && ((key.d && (usages ^ CryptoKeyUsageSign)) || (!key.d && (usages ^ CryptoKeyUsageVerify)))) {
     120        if (usages && ((!key.d.isNull() && (usages ^ CryptoKeyUsageSign)) || (key.d.isNull() && (usages ^ CryptoKeyUsageVerify)))) {
    121121            exceptionCallback(SYNTAX_ERR);
    122122            return;
    123123        }
    124         if (usages && key.use && key.use.value() != "sig") {
     124        if (usages && !key.use.isNull() && key.use != "sig") {
    125125            exceptionCallback(DataError);
    126126            return;
     
    130130        switch (rsaParameters.hashIdentifier) {
    131131        case CryptoAlgorithmIdentifier::SHA_1:
    132             isMatched = !key.alg || key.alg.value() == ALG1;
     132            isMatched = key.alg.isNull() || key.alg == ALG1;
    133133            break;
    134134        case CryptoAlgorithmIdentifier::SHA_224:
    135             isMatched = !key.alg || key.alg.value() == ALG224;
     135            isMatched = key.alg.isNull() || key.alg == ALG224;
    136136            break;
    137137        case CryptoAlgorithmIdentifier::SHA_256:
    138             isMatched = !key.alg || key.alg.value() == ALG256;
     138            isMatched = key.alg.isNull() || key.alg == ALG256;
    139139            break;
    140140        case CryptoAlgorithmIdentifier::SHA_384:
    141             isMatched = !key.alg || key.alg.value() == ALG384;
     141            isMatched = key.alg.isNull() || key.alg == ALG384;
    142142            break;
    143143        case CryptoAlgorithmIdentifier::SHA_512:
    144             isMatched = !key.alg || key.alg.value() == ALG512;
     144            isMatched = key.alg.isNull() || key.alg == ALG512;
    145145            break;
    146146        default:
  • trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp

    r210257 r212465  
    121121
    122122        bool isUsagesAllowed = false;
    123         if (key.d) {
     123        if (!key.d.isNull()) {
    124124            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageDecrypt);
    125125            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageUnwrapKey);
     
    136136        }
    137137
    138         if (usages && key.use && key.use.value() != "enc") {
     138        if (usages && !key.use.isNull() && key.use != "enc") {
    139139            exceptionCallback(DataError);
    140140            return;
     
    144144        switch (rsaParameters.hashIdentifier) {
    145145        case CryptoAlgorithmIdentifier::SHA_1:
    146             isMatched = !key.alg || key.alg.value() == ALG1;
     146            isMatched = key.alg.isNull() || key.alg == ALG1;
    147147            break;
    148148        case CryptoAlgorithmIdentifier::SHA_224:
    149             isMatched = !key.alg || key.alg.value() == ALG224;
     149            isMatched = key.alg.isNull() || key.alg == ALG224;
    150150            break;
    151151        case CryptoAlgorithmIdentifier::SHA_256:
    152             isMatched = !key.alg || key.alg.value() == ALG256;
     152            isMatched = key.alg.isNull() || key.alg == ALG256;
    153153            break;
    154154        case CryptoAlgorithmIdentifier::SHA_384:
    155             isMatched = !key.alg || key.alg.value() == ALG384;
     155            isMatched = key.alg.isNull() || key.alg == ALG384;
    156156            break;
    157157        case CryptoAlgorithmIdentifier::SHA_512:
    158             isMatched = !key.alg || key.alg.value() == ALG512;
     158            isMatched = key.alg.isNull() || key.alg == ALG512;
    159159            break;
    160160        default:
  • trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp

    r208737 r212465  
    8888    if (keyData.kty != "oct")
    8989        return nullptr;
    90     if (!keyData.k)
     90    if (keyData.k.isNull())
    9191        return nullptr;
    9292    Vector<uint8_t> octetSequence;
    93     if (!base64URLDecode(keyData.k.value(), octetSequence))
     93    if (!base64URLDecode(keyData.k, octetSequence))
    9494        return nullptr;
    9595    if (!callback(octetSequence.size() * 8, keyData.alg))
    9696        return nullptr;
    97     if (usages && keyData.use && keyData.use.value() != "enc")
     97    if (usages && !keyData.use.isNull() && keyData.use != "enc")
    9898        return nullptr;
    99     if (keyData.usages && ((keyData.usages & usages) != usages))
     99    if (keyData.key_ops && ((keyData.usages & usages) != usages))
    100100        return nullptr;
    101101    if (keyData.ext && !keyData.ext.value() && extractable)
  • trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h

    r208985 r212465  
    6969    static RefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsageBitmap);
    7070    static RefPtr<CryptoKeyAES> importRaw(CryptoAlgorithmIdentifier, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
    71     using CheckAlgCallback = WTF::Function<bool(size_t, const std::optional<String>&)>;
     71    using CheckAlgCallback = Function<bool(size_t, const String&)>;
    7272    static RefPtr<CryptoKeyAES> importJwk(CryptoAlgorithmIdentifier, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap, CheckAlgCallback&&);
    7373
  • trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp

    r208737 r212465  
    9898    if (keyData.kty != "oct")
    9999        return nullptr;
    100     if (!keyData.k)
     100    if (keyData.k.isNull())
    101101        return nullptr;
    102102    Vector<uint8_t> octetSequence;
    103     if (!base64URLDecode(keyData.k.value(), octetSequence))
     103    if (!base64URLDecode(keyData.k, octetSequence))
    104104        return nullptr;
    105105    if (!callback(hash, keyData.alg))
    106106        return nullptr;
    107     if (usages && keyData.use && keyData.use.value() != "sig")
     107    if (usages && !keyData.use.isNull() && keyData.use != "sig")
    108108        return nullptr;
    109109    if (keyData.usages && ((keyData.usages & usages) != usages))
  • trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h

    r208985 r212465  
    6565    static RefPtr<CryptoKeyHMAC> generate(size_t lengthBits, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap);
    6666    static RefPtr<CryptoKeyHMAC> importRaw(size_t lengthBits, CryptoAlgorithmIdentifier hash, Vector<uint8_t>&& keyData, bool extractable, CryptoKeyUsageBitmap);
    67     using CheckAlgCallback = WTF::Function<bool(CryptoAlgorithmIdentifier, const std::optional<String>&)>;
     67    using CheckAlgCallback = Function<bool(CryptoAlgorithmIdentifier, const String&)>;
    6868    static RefPtr<CryptoKeyHMAC> importJwk(size_t lengthBits, CryptoAlgorithmIdentifier hash, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap, CheckAlgCallback&&);
    6969
  • trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp

    r208985 r212465  
    4444        return nullptr;
    4545
    46     if (!keyData.n || !keyData.e)
     46    if (keyData.n.isNull() || keyData.e.isNull())
    4747        return nullptr;
    4848    Vector<uint8_t> modulus;
    49     if (!WTF::base64URLDecode(keyData.n.value(), modulus))
     49    if (!WTF::base64URLDecode(keyData.n, modulus))
    5050        return nullptr;
    5151    // Per RFC 7518 Section 6.3.1.1: https://tools.ietf.org/html/rfc7518#section-6.3.1.1
    52     if (!modulus[0])
     52    if (!modulus.isEmpty() && !modulus[0])
    5353        modulus.remove(0);
    5454    Vector<uint8_t> exponent;
    55     if (!WTF::base64URLDecode(keyData.e.value(), exponent))
     55    if (!WTF::base64URLDecode(keyData.e, exponent))
    5656        return nullptr;
    57     if (!keyData.d) {
     57    if (keyData.d.isNull()) {
    5858        // import public key
    5959        auto publicKeyComponents = CryptoKeyDataRSAComponents::createPublic(WTFMove(modulus), WTFMove(exponent));
     
    6464    // import private key
    6565    Vector<uint8_t> privateExponent;
    66     if (!WTF::base64URLDecode(keyData.d.value(), privateExponent))
     66    if (!WTF::base64URLDecode(keyData.d, privateExponent))
    6767        return nullptr;
    68     if (!keyData.p && !keyData.q && !keyData.dp && !keyData.dp && !keyData.qi) {
     68    if (keyData.p.isNull() && keyData.q.isNull() && keyData.dp.isNull() && keyData.dp.isNull() && keyData.qi.isNull()) {
    6969        auto privateKeyComponents = CryptoKeyDataRSAComponents::createPrivate(WTFMove(modulus), WTFMove(exponent), WTFMove(privateExponent));
    7070        // Notice: CryptoAlgorithmIdentifier::SHA_1 is just a placeholder. It should not have any effect if hash is std::nullopt.
     
    7272    }
    7373
    74     if (!keyData.p || !keyData.q || !keyData.dp || !keyData.dq || !keyData.qi)
     74    if (keyData.p.isNull() || keyData.q.isNull() || keyData.dp.isNull() || keyData.dq.isNull() || keyData.qi.isNull())
    7575        return nullptr;
    7676    CryptoKeyDataRSAComponents::PrimeInfo firstPrimeInfo;
    7777    CryptoKeyDataRSAComponents::PrimeInfo secondPrimeInfo;
    78     if (!WTF::base64URLDecode(keyData.p.value(), firstPrimeInfo.primeFactor))
     78    if (!WTF::base64URLDecode(keyData.p, firstPrimeInfo.primeFactor))
    7979        return nullptr;
    80     if (!WTF::base64URLDecode(keyData.dp.value(), firstPrimeInfo.factorCRTExponent))
     80    if (!WTF::base64URLDecode(keyData.dp, firstPrimeInfo.factorCRTExponent))
    8181        return nullptr;
    82     if (!WTF::base64URLDecode(keyData.q.value(), secondPrimeInfo.primeFactor))
     82    if (!WTF::base64URLDecode(keyData.q, secondPrimeInfo.primeFactor))
    8383        return nullptr;
    84     if (!WTF::base64URLDecode(keyData.dq.value(), secondPrimeInfo.factorCRTExponent))
     84    if (!WTF::base64URLDecode(keyData.dq, secondPrimeInfo.factorCRTExponent))
    8585        return nullptr;
    86     if (!WTF::base64URLDecode(keyData.qi.value(), secondPrimeInfo.factorCRTCoefficient))
     86    if (!WTF::base64URLDecode(keyData.qi, secondPrimeInfo.factorCRTCoefficient))
    8787        return nullptr;
    8888    if (!keyData.oth) {
  • trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp

    r209633 r212465  
    132132        return nullptr;
    133133    }
     134    // When an empty vector p is provided to CCRSACryptorCreateFromData to create a private key, it crashes.
     135    // <rdar://problem/30550228> tracks the issue.
     136    if (keyData.type() == CryptoKeyDataRSAComponents::Type::Private && keyData.firstPrimeInfo().primeFactor.isEmpty())
     137        return nullptr;
     138
    134139    CCRSACryptorRef cryptor;
    135140    // FIXME: It is so weired that we recaculate the private exponent from first prime factor and second prime factor,
Note: See TracChangeset for help on using the changeset viewer.