Index: LayoutTests/crypto/rsa-oaep-plaintext-length.html |
diff --git a/LayoutTests/crypto/rsassa-pkcs1-v1_5-import-jwk.html b/LayoutTests/crypto/rsa-oaep-plaintext-length.html |
similarity index 65% |
copy from LayoutTests/crypto/rsassa-pkcs1-v1_5-import-jwk.html |
copy to LayoutTests/crypto/rsa-oaep-plaintext-length.html |
index 2a0cb5e04fc059cd55a4024cbd4b9133971933a7..fe14caed009bfa1df1e361749a20566cad0a30ad 100644 |
--- a/LayoutTests/crypto/rsassa-pkcs1-v1_5-import-jwk.html |
+++ b/LayoutTests/crypto/rsa-oaep-plaintext-length.html |
@@ -9,22 +9,20 @@ |
<div id="console"></div> |
<script> |
-description("Test importing an RSA key for RSASSA-PKCS1-v1_5."); |
+description("Test what happens when trying to encrypt a too large plain text with RSA-OAEP."); |
jsTestIsAsync = true; |
-var extractable = true; |
- |
var publicKeyJSON = { |
kty: "RSA", |
- alg: "RS256", |
+ alg: "RSA-OAEP", |
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw", |
e: "AQAB" |
}; |
var privateKeyJSON = { |
kty: "RSA", |
- alg: "RS256", |
+ alg: "RSA-OAEP", |
n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw", |
e: "AQAB", |
d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ", |
@@ -34,29 +32,29 @@ var privateKeyJSON = { |
dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE", |
qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk" |
}; |
+var encryptAlgorithm = {name: "RSA-OAEP", hash: "sha-1"}; |
+var extractable = true; |
+var nonExtractable = false; |
-debug("Importing a public key..."); |
-crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), {name: "RSASSA-PKCS1-v1_5", hash: {name: "sha-256"}}, extractable, ["verify"]).then(function(result) { |
+debug("Importing RSA keys..."); |
+crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), {name:"rsa-oaep", hash:{name: "sha-1"}}, extractable, ["encrypt"]).then(function(result) { |
publicKey = result; |
- shouldBe("publicKey.toString()", "'[object Key]'"); |
- shouldBe("publicKey.type", "'public'"); |
- shouldBe("publicKey.usages", "['verify']"); |
- shouldBe("publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'"); |
- shouldBe("publicKey.algorithm.modulusLength", "2048"); |
- shouldBe("bytesToHexString(publicKey.algorithm.publicExponent)", "'010001'"); |
- shouldBe("publicKey.algorithm.hash.name", "'SHA-256'"); |
- debug("\nImporting a private key..."); |
- return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(privateKeyJSON)), {name: "RSASSA-PKCS1-v1_5", hash: {name: "sha-256"}}, extractable, ["sign"]); |
-}).then(function(result) { |
+ return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(privateKeyJSON)), {name:"rsa-oaep", hash:{name: "sha-1"}}, extractable, ["decrypt"]); |
+}, failAndFinishJSTest).then(function(result) { |
privateKey = result; |
- shouldBe("privateKey.toString()", "'[object Key]'"); |
- shouldBe("privateKey.type", "'private'"); |
- shouldBe("privateKey.usages", "['sign']"); |
- shouldBe("privateKey.algorithm.name", "'RSASSA-PKCS1-v1_5'"); |
- shouldBe("privateKey.algorithm.modulusLength", "2048"); |
- shouldBe("bytesToHexString(privateKey.algorithm.publicExponent)", "'010001'"); |
- shouldBe("privateKey.algorithm.hash.name", "'SHA-256'"); |
-}).then(finishJSTest, failAndFinishJSTest); |
+ |
+ debug("Encrypting a 214 byte buffer with RSA-OAEP SHA-1, 2048 bit key..."); |
+ return crypto.subtle.encrypt({name: "RSA-OAEP"}, publicKey, new Uint8Array(214)); |
+}, failAndFinishJSTest).then(function(result) { |
+ testPassed("Succeeded"); |
+ debug("Encrypting a 215 byte buffer..."); |
+ return crypto.subtle.encrypt({name: "RSA-OAEP"}, publicKey, new Uint8Array(215)); |
+}, failAndFinishJSTest).then(function(result) { |
+ testFailed("Succeeded"); |
+}, function(result) { |
+ logError(result); |
+ testPassed("Rejected"); |
+}).then(finishJSTest, failAndFinishJSTest); |
</script> |
</body> |