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

Side by Side Diff: chrome/test/data/extensions/api_test/enterprise_certificates/import.js

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow import of non-extractable keys. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var assertEq = chrome.test.assertEq;
6 var assertTrue = chrome.test.assertTrue;
7 var fail = chrome.test.fail;
8 var succeed = chrome.test.succeed;
9 var callback = chrome.test.callback;
10
11 // openssl genrsa > privkey.pem
12 // openssl pkcs8 -inform pem -in privkey.pem -topk8 \
13 // -outform der -out privkey8.der -nocrypt
14 // xxd -i privkey8.der
15 var privateKeyDer = new Uint8Array([
16 0x30, 0x82, 0x01, 0x56, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a,
17 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
18 0x01, 0x40, 0x30, 0x82, 0x01, 0x3c, 0x02, 0x01, 0x00, 0x02, 0x41, 0x00,
19 0xac, 0x6c, 0x72, 0x46, 0xa2, 0xde, 0x88, 0x30, 0x54, 0x06, 0xad, 0xc7,
20 0x2d, 0x64, 0x6e, 0xf6, 0x0f, 0x72, 0x3e, 0x92, 0x31, 0xcc, 0x0b, 0xa0,
21 0x18, 0x20, 0xb0, 0xdb, 0x86, 0xab, 0x11, 0xc6, 0xa5, 0x78, 0xea, 0x64,
22 0xe8, 0xeb, 0xa5, 0xb3, 0x78, 0x5d, 0xbb, 0x10, 0x57, 0xe6, 0x12, 0x23,
23 0x89, 0x92, 0x1d, 0xa0, 0xe5, 0x1e, 0xd1, 0xc9, 0x0e, 0x62, 0xcb, 0xc9,
24 0xaf, 0xde, 0x4e, 0x83, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x40, 0x43,
25 0xa4, 0x2f, 0x98, 0x82, 0x60, 0x66, 0x70, 0xff, 0x25, 0xb7, 0x9a, 0xc1,
26 0xb5, 0xfa, 0xc9, 0xd0, 0xf9, 0x72, 0x8e, 0x8b, 0xb6, 0x8e, 0x80, 0xf9,
27 0xb6, 0x29, 0x6b, 0x95, 0x83, 0x1a, 0xef, 0x7b, 0x98, 0xf1, 0x91, 0x52,
28 0xe8, 0x07, 0x8e, 0x6d, 0x3f, 0xca, 0x37, 0x12, 0x3b, 0x77, 0xc6, 0x65,
29 0xa0, 0xfd, 0xf6, 0x58, 0x24, 0xfd, 0x88, 0xb2, 0x56, 0x99, 0x7c, 0x3f,
30 0x3b, 0x27, 0x31, 0x02, 0x21, 0x00, 0xe5, 0x16, 0x34, 0x1c, 0x60, 0x35,
31 0x6d, 0x54, 0x4d, 0xe2, 0xc6, 0x40, 0xf4, 0xc5, 0x19, 0x1b, 0x58, 0xbe,
32 0x30, 0xca, 0x72, 0xc7, 0x03, 0x31, 0x74, 0xe8, 0xf7, 0xad, 0xf5, 0xdd,
33 0xba, 0x8f, 0x02, 0x21, 0x00, 0xc0, 0xae, 0x18, 0xb2, 0xa2, 0x26, 0x22,
34 0x7b, 0x32, 0x8b, 0x21, 0xd3, 0xfb, 0xa5, 0xe6, 0xca, 0xae, 0x55, 0xab,
35 0xf6, 0x8c, 0x32, 0xd4, 0x40, 0x41, 0x8f, 0x89, 0x7b, 0x02, 0x8e, 0x76,
36 0xcd, 0x02, 0x21, 0x00, 0xbf, 0x67, 0xa6, 0xd0, 0x92, 0x9d, 0xf1, 0x24,
37 0x00, 0x13, 0x5a, 0xbc, 0x09, 0x06, 0xe9, 0x2c, 0x4d, 0x20, 0x53, 0x99,
38 0xc2, 0xfe, 0x7e, 0xaf, 0x82, 0xd3, 0xe7, 0xa5, 0x64, 0x89, 0x07, 0x07,
39 0x02, 0x21, 0x00, 0xc0, 0x26, 0x9e, 0xd0, 0xbe, 0x6e, 0x03, 0x63, 0x13,
40 0x03, 0xb7, 0x87, 0x9c, 0xe5, 0x54, 0xe4, 0xf9, 0xb8, 0xcc, 0x56, 0x82,
41 0x78, 0x4a, 0x3d, 0x8e, 0x64, 0x23, 0xb9, 0xbd, 0xd1, 0xef, 0x5d, 0x02,
42 0x21, 0x00, 0xdd, 0x15, 0xd3, 0x12, 0xe2, 0x85, 0xcf, 0x41, 0x70, 0xad,
43 0xeb, 0xf6, 0xa0, 0x6d, 0xe6, 0x78, 0x10, 0x44, 0xdf, 0xce, 0xc4, 0x62,
44 0x25, 0x3a, 0x98, 0x46, 0x9e, 0x7c, 0xc6, 0x01, 0x6c, 0x3d
45 ]);
46
47 // openssl req -new -x509 -key privkey.pem -out cacert.pem -days 36500
48 var certDer = new Uint8Array([
49 0x30, 0x82, 0x01, 0xd5, 0x30, 0x82, 0x01, 0x7f, 0xa0, 0x03, 0x02, 0x01,
50 0x02, 0x02, 0x09, 0x00, 0x9e, 0x11, 0x7e, 0xff, 0x43, 0x84, 0xd4, 0xe6,
51 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
52 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
53 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03,
54 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74,
55 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a,
56 0x0c, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57,
57 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c,
58 0x74, 0x64, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x34, 0x30, 0x37,
59 0x31, 0x35, 0x35, 0x30, 0x30, 0x38, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31,
60 0x34, 0x30, 0x33, 0x31, 0x34, 0x31, 0x35, 0x35, 0x30, 0x30, 0x38, 0x5a,
61 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
62 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
63 0x0c, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65,
64 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x49,
65 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67,
66 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30,
67 0x5c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
68 0x01, 0x01, 0x05, 0x00, 0x03, 0x4b, 0x00, 0x30, 0x48, 0x02, 0x41, 0x00,
69 0xac, 0x6c, 0x72, 0x46, 0xa2, 0xde, 0x88, 0x30, 0x54, 0x06, 0xad, 0xc7,
70 0x2d, 0x64, 0x6e, 0xf6, 0x0f, 0x72, 0x3e, 0x92, 0x31, 0xcc, 0x0b, 0xa0,
71 0x18, 0x20, 0xb0, 0xdb, 0x86, 0xab, 0x11, 0xc6, 0xa5, 0x78, 0xea, 0x64,
72 0xe8, 0xeb, 0xa5, 0xb3, 0x78, 0x5d, 0xbb, 0x10, 0x57, 0xe6, 0x12, 0x23,
73 0x89, 0x92, 0x1d, 0xa0, 0xe5, 0x1e, 0xd1, 0xc9, 0x0e, 0x62, 0xcb, 0xc9,
74 0xaf, 0xde, 0x4e, 0x83, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30,
75 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14,
76 0x75, 0x6c, 0x61, 0xfb, 0xb0, 0x6e, 0x37, 0x32, 0x41, 0x62, 0x3b, 0x55,
77 0xbd, 0x5f, 0x6b, 0xe0, 0xdb, 0xb9, 0xc7, 0xec, 0x30, 0x1f, 0x06, 0x03,
78 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x75, 0x6c, 0x61,
79 0xfb, 0xb0, 0x6e, 0x37, 0x32, 0x41, 0x62, 0x3b, 0x55, 0xbd, 0x5f, 0x6b,
80 0xe0, 0xdb, 0xb9, 0xc7, 0xec, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13,
81 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a,
82 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x41,
83 0x00, 0xa5, 0xe8, 0x9d, 0x3d, 0xc4, 0x1a, 0x6e, 0xd2, 0x92, 0x42, 0x37,
84 0xb9, 0x3a, 0xb3, 0x8e, 0x2f, 0x55, 0xb5, 0xf2, 0xe4, 0x6e, 0x39, 0x0d,
85 0xa8, 0xba, 0x10, 0x43, 0x57, 0xdd, 0x4e, 0x4e, 0x52, 0xc6, 0xbe, 0x07,
86 0xdb, 0x83, 0x05, 0x97, 0x97, 0xc1, 0x7b, 0xd5, 0x5c, 0x50, 0x64, 0x0f,
87 0x96, 0xff, 0x3d, 0x83, 0x37, 0x8f, 0x3a, 0x85, 0x08, 0x62, 0x5c, 0xb1,
88 0x2f, 0x68, 0xb2, 0x4a, 0x4a
89 ]);
90
91 function checkPropertyIsDefined(prop) {
92 if (!chrome.enterprise.certificates) {
93 fail('chrome.enterprise.certificates is not defined');
94 return false;
95 }
96 if (!chrome.enterprise.certificates[prop]) {
97 fail('chrome.enterprise.certificates.' + prop + ' is not undefined');
98 return false;
99 }
100 return true;
101 }
102
103 chrome.test.runTests([function importClientCert() {
104 var algorithmKeyGen = {name: "RSASSA-PKCS1-v1_5", hash: {name: "SHA-256"}};
eroman 2014/04/10 18:45:46 nit: "algorithmKeyGen" --> "importAlgorithm" ?
pneubeck (no reviews) 2014/04/11 14:13:59 Done.
105
106 if (!window.crypto.subtle) {
107 fail('window.crypto.subtle is not defined.');
108 return;
109 }
110 window.crypto.subtle
111 .importKey('pkcs8', privateKeyDer, algorithmKeyGen, false, ["sign"])
eroman 2014/04/10 18:45:46 The tests should also exercise calling importClien
pneubeck (no reviews) 2014/04/11 14:13:59 Done.
112 .then(callback(function(key) {
113 if (!checkPropertyIsDefined('importClientCertificate'))
114 return;
115 console.log('Imported/generated a key');
116 chrome.enterprise.certificates.importClientCertificate(
117 key,
118 certDer.buffer,
119 'user',
120 callback(function() {
121 succeed();
122 }));
123 }),
124 callback(function(e) {
125 console.error("Unable to import/generate key " + e);
126 fail();
127 }))
128 }]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698