| 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 <script src="resources/keys.js"></script> | 
| 6 </head> | 7 </head> | 
| 7 <body> | 8 <body> | 
| 8 <p id="description"></p> | 9 <p id="description"></p> | 
| 9 <div id="console"></div> | 10 <div id="console"></div> | 
| 10 | 11 | 
| 11 <script> | 12 <script> | 
| 12 description("Tests cypto.subtle.importKey."); | 13 description("Tests cypto.subtle.importKey."); | 
| 13 | 14 | 
| 14 jsTestIsAsync = true; | 15 jsTestIsAsync = true; | 
| 15 | 16 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 70     algorithm = aesCbc; | 71     algorithm = aesCbc; | 
| 71     extractable = false; | 72     extractable = false; | 
| 72     keyUsages = []; | 73     keyUsages = []; | 
| 73 | 74 | 
| 74     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 75     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 
| 75 }).then(undefined, function(result) { | 76 }).then(undefined, function(result) { | 
| 76     debug("rejected with " + result); | 77     debug("rejected with " + result); | 
| 77 | 78 | 
| 78     // Import an spki formatted public key | 79     // Import an spki formatted public key | 
| 79     keyFormat = "spki"; | 80     keyFormat = "spki"; | 
| 80     data = hexStringToUint8Array(kPublicKeySpkiDerHex); | 81     data = hexStringToUint8Array(kKeyData.rsa1.spki); | 
| 81     algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; | 82     algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; | 
| 82     extractable = false; | 83     extractable = false; | 
| 83     keyUsages = []; | 84     keyUsages = []; | 
| 84 | 85 | 
| 85     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 86     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 
| 86 }).then(function(result) { | 87 }).then(function(result) { | 
| 87     key = result; | 88     key = result; | 
| 88     shouldBe("key.type", "'public'"); | 89     shouldBe("key.type", "'public'"); | 
| 89     // FIXME: Enable this once updated. | 90     // FIXME: Enable this once updated. | 
| 90     //shouldBe("key.extractable", "true"); | 91     //shouldBe("key.extractable", "true"); | 
| 91     shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | 92     shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | 
| 92     shouldBe("key.algorithm.hash.name", '"SHA-1"'); | 93     shouldBe("key.algorithm.hash.name", '"SHA-1"'); | 
| 93     shouldBe("key.algorithm.modulusLength", '1024'); | 94     shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthB
     its); | 
| 94     bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo
     rithm.publicExponent); | 95     bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publ
     icExponent, key.algorithm.publicExponent); | 
| 95     shouldBe("key.usages.join(',')", "''"); | 96     shouldBe("key.usages.join(',')", "''"); | 
| 96 | 97 | 
| 97     // Import a pkcs8 formatted private key | 98     // Import a pkcs8 formatted private key | 
| 98     keyFormat = "pkcs8"; | 99     keyFormat = "pkcs8"; | 
| 99     data = hexStringToUint8Array(kPrivateKeyPkcs8DerHex); | 100     data = hexStringToUint8Array(kKeyData.rsa1.pkcs8); | 
| 100     algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; | 101     algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; | 
| 101     extractable = false; | 102     extractable = false; | 
| 102     keyUsages = []; | 103     keyUsages = []; | 
| 103 | 104 | 
| 104     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 105     return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
     sages); | 
| 105 }).then(function(result) { | 106 }).then(function(result) { | 
| 106     key = result; | 107     key = result; | 
| 107     shouldBe("key.type", "'private'"); | 108     shouldBe("key.type", "'private'"); | 
| 108     shouldBe("key.extractable", "false"); | 109     shouldBe("key.extractable", "false"); | 
| 109     shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | 110     shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | 
| 110     shouldBe("key.algorithm.hash.name", '"SHA-1"'); | 111     shouldBe("key.algorithm.hash.name", '"SHA-1"'); | 
| 111     shouldBe("key.algorithm.modulusLength", '1024'); | 112     shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthB
     its); | 
| 112     bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo
     rithm.publicExponent); | 113     bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publ
     icExponent, key.algorithm.publicExponent); | 
| 113     shouldBe("key.usages.join(',')", "''") | 114     shouldBe("key.usages.join(',')", "''") | 
| 114 | 115 | 
| 115     keyFormat = "raw"; | 116     keyFormat = "raw"; | 
| 116     data = asciiToUint8Array(""); | 117     data = asciiToUint8Array(""); | 
| 117     algorithm = aesCbc; | 118     algorithm = aesCbc; | 
| 118     extractable = true; | 119     extractable = true; | 
| 119     keyUsages = []; | 120     keyUsages = []; | 
| 120 | 121 | 
| 121     // Invalid format. | 122     // Invalid format. | 
| 122     shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
      algorithm, extractable, keyUsages)"); | 123     shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
      algorithm, extractable, keyUsages)"); | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 143     shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
      'hmac'}, extractable, keyUsages)"); | 144     shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
      'hmac'}, extractable, keyUsages)"); | 
| 144 | 145 | 
| 145     // SHA-1 doesn't support the importKey operation. | 146     // SHA-1 doesn't support the importKey operation. | 
| 146     shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
      'sha-1'}, extractable, keyUsages)"); | 147     shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
      'sha-1'}, extractable, keyUsages)"); | 
| 147 }).then(finishJSTest, failAndFinishJSTest); | 148 }).then(finishJSTest, failAndFinishJSTest); | 
| 148 | 149 | 
| 149 </script> | 150 </script> | 
| 150 | 151 | 
| 151 </body> | 152 </body> | 
| 152 </html> | 153 </html> | 
| OLD | NEW | 
|---|