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

Side by Side Diff: chrome/common/extensions/docs/templates/intros/enterprise_platformKeys.html

Issue 312503004: Make enterprise.platformKeys documentation public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 <p class="note">
2 <b>Note: </b>
not at google - send to devlin 2014/06/02 17:05:16 consider using <strong> not <b>
pneubeck (no reviews) 2014/06/03 09:22:21 Done.
3 This API is only available on ChromeOS.
not at google - send to devlin 2014/06/02 17:05:16 mention what it will do on non-ChromeOS platforms
pneubeck (no reviews) 2014/06/03 09:22:21 What do you mean? On other platforms it's not avai
not at google - send to devlin 2014/06/03 14:44:15 Oops notifications is wrong. And good point on th
pneubeck (no reviews) 2014/06/03 14:48:58 Shouldn't this behavior be the same as for all API
not at google - send to devlin 2014/06/03 15:12:20 Yes! We can auto-generate it. But regarding my pr
4 </p>
5
6 <h2 id="usage">Usage</h2>
7
8 Typical usage of this API to enroll a client certificate follows these steps:
9 <ul>
10 <li>Get all available tokens using $(ref:enterprise.platformKeys.getTokens).
11 </li>
12 <li>Find the Token with <code>id</code> equal <code>'user'</code>. Use this
13 Token subsequently.</li>
14 <li>Generate a key pair using the <code>generateKey</code> Token method
15 (defined in SubtleCrypto). This will return handle to the key.</li>
16 <li>Export the public key using the <code>exportKey</code> Token method
17 (defined in SubtleCrypto).
18 <li>Create the signature of the certification request's data using the
19 <code>sign</code> Token method (defined in SubtleCrypto).</li>
20 <li>Complete the certification request and send it to the certification
21 authority.</li>
22 <li>If a certificate is received, import it using
23 $(ref:enterprise.platformKeys.importCertificate)</li>
24 </ul>
25
26 <p>
27 Here's an example that shows the major API interaction except the building and s ending of the certification request:
28 </p>
29
30 <pre>
31 function getUserToken(callback) {
32 chrome.enterprise.platformKeys.getTokens(function(tokens) {
33 for (var i = 0; i < tokens.length; i++) {
34 if (tokens[i].id == 'user') {
35 callback(tokens[i]);
36 return;
37 }
38 }
39 callback(undefined);
40 });
41 }
42
43 function generateAndSign(userToken) {
44 var data = new Uint8Array([0, 5, 1, 2, 3, 4, 5, 6]);
45 var algorithm = {
46 name: "RSASSA-PKCS1-v1_5",
47 // RsaHashedKeyGenParams
48 modulusLength: 2048,
49 publicExponent:
50 new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
51 hash: {
52 name: "SHA-1",
53 }
54 };
55 var cachedKeyPair;
56 userToken.subtleCrypto.generateKey(algorithm, false, ["sign"])
57 .then(function(keyPair) {
58 cachedKeyPair = keyPair;
59 return userToken.subtleCrypto.exportKey('spki', keyPair.publicKey);
60 },
61 console.log.bind(console))
62 .then(function(publicKeySpki) {
63 // Build the Certification Request using the public key.
64 return userToken.subtleCrypto.sign(
65 {}, cachedKeyPair.privateKey, data);
66 },
67 console.log.bind(console))
68 .then(function(signature) {
69 // Complete the Certification Request with |signature|.
70 // Send out the request to the CA, calling back
71 // onClientCertificateReceived.
72 },
73 console.log.bind(console));
74 }
75
76 function onClientCertificateReceived(userToken, certificate) {
77 chrome.enterprise.platformKeys.importCertificate(userToken.id, certificate);
78 }
79
80 getUserToken(generateAndSign);
81 </pre>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698