| <!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 generating an AES key with malformed-paramters."); |
| |
| var extractable = true; |
| |
| // Malformed AlgorithmIdentifiers |
| shouldReject('crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: true}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: null}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: Symbol()}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: { }}, extractable, ["encrypt", "decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: "foo"}, extractable, ["encrypt", "decrypt"])'); |
| // Wrong usages |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["sign"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["verify"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["deriveKey"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["deriveBits"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["encrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["decrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["sign"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["verify"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["deriveKey"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 128}, extractable, ["deriveBits"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["sign"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["verify"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["deriveKey"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-cfb-8", length: 128}, extractable, ["deriveBits"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["sign"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["verify"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["deriveKey"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-gcm", length: 128}, extractable, ["deriveBits"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["sign"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["verify"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["deriveKey"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-ctr", length: 128}, extractable, ["deriveBits"])'); |
| // Wrong length |
| shouldReject('crypto.subtle.generateKey({name: "aes-cbc", length: 111}, extractable, ["encrypt"])'); |
| shouldReject('crypto.subtle.generateKey({name: "aes-kw", length: 111}, extractable, ["wrapKey"])'); |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |