Artifact 5dbcaf75a3c06d45423561c00cc98eef54335197:
0000: 2f 2a 0a 20 2a 20 43 41 43 4b 65 79 20 43 68 72 /*. * CACKey Chr
0010: 6f 6d 65 4f 53 20 63 68 72 6f 6d 65 2e 63 65 72 omeOS chrome.cer
0020: 74 69 66 69 63 61 74 65 50 72 6f 76 69 64 65 72 tificateProvider
0030: 20 49 6d 70 6c 65 6d 65 6e 74 61 74 69 6f 6e 0a Implementation.
0040: 20 2a 2f 0a 0a 66 75 6e 63 74 69 6f 6e 20 6f 6e */..function on
0050: 43 65 72 74 69 66 69 63 61 74 65 73 52 65 6a 65 CertificatesReje
0060: 63 74 65 64 28 72 65 6a 65 63 74 65 64 43 65 72 cted(rejectedCer
0070: 74 73 29 20 7b 0a 09 2f 2f 20 49 66 20 63 65 72 ts) {..// If cer
0080: 74 69 66 69 63 61 74 65 73 20 77 65 72 65 20 72 tificates were r
0090: 65 6a 65 63 74 65 64 20 62 79 20 74 68 65 20 41 ejected by the A
00a0: 50 49 2c 20 6c 6f 67 20 61 6e 20 65 72 72 6f 72 PI, log an error
00b0: 2c 20 66 6f 72 20 65 78 61 6d 70 6c 65 2e 0a 09 , for example...
00c0: 63 6f 6e 73 6f 6c 65 2e 65 72 72 6f 72 28 72 65 console.error(re
00d0: 6a 65 63 74 65 64 43 65 72 74 73 2e 6c 65 6e 67 jectedCerts.leng
00e0: 74 68 20 2b 20 27 20 63 65 72 74 69 66 69 63 61 th + ' certifica
00f0: 74 65 73 20 77 65 72 65 20 72 65 6a 65 63 74 65 tes were rejecte
0100: 64 2e 27 29 3b 0a 09 72 65 74 75 72 6e 3b 0a 7d d.');..return;.}
0110: 0a 0a 2f 2a 0a 20 2a 20 48 61 6e 64 6c 65 20 66 ../*. * Handle f
0120: 6f 72 20 74 68 65 20 43 41 43 4b 65 79 20 4e 61 or the CACKey Na
0130: 43 6c 20 54 61 72 67 65 74 0a 20 2a 2f 0a 76 61 Cl Target. */.va
0140: 72 20 63 61 63 6b 65 79 48 61 6e 64 6c 65 20 3d r cackeyHandle =
0150: 20 6e 75 6c 6c 3b 0a 0a 2f 2a 0a 20 2a 20 48 61 null;../*. * Ha
0160: 6e 64 6c 65 20 61 6e 64 20 49 44 20 66 6f 72 20 ndle and ID for
0170: 6f 75 74 73 74 61 6e 64 69 6e 67 20 63 61 6c 6c outstanding call
0180: 62 61 63 6b 73 0a 20 2a 2f 0a 76 61 72 20 63 61 backs. */.var ca
0190: 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 6e 67 43 ckeyOutstandingC
01a0: 61 6c 6c 62 61 63 6b 73 20 3d 20 5b 5d 0a 76 61 allbacks = [].va
01b0: 72 20 63 61 63 6b 65 79 4f 75 74 73 74 61 6e 64 r cackeyOutstand
01c0: 69 6e 67 43 61 6c 6c 62 61 63 6b 43 6f 75 6e 74 ingCallbackCount
01d0: 65 72 20 3d 20 2d 31 3b 0a 0a 2f 2a 0a 20 2a 20 er = -1;../*. *
01e0: 43 6f 6d 6d 75 6e 69 63 61 74 69 6f 6e 20 77 69 Communication wi
01f0: 74 68 20 74 68 65 20 50 49 4e 20 65 6e 74 72 79 th the PIN entry
0200: 20 77 69 6e 64 6f 77 0a 20 2a 2f 0a 76 61 72 20 window. */.var
0210: 70 69 6e 57 69 6e 64 6f 77 44 69 64 57 6f 72 6b pinWindowDidWork
0220: 20 3d 20 30 3b 0a 0a 2f 2a 0a 20 2a 20 48 61 6e = 0;../*. * Han
0230: 64 6c 65 20 61 20 72 65 73 70 6f 6e 73 65 20 66 dle a response f
0240: 72 6f 6d 20 74 68 65 20 4e 61 43 6c 20 73 69 64 rom the NaCl sid
0250: 65 20 72 65 67 61 72 64 69 6e 67 20 63 65 72 74 e regarding cert
0260: 69 66 69 63 61 74 65 73 20 61 76 61 69 6c 61 62 ificates availab
0270: 6c 65 0a 20 2a 2f 0a 66 75 6e 63 74 69 6f 6e 20 le. */.function
0280: 63 61 63 6b 65 79 4d 65 73 73 61 67 65 49 6e 63 cackeyMessageInc
0290: 6f 6d 69 6e 67 4c 69 73 74 43 65 72 74 69 66 69 omingListCertifi
02a0: 63 61 74 65 73 28 6d 65 73 73 61 67 65 2c 20 63 cates(message, c
02b0: 68 72 6f 6d 65 43 61 6c 6c 62 61 63 6b 29 20 7b hromeCallback) {
02c0: 0a 09 76 61 72 20 69 64 78 3b 0a 09 76 61 72 20 ..var idx;..var
02d0: 63 65 72 74 69 66 69 63 61 74 65 73 20 3d 20 5b certificates = [
02e0: 5d 3b 0a 0a 09 66 6f 72 20 28 69 64 78 20 3d 20 ];...for (idx =
02f0: 30 3b 20 69 64 78 20 3c 20 6d 65 73 73 61 67 65 0; idx < message
0300: 2e 63 65 72 74 69 66 69 63 61 74 65 73 2e 6c 65 .certificates.le
0310: 6e 67 74 68 3b 20 69 64 78 2b 2b 29 20 7b 0a 09 ngth; idx++) {..
0320: 09 63 65 72 74 69 66 69 63 61 74 65 73 2e 70 75 .certificates.pu
0330: 73 68 28 0a 09 09 09 7b 0a 09 09 09 09 63 65 72 sh(....{.....cer
0340: 74 69 66 69 63 61 74 65 3a 20 6d 65 73 73 61 67 tificate: messag
0350: 65 2e 63 65 72 74 69 66 69 63 61 74 65 73 5b 69 e.certificates[i
0360: 64 78 5d 2c 0a 09 09 09 09 73 75 70 70 6f 72 74 dx],.....support
0370: 65 64 48 61 73 68 65 73 3a 20 5b 27 53 48 41 31 edHashes: ['SHA1
0380: 27 2c 20 27 53 48 41 32 35 36 27 5d 0a 09 09 09 ', 'SHA256']....
0390: 7d 0a 09 09 29 3b 0a 09 7d 0a 0a 09 63 68 72 6f }...);..}...chro
03a0: 6d 65 43 61 6c 6c 62 61 63 6b 28 63 65 72 74 69 meCallback(certi
03b0: 66 69 63 61 74 65 73 2c 0a 09 09 66 75 6e 63 74 ficates,...funct
03c0: 69 6f 6e 28 72 65 6a 65 63 74 65 64 43 65 72 74 ion(rejectedCert
03d0: 73 29 20 7b 0a 09 09 09 69 66 20 28 63 68 72 6f s) {....if (chro
03e0: 6d 65 2e 72 75 6e 74 69 6d 65 2e 6c 61 73 74 45 me.runtime.lastE
03f0: 72 72 6f 72 29 20 7b 0a 09 09 09 09 72 65 74 75 rror) {.....retu
0400: 72 6e 3b 0a 09 09 09 7d 0a 0a 09 09 09 69 66 20 rn;....}.....if
0410: 28 72 65 6a 65 63 74 65 64 43 65 72 74 73 2e 6c (rejectedCerts.l
0420: 65 6e 67 74 68 20 21 3d 3d 20 30 29 20 7b 0a 09 ength !== 0) {..
0430: 09 09 09 6f 6e 43 65 72 74 69 66 69 63 61 74 65 ...onCertificate
0440: 73 52 65 6a 65 63 74 65 64 28 72 65 6a 65 63 74 sRejected(reject
0450: 65 64 43 65 72 74 73 29 3b 0a 09 09 09 7d 0a 0a edCerts);....}..
0460: 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 7d 0a 09 ...return;...}..
0470: 29 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 48 61 6e 64 );.}../*. * Hand
0480: 6c 65 20 61 20 72 65 73 70 6f 6e 73 65 20 66 72 le a response fr
0490: 6f 6d 20 74 68 65 20 4e 61 43 6c 20 73 69 64 65 om the NaCl side
04a0: 20 72 65 67 61 72 64 69 6e 67 20 73 69 67 6e 69 regarding signi
04b0: 6e 67 20 61 20 6d 65 73 73 61 67 65 0a 20 2a 2f ng a message. */
04c0: 0a 66 75 6e 63 74 69 6f 6e 20 63 61 63 6b 65 79 .function cackey
04d0: 4d 65 73 73 61 67 65 49 6e 63 6f 6d 69 6e 67 53 MessageIncomingS
04e0: 69 67 6e 4d 65 73 73 61 67 65 28 6d 65 73 73 61 ignMessage(messa
04f0: 67 65 2c 20 63 68 72 6f 6d 65 43 61 6c 6c 62 61 ge, chromeCallba
0500: 63 6b 29 20 7b 0a 09 76 61 72 20 70 61 79 6c 6f ck) {..var paylo
0510: 61 64 3b 0a 0a 09 70 61 79 6c 6f 61 64 20 3d 20 ad;...payload =
0520: 6d 65 73 73 61 67 65 2e 73 69 67 6e 65 64 44 61 message.signedDa
0530: 74 61 3b 0a 0a 09 63 68 72 6f 6d 65 43 61 6c 6c ta;...chromeCall
0540: 62 61 63 6b 28 70 61 79 6c 6f 61 64 29 3b 0a 7d back(payload);.}
0550: 0a 0a 2f 2a 0a 20 2a 20 48 61 6e 64 6c 65 20 61 ../*. * Handle a
0560: 6e 20 69 6e 63 6f 6d 69 6e 67 20 6d 65 73 73 61 n incoming messa
0570: 67 65 20 66 72 6f 6d 20 74 68 65 20 4e 61 43 6c ge from the NaCl
0580: 20 73 69 64 65 20 61 6e 64 20 70 61 73 73 20 69 side and pass i
0590: 74 20 6f 66 66 20 74 6f 0a 20 2a 20 6f 6e 65 20 t off to. * one
05a0: 6f 66 20 74 68 65 20 68 61 6e 64 6c 65 72 73 20 of the handlers
05b0: 61 62 6f 76 65 20 66 6f 72 20 61 63 74 75 61 6c above for actual
05c0: 20 66 6f 72 6d 61 74 74 69 6e 67 20 61 6e 64 20 formatting and
05d0: 70 61 73 73 69 6e 67 20 74 6f 0a 20 2a 20 74 68 passing to. * th
05e0: 65 20 63 61 6c 6c 62 61 63 6b 0a 20 2a 0a 20 2a e callback. *. *
05f0: 20 49 66 20 61 6e 20 65 72 72 6f 72 20 6f 63 63 If an error occ
0600: 75 72 65 64 2c 20 69 6e 76 6f 6b 65 20 74 68 65 ured, invoke the
0610: 20 63 61 6c 6c 62 61 63 6b 20 77 69 74 68 20 6e callback with n
0620: 6f 20 61 72 67 75 6d 65 6e 74 73 2e 0a 20 2a 2f o arguments.. */
0630: 0a 66 75 6e 63 74 69 6f 6e 20 63 61 63 6b 65 79 .function cackey
0640: 4d 65 73 73 61 67 65 49 6e 63 6f 6d 69 6e 67 28 MessageIncoming(
0650: 6d 65 73 73 61 67 65 45 76 65 6e 74 29 20 7b 0a messageEvent) {.
0660: 09 76 61 72 20 6e 65 78 74 46 75 6e 63 74 69 6f .var nextFunctio
0670: 6e 20 3d 20 6e 75 6c 6c 3b 0a 09 76 61 72 20 63 n = null;..var c
0680: 68 72 6f 6d 65 43 61 6c 6c 62 61 63 6b 20 3d 20 hromeCallback =
0690: 6e 75 6c 6c 3b 0a 0a 09 69 66 20 28 6d 65 73 73 null;...if (mess
06a0: 61 67 65 45 76 65 6e 74 2e 64 61 74 61 2e 74 61 ageEvent.data.ta
06b0: 72 67 65 74 20 21 3d 20 22 63 61 63 6b 65 79 22 rget != "cackey"
06c0: 29 20 7b 0a 09 09 72 65 74 75 72 6e 3b 0a 09 7d ) {...return;..}
06d0: 0a 0a 09 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 ...console.log("
06e0: 53 54 41 52 54 20 4d 45 53 53 41 47 45 22 29 3b START MESSAGE");
06f0: 0a 09 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 6d 65 ..console.log(me
0700: 73 73 61 67 65 45 76 65 6e 74 2e 64 61 74 61 29 ssageEvent.data)
0710: 3b 0a 09 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 ;..console.log("
0720: 45 4e 44 20 4d 45 53 53 41 47 45 22 29 3b 0a 0a END MESSAGE");..
0730: 09 63 68 72 6f 6d 65 43 61 6c 6c 62 61 63 6b 20 .chromeCallback
0740: 3d 20 63 61 63 6b 65 79 4f 75 74 73 74 61 6e 64 = cackeyOutstand
0750: 69 6e 67 43 61 6c 6c 62 61 63 6b 73 5b 6d 65 73 ingCallbacks[mes
0760: 73 61 67 65 45 76 65 6e 74 2e 64 61 74 61 2e 69 sageEvent.data.i
0770: 64 5d 3b 0a 0a 09 69 66 20 28 63 68 72 6f 6d 65 d];...if (chrome
0780: 43 61 6c 6c 62 61 63 6b 20 3d 3d 20 6e 75 6c 6c Callback == null
0790: 29 20 7b 0a 09 09 63 6f 6e 73 6f 6c 65 2e 6c 6f ) {...console.lo
07a0: 67 28 22 5b 63 61 63 6b 65 79 5d 20 44 69 73 63 g("[cackey] Disc
07b0: 61 72 64 69 6e 67 20 6f 75 74 64 61 74 65 64 20 arding outdated
07c0: 6d 65 73 73 61 67 65 22 29 3b 0a 0a 09 09 72 65 message");....re
07d0: 74 75 72 6e 3b 0a 09 7d 0a 0a 09 73 77 69 74 63 turn;..}...switc
07e0: 68 20 28 6d 65 73 73 61 67 65 45 76 65 6e 74 2e h (messageEvent.
07f0: 64 61 74 61 2e 73 74 61 74 75 73 29 20 7b 0a 09 data.status) {..
0800: 09 63 61 73 65 20 22 65 72 72 6f 72 22 3a 0a 09 .case "error":..
0810: 09 09 63 6f 6e 73 6f 6c 65 2e 65 72 72 6f 72 28 ..console.error(
0820: 22 5b 63 61 63 6b 65 79 5d 20 46 61 69 6c 65 64 "[cackey] Failed
0830: 20 74 6f 20 65 78 65 63 75 74 65 20 63 6f 6d 6d to execute comm
0840: 61 6e 64 20 27 22 20 2b 20 6d 65 73 73 61 67 65 and '" + message
0850: 45 76 65 6e 74 2e 64 61 74 61 2e 63 6f 6d 6d 61 Event.data.comma
0860: 6e 64 20 2b 20 22 27 3a 20 22 20 2b 20 6d 65 73 nd + "': " + mes
0870: 73 61 67 65 45 76 65 6e 74 2e 64 61 74 61 2e 65 sageEvent.data.e
0880: 72 72 6f 72 29 3b 0a 0a 09 09 09 63 68 72 6f 6d rror);.....chrom
0890: 65 43 61 6c 6c 62 61 63 6b 28 29 3b 0a 0a 09 09 eCallback();....
08a0: 09 62 72 65 61 6b 3b 0a 09 09 63 61 73 65 20 22 .break;...case "
08b0: 72 65 74 72 79 22 3a 0a 09 09 09 70 69 6e 57 69 retry":....pinWi
08c0: 6e 64 6f 77 44 69 64 57 6f 72 6b 20 3d 20 30 3b ndowDidWork = 0;
08d0: 0a 0a 09 09 09 63 68 72 6f 6d 65 2e 61 70 70 2e .....chrome.app.
08e0: 77 69 6e 64 6f 77 2e 63 72 65 61 74 65 28 22 70 window.create("p
08f0: 69 6e 2e 68 74 6d 6c 22 2c 20 7b 0a 09 09 09 09 in.html", {.....
0900: 22 69 64 22 3a 20 22 63 61 63 6b 65 79 50 49 4e "id": "cackeyPIN
0910: 45 6e 74 72 79 22 2c 0a 09 09 09 09 22 72 65 73 Entry",....."res
0920: 69 7a 61 62 6c 65 22 3a 20 66 61 6c 73 65 2c 0a izable": false,.
0930: 09 09 09 09 22 61 6c 77 61 79 73 4f 6e 54 6f 70 ...."alwaysOnTop
0940: 22 3a 20 74 72 75 65 2c 0a 09 09 09 09 22 66 6f ": true,....."fo
0950: 63 75 73 65 64 22 3a 20 74 72 75 65 2c 0a 09 09 cused": true,...
0960: 09 09 22 76 69 73 69 62 6c 65 4f 6e 41 6c 6c 57 .."visibleOnAllW
0970: 6f 72 6b 73 70 61 63 65 73 22 3a 20 74 72 75 65 orkspaces": true
0980: 2c 0a 09 09 09 09 22 69 6e 6e 65 72 42 6f 75 6e ,....."innerBoun
0990: 64 73 22 3a 20 7b 0a 09 09 09 09 09 22 77 69 64 ds": {......"wid
09a0: 74 68 22 3a 20 33 35 30 2c 0a 09 09 09 09 09 22 th": 350,......"
09b0: 6d 69 6e 57 69 64 74 68 22 3a 20 33 35 30 2c 0a minWidth": 350,.
09c0: 09 09 09 09 09 22 68 65 69 67 68 74 22 3a 20 31 ....."height": 1
09d0: 33 35 2c 0a 09 09 09 09 09 22 6d 69 6e 48 65 69 35,......"minHei
09e0: 67 68 74 22 3a 20 31 33 35 0a 09 09 09 09 7d 0a ght": 135.....}.
09f0: 09 09 09 7d 2c 20 66 75 6e 63 74 69 6f 6e 28 70 ...}, function(p
0a00: 69 6e 57 69 6e 64 6f 77 29 20 7b 0a 09 09 09 09 inWindow) {.....
0a10: 69 66 20 28 21 70 69 6e 57 69 6e 64 6f 77 29 20 if (!pinWindow)
0a20: 7b 0a 09 09 09 09 09 63 6f 6e 73 6f 6c 65 2e 6c {......console.l
0a30: 6f 67 28 22 5b 63 61 63 6b 65 79 5d 20 4e 6f 20 og("[cackey] No
0a40: 77 69 6e 64 6f 77 20 77 61 73 20 70 72 6f 76 69 window was provi
0a50: 64 65 64 20 66 6f 72 20 50 49 4e 20 65 6e 74 72 ded for PIN entr
0a60: 79 2c 20 74 68 69 73 20 77 69 6c 6c 20 6e 6f 74 y, this will not
0a70: 20 67 6f 20 77 65 6c 6c 2e 22 29 3b 0a 0a 09 09 go well.");....
0a80: 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 09 09 7d ...return;.....}
0a90: 0a 09 09 09 09 70 69 6e 57 69 6e 64 6f 77 2e 64 .....pinWindow.d
0aa0: 72 61 77 41 74 74 65 6e 74 69 6f 6e 28 29 3b 0a rawAttention();.
0ab0: 09 09 09 09 70 69 6e 57 69 6e 64 6f 77 2e 66 6f ....pinWindow.fo
0ac0: 63 75 73 28 29 3b 0a 0a 09 09 09 09 2f 2a 0a 09 cus();....../*..
0ad0: 09 09 09 20 2a 20 52 65 67 69 73 74 65 72 20 61 ... * Register a
0ae0: 20 68 61 6e 64 6c 65 72 20 74 6f 20 68 61 6e 64 handler to hand
0af0: 6c 65 20 74 68 65 20 77 69 6e 64 6f 77 20 62 65 le the window be
0b00: 69 6e 67 20 63 6c 6f 73 65 64 20 77 69 74 68 6f ing closed witho
0b10: 75 74 0a 09 09 09 09 20 2a 20 68 61 76 69 6e 67 ut..... * having
0b20: 20 73 65 6e 74 20 61 6e 79 74 68 69 6e 67 0a 09 sent anything..
0b30: 09 09 09 20 2a 2f 0a 09 09 09 09 70 69 6e 57 69 ... */.....pinWi
0b40: 6e 64 6f 77 2e 6f 6e 43 6c 6f 73 65 64 2e 61 64 ndow.onClosed.ad
0b50: 64 4c 69 73 74 65 6e 65 72 28 66 75 6e 63 74 69 dListener(functi
0b60: 6f 6e 28 29 20 7b 0a 09 09 09 09 09 69 66 20 28 on() {......if (
0b70: 70 69 6e 57 69 6e 64 6f 77 44 69 64 57 6f 72 6b pinWindowDidWork
0b80: 20 21 3d 20 31 29 20 7b 0a 09 09 09 09 09 09 63 != 1) {.......c
0b90: 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 5b 63 61 63 onsole.log("[cac
0ba0: 6b 65 79 5d 20 54 68 65 20 50 49 4e 20 64 69 61 key] The PIN dia
0bb0: 6c 6f 67 20 77 61 73 20 63 6c 6f 73 65 64 20 77 log was closed w
0bc0: 69 74 68 6f 75 74 20 72 65 73 75 62 6d 69 74 74 ithout resubmitt
0bd0: 69 6e 67 20 74 68 65 20 72 65 71 75 65 73 74 2c ing the request,
0be0: 20 74 72 65 61 74 69 6e 67 20 69 74 20 61 73 20 treating it as
0bf0: 61 20 66 61 69 6c 75 72 65 22 29 3b 0a 0a 09 09 a failure");....
0c00: 09 09 09 09 63 61 63 6b 65 79 4d 65 73 73 61 67 ....cackeyMessag
0c10: 65 49 6e 63 6f 6d 69 6e 67 28 0a 09 09 09 09 09 eIncoming(......
0c20: 09 09 7b 0a 09 09 09 09 09 09 09 09 22 64 61 74 ..{........."dat
0c30: 61 22 3a 20 7b 0a 09 09 09 09 09 09 09 09 09 22 a": {.........."
0c40: 74 61 72 67 65 74 22 3a 20 22 63 61 63 6b 65 79 target": "cackey
0c50: 22 2c 0a 09 09 09 09 09 09 09 09 09 22 63 6f 6d ",.........."com
0c60: 6d 61 6e 64 22 3a 20 6d 65 73 73 61 67 65 45 76 mand": messageEv
0c70: 65 6e 74 2e 64 61 74 61 2e 63 6f 6d 6d 61 6e 64 ent.data.command
0c80: 2c 0a 09 09 09 09 09 09 09 09 09 22 69 64 22 3a ,.........."id":
0c90: 20 6d 65 73 73 61 67 65 45 76 65 6e 74 2e 64 61 messageEvent.da
0ca0: 74 61 2e 69 64 2c 0a 09 09 09 09 09 09 09 09 09 ta.id,..........
0cb0: 22 73 74 61 74 75 73 22 3a 20 22 65 72 72 6f 72 "status": "error
0cc0: 22 2c 0a 09 09 09 09 09 09 09 09 09 22 65 72 72 ",.........."err
0cd0: 6f 72 22 3a 20 22 50 49 4e 20 77 69 6e 64 6f 77 or": "PIN window
0ce0: 20 63 6c 6f 73 65 64 20 77 69 74 68 6f 75 74 20 closed without
0cf0: 61 20 50 49 4e 20 62 65 69 6e 67 20 70 72 6f 76 a PIN being prov
0d00: 69 64 65 64 22 0a 09 09 09 09 09 09 09 09 7d 0a ided".........}.
0d10: 09 09 09 09 09 09 09 7d 0a 09 09 09 09 09 09 29 .......}.......)
0d20: 0a 0a 09 09 09 09 09 7d 0a 09 09 09 09 09 72 65 .......}......re
0d30: 74 75 72 6e 3b 0a 09 09 09 09 7d 29 0a 0a 09 09 turn;.....})....
0d40: 09 09 2f 2a 0a 09 09 09 09 20 2a 20 50 61 73 73 ../*..... * Pass
0d50: 20 74 68 69 73 20 6d 65 73 73 61 67 65 20 6f 66 this message of
0d60: 66 20 74 6f 20 74 68 65 20 6f 74 68 65 72 20 77 f to the other w
0d70: 69 6e 64 6f 77 20 73 6f 20 74 68 61 74 20 69 74 indow so that it
0d80: 20 6d 61 79 20 72 65 73 75 62 6d 69 74 20 74 68 may resubmit th
0d90: 65 20 72 65 71 75 65 73 74 2e 0a 09 09 09 09 20 e request......
0da0: 2a 2f 0a 09 09 09 09 70 69 6e 57 69 6e 64 6f 77 */.....pinWindow
0db0: 2e 63 6f 6e 74 65 6e 74 57 69 6e 64 6f 77 2e 70 .contentWindow.p
0dc0: 61 72 65 6e 74 57 69 6e 64 6f 77 20 3d 20 77 69 arentWindow = wi
0dd0: 6e 64 6f 77 3b 0a 09 09 09 09 70 69 6e 57 69 6e ndow;.....pinWin
0de0: 64 6f 77 2e 63 6f 6e 74 65 6e 74 57 69 6e 64 6f dow.contentWindo
0df0: 77 2e 6d 65 73 73 61 67 65 45 76 65 6e 74 20 3d w.messageEvent =
0e00: 20 6d 65 73 73 61 67 65 45 76 65 6e 74 3b 0a 0a messageEvent;..
0e10: 09 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 09 7d ....return;....}
0e20: 29 3b 0a 0a 09 09 09 2f 2a 0a 09 09 09 20 2a 20 );...../*.... *
0e30: 57 65 20 72 65 74 75 72 6e 20 68 65 72 65 20 69 We return here i
0e40: 6e 73 74 65 61 64 20 6f 66 20 62 72 65 61 6b 20 nstead of break
0e50: 74 6f 20 61 76 6f 69 64 20 64 65 6c 65 74 69 6e to avoid deletin
0e60: 67 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 0a 09 g the callback..
0e70: 09 09 20 2a 20 65 6e 74 72 79 2e 0a 09 09 09 20 .. * entry.....
0e80: 2a 2f 0a 09 09 09 72 65 74 75 72 6e 3b 0a 09 09 */....return;...
0e90: 63 61 73 65 20 22 73 75 63 63 65 73 73 22 3a 0a case "success":.
0ea0: 09 09 09 73 77 69 74 63 68 20 28 6d 65 73 73 61 ...switch (messa
0eb0: 67 65 45 76 65 6e 74 2e 64 61 74 61 2e 63 6f 6d geEvent.data.com
0ec0: 6d 61 6e 64 29 20 7b 0a 09 09 09 09 63 61 73 65 mand) {.....case
0ed0: 20 22 6c 69 73 74 63 65 72 74 69 66 69 63 61 74 "listcertificat
0ee0: 65 73 22 3a 0a 09 09 09 09 09 6e 65 78 74 46 75 es":......nextFu
0ef0: 6e 63 74 69 6f 6e 20 3d 20 63 61 63 6b 65 79 4d nction = cackeyM
0f00: 65 73 73 61 67 65 49 6e 63 6f 6d 69 6e 67 4c 69 essageIncomingLi
0f10: 73 74 43 65 72 74 69 66 69 63 61 74 65 73 3b 0a stCertificates;.
0f20: 0a 09 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 ......break;....
0f30: 09 63 61 73 65 20 22 73 69 67 6e 22 3a 0a 09 09 .case "sign":...
0f40: 09 09 09 6e 65 78 74 46 75 6e 63 74 69 6f 6e 20 ...nextFunction
0f50: 3d 20 63 61 63 6b 65 79 4d 65 73 73 61 67 65 49 = cackeyMessageI
0f60: 6e 63 6f 6d 69 6e 67 53 69 67 6e 4d 65 73 73 61 ncomingSignMessa
0f70: 67 65 3b 0a 0a 09 09 09 09 09 62 72 65 61 6b 3b ge;.......break;
0f80: 0a 09 09 09 7d 0a 0a 09 09 09 62 72 65 61 6b 3b ....}.....break;
0f90: 0a 09 7d 0a 0a 09 69 66 20 28 6e 65 78 74 46 75 ..}...if (nextFu
0fa0: 6e 63 74 69 6f 6e 20 21 3d 20 6e 75 6c 6c 29 20 nction != null)
0fb0: 7b 0a 09 09 6e 65 78 74 46 75 6e 63 74 69 6f 6e {...nextFunction
0fc0: 28 6d 65 73 73 61 67 65 45 76 65 6e 74 2e 64 61 (messageEvent.da
0fd0: 74 61 2c 20 63 68 72 6f 6d 65 43 61 6c 6c 62 61 ta, chromeCallba
0fe0: 63 6b 29 3b 0a 09 7d 0a 0a 09 64 65 6c 65 74 65 ck);..}...delete
0ff0: 20 63 61 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 cackeyOutstandi
1000: 6e 67 43 61 6c 6c 62 61 63 6b 73 5b 6d 65 73 73 ngCallbacks[mess
1010: 61 67 65 45 76 65 6e 74 2e 64 61 74 61 2e 69 64 ageEvent.data.id
1020: 5d 3b 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a ];...return;.}..
1030: 2f 2a 0a 20 2a 20 48 61 6e 64 6c 65 72 20 66 6f /*. * Handler fo
1040: 72 20 6d 65 73 73 61 67 65 73 20 66 72 6f 6d 20 r messages from
1050: 43 68 72 6f 6d 65 20 72 65 6c 61 74 65 64 20 74 Chrome related t
1060: 6f 20 6c 69 73 74 69 6e 67 20 63 65 72 74 69 66 o listing certif
1070: 69 63 61 74 65 73 0a 20 2a 2f 0a 66 75 6e 63 74 icates. */.funct
1080: 69 6f 6e 20 63 61 63 6b 65 79 4c 69 73 74 43 65 ion cackeyListCe
1090: 72 74 69 66 69 63 61 74 65 73 28 63 68 72 6f 6d rtificates(chrom
10a0: 65 43 61 6c 6c 62 61 63 6b 29 20 7b 0a 09 76 61 eCallback) {..va
10b0: 72 20 63 61 6c 6c 62 61 63 6b 49 64 3b 0a 0a 09 r callbackId;...
10c0: 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 5b 63 61 console.log("[ca
10d0: 63 6b 65 79 5d 20 41 73 6b 65 64 20 74 6f 20 70 ckey] Asked to p
10e0: 72 6f 76 69 64 65 20 61 20 6c 69 73 74 20 6f 66 rovide a list of
10f0: 20 63 65 72 74 69 66 69 63 61 74 65 73 20 2d 2d certificates --
1100: 20 74 68 72 6f 77 69 6e 67 20 74 68 61 74 20 72 throwing that r
1110: 65 71 75 65 73 74 20 6f 76 65 72 20 74 6f 20 74 equest over to t
1120: 68 65 20 4e 61 43 6c 20 73 69 64 65 2e 2e 2e 20 he NaCl side...
1130: 22 29 3b 0a 0a 09 63 61 6c 6c 62 61 63 6b 49 64 ");...callbackId
1140: 20 3d 20 63 61 63 6b 65 79 4f 75 74 73 74 61 6e = cackeyOutstan
1150: 64 69 6e 67 43 61 6c 6c 62 61 63 6b 43 6f 75 6e dingCallbackCoun
1160: 74 65 72 20 2b 20 31 3b 0a 0a 09 63 61 63 6b 65 ter + 1;...cacke
1170: 79 48 61 6e 64 6c 65 2e 70 6f 73 74 4d 65 73 73 yHandle.postMess
1180: 61 67 65 28 0a 09 09 7b 0a 09 09 09 27 74 61 72 age(...{....'tar
1190: 67 65 74 27 3a 20 22 63 61 63 6b 65 79 22 2c 0a get': "cackey",.
11a0: 09 09 09 27 63 6f 6d 6d 61 6e 64 27 3a 20 22 6c ...'command': "l
11b0: 69 73 74 63 65 72 74 69 66 69 63 61 74 65 73 22 istcertificates"
11c0: 2c 0a 09 09 09 27 69 64 27 3a 20 63 61 6c 6c 62 ,....'id': callb
11d0: 61 63 6b 49 64 0a 09 09 7d 0a 09 29 3b 0a 0a 09 ackId...}..);...
11e0: 63 61 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 6e cackeyOutstandin
11f0: 67 43 61 6c 6c 62 61 63 6b 43 6f 75 6e 74 65 72 gCallbackCounter
1200: 20 3d 20 63 61 6c 6c 62 61 63 6b 49 64 3b 0a 09 = callbackId;..
1210: 63 61 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 6e cackeyOutstandin
1220: 67 43 61 6c 6c 62 61 63 6b 73 5b 63 61 6c 6c 62 gCallbacks[callb
1230: 61 63 6b 49 64 5d 20 3d 20 63 68 72 6f 6d 65 43 ackId] = chromeC
1240: 61 6c 6c 62 61 63 6b 3b 0a 0a 09 63 6f 6e 73 6f allback;...conso
1250: 6c 65 2e 6c 6f 67 28 22 5b 63 61 63 6b 65 79 5d le.log("[cackey]
1260: 20 54 68 72 6f 77 6e 2e 22 29 3b 0a 0a 09 72 65 Thrown.");...re
1270: 74 75 72 6e 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 48 turn;.}../*. * H
1280: 61 6e 64 6c 65 72 20 66 6f 72 20 6d 65 73 73 61 andler for messa
1290: 67 65 73 20 66 72 6f 6d 20 43 68 72 6f 6d 65 20 ges from Chrome
12a0: 72 65 6c 61 74 65 64 20 74 6f 20 73 69 67 6e 69 related to signi
12b0: 6e 67 20 61 20 68 61 73 68 20 6f 66 20 73 6f 6d ng a hash of som
12c0: 65 20 73 6f 72 74 0a 20 2a 2f 0a 66 75 6e 63 74 e sort. */.funct
12d0: 69 6f 6e 20 63 61 63 6b 65 79 53 69 67 6e 4d 65 ion cackeySignMe
12e0: 73 73 61 67 65 28 73 69 67 6e 52 65 71 75 65 73 ssage(signReques
12f0: 74 2c 20 63 68 72 6f 6d 65 43 61 6c 6c 62 61 63 t, chromeCallbac
1300: 6b 29 20 7b 0a 09 76 61 72 20 63 61 6c 6c 62 61 k) {..var callba
1310: 63 6b 49 64 3b 0a 0a 09 63 6f 6e 73 6f 6c 65 2e ckId;...console.
1320: 6c 6f 67 28 22 5b 63 61 63 6b 65 79 5d 20 41 73 log("[cackey] As
1330: 6b 65 64 20 74 6f 20 73 69 67 6e 20 61 20 6d 65 ked to sign a me
1340: 73 73 61 67 65 20 2d 2d 20 74 68 72 6f 77 69 6e ssage -- throwin
1350: 67 20 74 68 61 74 20 72 65 71 75 65 73 74 20 6f g that request o
1360: 76 65 72 20 74 6f 20 74 68 65 20 4e 61 43 6c 20 ver to the NaCl
1370: 73 69 64 65 2e 2e 2e 20 22 29 3b 0a 0a 09 63 61 side... ");...ca
1380: 6c 6c 62 61 63 6b 49 64 20 3d 20 63 61 63 6b 65 llbackId = cacke
1390: 79 4f 75 74 73 74 61 6e 64 69 6e 67 43 61 6c 6c yOutstandingCall
13a0: 62 61 63 6b 43 6f 75 6e 74 65 72 20 2b 20 31 3b backCounter + 1;
13b0: 0a 0a 09 63 61 63 6b 65 79 48 61 6e 64 6c 65 2e ...cackeyHandle.
13c0: 70 6f 73 74 4d 65 73 73 61 67 65 28 0a 09 09 7b postMessage(...{
13d0: 0a 09 09 09 27 74 61 72 67 65 74 27 3a 20 22 63 ....'target': "c
13e0: 61 63 6b 65 79 22 2c 0a 09 09 09 27 63 6f 6d 6d ackey",....'comm
13f0: 61 6e 64 27 3a 20 22 73 69 67 6e 22 2c 0a 09 09 and': "sign",...
1400: 09 27 69 64 27 3a 20 63 61 6c 6c 62 61 63 6b 49 .'id': callbackI
1410: 64 2c 0a 09 09 09 27 63 65 72 74 69 66 69 63 61 d,....'certifica
1420: 74 65 27 3a 20 73 69 67 6e 52 65 71 75 65 73 74 te': signRequest
1430: 2e 63 65 72 74 69 66 69 63 61 74 65 2c 0a 09 09 .certificate,...
1440: 09 27 64 61 74 61 27 3a 20 73 69 67 6e 52 65 71 .'data': signReq
1450: 75 65 73 74 2e 64 69 67 65 73 74 20 2f 2a 20 58 uest.digest /* X
1460: 58 58 3a 54 4f 44 4f 3a 20 54 68 69 73 20 6e 65 XX:TODO: This ne
1470: 65 64 73 20 74 6f 20 62 65 20 70 72 65 66 69 78 eds to be prefix
1480: 65 64 20 62 61 73 65 64 20 6f 6e 20 74 68 65 20 ed based on the
1490: 73 69 67 6e 52 65 71 75 65 73 74 2e 68 61 73 68 signRequest.hash
14a0: 20 2a 2f 0a 09 09 7d 0a 09 29 3b 0a 0a 09 63 61 */...}..);...ca
14b0: 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 6e 67 43 ckeyOutstandingC
14c0: 61 6c 6c 62 61 63 6b 43 6f 75 6e 74 65 72 20 3d allbackCounter =
14d0: 20 63 61 6c 6c 62 61 63 6b 49 64 3b 0a 09 63 61 callbackId;..ca
14e0: 63 6b 65 79 4f 75 74 73 74 61 6e 64 69 6e 67 43 ckeyOutstandingC
14f0: 61 6c 6c 62 61 63 6b 73 5b 63 61 6c 6c 62 61 63 allbacks[callbac
1500: 6b 49 64 5d 20 3d 20 63 68 72 6f 6d 65 43 61 6c kId] = chromeCal
1510: 6c 62 61 63 6b 3b 0a 0a 09 63 6f 6e 73 6f 6c 65 lback;...console
1520: 2e 6c 6f 67 28 22 5b 63 61 63 6b 65 79 5d 20 54 .log("[cackey] T
1530: 68 72 6f 77 6e 2e 22 29 3b 0a 0a 09 72 65 74 75 hrown.");...retu
1540: 72 6e 3b 0a 7d 0a 0a 2f 2a 0a 20 2a 20 46 69 6e rn;.}../*. * Fin
1550: 69 73 68 20 70 65 72 66 6f 72 6d 69 6e 67 20 69 ish performing i
1560: 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 74 68 nitialization th
1570: 61 74 20 6d 75 73 74 20 77 61 69 74 20 75 6e 74 at must wait unt
1580: 69 6c 20 77 65 20 68 61 76 65 20 6c 6f 61 64 65 il we have loade
1590: 64 20 74 68 65 20 43 41 43 4b 65 79 20 6d 6f 64 d the CACKey mod
15a0: 75 6c 65 0a 20 2a 2f 0a 66 75 6e 63 74 69 6f 6e ule. */.function
15b0: 20 63 61 63 6b 65 79 49 6e 69 74 4c 6f 61 64 65 cackeyInitLoade
15c0: 64 28 6d 65 73 73 61 67 65 45 76 65 6e 74 29 20 d(messageEvent)
15d0: 7b 0a 09 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 {..console.log("
15e0: 5b 63 61 63 6b 65 79 5d 20 4c 6f 61 64 65 64 20 [cackey] Loaded
15f0: 43 41 43 4b 65 79 20 50 4e 61 43 6c 20 4d 6f 64 CACKey PNaCl Mod
1600: 75 6c 65 22 29 3b 0a 0a 09 2f 2a 20 52 65 67 69 ule");.../* Regi
1610: 73 74 65 72 20 6c 69 73 74 65 6e 65 72 73 20 77 ster listeners w
1620: 69 74 68 20 43 68 72 6f 6d 65 20 2a 2f 0a 09 69 ith Chrome */..i
1630: 66 20 28 63 68 72 6f 6d 65 2e 63 65 72 74 69 66 f (chrome.certif
1640: 69 63 61 74 65 50 72 6f 76 69 64 65 72 29 20 7b icateProvider) {
1650: 0a 09 09 63 68 72 6f 6d 65 2e 63 65 72 74 69 66 ...chrome.certif
1660: 69 63 61 74 65 50 72 6f 76 69 64 65 72 2e 6f 6e icateProvider.on
1670: 43 65 72 74 69 66 69 63 61 74 65 73 52 65 71 75 CertificatesRequ
1680: 65 73 74 65 64 2e 61 64 64 4c 69 73 74 65 6e 65 ested.addListene
1690: 72 28 63 61 63 6b 65 79 4c 69 73 74 43 65 72 74 r(cackeyListCert
16a0: 69 66 69 63 61 74 65 73 29 3b 0a 09 09 63 68 72 ificates);...chr
16b0: 6f 6d 65 2e 63 65 72 74 69 66 69 63 61 74 65 50 ome.certificateP
16c0: 72 6f 76 69 64 65 72 2e 6f 6e 53 69 67 6e 44 69 rovider.onSignDi
16d0: 67 65 73 74 52 65 71 75 65 73 74 65 64 2e 61 64 gestRequested.ad
16e0: 64 4c 69 73 74 65 6e 65 72 28 63 61 63 6b 65 79 dListener(cackey
16f0: 53 69 67 6e 4d 65 73 73 61 67 65 29 3b 0a 09 7d SignMessage);..}
1700: 0a 0a 09 72 65 74 75 72 6e 3b 0a 7d 0a 0a 2f 2a ...return;.}../*
1710: 0a 20 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 43 . * Initialize C
1720: 41 43 4b 65 79 20 61 6e 64 20 74 68 65 20 50 43 ACKey and the PC
1730: 53 43 20 6c 69 62 72 61 72 79 20 66 72 6f 6d 20 SC library from
1740: 47 6f 6f 67 6c 65 0a 20 2a 2f 0a 66 75 6e 63 74 Google. */.funct
1750: 69 6f 6e 20 63 61 63 6b 65 79 49 6e 69 74 28 29 ion cackeyInit()
1760: 20 7b 0a 09 76 61 72 20 65 6c 65 6d 65 6e 74 45 {..var elementE
1770: 6d 62 65 64 3b 0a 0a 09 2f 2a 20 4c 6f 67 20 74 mbed;.../* Log t
1780: 68 61 74 20 77 65 20 61 72 65 20 6f 70 65 72 61 hat we are opera
1790: 74 69 6f 6e 61 6c 20 2a 2f 0a 09 63 6f 6e 73 6f tional */..conso
17a0: 6c 65 2e 6c 6f 67 28 22 5b 63 61 63 6b 65 79 5d le.log("[cackey]
17b0: 20 63 61 63 6b 65 79 49 6e 69 74 28 29 3a 20 43 cackeyInit(): C
17c0: 61 6c 6c 65 64 2e 22 29 3b 0a 0a 09 2f 2a 20 56 alled.");.../* V
17d0: 65 72 69 66 79 20 74 68 61 74 20 77 65 20 63 61 erify that we ca
17e0: 6e 20 72 65 67 69 73 74 65 72 20 63 61 6c 6c 62 n register callb
17f0: 61 63 6b 73 20 2a 2f 0a 09 69 66 20 28 21 63 68 acks */..if (!ch
1800: 72 6f 6d 65 2e 63 65 72 74 69 66 69 63 61 74 65 rome.certificate
1810: 50 72 6f 76 69 64 65 72 29 20 7b 0a 09 09 69 66 Provider) {...if
1820: 20 28 21 47 6f 6f 67 6c 65 53 6d 61 72 74 43 61 (!GoogleSmartCa
1830: 72 64 2e 49 53 5f 44 45 42 55 47 5f 42 55 49 4c rd.IS_DEBUG_BUIL
1840: 44 29 20 7b 0a 09 09 09 63 6f 6e 73 6f 6c 65 2e D) {....console.
1850: 65 72 72 6f 72 28 22 5b 63 61 63 6b 65 79 5d 20 error("[cackey]
1860: 54 68 69 73 20 65 78 74 65 6e 73 69 6f 6e 20 6f This extension o
1870: 6e 6c 79 20 77 6f 72 6b 73 20 6f 6e 20 43 68 72 nly works on Chr
1880: 6f 6d 65 4f 53 21 22 29 3b 0a 0a 09 09 09 72 65 omeOS!");.....re
1890: 74 75 72 6e 3b 0a 09 09 7d 20 65 6c 73 65 20 7b turn;...} else {
18a0: 0a 09 09 09 63 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 ....console.log(
18b0: 22 5b 63 61 63 6b 65 79 5d 20 54 68 69 73 20 65 "[cackey] This e
18c0: 78 74 65 6e 73 69 6f 6e 20 6f 6e 6c 79 20 77 6f xtension only wo
18d0: 72 6b 73 20 6f 6e 20 43 68 72 6f 6d 65 4f 53 2c rks on ChromeOS,
18e0: 20 62 75 74 20 79 6f 75 20 61 70 70 65 61 72 20 but you appear
18f0: 74 6f 20 62 65 20 64 65 62 75 67 67 69 6e 67 20 to be debugging
1900: 69 74 20 2d 2d 20 74 72 79 69 6e 67 20 61 6e 79 it -- trying any
1910: 77 61 79 2e 22 29 3b 0a 09 09 7d 0a 09 7d 0a 0a way.");...}..}..
1920: 09 69 66 20 28 63 61 63 6b 65 79 48 61 6e 64 6c .if (cackeyHandl
1930: 65 20 21 3d 20 6e 75 6c 6c 29 20 7b 0a 09 09 63 e != null) {...c
1940: 6f 6e 73 6f 6c 65 2e 6c 6f 67 28 22 5b 63 61 63 onsole.log("[cac
1950: 6b 65 79 5d 20 63 61 63 6b 65 79 49 6e 69 74 28 key] cackeyInit(
1960: 29 3a 20 41 6c 72 65 61 64 79 20 69 6e 69 74 69 ): Already initi
1970: 61 6c 69 7a 65 64 2e 20 20 52 65 74 75 72 6e 69 alized. Returni
1980: 6e 67 2e 22 29 3b 0a 0a 09 09 72 65 74 75 72 6e ng.");....return
1990: 3b 0a 09 7d 0a 0a 09 65 6c 65 6d 65 6e 74 45 6d ;..}...elementEm
19a0: 62 65 64 20 3d 20 64 6f 63 75 6d 65 6e 74 2e 63 bed = document.c
19b0: 72 65 61 74 65 45 6c 65 6d 65 6e 74 28 27 65 6d reateElement('em
19c0: 62 65 64 27 29 3b 0a 09 65 6c 65 6d 65 6e 74 45 bed');..elementE
19d0: 6d 62 65 64 2e 74 79 70 65 20 3d 20 22 61 70 70 mbed.type = "app
19e0: 6c 69 63 61 74 69 6f 6e 2f 78 2d 70 6e 61 63 6c lication/x-pnacl
19f0: 22 3b 0a 09 65 6c 65 6d 65 6e 74 45 6d 62 65 64 ";..elementEmbed
1a00: 2e 77 69 64 74 68 20 3d 20 30 3b 0a 09 65 6c 65 .width = 0;..ele
1a10: 6d 65 6e 74 45 6d 62 65 64 2e 68 65 69 67 68 74 mentEmbed.height
1a20: 20 3d 20 30 3b 0a 09 65 6c 65 6d 65 6e 74 45 6d = 0;..elementEm
1a30: 62 65 64 2e 73 72 63 20 3d 20 22 63 61 63 6b 65 bed.src = "cacke
1a40: 79 2e 6e 6d 66 22 3b 0a 09 65 6c 65 6d 65 6e 74 y.nmf";..element
1a50: 45 6d 62 65 64 2e 69 64 20 3d 20 22 63 61 63 6b Embed.id = "cack
1a60: 65 79 4d 6f 64 75 6c 65 22 3b 0a 09 65 6c 65 6d eyModule";..elem
1a70: 65 6e 74 45 6d 62 65 64 2e 61 64 64 45 76 65 6e entEmbed.addEven
1a80: 74 4c 69 73 74 65 6e 65 72 28 27 65 72 72 6f 72 tListener('error
1a90: 27 2c 20 66 75 6e 63 74 69 6f 6e 28 6d 65 73 73 ', function(mess
1aa0: 61 67 65 45 76 65 6e 74 29 20 7b 20 63 6f 6e 73 ageEvent) { cons
1ab0: 6f 6c 65 2e 65 72 72 6f 72 28 22 45 72 72 6f 72 ole.error("Error
1ac0: 20 6c 6f 61 64 69 6e 67 20 43 41 43 4b 65 79 20 loading CACKey
1ad0: 50 4e 61 43 6c 20 4d 6f 64 75 6c 65 3a 20 22 20 PNaCl Module: "
1ae0: 2b 20 6d 65 73 73 61 67 65 45 76 65 6e 74 2e 64 + messageEvent.d
1af0: 61 74 61 29 3b 20 7d 2c 20 74 72 75 65 29 3b 0a ata); }, true);.
1b00: 09 65 6c 65 6d 65 6e 74 45 6d 62 65 64 2e 61 64 .elementEmbed.ad
1b10: 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 28 27 dEventListener('
1b20: 6c 6f 61 64 27 2c 20 63 61 63 6b 65 79 49 6e 69 load', cackeyIni
1b30: 74 4c 6f 61 64 65 64 2c 20 74 72 75 65 29 3b 0a tLoaded, true);.
1b40: 09 65 6c 65 6d 65 6e 74 45 6d 62 65 64 2e 61 64 .elementEmbed.ad
1b50: 64 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 28 27 dEventListener('
1b60: 6d 65 73 73 61 67 65 27 2c 20 63 61 63 6b 65 79 message', cackey
1b70: 4d 65 73 73 61 67 65 49 6e 63 6f 6d 69 6e 67 2c MessageIncoming,
1b80: 20 74 72 75 65 29 3b 0a 0a 09 63 61 63 6b 65 79 true);...cackey
1b90: 48 61 6e 64 6c 65 20 3d 20 65 6c 65 6d 65 6e 74 Handle = element
1ba0: 45 6d 62 65 64 3b 0a 0a 09 2f 2a 0a 09 20 2a 20 Embed;.../*.. *
1bb0: 53 74 61 72 74 20 74 68 65 20 47 6f 6f 67 6c 65 Start the Google
1bc0: 20 50 43 53 43 20 49 6e 74 65 72 66 61 63 65 0a PCSC Interface.
1bd0: 09 20 2a 2f 0a 09 6e 65 77 20 47 6f 6f 67 6c 65 . */..new Google
1be0: 53 6d 61 72 74 43 61 72 64 2e 50 63 73 63 4e 61 SmartCard.PcscNa
1bf0: 63 6c 28 63 61 63 6b 65 79 48 61 6e 64 6c 65 29 cl(cackeyHandle)
1c00: 3b 0a 0a 09 64 6f 63 75 6d 65 6e 74 2e 62 6f 64 ;...document.bod
1c10: 79 2e 61 70 70 65 6e 64 43 68 69 6c 64 28 63 61 y.appendChild(ca
1c20: 63 6b 65 79 48 61 6e 64 6c 65 29 0a 0a 09 63 6f ckeyHandle)...co
1c30: 6e 73 6f 6c 65 2e 6c 6f 67 28 22 5b 63 61 63 6b nsole.log("[cack
1c40: 65 79 5d 20 63 61 63 6b 65 79 49 6e 69 74 28 29 ey] cackeyInit()
1c50: 3a 20 43 6f 6d 70 6c 65 74 65 64 2e 20 20 52 65 : Completed. Re
1c60: 74 75 72 6e 69 6e 67 2e 22 29 3b 0a 7d 0a 0a 2f turning.");.}../
1c70: 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 43 41 43 * Initialize CAC
1c80: 4b 65 79 20 2a 2f 0a 63 61 63 6b 65 79 49 6e 69 Key */.cackeyIni
1c90: 74 28 29 3b 0a t();.