Check-in [b7dc336d0f]
Overview
Comment:ChromeOS: Updated to pass messages to the PCSC-NACL plugin if they do not belong to us
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b7dc336d0f39e698bd922208afba857a8e5383c2
User & Date: rkeene on 2016-02-11 18:33:00
Original Comment: Updated to pass messages to the PCSC-NACL plugin if they do not belong to us
Other Links: manifest | tags
Context
2016-02-12
03:47
Renamed our C_Login() function with a mutex arg to be a less annoying name check-in: bd977f41d5 user: rkeene tags: trunk
2016-02-11
18:33
ChromeOS: Updated to pass messages to the PCSC-NACL plugin if they do not belong to us check-in: b7dc336d0f user: rkeene tags: trunk
18:32
ChromeOS: Remove USB requirement -- we talk to the Smartcard Manager App for this check-in: 35a258e3b8 user: rkeene tags: trunk
Changes

Modified build/chrome/build-deps from [8ff9a8d29a] to [417516a8f7].

235
236
237
238
239
240
241


242
243
244
245
246
247
248
#ifndef PCSC_NACL_H
#define PCSC_NACL_H 1
#ifdef __cplusplus
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

void pcscNaClInit(pp::Instance *instance, pp::Core *core);


#endif
#endif
_EOF_

		# Copy out JavaScript files for later use
		mkdir "${instdir}/js" || exit 1
		cp common-utils/*.js "${instdir}/js" || exit 1







>
>







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#ifndef PCSC_NACL_H
#define PCSC_NACL_H 1
#ifdef __cplusplus
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

void pcscNaClInit(pp::Instance *instance, pp::Core *core);
bool pcscNaClHandleMessage(const pp::Var &message);

#endif
#endif
_EOF_

		# Copy out JavaScript files for later use
		mkdir "${instdir}/js" || exit 1
		cp common-utils/*.js "${instdir}/js" || exit 1
298
299
300
301
302
303
304

305
306
307
308
309


310
311
312
313
314
315
316
317
318
319


320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336




337
338
339
340
341
342
343
_EOF_

		## Create initialization procedure, since it lacks one
		cat << \_EOF_ > third_party/pcsc-lite/client-side/pcsc_nacl_init.cc
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>


#include <stdio.h>

#include "pcsc_nacl_global.h"
#include "dom_requests_manager.h"
#include "pcsc_nacl.h"



void pcscNaClInit(pp::Instance *instance, pp::Core *core) {
	DomRequestsManager::PpDelegateImpl *drmDelegateImpl;
	PcscNacl *pcsc_nacl;

	fprintf(stderr, "Called pcscNaClInit()\n");

	drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core);

	pcsc_nacl = new PcscNacl(new DomRequestsManager("pcsc-nacl", drmDelegateImpl), "khpfeaanjngmcnplbdlpegiifgpfgdco", "CACKey");



	fprintf(stderr, "New PcscNacl object = %p\n", pcsc_nacl);

	if (!pcsc_nacl->Initialize()) {
		fprintf(stderr, "PcscNacl->Initialize() failed !");

		return;
	}

	SetPcscNaclGlobalInstance(pcsc_nacl);

	fprintf(stderr, "Global instance set to %p\n", pcsc_nacl);

	fprintf(stderr, "Returning.\n");

	return;
}




_EOF_

		## Make it
		make -C third_party/pcsc-lite/client-side || exit 1

		# Install the built libpcsc
		mkdir -p "${instdir}/lib" || exit 1







>





>
>









|
>
>

















>
>
>
>







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
_EOF_

		## Create initialization procedure, since it lacks one
		cat << \_EOF_ > third_party/pcsc-lite/client-side/pcsc_nacl_init.cc
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

#include <unistd.h>
#include <stdio.h>

#include "pcsc_nacl_global.h"
#include "dom_requests_manager.h"
#include "pcsc_nacl.h"

static DomRequestsManager *pcscNaClDRM = NULL;

void pcscNaClInit(pp::Instance *instance, pp::Core *core) {
	DomRequestsManager::PpDelegateImpl *drmDelegateImpl;
	PcscNacl *pcsc_nacl;

	fprintf(stderr, "Called pcscNaClInit()\n");

	drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core);

	pcscNaClDRM = new DomRequestsManager("pcsc-nacl", drmDelegateImpl);

	pcsc_nacl = new PcscNacl(pcscNaClDRM, "khpfeaanjngmcnplbdlpegiifgpfgdco", "CACKey");

	fprintf(stderr, "New PcscNacl object = %p\n", pcsc_nacl);

	if (!pcsc_nacl->Initialize()) {
		fprintf(stderr, "PcscNacl->Initialize() failed !");

		return;
	}

	SetPcscNaclGlobalInstance(pcsc_nacl);

	fprintf(stderr, "Global instance set to %p\n", pcsc_nacl);

	fprintf(stderr, "Returning.\n");

	return;
}

bool pcscNaClHandleMessage(const pp::Var &message) {
	return(pcscNaClDRM->HandleMessage(message));
}
_EOF_

		## Make it
		make -C third_party/pcsc-lite/client-side || exit 1

		# Install the built libpcsc
		mkdir -p "${instdir}/lib" || exit 1

Modified build/chrome/cackey-chrome-init.cc from [ce1d3f96e0] to [9641a2fef0].

87
88
89
90
91
92
93


94
95
96
97
98
99
100
101
102
103
104


105
106
107
108
109
110
111
112
113
114
115
116




117
118
119
120
121




122
123
124
125
126
127
128




129
130
131
132
133
134
135
			}

			/*
			 * Send the reply back to the requestor, hopefully they are waiting for this message
			 */
			PostMessage(*reply);



			return;
		}

		virtual void HandleMessage(const pp::Var& messagePlain) {
			pp::VarDictionary *message;
			pp::Var target;

			/*
			 * The incoming message must be a dictionary
			 */
			if (!messagePlain.is_dictionary()) {


				return;
			}

			/*
			 * Process the appropriate command from the incoming message
			 */
			message = new pp::VarDictionary(messagePlain);

			/*
			 * Verify that this message is destined for us
			 */
			if (!message->HasKey("target")) {




				return;
			}

			target = message->Get("target");
			if (target.AsString() != "cackey") {




				return;
			}

			/*
			 * Determine what we are being asked to do
			 */
			if (!message->HasKey("command")) {




				return;
			}

			/*
			 * Process the request in another thread
			 */
			std::thread(&CACKeyInstance::HandleMessageThread, this, message).detach();







>
>











>
>












>
>
>
>





>
>
>
>







>
>
>
>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
			}

			/*
			 * Send the reply back to the requestor, hopefully they are waiting for this message
			 */
			PostMessage(*reply);

			delete message;

			return;
		}

		virtual void HandleMessage(const pp::Var& messagePlain) {
			pp::VarDictionary *message;
			pp::Var target;

			/*
			 * The incoming message must be a dictionary
			 */
			if (!messagePlain.is_dictionary()) {
				pcscNaClHandleMessage(messagePlain);

				return;
			}

			/*
			 * Process the appropriate command from the incoming message
			 */
			message = new pp::VarDictionary(messagePlain);

			/*
			 * Verify that this message is destined for us
			 */
			if (!message->HasKey("target")) {
				delete message;

				pcscNaClHandleMessage(messagePlain);

				return;
			}

			target = message->Get("target");
			if (target.AsString() != "cackey") {
				delete message;

				pcscNaClHandleMessage(messagePlain);

				return;
			}

			/*
			 * Determine what we are being asked to do
			 */
			if (!message->HasKey("command")) {
				delete message;

				pcscNaClHandleMessage(messagePlain);

				return;
			}

			/*
			 * Process the request in another thread
			 */
			std::thread(&CACKeyInstance::HandleMessageThread, this, message).detach();

Modified build/chrome/cackey.js from [94b1497683] to [3365edf925].

311
312
313
314
315
316
317

318
319
320



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
}

