Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: LayoutTests/crypto/rsa-indexeddb.html

Issue 806913006: [WebCrypto] Move LayoutTests from crypto to crypto/subtle (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update path for deserialize legacy tests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <script>
9
10 description("Test storing a private RSA key in IndexedDB, and retrieving it.");
11
12 jsTestIsAsync = true;
13
14 var privateKeyJSON = {
15 kty: "RSA",
16 alg: "RS256",
17 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6 s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7 2KUp02mJDZiiyiglxML_i3-_CeecCw",
18 e: "AQAB",
19 d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238ds IWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_Lw srMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3 hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM 3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
20 p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O _ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVL viwposOnyyWqwM5AXp0",
21 q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2G ZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV -cwzOPdcVAfVuZlxUMc",
22 dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiD HdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt 6F_fxow4Kb2xonGT0GGk",
23 dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U 0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5 x-r9KwBZFC4FCG2hg_zE",
24 qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG 5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf 9-2QuKDoWeRdd7NsdxTk"
25 };
26
27 crypto.subtle.importKey("jwk", privateKeyJSON, {name: "RSASSA-PKCS1-v1_5", hash: {name: "sha-256"}}, true, ["sign"]).then(function(key) {
28 var openRequest = indexedDB.open("crypto_subtle");
29 openRequest.onupgradeneeded = function(event) {
30 var objectStore = event.target.result.createObjectStore("rsa-indexeddb") ;
31 }
32 openRequest.onerror = function(event) {
33 testFailed("Could not open database: " + event.target.error.name);
34 finishJSTest();
35 }
36 openRequest.onsuccess = function(event) {
37 db = event.target.result;
38 storeKey();
39 }
40
41 function storeKey() {
42 var tx = db.transaction("rsa-indexeddb", "readwrite");
43 var objectStore = tx.objectStore("rsa-indexeddb");
44 var req = objectStore.put(key, "mykey");
45 req.onerror = function(event) {
46 testFailed("Could not put a key into database: " + event.target.erro r.name);
47 finishJSTest();
48 }
49 req.onsuccess = function(event) {
50 debug("Put key into database successfully");
51 }
52
53 tx.oncomplete = function() {
54 readKey();
55 }
56 }
57
58 function readKey() {
59 var objectStore = db.transaction("rsa-indexeddb").objectStore("rsa-index eddb");
60 var req = objectStore.get("mykey");
61 req.onerror = function(event) {
62 testFailed("Could not get a key from database: " + event.target.erro r.name);
63 finishJSTest();
64 }
65 req.onsuccess = function(event) {
66 window.retrievedKey = event.target.result;
67 shouldBe("retrievedKey.type", "'private'");
68 shouldBe("retrievedKey.extractable", "true");
69 shouldBe("retrievedKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
70 shouldBe("retrievedKey.algorithm.modulusLength", "2048");
71 shouldBe("bytesToHexString(retrievedKey.algorithm.publicExponent)", "'010001'");
72 shouldBe("retrievedKey.usages", '["sign"]');
73
74 finishJSTest();
75 }
76 }
77 }).catch(failAndFinishJSTest);
78 </script>
79 </body>
80 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/rsa-importKey-badUsages-expected.txt ('k') | LayoutTests/crypto/rsa-indexeddb-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698