| 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 21 matching lines...) Expand all Loading... |
| 32 shouldBe("keyPair.publicKey.usages", '["encrypt", "wrapKey"]'); | 32 shouldBe("keyPair.publicKey.usages", '["encrypt", "wrapKey"]'); |
| 33 shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'0
10001'"); | 33 shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'0
10001'"); |
| 34 shouldBe("keyPair.publicKey.algorithm.hash.name", "'SHA-1'"); | 34 shouldBe("keyPair.publicKey.algorithm.hash.name", "'SHA-1'"); |
| 35 shouldBe("keyPair.privateKey.type", "'private'"); | 35 shouldBe("keyPair.privateKey.type", "'private'"); |
| 36 shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'"); | 36 shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'"); |
| 37 shouldBe("keyPair.privateKey.algorithm.modulusLength", "512"); | 37 shouldBe("keyPair.privateKey.algorithm.modulusLength", "512"); |
| 38 shouldBe("keyPair.privateKey.usages", '["decrypt", "unwrapKey"]'); | 38 shouldBe("keyPair.privateKey.usages", '["decrypt", "unwrapKey"]'); |
| 39 shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'
010001'"); | 39 shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'
010001'"); |
| 40 shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'"); | 40 shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'"); |
| 41 | 41 |
| 42 debug("\nTesting that the keys can't be used with different algorithms..."); | 42 debug("\nUsing the RSA-OAEP private key for AES-CBC encryption..."); |
| 43 iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f"); | 43 iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f"); |
| 44 | 44 |
| 45 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey,
hexStringToUint8Array("00")); | 45 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey,
hexStringToUint8Array("00")); |
| 46 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { | 46 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { |
| 47 logError(result); | 47 logError(result); |
| 48 |
| 49 debug("\nUsing the RSA-OAEP public key for AES-CBC encryption..."); |
| 48 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.publicKey, h
exStringToUint8Array("00")); | 50 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.publicKey, h
exStringToUint8Array("00")); |
| 49 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { | 51 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { |
| 50 logError(result); | 52 logError(result); |
| 51 debug("\nTrying to export keys to raw..."); | 53 debug("\nTrying to export keys to raw..."); |
| 52 return crypto.subtle.exportKey('raw', keyPair.publicKey); | 54 return crypto.subtle.exportKey('raw', keyPair.publicKey); |
| 53 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { | 55 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { |
| 54 logError(result); | 56 logError(result); |
| 55 testPassed("Promise rejected for exporting public key"); | 57 testPassed("Promise rejected for exporting public key"); |
| 56 return crypto.subtle.exportKey('raw', keyPair.privateKey); | 58 return crypto.subtle.exportKey('raw', keyPair.privateKey); |
| 57 }).then(failAndFinishJSTest, function(result) { | 59 }).then(failAndFinishJSTest, function(result) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 80 shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'"); | 82 shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'"); |
| 81 shouldBe("exportedPublicKey.extractable", "true"); | 83 shouldBe("exportedPublicKey.extractable", "true"); |
| 82 shouldBe("exportedPublicKey.usages", "['encrypt','wrapKey']"); | 84 shouldBe("exportedPublicKey.usages", "['encrypt','wrapKey']"); |
| 83 | 85 |
| 84 }).then(finishJSTest, failAndFinishJSTest); | 86 }).then(finishJSTest, failAndFinishJSTest); |
| 85 | 87 |
| 86 </script> | 88 </script> |
| 87 | 89 |
| 88 </body> | 90 </body> |
| 89 </html> | 91 </html> |
| OLD | NEW |