Diff

Differences From Artifact [5ad72ed1f7]:

To Artifact [1a209c8c6b]:


295
296
297
298
299
300
301


































302
303
304
305
306
307
308
/* MARK2 */

function onCertificatesRejected(rejectedCerts) {
	// If certificates were rejected by the API, log an error, for example.
	console.error(rejectedCerts.length + ' certificates were rejected.');
	return;
}



































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

	certificates.push(
		{
			certificate: new Uint8Array([







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







295
296
297
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
/* MARK2 */

function onCertificatesRejected(rejectedCerts) {
	// If certificates were rejected by the API, log an error, for example.
	console.error(rejectedCerts.length + ' certificates were rejected.');
	return;
}

var cackeyHandle = null;

function cackeyInitLoaded(messageEvent) {
	console.log("Loaded CACKey PNaCl Module");

	/* Register listeners with Chrome */
	chrome.certificateProvider.onCertificatesRequested.addListener(cackeyListCertificates);
	chrome.certificateProvider.onSignDigestRequested.addListener(cackeySignMessage);
}

function cackeyInit() {
	var elementEmbed;

	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(
		{
			certificate: new Uint8Array([
384
385
386
387
388
389
390
391

392

393
	payload = new Uint8Array(stoBA(hextorstr(payload))).buffer;

	chromeCallback(payload);

	return;
}

/* Register listeners with Chrome */

chrome.certificateProvider.onCertificatesRequested.addListener(cackeyListCertificates);

chrome.certificateProvider.onSignDigestRequested.addListener(cackeySignMessage);







|
>
|
>
|
418
419
420
421
422
423
424
425
426
427
428
429
	payload = new Uint8Array(stoBA(hextorstr(payload))).buffer;

	chromeCallback(payload);

	return;
}

/* Enable debugging */
GoogleSmartCard.logger.setLevel(GoogleSmartCard.Logger.prototype.DEBUG);

/* Initialize CACKey */
cackeyInit();