Check-in [e5a1e29b79]
Overview
Comment:Potentially better PIN handling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e5a1e29b7926adf29f488af7d2215cc740d7573d
User & Date: rkeene on 2019-06-05 21:35:27
Other Links: manifest | tags
Context
2019-06-05
21:38
Added a toggle for disabling the Chrome PIN dialog check-in: 2a4f67952b user: rkeene tags: trunk
21:35
Potentially better PIN handling check-in: e5a1e29b79 user: rkeene tags: trunk
20:40
Updated to support using the Chrome PIN dialog if doing a Chrome Certificate request check-in: f486b04a4b user: rkeene tags: trunk
Changes

Modified build/chrome/cackey.js from [dc80ae3ba4] to [b238d95675].

1
2
3
4
5
6
7
8
9
10







11
12
13
14
15
16
17
/*
 * CACKey ChromeOS chrome.certificateProvider Implementation
 */

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








/*
 * Handle for the CACKey NaCl Target
 */
var cackeyHandle = null;
var cackeyPCSCHandle = null;
var cackeyPCSCHandleUsable = false;
var cackeyPCSCHandleLastUsed = (new Date()).getTime();










>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * CACKey ChromeOS chrome.certificateProvider Implementation
 */

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

/*
 * Optional features for CACKey
 */
var cackeyFeatures = {
	customPINPrompt: true
};

/*
 * Handle for the CACKey NaCl Target
 */
var cackeyHandle = null;
var cackeyPCSCHandle = null;
var cackeyPCSCHandleUsable = false;
var cackeyPCSCHandleLastUsed = (new Date()).getTime();
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
					if (!pinWindow) {
						console.error("[cackey] No window was provided for PIN entry, this will not go well.");
	
						return;
					}
	
					pinWindowPreviousHandle = pinWindow;
	
					pinWindow.drawAttention();
					pinWindow.focus();
	
					/*
					 * Register a handler to handle the window being closed without
					 * having sent anything
					 */







|







345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
					if (!pinWindow) {
						console.error("[cackey] No window was provided for PIN entry, this will not go well.");
	
						return;
					}
	
					pinWindowPreviousHandle = pinWindow;

					pinWindow.drawAttention();
					pinWindow.focus();
	
					/*
					 * Register a handler to handle the window being closed without
					 * having sent anything
					 */
369
370
371
372
373
374
375




376
377
378
379
380
381
382
383




384
385
386
387


388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
					})
	
					/*
					 * Pass this message off to the other window so that it may resubmit the request.
					 */
					pinWindow.contentWindow.parentWindow = window;
					pinWindow.contentWindow.messageEvent = messageEvent;




	
					return;
				});
			} else {
				chrome.certificateProvider.requestPin({
					signRequestId: messageEvent.data.originalrequest.signRequestId,
					requestType: "PIN"
				}, function(userInfo) {




					chrome.certificateProvider.stopPinRequest({
						signRequestId: messageEvent.data.originalrequest.signRequestId
					}, function() {
						var pinValue = "";




						pinWindowPreviousHandle = null;

						if (userInfo && userInfo.userInput) {
							pinValue = userInfo.userInput;
						}

						return(cackeyPINPromptCompleted(pinValue));
					});
				});
			}

			/*
			 * We return here instead of break to avoid deleting the callback
			 * entry.
			 */







>
>
>
>








>
>
>
>
|
|
|
<
>
>
|
>
|

|
|
|

|
<







376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
410
411
412

413
414
415
416
417
418
419
					})
	
					/*
					 * Pass this message off to the other window so that it may resubmit the request.
					 */
					pinWindow.contentWindow.parentWindow = window;
					pinWindow.contentWindow.messageEvent = messageEvent;

					if (cackeyFeatures.customPINPrompt) {
						pinWindow.contentWindow.pinprompt = messageEvent.data.pinprompt;
					}
	
					return;
				});
			} else {
				chrome.certificateProvider.requestPin({
					signRequestId: messageEvent.data.originalrequest.signRequestId,
					requestType: "PIN"
				}, function(userInfo) {
					var destroyError;
					var pinValue = "";

					try {
						chrome.certificateProvider.stopPinRequest({
							signRequestId: messageEvent.data.originalrequest.signRequestId
						}, function() {});

					} catch (destroyError) {
						/* Do nothing, we don't care if it fails really */
					}

					pinWindowPreviousHandle = null;

					if (userInfo && userInfo.userInput) {
						pinValue = userInfo.userInput;
					}

					return(cackeyPINPromptCompleted(pinValue));

				});
			}

			/*
			 * We return here instead of break to avoid deleting the callback
			 * entry.
			 */