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

Side by Side Diff: third_party/WebKit/LayoutTests/crypto/subtle/pbkdf2/deriveBits.html

Issue 2164753002: Reject deriveBits() for PBKDF2 when given a length of 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
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 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Empty password. 61 // Empty password.
62 { 62 {
63 password: [], 63 password: [],
64 salt: "salt", 64 salt: "salt",
65 c: 20, 65 c: 20,
66 dkLen: 16, 66 dkLen: 16,
67 hash: "SHA-384", 67 hash: "SHA-384",
68 derived_key: "750261780a187897a9978371599db5d1" 68 derived_key: "750261780a187897a9978371599db5d1"
69 }, 69 },
70
71 // Derive zero bytes.
72 {
73 password: "password",
74 salt: "salt",
75 c: 4096,
76 dkLen: 0,
77 hash: "SHA-512",
78 derived_key: ""
79 },
80 ]; 70 ];
81 71
82 function runPbkdf2SuccessTestCase(testCase) 72 function runPbkdf2SuccessTestCase(testCase)
83 { 73 {
84 var algorithm = {name: 'PBKDF2'}; 74 var algorithm = {name: 'PBKDF2'};
85 75
86 var key = null; 76 var key = null;
87 var password = null; 77 var password = null;
88 if (typeof testCase.password === 'string') 78 if (typeof testCase.password === 'string')
89 password = asciiToUint8Array(testCase.password); 79 password = asciiToUint8Array(testCase.password);
(...skipping 16 matching lines...) Expand all
106 tmpKey = key; 96 tmpKey = key;
107 shouldEvaluateAs("tmpKey.type", "secret"); 97 shouldEvaluateAs("tmpKey.type", "secret");
108 shouldEvaluateAs("tmpKey.extractable", false); 98 shouldEvaluateAs("tmpKey.extractable", false);
109 shouldEvaluateAs("tmpKey.algorithm.name", "PBKDF2"); 99 shouldEvaluateAs("tmpKey.algorithm.name", "PBKDF2");
110 shouldEvaluateAs("tmpKey.usages.join(',')", "deriveKey,deriveBits"); 100 shouldEvaluateAs("tmpKey.usages.join(',')", "deriveKey,deriveBits");
111 101
112 // (2) Derive bits 102 // (2) Derive bits
113 return crypto.subtle.deriveBits(params, key, testCase.dkLen*8); 103 return crypto.subtle.deriveBits(params, key, testCase.dkLen*8);
114 }).then(function(result) { 104 }).then(function(result) {
115 bytesShouldMatchHexString("deriveBits", testCase.derived_key, result); 105 bytesShouldMatchHexString("deriveBits", testCase.derived_key, result);
116 return crypto.subtle.deriveBits(params, key, 0);
117 }).then(function(result) {
118 derivedBits = result;
119 shouldBe("derivedBits.byteLength", "0");
120 }); 106 });
121 } 107 }
122 108
123 var lastPromise = Promise.resolve(null); 109 var lastPromise = Promise.resolve(null);
124 110
125 kPbkdf2SuccessVectors.forEach(function(test) { 111 kPbkdf2SuccessVectors.forEach(function(test) {
126 lastPromise = lastPromise.then(runPbkdf2SuccessTestCase.bind(null, test)); 112 lastPromise = lastPromise.then(runPbkdf2SuccessTestCase.bind(null, test));
127 }); 113 });
128 114
129 lastPromise.then(finishJSTest, failAndFinishJSTest); 115 lastPromise.then(finishJSTest, failAndFinishJSTest);
130 116
131 </script> 117 </script>
132 118
133 </body> 119 </body>
134 </html> 120 </html>
OLDNEW
« no previous file with comments | « components/webcrypto/status.cc ('k') | third_party/WebKit/LayoutTests/crypto/subtle/pbkdf2/deriveBits-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698