Check-in [7879121689]
Overview
SHA1:7879121689eac39fe699e15d812e47aaf8d46648
Date: 2016-02-15 07:31:49
User: rkeene
Comment:ChromeOS: Attempt to sign the correctly prefixed data
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-02-15
07:34
[e0d9e2f1fb] ChromeOS: Sanity -- initialize PIN prompt (user: rkeene, tags: trunk)
07:31
[7879121689] ChromeOS: Attempt to sign the correctly prefixed data (user: rkeene, tags: trunk)
07:22
[036113d051] ChromeOS: Try to supply the user PIN to the card (user: rkeene, tags: trunk)
Changes

Modified build/chrome/cackey.js from [bf69054466] to [10c678f515].

   305    305   /*
   306    306    * Handler for messages from Chrome related to signing a hash of some sort
   307    307    */
   308    308   function cackeySignMessage(signRequest, chromeCallback) {
   309    309   	var callbackId;
   310    310   	var command;
   311    311   	var certificateId;
          312  +	var digest, digestHeader;
          313  +
          314  +	/*
          315  +	 * Prefix the digest with the ASN.1 header required of it
          316  +	 */
          317  +	switch (signRequest.hash) {
          318  +		case "SHA-1":
          319  +			digestHeader = new Uint8Array([0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14]);
          320  +			break;
          321  +		case "SHA-256":
          322  +			digestHeader = new Uint8Array([0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20]);
          323  +			break;
          324  +		default:
          325  +			console.error("[cackey] Asked to sign a message with a hash we do not support: " + signRequest.hash);
          326  +
          327  +			chromeCallback();
          328  +
          329  +			return;
          330  +	}
          331  +
          332  +	digest = new Uint8Array(digestHeader.length + signRequest.digest.byteLength);
          333  +	digest.set(digestHeader, 0);
          334  +	digest.set(new Uint8Array(signRequest.digest), digestHeader.length);
          335  +
          336  +	delete digestHeader;
   312    337   
   313    338   	console.log("[cackey] Asked to sign a message -- throwing that request over to the NaCl side... ");
   314    339   
   315    340   	callbackId = cackeyOutstandingCallbackCounter + 1;
   316    341   
   317    342   	command = {
   318    343   		'target': "cackey",
   319    344   		'command': "sign",
   320    345   		'id': callbackId,
   321    346   		'certificate': signRequest.certificate,
   322         -		'data': signRequest.digest /* XXX:TODO: This needs to be prefixed based on the signRequest.hash */
          347  +		'data': digest.buffer
   323    348   	};
   324    349   
   325    350   	certificateId = cackeyCertificateToPINID(command.certificate);
   326    351   
   327    352   	if (cackeyCertificateToPINMap[certificateId]) {
   328    353   		command.pin = cackeyCertificateToPINMap[certificateId];
   329    354   	}