| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../resources/common.js"></script> |
| </head> |
| <body> |
| <p id="description"></p> |
| <div id="console"></div> |
| |
| <script> |
| description("Test exporting a RSA key with malformed parameters"); |
| |
| jsTestIsAsync = true; |
| |
| var algorithmKeyGen = { |
| name: "RSA-OAEP", |
| // RsaKeyGenParams |
| modulusLength: 2048, |
| publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537 |
| hash: "sha-1" |
| }; |
| var extractable = true; |
| |
| crypto.subtle.generateKey(algorithmKeyGen, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]).then(function(result) { |
| publicKey = result.publicKey; |
| privateKey = result.privateKey; |
| |
| // Wrong key and format. |
| return shouldReject('crypto.subtle.exportKey("pkcs8", publicKey)'); |
| }).then(function() { |
| // Not support format. |
| return shouldReject('crypto.subtle.exportKey("raw", publicKey)'); |
| }).then(function() { |
| // Wrong key and format. |
| return shouldReject('crypto.subtle.exportKey("spki", privateKey)'); |
| }).then(finishJSTest, finishJSTest); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |