Check-in [3783f79015]
Overview
SHA1:3783f79015b8cf7c93ed240588da0d1f07124dec
Date: 2016-02-26 16:35:42
User: rkeene
Edited Comment: ChromeOS: Updated to pass original message back correctly
Original Comment: Updated to pass original message back correctly
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-02-26
18:20
[c27bb81788] ChromeOS: Fixed issue with including signed data in the reply (user: rkeene, tags: trunk)
16:35
[3783f79015] ChromeOS: Updated to pass original message back correctly (user: rkeene, tags: trunk)
16:23
[ea7a58ef60] ChromeOS: Updated to support raw PKCS#1 message signing using the interface Chrome provides it (user: rkeene, tags: trunk)
Changes

Modified build/chrome/cackey-chrome-init.cc from [84155dbf3d] to [cd9d30207a].

    26     26   	public:
    27     27   		explicit CACKeyInstance(PP_Instance instance, pp::Core *core) : pp::Instance(instance) {
    28     28   			corePointer = core;
    29     29   		}
    30     30   
    31     31   		virtual ~CACKeyInstance() {}
    32     32   
    33         -		virtual void HandleMessageThread(pp::VarDictionary *message) {
           33  +		virtual void HandleMessageThread(pp::VarDictionary *message, pp::Var *messagePlain) {
    34     34   			cackey_chrome_returnType signRet;
    35     35   			char *pinPrompt = NULL;
    36     36   			const char *pin;
    37     37   			const char *smartcardManagerAppId = NULL;
    38     38   			unsigned char buffer[8192];
    39     39   			struct cackey_certificate *certificates, incomingCertificateCACKey;
    40     40   			pp::VarDictionary *reply;
    41     41   			pp::VarArray certificatesPPArray;
    42     42   			pp::VarArrayBuffer *certificateContents, *incomingCertificateContents, *incomingData, *outgoingData;
    43     43   			pp::Var command;
    44         -			const pp::Var *messageAsVar = NULL, *outgoingDataAsVar = NULL;
           44  +			const pp::Var *outgoingDataAsVar = NULL;
    45     45   			int numCertificates, i;
    46     46   			unsigned long outgoingDataLength;
    47     47   
    48     48   			/*
    49     49   			 * Extract the command
    50     50   			 */
    51     51   			command = message->Get("command");
................................................................................
   133    133   							outgoingDataAsVar = new pp::Var(outgoingData->pp_var());
   134    134   
   135    135   							delete outgoingData;
   136    136   
   137    137   							reply->Set("status", "success");
   138    138   							reply->Set("signedData", outgoingDataAsVar);
   139    139   
   140         -							delete outgoingDataAsVar;
   141         -
   142    140   							break;
   143    141   						case CACKEY_CHROME_ERROR:
   144    142   							reply->Set("status", "error");
   145    143   							reply->Set("error", "Unable to sign data");
   146    144   							break;
   147    145   						case CACKEY_CHROME_NEEDLOGIN:
   148    146   						case CACKEY_CHROME_NEEDPROTECTEDLOGIN:
   149         -							messageAsVar = new pp::Var(message->pp_var());
   150         -
   151    147   							reply->Set("status", "retry");
   152         -							reply->Set("originalrequest", messageAsVar);
          148  +							reply->Set("originalrequest", *messagePlain);
   153    149   							reply->Set("pinprompt", pinPrompt);
   154    150   
   155         -							delete messageAsVar;
   156         -
   157    151   							break;
   158    152   					}
   159    153   
   160    154   					if (pinPrompt != NULL) {
   161    155   						free(pinPrompt);
   162    156   					}
   163    157   				}
................................................................................
   183    177   			 * Send the reply back to the requestor, hopefully they are waiting for this message
   184    178   			 */
   185    179   			PostMessage(*reply);
   186    180   
   187    181   			delete reply;
   188    182   
   189    183   			delete message;
          184  +
          185  +			delete messagePlain;
          186  +
          187  +			if (outgoingDataAsVar) {
          188  +				delete outgoingDataAsVar;
          189  +			}
   190    190   
   191    191   			return;
   192    192   		}
   193    193   
   194    194   		virtual void HandleMessage(const pp::Var& messagePlain) {
   195    195   			pp::VarDictionary *message;
          196  +			pp::Var *messagePlainCopy;
   196    197   			pp::Var target;
   197    198   
   198    199   			/*
   199    200   			 * The incoming message must be a dictionary
   200    201   			 */
   201    202   			if (!messagePlain.is_dictionary()) {
   202    203   				pcscNaClHandleMessage(messagePlain);
................................................................................
   242    243   
   243    244   				return;
   244    245   			}
   245    246   
   246    247   			/*
   247    248   			 * Process the request in another thread
   248    249   			 */
   249         -			std::thread(&CACKeyInstance::HandleMessageThread, this, message).detach();
          250  +			messagePlainCopy = new pp::Var(messagePlain);
          251  +			std::thread(&CACKeyInstance::HandleMessageThread, this, message, messagePlainCopy).detach();
   250    252   
   251    253   			return;
   252    254   		}
   253    255   };
   254    256   
   255    257   class CACKeyModule : public pp::Module {
   256    258   	public: