| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 <script src="resources/common.js"></script> | 5 <script src="resources/common.js"></script> |
| 6 </head> | 6 </head> |
| 7 <body> | 7 <body> |
| 8 <p id="description"></p> | 8 <p id="description"></p> |
| 9 <div id="console"></div> | 9 <div id="console"></div> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 }).then(function(result) { | 31 }).then(function(result) { |
| 32 keyPairs.ecdh.p384_1 = result; | 32 keyPairs.ecdh.p384_1 = result; |
| 33 | 33 |
| 34 return crypto.subtle.generateKey({name: "ecdsa", namedCurve: "P-256"}, tru
e, ["sign"]); | 34 return crypto.subtle.generateKey({name: "ecdsa", namedCurve: "P-256"}, tru
e, ["sign"]); |
| 35 }).then(function(result) { | 35 }).then(function(result) { |
| 36 keyPairs.ecdsa.p256_1 = result; | 36 keyPairs.ecdsa.p256_1 = result; |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 | 39 |
| 40 createTestKeys().then(function(result) { | 40 createTestKeys().then(function(result) { |
| 41 // Bad algorithm parameter (no algorithm name or public key) | 41 debug("\nderiveBits() without algorithm name or public key..."); |
| 42 return crypto.subtle.deriveBits({}, keyPairs.ecdh.p256_1.privateKey, 256); | 42 return crypto.subtle.deriveBits({}, keyPairs.ecdh.p256_1.privateKey, 256); |
| 43 }).then(failAndFinishJSTest, function(result) { | 43 }).then(failAndFinishJSTest, function(result) { |
| 44 logError(result); | 44 logError(result); |
| 45 | 45 |
| 46 // Bad algorithm parameter (no public key) | 46 debug("\nderiveBits() without public key..."); |
| 47 return crypto.subtle.deriveBits({name: 'ecdh'}, keyPairs.ecdh.p256_1.privateKe
y, 256); | 47 return crypto.subtle.deriveBits({name: 'ecdh'}, keyPairs.ecdh.p256_1.privateKe
y, 256); |
| 48 }).then(failAndFinishJSTest, function(result) { | 48 }).then(failAndFinishJSTest, function(result) { |
| 49 logError(result); | 49 logError(result); |
| 50 | 50 |
| 51 // Bad algorithm parameter (null) | 51 debug("\nderiveBits() with algorithm that is null..."); |
| 52 return crypto.subtle.deriveBits(null, keyPairs.ecdh.p256_1.privateKey, 256); | 52 return crypto.subtle.deriveBits(null, keyPairs.ecdh.p256_1.privateKey, 256); |
| 53 }).then(failAndFinishJSTest, function(result) { | 53 }).then(failAndFinishJSTest, function(result) { |
| 54 logError(result); | 54 logError(result); |
| 55 | 55 |
| 56 // Bad algorithm parameter (not an object) | 56 debug("\nderiveBits() with algorithm that is -1..."); |
| 57 return crypto.subtle.deriveBits(-1, keyPairs.ecdh.p256_1.privateKey, 256); | 57 return crypto.subtle.deriveBits(-1, keyPairs.ecdh.p256_1.privateKey, 256); |
| 58 }).then(failAndFinishJSTest, function(result) { | 58 }).then(failAndFinishJSTest, function(result) { |
| 59 logError(result); | 59 logError(result); |
| 60 | 60 |
| 61 // Bad algorithm parameter (public key is null) | 61 debug("\nderiveBits() with public key that is null..."); |
| 62 return crypto.subtle.deriveBits({name: 'ecdh', public: null}, keyPairs.ecdh.p2
56_1.privateKey, 256); | 62 return crypto.subtle.deriveBits({name: 'ecdh', public: null}, keyPairs.ecdh.p2
56_1.privateKey, 256); |
| 63 }).then(failAndFinishJSTest, function(result) { | 63 }).then(failAndFinishJSTest, function(result) { |
| 64 logError(result); | 64 logError(result); |
| 65 | 65 |
| 66 // Bad algorithm parameter (public key is wrong type) | 66 debug("\nderiveBits() with public key that is -1..."); |
| 67 return crypto.subtle.deriveBits({name: 'ecdh', public: -1}, keyPairs.ecdh.p256
_1.privateKey, 256); | 67 return crypto.subtle.deriveBits({name: 'ecdh', public: -1}, keyPairs.ecdh.p256
_1.privateKey, 256); |
| 68 }).then(failAndFinishJSTest, function(result) { | 68 }).then(failAndFinishJSTest, function(result) { |
| 69 logError(result); | 69 logError(result); |
| 70 | 70 |
| 71 // Bad algorithm parameter (public key is wrong type) | 71 debug("\nderiveBits() with public key that is a string..."); |
| 72 return crypto.subtle.deriveBits({name: 'ecdh', public: "foo"}, keyPairs.ecdh.p
256_1.privateKey, 256); | 72 return crypto.subtle.deriveBits({name: 'ecdh', public: "foo"}, keyPairs.ecdh.p
256_1.privateKey, 256); |
| 73 }).then(failAndFinishJSTest, function(result) { | 73 }).then(failAndFinishJSTest, function(result) { |
| 74 logError(result); | 74 logError(result); |
| 75 | 75 |
| 76 // Bad algorithm parameter (public key is for wrong curve) | 76 debug("\nderiveBits() with wrong curve public key..."); |
| 77 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p384_1.pu
blicKey}, keyPairs.ecdh.p256_1.privateKey, 256); | 77 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p384_1.pu
blicKey}, keyPairs.ecdh.p256_1.privateKey, 256); |
| 78 }).then(failAndFinishJSTest, function(result) { | 78 }).then(failAndFinishJSTest, function(result) { |
| 79 logError(result); | 79 logError(result); |
| 80 | 80 |
| 81 // Bad algorithm parameter (public key is not a public key) | 81 debug("\nderiveBits() with a private key as the 'public' parameter"); |
| 82 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p256_2.pr
ivateKey}, keyPairs.ecdh.p256_1.privateKey, 256); | 82 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdh.p256_2.pr
ivateKey}, keyPairs.ecdh.p256_1.privateKey, 256); |
| 83 }).then(failAndFinishJSTest, function(result) { | 83 }).then(failAndFinishJSTest, function(result) { |
| 84 logError(result); | 84 logError(result); |
| 85 | 85 |
| 86 // Bad algorithm parameter (public key is for ECDSA). | 86 debug("\nderiveBits() with public key that is for ECDSA..."); |
| 87 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdsa.p256_1.p
ublicKey}, keyPairs.ecdh.p256_1.privateKey, {test: 3}); | 87 return crypto.subtle.deriveBits({name: 'ecdh', public: keyPairs.ecdsa.p256_1.p
ublicKey}, keyPairs.ecdh.p256_1.privateKey, {test: 3}); |
| 88 }).then(failAndFinishJSTest, function(result) { | 88 }).then(failAndFinishJSTest, function(result) { |
| 89 logError(result); | 89 logError(result); |
| 90 }).then(finishJSTest, failAndFinishJSTest); | 90 }).then(finishJSTest, failAndFinishJSTest); |
| 91 | 91 |
| 92 </script> | 92 </script> |
| 93 | 93 |
| 94 </body> | 94 </body> |
| 95 </html> | 95 </html> |
| OLD | NEW |