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