Changeset 160061 in webkit
- Timestamp:
- Dec 3, 2013 4:51:14 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r160049 r160061 1 2013-12-03 Alexey Proskuryakov <ap@apple.com> 2 3 Update WebCrypto JWK mapping to newer proposal 4 https://bugs.webkit.org/show_bug.cgi?id=124218 5 6 Reviewed by Anders Carlsson. 7 8 * crypto/subtle/jwk-export-use-values-expected.txt: Added. 9 * crypto/subtle/jwk-export-use-values.html: Added. 10 * crypto/subtle/jwk-import-use-values-expected.txt: Added. 11 * crypto/subtle/jwk-import-use-values.html: Added. 12 New tests for "use" mapping. 13 14 * crypto/subtle/aes-cbc-import-jwk.html: 15 * crypto/subtle/aes-cbc-unwrap-rsa.html: 16 * crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html: 17 * crypto/subtle/aes-cbc-wrap-rsa.html: 18 * crypto/subtle/aes-export-key-expected.txt: 19 * crypto/subtle/aes-export-key.html: 20 * crypto/subtle/hmac-export-key-expected.txt: 21 * crypto/subtle/hmac-export-key.html: 22 * crypto/subtle/hmac-import-jwk.html: 23 * crypto/subtle/import-jwk-expected.txt: 24 * crypto/subtle/import-jwk.html: 25 * crypto/subtle/rsa-export-key-expected.txt: 26 * crypto/subtle/rsa-export-key.html: 27 * crypto/subtle/rsa-export-private-key-expected.txt: 28 * crypto/subtle/rsa-export-private-key.html: 29 * crypto/subtle/rsa-oaep-key-manipulation-expected.txt: 30 * crypto/subtle/rsa-oaep-key-manipulation.html: 31 1 32 2013-12-03 Alexey Proskuryakov <ap@apple.com> 2 33 -
trunk/LayoutTests/crypto/subtle/aes-cbc-import-jwk.html
r159379 r160061 23 23 "alg": "A192CBC", 24 24 "use": "enc", 25 "ext ractable": true,25 "ext": true, 26 26 "k": "jnOw99oOZFLIEPMrgJB55WL46tJSLGt7" 27 27 }; -
trunk/LayoutTests/crypto/subtle/aes-cbc-unwrap-rsa.html
r159637 r160061 22 22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw", 23 23 e: "AQAB", 24 ext ractable: false,24 ext: false, 25 25 use: "sig" 26 26 }; 27 27 28 28 var unwrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"); 29 var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25cb6c88292fbcb4547570afdc32e4003fe4d65f1e7df60dc1fdb3df36c3f58ab228e33aa31005852d46d0c2ad1318435a071bbb5bbb05650ea63d551698b0c040dd95ed0d379b5e2eccb545ae5620acb8051174cd2ad647328ad99dcd462fec40748724eb1e68f209f779faa2c35b4d4d1b6604a74e62a1846249ea6192954a5af10c71ebfea79948142441ed307e9f52e797a51a8007a6f87b57c51f9e7eef54b7e4a1f818ba6ac25ee5935c23b3253d6d9d222262c79ccdb7147d9c07527c22fe7a4ab91af20479edf5930b3c053c0a0b27092cfb53203633d01dcf6e333b5be7c1933c321c953f962b934ebefd9df8cca6c0a25fcd5fb96105435c42d9902406f82bc8daa8ec12fa85d9afa65adbfe3f60828ef64adaf43ad8e3b0af104cbfafd994323732bba08f84d5cac1d157b276233dffecafe47942b83c85ead6d5886c6badf534d4a32d3f545e8032dd5e419d7bff3acde2c37a96fc34fda8747d89500bf9f7ef45873c6b3b2741 97c184fe91badeeddf5045f982ecc66b61e0c4d75fd496c61ffcbb36e079faf20aa0c05cd12742aefdf1f6a39c4a9c5a");29 var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25cb6c88292fbcb4547570afdc32e4003fe4d65f1e7df60dc1fdb3df36c3f58ab228e33aa31005852d46d0c2ad1318435a071bbb5bbb05650ea63d551698b0c040dd95ed0d379b5e2eccb545ae5620acb8051174cd2ad647328ad99dcd462fec40748724eb1e68f209f779faa2c35b4d4d1b6604a74e62a1846249ea6192954a5af10c71ebfea79948142441ed307e9f52e797a51a8007a6f87b57c51f9e7eef54b7e4a1f818ba6ac25ee5935c23b3253d6d9d222262c79ccdb7147d9c07527c22fe7a4ab91af20479edf5930b3c053c0a0b27092cfb53203633d01dcf6e333b5be7c1933c321c953f962b934ebefd9df8cca6c0a25fcd5fb96105435c42d9902406f82bc8daa8ec12fa85d9afa65adbfe3f60828ef64adaf43ad8e3b0af104cbfafd994323732bba08f84d5cac1d157b276233dffecafe47942b83c85ead6d5886c6badf534d4a32d3f545e8032dd5e419d7bff3acde2c37a96fc34fda8747d89500bf9f7ef45873c6b3b2741aaf74ff96a2f950028f38eb62f1be936fe0a994ebfa928021c0c96172d84584e"); 30 30 31 31 debug("Importing an unwrapping key..."); -
trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html
r159644 r160061 22 22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw", 23 23 e: "AQAB", 24 ext ractable: false,24 ext: false, 25 25 use: "sig" 26 26 }; -
trunk/LayoutTests/crypto/subtle/aes-cbc-wrap-rsa.html
r159644 r160061 22 22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw", 23 23 e: "AQAB", 24 ext ractable: true,24 ext: true, 25 25 use: "sig" 26 26 }; -
trunk/LayoutTests/crypto/subtle/aes-export-key-expected.txt
r159644 r160061 23 23 PASS exportedJWK.k is 'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7' 24 24 PASS exportedJWK.alg is 'A192CBC' 25 PASS exportedJWK.ext ractableis true25 PASS exportedJWK.ext is true 26 26 PASS exportedJWK.use is 'enc' 27 27 … … 32 32 Trying to export as jwk... 33 33 PASS Rejected, as expected 34 35 Importing a key with only encrypt+decrypt usage (this doesn't map to anything in JWK, as 'enc' also allows wrap/unwrap)...36 PASS crypto.subtle.exportKey("jwk", key) threw exception TypeError: Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey.37 34 PASS successfullyParsed is true 38 35 -
trunk/LayoutTests/crypto/subtle/aes-export-key.html
r159392 r160061 53 53 shouldBe("exportedJWK.k", "'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7'"); 54 54 shouldBe("exportedJWK.alg", "'A192CBC'"); 55 shouldBe("exportedJWK.ext ractable", "true");55 shouldBe("exportedJWK.ext", "true"); 56 56 shouldBe("exportedJWK.use", "'enc'"); 57 57 … … 77 77 testPassed("Rejected, as expected"); 78 78 79 // If this test starts to fail because a way to encode encrypt+decrypt is added to JWK, change to something that's not there.80 // If all WebCrypto modes are added to JWK, then this test will be obsolete.81 debug("\nImporting a key with only encrypt+decrypt usage (this doesn't map to anything in JWK, as 'enc' also allows wrap/unwrap)...");82 return crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, "AES-CBC", extractable, ['encrypt', 'decrypt'])83 }).then(function(result) {84 key = result;85 86 // Maybe this should be a rejected promise, not an exception. We'll need to find a way to provide meaningful error messages with such failures.87 shouldThrow('crypto.subtle.exportKey("jwk", key)');88 89 79 finishJSTest(); 90 80 }); -
trunk/LayoutTests/crypto/subtle/hmac-export-key-expected.txt
r159644 r160061 16 16 PASS exportedJWK.k is 'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs' 17 17 PASS exportedJWK.alg is 'HS256' 18 PASS exportedJWK.ext ractableis true18 PASS exportedJWK.ext is true 19 19 PASS exportedJWK.use is 'sig' 20 20 … … 25 25 Trying to export as jwk... 26 26 PASS Rejected, as expected 27 28 Importing a key with only sign usage (this doesn't map to anything in JWK, as 'sig' allows both sign and verify)...29 PASS crypto.subtle.exportKey("jwk", key) threw exception TypeError: Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey.30 27 PASS successfullyParsed is true 31 28 -
trunk/LayoutTests/crypto/subtle/hmac-export-key.html
r159392 r160061 47 47 shouldBe("exportedJWK.k", "'ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs'"); 48 48 shouldBe("exportedJWK.alg", "'HS256'"); 49 shouldBe("exportedJWK.ext ractable", "true");49 shouldBe("exportedJWK.ext", "true"); 50 50 shouldBe("exportedJWK.use", "'sig'"); 51 51 … … 71 71 testPassed("Rejected, as expected"); 72 72 73 // If this test starts to fail because a way to encode encrypt+decrypt is added to JWK, change to something that's not there.74 // If all WebCrypto modes are added to JWK, then this test will be obsolete.75 debug("\nImporting a key with only sign usage (this doesn't map to anything in JWK, as 'sig' allows both sign and verify)...");76 return crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, { name: "HMAC", hash: "SHA-256" }, extractable, ['sign'])77 }).then(function(result) {78 key = result;79 80 // Maybe this should be a rejected promise, not an exception. We'll need to find a way to provide meaningful error messages with such failures.81 shouldThrow('crypto.subtle.exportKey("jwk", key)');82 83 73 finishJSTest(); 84 74 }); -
trunk/LayoutTests/crypto/subtle/hmac-import-jwk.html
r159379 r160061 20 20 "alg": "HS256", 21 21 "use": "sig", 22 "ext ractable": false,22 "ext": false, 23 23 "k": "ahjkn-_387fgnsibf23qsvahjkn-_387fgnsibf23qs" 24 24 }; -
trunk/LayoutTests/crypto/subtle/import-jwk-expected.txt
r159327 r160061 12 12 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "foobar", "alg": "HS256", "use": "sig", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Unsupported JWK key type foobar. 13 13 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "foobar", "use": "sig", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Unsupported JWK algorithm foobar. 14 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), "aes-cbc") threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.15 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), { name: "hmac", hash: "sha-1" }) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument.14 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), "aes-cbc") threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument. 15 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), { name: "hmac", hash: "sha-1" }) threw exception TypeError: Algorithm specified in key is not compatible with one passed to importKey as argument. 16 16 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256" }'), null) threw exception TypeError: Secret key data is not present is JWK. 17 17 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC" }'), null) threw exception TypeError: Secret key data is not present is JWK. 18 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for HS256.19 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext ractable": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for A128CBC.20 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Key size is not valid for A128CBC.21 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Cannot decode base64url key data in JWK.22 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": 1, "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "kty" JSON key.23 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": 1, "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "alg" JSON key.24 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": 1, "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "use" JSON key.25 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": "false", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a boolean value for "extractable" JSON key.26 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": 1 }'), null) threw exception TypeError: Expected a string value for "k" JSON key.18 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for HS256. 19 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "1234" }'), null) threw exception TypeError: Key size is not valid for A128CBC. 20 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Key size is not valid for A128CBC. 21 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Cannot decode base64url key data in JWK. 22 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": 1, "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "kty" JSON key. 23 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": 1, "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "alg" JSON key. 24 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": 1, "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a string value for "use" JSON key. 25 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": "false", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }'), null) threw exception TypeError: Expected a boolean value for "ext" JSON key. 26 PASS crypto.subtle.importKey("jwk", asciiToUint8Array('{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": 1 }'), null) threw exception TypeError: Expected a string value for "k" JSON key. 27 27 PASS successfullyParsed is true 28 28 -
trunk/LayoutTests/crypto/subtle/import-jwk.html
r159327 r160061 24 24 25 25 // Algorithm mismatch. 26 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), "aes-cbc")')27 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), { name: "hmac", hash: "sha-1" })')26 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), "aes-cbc")') 27 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), { name: "hmac", hash: "sha-1" })') 28 28 29 29 // No key data. … … 32 32 33 33 // Key data length is incorrect, not allowed in JWK. 34 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "1234" }\'), null)')35 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext ractable": false, "k": "1234" }\'), null)')36 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')34 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "1234" }\'), null)') 35 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "1234" }\'), null)') 36 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "A128CBC", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 37 37 38 38 // Key data is not valid base64url. 39 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')39 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387f+nsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 40 40 41 41 // Incorrect data types. 42 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": 1, "alg": "HS256", "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')43 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": 1, "use": "sig", "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')44 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": 1, "ext ractable": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')45 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": "false", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)')46 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext ractable": false, "k": 1 }\'), null)')42 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": 1, "alg": "HS256", "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 43 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": 1, "use": "sig", "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 44 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": 1, "ext": false, "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 45 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": "false", "k": "ahjkn23387fgnsibf23qsvahjkn37387fgnsibf23qs" }\'), null)') 46 shouldThrow('crypto.subtle.importKey("jwk", asciiToUint8Array(\'{ "kty": "oct", "alg": "HS256", "use": "sig", "ext": false, "k": 1 }\'), null)') 47 47 </script> 48 48 -
trunk/LayoutTests/crypto/subtle/rsa-export-key-expected.txt
r159403 r160061 17 17 PASS exportedJWK.e is publicKeyJSON.e 18 18 PASS exportedJWK.alg is 'RS256' 19 PASS exportedJWK.ext ractableis true19 PASS exportedJWK.ext is true 20 20 PASS exportedJWK.use is 'sig' 21 21 PASS successfullyParsed is true -
trunk/LayoutTests/crypto/subtle/rsa-export-key.html
r159403 r160061 45 45 shouldBe("exportedJWK.e", "publicKeyJSON.e"); 46 46 shouldBe("exportedJWK.alg", "'RS256'"); 47 shouldBe("exportedJWK.ext ractable", "true");47 shouldBe("exportedJWK.ext", "true"); 48 48 shouldBe("exportedJWK.use", "'sig'"); 49 49 -
trunk/LayoutTests/crypto/subtle/rsa-export-private-key-expected.txt
r160029 r160061 19 19 PASS exportedJWK.oth is privateKeyJSON.oth 20 20 PASS exportedJWK.alg is privateKeyJSON.alg 21 PASS exportedJWK.ext ractableis true21 PASS exportedJWK.ext is true 22 22 PASS exportedJWK.use is 'sig' 23 23 PASS successfullyParsed is true -
trunk/LayoutTests/crypto/subtle/rsa-export-private-key.html
r160029 r160061 53 53 shouldBe("exportedJWK.oth", "privateKeyJSON.oth"); 54 54 shouldBe("exportedJWK.alg", "privateKeyJSON.alg"); 55 shouldBe("exportedJWK.ext ractable", "true");55 shouldBe("exportedJWK.ext", "true"); 56 56 shouldBe("exportedJWK.use", "'sig'"); 57 57 -
trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt
r159944 r160061 27 27 Exporting public key to JWK... 28 28 PASS jwkPublicKey.alg is 'RSA-OAEP' 29 PASS jwkPublicKey.ext ractableis true29 PASS jwkPublicKey.ext is true 30 30 PASS jwkPublicKey.use is 'enc' 31 31 PASS jwkPublicKey.kty is 'RSA' -
trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html
r159944 r160061 56 56 jwkPublicKey = JSON.parse(bytesToASCIIString(jwkPublicKeyArray)); 57 57 shouldBe("jwkPublicKey.alg", "'RSA-OAEP'"); 58 shouldBe("jwkPublicKey.ext ractable", "true");58 shouldBe("jwkPublicKey.ext", "true"); 59 59 shouldBe("jwkPublicKey.use", "'enc'"); 60 60 shouldBe("jwkPublicKey.kty", "'RSA'"); -
trunk/Source/WebCore/ChangeLog
r160050 r160061 1 2013-12-03 Alexey Proskuryakov <ap@apple.com> 2 3 Update WebCrypto JWK mapping to newer proposal 4 https://bugs.webkit.org/show_bug.cgi?id=124218 5 6 Reviewed by Anders Carlsson. 7 8 Tests: crypto/subtle/jwk-export-use-values.html 9 crypto/subtle/jwk-import-use-values.html 10 11 1. "extractable" renamed to "ext" in JWK. 12 2. New values for "use" mapping, which can now be combined into comma separated lists, 13 and cover all possible WebCrypto usages. 14 15 * bindings/js/JSCryptoKeySerializationJWK.cpp: 16 (WebCore::JSCryptoKeySerializationJWK::reconcileUsages): 17 (WebCore::JSCryptoKeySerializationJWK::reconcileExtractable): 18 (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON): 19 (WebCore::processUseValue): 20 (WebCore::JSCryptoKeySerializationJWK::addJWKUseToJSON): 21 (WebCore::JSCryptoKeySerializationJWK::serialize): 22 1 23 2013-12-03 Simon Fraser <simon.fraser@apple.com> 2 24 -
trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp
r159966 r160061 246 246 } 247 247 248 void JSCryptoKeySerializationJWK::reconcileUsages(CryptoKeyUsage& suggestedUsage ) const248 void JSCryptoKeySerializationJWK::reconcileUsages(CryptoKeyUsage& suggestedUsages) const 249 249 { 250 250 String jwkUseString; … … 254 254 } 255 255 256 // FIXME: CryptoKeyUsageDeriveKey, CryptoKeyUsageDeriveBits - should these be implicitly allowed by any JWK use value? 257 // FIXME: "use" mapping is in flux, see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796>. 258 if (jwkUseString == "sig") 259 suggestedUsage = suggestedUsage & (CryptoKeyUsageSign | CryptoKeyUsageVerify); 260 else if (jwkUseString == "enc") 261 suggestedUsage = suggestedUsage & (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey); 262 else if (jwkUseString == "wrap") 263 suggestedUsage = suggestedUsage & (CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey); 264 else 265 suggestedUsage = 0; // Unknown usage, better be safe. 256 // Implemented according to a proposal in <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796>. 257 Vector<String> jwkUsageValues; 258 jwkUseString.split(',', jwkUsageValues); 259 CryptoKeyUsage jwkUsages = 0; 260 for (size_t i = 0, size = jwkUsageValues.size(); i < size; ++i) { 261 String jwkUse = jwkUsageValues[i]; 262 if (jwkUse == "sig") 263 jwkUsages |= (CryptoKeyUsageSign | CryptoKeyUsageVerify); 264 else if (jwkUse == "enc") 265 jwkUsages |= (CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey); 266 else if (jwkUse == "enconly") 267 jwkUsages |= CryptoKeyUsageEncrypt; 268 else if (jwkUse == "deconly") 269 jwkUsages |= CryptoKeyUsageDecrypt; 270 else if (jwkUse == "sigonly") 271 jwkUsages |= CryptoKeyUsageSign; 272 else if (jwkUse == "vfyonly") 273 jwkUsages |= CryptoKeyUsageVerify; 274 else if (jwkUse == "drvkey") 275 jwkUsages |= CryptoKeyUsageDeriveKey; 276 else if (jwkUse == "drvbits") 277 jwkUsages |= CryptoKeyUsageDeriveBits; 278 else if (jwkUse == "wrap") 279 jwkUsages |= CryptoKeyUsageWrapKey; 280 else if (jwkUse == "unwrap") 281 jwkUsages |= CryptoKeyUsageUnwrapKey; 282 } 283 284 suggestedUsages = suggestedUsages & jwkUsages; 266 285 } 267 286 … … 269 288 { 270 289 bool jwkExtractable; 271 if (!getBooleanFromJSON(m_exec, m_json.get(), "ext ractable", jwkExtractable)) {272 // "ext ractable" is a Netflix proposal that's not in any spec yet. It will certainly be optional once specified.290 if (!getBooleanFromJSON(m_exec, m_json.get(), "ext", jwkExtractable)) { 291 // "ext" not in JWK or WebCrypto specs yet, implemented according to a proposal in <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796>. 273 292 return; 274 293 } … … 590 609 if (jwkAlgorithm.isNull()) { 591 610 // The spec doesn't currently tell whether export should fail, or just skip "alg" (which is an optional key in JWK). 592 // Perhaps this should depend on whether the key is extractable?593 611 throwTypeError(exec, "Key algorithm and size do not map to any JWK algorithm identifier"); 594 612 return; … … 598 616 } 599 617 618 static bool processUseValue(StringBuilder& builder, CryptoKeyUsage& usages, const String& useString, CryptoKeyUsage usagesForUseString) 619 { 620 if ((usages & usagesForUseString) != usagesForUseString) 621 return false; 622 623 if (!builder.isEmpty()) 624 builder.append(','); 625 builder.append(useString); 626 627 usages &= ~usagesForUseString; 628 629 return true; 630 } 631 600 632 void JSCryptoKeySerializationJWK::addJWKUseToJSON(ExecState* exec, JSObject* json, CryptoKeyUsage usages) 601 633 { 602 // FIXME: "use" mapping is in flux, see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796>. 603 switch (usages) { 604 case CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey: 605 addToJSON(exec, json, "use", "enc"); 606 break; 607 case CryptoKeyUsageSign | CryptoKeyUsageVerify: 608 addToJSON(exec, json, "use", "sig"); 609 break; 610 default: 611 throwTypeError(exec, "Key usages cannot be represented in JWK. Only two variants are supported: sign+verify and encrypt+decrypt+wrapKey+unwrapKey"); 612 } 634 // Use mapping implemented according to a proposal in <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23796>. 635 StringBuilder useBuilder; 636 CryptoKeyUsage remainingUsages = usages; 637 while (remainingUsages) { 638 if (processUseValue(useBuilder, remainingUsages, "enc", CryptoKeyUsageEncrypt | CryptoKeyUsageDecrypt | CryptoKeyUsageWrapKey | CryptoKeyUsageUnwrapKey)) 639 continue; 640 if (processUseValue(useBuilder, remainingUsages, "sig", CryptoKeyUsageSign | CryptoKeyUsageVerify)) 641 continue; 642 if (processUseValue(useBuilder, remainingUsages, "enconly", CryptoKeyUsageEncrypt)) 643 continue; 644 if (processUseValue(useBuilder, remainingUsages, "deconly", CryptoKeyUsageDecrypt)) 645 continue; 646 if (processUseValue(useBuilder, remainingUsages, "sigonly", CryptoKeyUsageSign)) 647 continue; 648 if (processUseValue(useBuilder, remainingUsages, "vfyonly", CryptoKeyUsageVerify)) 649 continue; 650 if (processUseValue(useBuilder, remainingUsages, "drvkey", CryptoKeyUsageDeriveKey)) 651 continue; 652 if (processUseValue(useBuilder, remainingUsages, "drvbits", CryptoKeyUsageDeriveBits)) 653 continue; 654 if (processUseValue(useBuilder, remainingUsages, "wrap", CryptoKeyUsageWrapKey)) 655 continue; 656 if (processUseValue(useBuilder, remainingUsages, "unwrap", CryptoKeyUsageUnwrapKey)) 657 continue; 658 throwTypeError(exec, "Key usages cannot be represented in JWK."); 659 return; 660 } 661 662 addToJSON(exec, json, "use", useBuilder.toString()); 613 663 } 614 664 … … 628 678 return String(); 629 679 630 addBoolToJSON(exec, result, "ext ractable", key.extractable());680 addBoolToJSON(exec, result, "ext", key.extractable()); 631 681 632 682 addJWKUseToJSON(exec, result, key.usagesBitmap());
Note: See TracChangeset
for help on using the changeset viewer.