function cackeyInit() {
	var elementEmbed;

	/* Verify that we can register callbacks */
	if (!chrome.certificateProvider) {

		console.error("This extension only works on ChromeOS!");

		return;



	}

	if (cackeyHandle != null) {
		return;
	}

	elementEmbed = document.createElement('embed');
	elementEmbed.type = "application/x-pnacl";
	elementEmbed.width = 0;
	elementEmbed.height = 0;
	elementEmbed.src = "cackey.nmf";
	elementEmbed.id = "cackeyModule";
	elementEmbed.addEventListener('error', function(messageEvent) { console.error("Error loading CACKey PNaCl Module: " + messageEvent.data); }, true);
	elementEmbed.addEventListener('load', cackeyInitLoaded, true);
	elementEmbed.addEventListener('message', function(messageEvent) { console.log("Start message"); console.log(messageEvent.data); console.log("End message"); }, true);

	new GoogleSmartCard.PcscNacl(elementEmbed);

	document.body.appendChild(elementEmbed)

	cackeyHandle = elementEmbed;
}

function cackeyListCertificates(chromeCallback) {
	var certificates = [];

	certificates.push(
		{







>
|

|
>
>
>
















|

|

|







311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
}

function cackeyInit() {
	var elementEmbed;

	/* Verify that we can register callbacks */
	if (!chrome.certificateProvider) {
		if (!GoogleSmartCard.IS_DEBUG_BUILD) {
			console.error("This extension only works on ChromeOS!");

			return;
		} else {
			console.log("This extension only works on ChromeOS, but you appear to be debugging it -- trying anyway.");
		}
	}

	if (cackeyHandle != null) {
		return;
	}

	elementEmbed = document.createElement('embed');
	elementEmbed.type = "application/x-pnacl";
	elementEmbed.width = 0;
	elementEmbed.height = 0;
	elementEmbed.src = "cackey.nmf";
	elementEmbed.id = "cackeyModule";
	elementEmbed.addEventListener('error', function(messageEvent) { console.error("Error loading CACKey PNaCl Module: " + messageEvent.data); }, true);
	elementEmbed.addEventListener('load', cackeyInitLoaded, true);
	elementEmbed.addEventListener('message', function(messageEvent) { console.log("Start message"); console.log(messageEvent.data); console.log("End message"); }, true);

	cackeyHandle = elementEmbed;

	document.body.appendChild(cackeyHandle)

	new GoogleSmartCard.PcscNacl(cackeyHandle);
}

function cackeyListCertificates(chromeCallback) {
	var certificates = [];

	certificates.push(
		{