OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 var systemTokenEnabled = (location.search.indexOf("systemTokenEnabled") != -1); | 7 var systemTokenEnabled = (location.search.indexOf("systemTokenEnabled") != -1); |
8 var selectedTestSuite = location.hash.slice(1); | 8 var selectedTestSuite = location.hash.slice(1); |
9 console.log('[SELECTED TEST SUITE] ' + selectedTestSuite + | 9 console.log('[SELECTED TEST SUITE] ' + selectedTestSuite + |
10 ', systemTokenEnable ' + systemTokenEnabled); | 10 ', systemTokenEnable ' + systemTokenEnabled); |
11 | 11 |
12 var assertEq = chrome.test.assertEq; | 12 var assertEq = chrome.test.assertEq; |
13 var assertTrue = chrome.test.assertTrue; | 13 var assertTrue = chrome.test.assertTrue; |
14 var fail = chrome.test.fail; | 14 var fail = chrome.test.fail; |
15 var succeed = chrome.test.succeed; | 15 var succeed = chrome.test.succeed; |
16 var callbackPass = chrome.test.callbackPass; | 16 var callbackPass = chrome.test.callbackPass; |
17 var callbackFail= chrome.test.callbackFail; | 17 var callbackFail= chrome.test.callbackFail; |
18 | 18 |
19 // Each value is the path to a file in this extension's folder that will be | 19 // Each value is the path to a file in this extension's folder that will be |
20 // loaded and replaced by a Uint8Array in the setUp() function below. | 20 // loaded and replaced by a Uint8Array in the setUp() function below. |
21 var data = { | 21 var data = { |
22 // X.509 client certificates in DER encoding. | 22 // X.509 client certificate in DER encoding. |
| 23 // Algorithm in SPKI: rsaEncryption. |
23 // openssl x509 -in net/data/ssl/certificates/client_1.pem -outform DER -out | 24 // openssl x509 -in net/data/ssl/certificates/client_1.pem -outform DER -out |
24 // client_1.der | 25 // client_1.der |
25 client_1: 'client_1.der', | 26 client_1: 'client_1.der', |
26 | 27 |
| 28 // X.509 client certificate in DER encoding. |
| 29 // Algorithm in SPKI: rsaEncryption. |
27 // openssl x509 -in net/data/ssl/certificates/client_2.pem -outform DER -out | 30 // openssl x509 -in net/data/ssl/certificates/client_2.pem -outform DER -out |
28 // client_2.der | 31 // client_2.der |
29 client_2: 'client_2.der', | 32 client_2: 'client_2.der', |
30 | 33 |
31 // The public key of client_1 as Subject Public Key Info in DER encoding. | 34 // The public key of client_1 as Subject Public Key Info in DER encoding. |
32 // openssl rsa -in net/data/ssl/certificates/client_1.key -inform PEM -out | 35 // openssl rsa -in net/data/ssl/certificates/client_1.key -inform PEM -out |
33 // pubkey.der -pubout -outform DER | 36 // pubkey.der -pubout -outform DER |
34 client_1_spki: 'client_1_spki.der', | 37 client_1_spki: 'client_1_spki.der', |
35 | 38 |
36 // The distinguished name of the CA that issued client_1 in DER encoding. | 39 // The distinguished name of the CA that issued client_1 in DER encoding. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 data.client_1.buffer, keyParams, function(error) { | 263 data.client_1.buffer, keyParams, function(error) { |
261 fail('getKeyPair call was expected to fail.'); | 264 fail('getKeyPair call was expected to fail.'); |
262 }); | 265 }); |
263 fail('getKeyPair did not throw error'); | 266 fail('getKeyPair did not throw error'); |
264 } catch (e) { | 267 } catch (e) { |
265 assertEq('Algorithm: name: Missing or not a String', e.message); | 268 assertEq('Algorithm: name: Missing or not a String', e.message); |
266 succeed(); | 269 succeed(); |
267 } | 270 } |
268 } | 271 } |
269 | 272 |
| 273 function testGetKeyPairRejectsRSAPSS() { |
| 274 var keyParams = { |
| 275 name: 'RSA-PSS', |
| 276 hash: {name: 'SHA-1'} |
| 277 }; |
| 278 chrome.platformKeys.getKeyPair( |
| 279 data.client_1.buffer, keyParams, |
| 280 callbackFail( |
| 281 'The requested Algorithm is not permitted by the certificate.')); |
| 282 } |
| 283 |
270 function testGetKeyPair() { | 284 function testGetKeyPair() { |
271 var keyParams = { | 285 var keyParams = { |
272 // Algorithm names are case-insensitive. | 286 // Algorithm names are case-insensitive. |
273 name: 'RSASSA-Pkcs1-V1_5', | 287 name: 'RSASSA-Pkcs1-V1_5', |
274 hash: {name: 'sha-1'} | 288 hash: {name: 'sha-1'} |
275 }; | 289 }; |
276 chrome.platformKeys.getKeyPair( | 290 chrome.platformKeys.getKeyPair( |
277 data.client_1.buffer, keyParams, | 291 data.client_1.buffer, keyParams, |
278 callbackPass(function(publicKey, privateKey) { | 292 callbackPass(function(publicKey, privateKey) { |
279 var expectedAlgorithm = { | 293 var expectedAlgorithm = { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // On interactive selectClientCertificates calls, the simulated user does not | 397 // On interactive selectClientCertificates calls, the simulated user does not |
384 // select any cert. | 398 // select any cert. |
385 basicTests: function() { | 399 basicTests: function() { |
386 var tests = [ | 400 var tests = [ |
387 testStaticMethods, | 401 testStaticMethods, |
388 testSelectAllCerts, | 402 testSelectAllCerts, |
389 testSelectCA1Certs, | 403 testSelectCA1Certs, |
390 testInteractiveSelectNoCerts, | 404 testInteractiveSelectNoCerts, |
391 testMatchResult, | 405 testMatchResult, |
392 testGetKeyPairMissingAlgorithName, | 406 testGetKeyPairMissingAlgorithName, |
| 407 testGetKeyPairRejectsRSAPSS, |
393 testGetKeyPair, | 408 testGetKeyPair, |
394 testSignNoHash, | 409 testSignNoHash, |
395 testSignSha1Client1, | 410 testSignSha1Client1, |
396 ]; | 411 ]; |
397 | 412 |
398 chrome.test.runTests(tests); | 413 chrome.test.runTests(tests); |
399 }, | 414 }, |
400 | 415 |
401 // This test suite starts without any granted permissions. | 416 // This test suite starts without any granted permissions. |
402 // On interactive selectClientCertificates calls, the simulated user selects | 417 // On interactive selectClientCertificates calls, the simulated user selects |
(...skipping 21 matching lines...) Expand all Loading... |
424 // Verify that client_1 but not client_2 is selected in non-interactive | 439 // Verify that client_1 but not client_2 is selected in non-interactive |
425 // calls. | 440 // calls. |
426 testSelectAllReturnsClient1, | 441 testSelectAllReturnsClient1, |
427 ]; | 442 ]; |
428 | 443 |
429 chrome.test.runTests(tests); | 444 chrome.test.runTests(tests); |
430 } | 445 } |
431 }; | 446 }; |
432 | 447 |
433 setUp(testSuites[selectedTestSuite]); | 448 setUp(testSuites[selectedTestSuite]); |
OLD | NEW |