15
16
17
18
19
20
21
22
23
24
25
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
52
53
54
55
56
57
58
59
60
61
62
63
|
#include <ppapi/cpp/var_array_buffer.h>
#include "pcsc-nacl.h"
#include "cackey-chrome.h"
class CACKeyInstance : public pp::Instance {
private:
void pcscNaClInitWrapper(pp::Core *core) {
pcscNaClInit(this, core);
}
public:
explicit CACKeyInstance(PP_Instance instance, pp::Core *core) : pp::Instance(instance) {
std::thread(&CACKeyInstance::pcscNaClInitWrapper, this, core).detach();
}
virtual ~CACKeyInstance() {}
virtual void HandleMessageThread(pp::VarDictionary *message) {
cackey_chrome_returnType signRet;
char *pinPrompt;
const char *pin;
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;
int numCertificates, i;
unsigned long outgoingDataLength;
/*
* Extract the command
*/
command = message->Get("command");
/*
* Do the thing we are being asked to do
*/
reply = new pp::VarDictionary();
if (command.AsString() == "listcertificates") {
numCertificates = cackey_chrome_listCertificates(&certificates);
certificatesPPArray.SetLength(numCertificates);
for (i = 0; i < numCertificates; i++) {
certificateContents = new pp::VarArrayBuffer(certificates[i].certificate_len);
|
|
<
<
<
>
>
|
>
>
>
>
>
>
>
>
|
15
16
17
18
19
20
21
22
23
24
25
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <ppapi/cpp/var_array_buffer.h>
#include "pcsc-nacl.h"
#include "cackey-chrome.h"
class CACKeyInstance : public pp::Instance {
private:
pp::Core *corePointer;
public:
explicit CACKeyInstance(PP_Instance instance, pp::Core *core) : pp::Instance(instance) {
corePointer = core;
}
virtual ~CACKeyInstance() {}
virtual void HandleMessageThread(pp::VarDictionary *message) {
cackey_chrome_returnType signRet;
char *pinPrompt;
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;
int numCertificates, i;
unsigned long outgoingDataLength;
/*
* Extract the command
*/
command = message->Get("command");
/*
* Do the thing we are being asked to do
*/
reply = new pp::VarDictionary();
if (command.AsString() == "init") {
if (message->HasKey("smartcardManagerAppId")) {
smartcardManagerAppId = message->Get("smartcardManagerAppId").AsString().c_str();
}
pcscNaClInit(this, corePointer, smartcardManagerAppId, "CACKey");
reply->Set("status", "success");
} else if (command.AsString() == "listcertificates") {
numCertificates = cackey_chrome_listCertificates(&certificates);
certificatesPPArray.SetLength(numCertificates);
for (i = 0; i < numCertificates; i++) {
certificateContents = new pp::VarArrayBuffer(certificates[i].certificate_len);
|