Check-in [c3e0c9025e]
Overview
Comment:Updated to use NaCl libpcsc (in progress)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c3e0c9025e3d68182983b150b56d0c1d58d94e1e
User & Date: rkeene on 2016-04-14 17:07:11
Other Links: manifest | tags
Context
2016-04-14
18:16
Upgraded to latest nacl-libpcsc and started using the sightly cleaner interfaces check-in: 357cf7b22f user: rkeene tags: trunk
17:07
Updated to use NaCl libpcsc (in progress) check-in: c3e0c9025e user: rkeene tags: trunk
2016-03-15
17:57
Updated to parse X.509v1 implied version certificates check-in: 899318c012 user: rkeene tags: trunk
Changes

Modified build/chrome/Makefile from [7468d6c1f8] to [44984e905a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CC       = pnacl-clang
CXX      = pnacl-clang++
AR       = pnacl-ar
RANLIB   = pnacl-ranlib
FINALIZE = pnacl-finalize

CACKEY_LIBS = -Llib -lcackey -lz
PCSC_LIBS   = -Llib -lpcsc -L${NACL_SDK_ROOT}/lib/pnacl/Release -lppapi -lppapi_cpp
LIBS        = $(CACKEY_LIBS) $(PCSC_LIBS)
CFLAGS      = -Wall -I${NACL_SDK_ROOT}/include -I../../pkcs11 -Iinclude/PCSC
CXXFLAGS    = $(CFLAGS) -std=gnu++11

CACKEY_DEBUG = 0
ifeq (1,$(CACKEY_DEBUG))
CACKEY_LIBNAME     = libcackey_g
CACKEY_EXECUTABLES = cackey.pexe cackey.bc
CFLAGS             += -g3 -ggdb3









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CC       = pnacl-clang
CXX      = pnacl-clang++
AR       = pnacl-ar
RANLIB   = pnacl-ranlib
FINALIZE = pnacl-finalize

CACKEY_LIBS = -Llib -lcackey -lz
PCSC_LIBS   = -Llib -lpcsc -L${NACL_SDK_ROOT}/lib/pnacl/Release -lppapi -lppapi_cpp
LIBS        = $(CACKEY_LIBS) $(PCSC_LIBS)
CFLAGS      = -Wall -I${NACL_SDK_ROOT}/include -I../../pkcs11 -Iinclude
CXXFLAGS    = $(CFLAGS) -std=gnu++11

CACKEY_DEBUG = 0
ifeq (1,$(CACKEY_DEBUG))
CACKEY_LIBNAME     = libcackey_g
CACKEY_EXECUTABLES = cackey.pexe cackey.bc
CFLAGS             += -g3 -ggdb3
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	mkdir -p lib
	rm -f lib/libz.a
	cd lib && ln -s ../workdir-*.inst/lib/libz.a .
	touch lib/libz.a

google-pcsc.js: lib/libcackey.a
	rm -f google-pcsc.js google-pcsc.js.new
	cat workdir-*.inst/js/scope.js > google-pcsc.js.new
	echo 'GoogleSmartCard.IS_DEBUG_BUILD = $(CACKEY_DEBUG);' >> google-pcsc.js.new
	cat workdir-*.inst/js/{logging,pcsc,pcsc-nacl}.js >> google-pcsc.js.new
	mv google-pcsc.js.new google-pcsc.js

include/PCSC/pcsc-nacl.h: lib/libcackey.a
	mkdir -p include/PCSC
	rm -f include/PCSC/pcsc-nacl.h.new include/PCSC/pcsc-nacl.h
	cd include/PCSC && ln -s ../../workdir-*.inst/include/PCSC/pcsc-nacl.h pcsc-nacl.h.new
	touch include/PCSC/pcsc-nacl.h.new
	mv include/PCSC/pcsc-nacl.h.new include/PCSC/pcsc-nacl.h

manifest.json: manifest.json.in ../../configure.ac
	rm -f manifest.json.new
	sed 's/@PACKAGE_VERSION@/$(shell sed '/^AC_INIT/ {s@.*, @@;s@[^0-9\.].@@g;p};d' ../../configure.ac)/g' manifest.json.in > manifest.json.new
	mv manifest.json.new manifest.json

jsrsasign.js:
	wget --no-check-certificate -O jsrsasign.js.new 'https://github.com/kjur/jsrsasign/raw/2989e2cdc29219f5fb1743dffd9cee93b7090832/jsrsasign-latest-all-min.js'
	test "`openssl sha256 jsrsasign.js.new | sed 's@.*= *@@'`" = '99b041bccc846f03623ce52f5932bd3ff282a064e7077a4ad1c600fc70c1176b'
	mv jsrsasign.js.new jsrsasign.js

test: cackey-chrome-pkcs11.c cackey-chrome-test.c ../../cackey.c Makefile
	gcc -g3 -ggdb3 -Wall -I. -I../../pkcs11 -I/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/include -I/opt/appfs/rkeene.org/pcsc-lite/platform/latest/include/PCSC -DHAVE_WINTYPES_H=1 -DHAVE_PCSCLITE_H=1 -DHAVE_WINSCARD_H=1 -DHAVE_STDINT_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_PTHREAD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_STDIO_H=1 -DHAVE_ZLIB_H -DHAVE_LIBZ -DCACKEY_DEBUG=1 -o test cackey-chrome-pkcs11.c cackey-chrome-test.c ../../cackey.c -L/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/lib -lz -L/opt/appfs/rkeene.org/pcsc-lite/platform/latest/lib -lpcsclite -L/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib -lc -lpthread -Wl,-R,/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/lib -Wl,-R,/opt/appfs/rkeene.org/pcsc-lite/platform/latest/lib -Wl,-R,/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib -Wl,-dynamic-linker,/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib/ld-linux-x86-64.so.2

cackey-chrome-pkcs11.o: cackey-chrome-pkcs11.c cackey-chrome.h
cackey-chrome-plugin.o: cackey-chrome-plugin.cc cackey-chrome.h include/PCSC/pcsc-nacl.h

clean:
	rm -f cackey-chrome-pkcs11.o cackey-chrome-plugin.o
	rm -f cackey.pexe cackey.bc
	rm -f cackey.zip cackey.nmf
	rm -f manifest.json manifest.json.new
	rm -f test

distclean: clean
	rm -f lib/libcackey.a lib/libpcsc.a lib/libz.a
	-rmdir lib
	rm -f include/PCSC/pcsc-nacl.h
	-rmdir include/PCSC
	-rmdir include
	rm -f google-pcsc.js
	rm -rf workdir-*
	rm -f jsrsasign.js jsrsasign.js.new

.PHONY: all clean distclean







|
<
<


|
|
|
|
|
|















|











|







68
69
70
71
72
73
74
75


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
	mkdir -p lib
	rm -f lib/libz.a
	cd lib && ln -s ../workdir-*.inst/lib/libz.a .
	touch lib/libz.a

google-pcsc.js: lib/libcackey.a
	rm -f google-pcsc.js google-pcsc.js.new
	cat workdir-*.inst/js/libpcsc.js > google-pcsc.js.new


	mv google-pcsc.js.new google-pcsc.js

include/libpcsc.h: lib/libcackey.a
	mkdir -p include
	rm -f include/libpcsc.h.new include/libpcsc.h
	cd include && ln -s ../workdir-*.inst/include/libpcsc.h libpcsc.h.new
	touch include/libpcsc.h.new
	mv include/libpcsc.h.new include/libpcsc.h

manifest.json: manifest.json.in ../../configure.ac
	rm -f manifest.json.new
	sed 's/@PACKAGE_VERSION@/$(shell sed '/^AC_INIT/ {s@.*, @@;s@[^0-9\.].@@g;p};d' ../../configure.ac)/g' manifest.json.in > manifest.json.new
	mv manifest.json.new manifest.json

jsrsasign.js:
	wget --no-check-certificate -O jsrsasign.js.new 'https://github.com/kjur/jsrsasign/raw/2989e2cdc29219f5fb1743dffd9cee93b7090832/jsrsasign-latest-all-min.js'
	test "`openssl sha256 jsrsasign.js.new | sed 's@.*= *@@'`" = '99b041bccc846f03623ce52f5932bd3ff282a064e7077a4ad1c600fc70c1176b'
	mv jsrsasign.js.new jsrsasign.js

test: cackey-chrome-pkcs11.c cackey-chrome-test.c ../../cackey.c Makefile
	gcc -g3 -ggdb3 -Wall -I. -I../../pkcs11 -I/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/include -I/opt/appfs/rkeene.org/pcsc-lite/platform/latest/include/PCSC -DHAVE_WINTYPES_H=1 -DHAVE_PCSCLITE_H=1 -DHAVE_WINSCARD_H=1 -DHAVE_STDINT_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_PTHREAD_H=1 -DHAVE_LIMITS_H=1 -DHAVE_STDIO_H=1 -DHAVE_ZLIB_H -DHAVE_LIBZ -DCACKEY_DEBUG=1 -o test cackey-chrome-pkcs11.c cackey-chrome-test.c ../../cackey.c -L/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/lib -lz -L/opt/appfs/rkeene.org/pcsc-lite/platform/latest/lib -lpcsclite -L/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib -lc -lpthread -Wl,-R,/opt/appfs/core.appfs.rkeene.org/zlib/platform/latest/lib -Wl,-R,/opt/appfs/rkeene.org/pcsc-lite/platform/latest/lib -Wl,-R,/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib -Wl,-dynamic-linker,/opt/appfs/core.appfs.rkeene.org/glibc/platform/latest/lib/ld-linux-x86-64.so.2

cackey-chrome-pkcs11.o: cackey-chrome-pkcs11.c cackey-chrome.h
cackey-chrome-plugin.o: cackey-chrome-plugin.cc cackey-chrome.h include/libpcsc.h

clean:
	rm -f cackey-chrome-pkcs11.o cackey-chrome-plugin.o
	rm -f cackey.pexe cackey.bc
	rm -f cackey.zip cackey.nmf
	rm -f manifest.json manifest.json.new
	rm -f test

distclean: clean
	rm -f lib/libcackey.a lib/libpcsc.a lib/libz.a
	-rmdir lib
	rm -f include/libpcsc.h
	-rmdir include/PCSC
	-rmdir include
	rm -f google-pcsc.js
	rm -rf workdir-*
	rm -f jsrsasign.js jsrsasign.js.new

.PHONY: all clean distclean

Modified build/chrome/build-deps from [dd6eb9c6ce] to [faff128b75].

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	rm -f "${file}.new"
	wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
		wget -O "${file}.new" "${url}" || \
		return 1

	chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"

	if [ "${chkHash}" != "${hash}" ]; then
		echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2

		return 1
	fi

	mv "${file}.new" "${file}"








|







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
	rm -f "${file}.new"
	wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
		wget -O "${file}.new" "${url}" || \
		return 1

	chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"

	if [ "${chkHash}" != "${hash}" -a "${hash}" != '-' ]; then
		echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2

		return 1
	fi

	mv "${file}.new" "${file}"

166
167
168
169
170
171
172
173
174
175
176
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
	) || return 1

	rm -rf "${workdir}"

	return 0
}

# Build "boost"
function buildBoost() {
	local version url pkg sha256 configure_extra
	local archive workdir

	pkg='boost'
	version='1.57.0'
	url="http://downloads.sourceforge.net/project/boost/boost/${version}/boost_`echo ${version} | sed 's_\._\__g'`.tar.bz2"
	sha256='910c8c022a33ccec7f088bd65d4f14b466588dda94ba2124e78b8c57db264967'

	archive="archive/${pkg}-${version}.tar.bz2"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		cd "${workdir}" || exit 1

		./bootstrap.sh --prefix="${instdir}" --with-python=false --show-libraries

		./bootstrap.sh --prefix="${instdir}" --with-python=false --without-libraries='atomic,chrono,container,context,coroutine,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,log,math,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,wave' || exit 1

		echo "using gcc : pnacl : ${CXX} ;" >> project-config.jam

		./b2 --debug-configuration toolset=gcc-pnacl target-os=linux link=static runtime-link=static || exit 1

		./bjam install | grep -v '^common.copy '

		exit 0
	) || return 1

	rm -rf "${workdir}"

	return 0
}

# Build the libpcsc we need
function buildPCSC() {
	local version url pkg sha256 configure_extra
	local archive workdir

	buildBoost || return 1

	pkg='smart-card-client-c-example-app-sources'
	version='0.0.0'
	sha256='68970c6dc4b55d24a453bcfe5768af2b877f553a92a390be7f935db6223d4bc5'

	archive="archive/${pkg}.zip"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"

	extract "${archive}" "${workdir}" || return 1

	(
		cd "${workdir}" || exit 1

		# Copy out PC/SC headers for later use
		mkdir -p "${instdir}/include/PCSC" || exit 1
		cp third_party/pcsc-lite/src/src/PCSC/*.h "${instdir}/include/PCSC" || exit 1

		# Copy out extra headers
		cat << \_EOF_ > "${instdir}/include/PCSC/pcsc-nacl.h"
#ifndef PCSC_NACL_H
#define PCSC_NACL_H 1
#ifdef __cplusplus
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId);
bool pcscNaClHandleMessage(const pp::Var &message);

#endif
#endif
_EOF_

		# Copy out JavaScript files for later use
		mkdir "${instdir}/js" || exit 1
		cp common-utils/*.js "${instdir}/js" || exit 1
		cp third_party/pcsc-lite/client-side/*.js "${instdir}/js" || exit 1

		# Build libpcsc
		## Assemble all the files into a single tree
		for file in logging.h scard_structs_serialization.h dom_requests_manager.h thread_safe_string_pool.h \
		    pp_var_utils.cc pp_var_utils.h scard_structs_serialization.cc dom_requests_manager.cc logging.cc; do
			find . -type f -name "${file}" -exec cp '{}' third_party/pcsc-lite/client-side/ ';'
		done

		## Create Makefile
		cat << \_EOF_ > third_party/pcsc-lite/client-side/Makefile || exit 1
CFLAGS   += -Wall -std=gnu++11 -g3 -ggdb3
CXXFLAGS += -Wall -std=gnu++11 -g3 -ggdb3
CPPFLAGS += -I../src/src/PCSC

OBJS = pcsc_nacl.o pcsc_nacl_global.o scard_structs_serialization.o pp_var_utils.o logging.o dom_requests_manager.o pcsc_nacl_init.o

all: libpcsc.a

libpcsc.a: $(OBJS)
	rm -f libpcsc.a
	$(AR) rc libpcsc.a $(OBJS)
	-$(RANLIB) libpcsc.a

pcsc_nacl_init.o: pcsc_nacl_init.cc pcsc_nacl_global.h dom_requests_manager.h pcsc_nacl.h

pcsc_nacl.o: pcsc_nacl.cc pcsc_nacl.h logging.h pp_var_utils.h scard_structs_serialization.h
pcsc_nacl.h: dom_requests_manager.h thread_safe_string_pool.h

pcsc_nacl_global.o: pcsc_nacl_global.cc pcsc_nacl_global.h logging.h
pcsc_nacl_global.h: pcsc_nacl.h

pp_var_utils.o: pp_var_utils.cc pp_var_utils.h logging.h
pp_var_utils.h: logging.h

scard_structs_serialization.o: scard_structs_serialization.cc scard_structs_serialization.h pp_var_utils.h
scard_structs_serialization.h: pp_var_utils.h

dom_requests_manager.o: dom_requests_manager.cc dom_requests_manager.h logging.h pp_var_utils.h

logging.o: logging.cc logging.h

clean:
	rm -f $(OBJS)
	rm -f libpcsc.a

distclean: clean

.PHONY: all clean distclean
_EOF_

		## Create initialization procedure, since it lacks one
		cat << \_EOF_ > third_party/pcsc-lite/client-side/pcsc_nacl_init.cc
#include <ppapi/cpp/core.h>
#include <ppapi/cpp/instance.h>

#include <unistd.h>

#include "pcsc_nacl_global.h"
#include "dom_requests_manager.h"
#include "pcsc_nacl.h"

static DomRequestsManager *pcscNaClDRM = NULL;

void pcscNaClInit(pp::Instance *instance, pp::Core *core, const char *smartcardManagerAppId, const char *clientId) {
	DomRequestsManager::PpDelegateImpl *drmDelegateImpl;
	PcscNacl *pcsc_nacl;

	if (smartcardManagerAppId == NULL) {
		smartcardManagerAppId = "khpfeaanjngmcnplbdlpegiifgpfgdco";
	}

	if (clientId == NULL) {
		clientId = "UNKNOWN";
	}

	if (pcscNaClDRM == NULL) {
		drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core);
	
		pcscNaClDRM = new DomRequestsManager("pcsc-nacl", drmDelegateImpl);
	}

	pcsc_nacl = new PcscNacl(pcscNaClDRM, smartcardManagerAppId, clientId);

	if (!pcsc_nacl->Initialize()) {
		return;
	}

	SetPcscNaclGlobalInstance(pcsc_nacl);

	return;
}

bool pcscNaClHandleMessage(const pp::Var &message) {
	return(pcscNaClDRM->HandleMessage(message));
}
_EOF_

		## Make it
		make -C third_party/pcsc-lite/client-side || exit 1

		# Install the built libpcsc
		mkdir -p "${instdir}/lib" || exit 1
		cp third_party/pcsc-lite/client-side/libpcsc.a "${instdir}/lib" || exit 1
	) || return 1

	rm -rf "${workdir}"

	return 0
}

# Build our CACKey







|
|



|
|
|
|

|








<
|
<
|
<
|
<
<
<
<
<


<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







166
167
168
169
170
171
172
173
174
175
176
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
204
	) || return 1

	rm -rf "${workdir}"

	return 0
}

# Build the libpcsc we need
function buildPCSC() {
	local version url pkg sha256 configure_extra
	local archive workdir

	pkg='nacl-libpcsc'
	version='179983e00b5ed8a8fead5d2f9bb35f5304716041'
	url="https://chiselapp.com/user/rkeene/repository/nacl-libpcsc/tarball/nacl-libpcsc-${version}.tar.gz?uuid=${version}"
	sha256='-'

	archive="archive/${pkg}-${version}.tar.gz"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		cd "${workdir}" || exit 1


		if [ ! -d pcsc/src ]; then

			./build/assemble-source-from-google.sh || exit 1

		fi





	) || return 1


	make -C "${workdir}" prefix="${instdir}" install || return 1






















































































































































	rm -rf "${workdir}"

	return 0
}

# Build our CACKey

Modified build/chrome/cackey-chrome-plugin.cc from [cf6e270a5f] to [06cf85fd98].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <ppapi/cpp/var_dictionary.h>
#include <ppapi/cpp/var_array.h>
#include <ppapi/cpp/var_array_buffer.h>

#include <string.h>
#include <stdlib.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) {







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <ppapi/cpp/var_dictionary.h>
#include <ppapi/cpp/var_array.h>
#include <ppapi/cpp/var_array_buffer.h>

#include <string.h>
#include <stdlib.h>

#include "libpcsc.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) {

Modified build/chrome/cackey.js from [cc6681845c] to [94fd0f8405].

186
187
188
189
190
191
192



193
194
195
196
197
198
199
 *
 * If an error occured, invoke the callback with no arguments.
 */
function cackeyMessageIncoming(messageEvent) {
	var nextFunction = null;
	var chromeCallback = null;




	if (messageEvent.data.target != "cackey") {
		return;
	}

	if (GoogleSmartCard.IS_DEBUG_BUILD) {
		console.log("START MESSAGE");
		console.log(messageEvent.data);







>
>
>







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
 *
 * If an error occured, invoke the callback with no arguments.
 */
function cackeyMessageIncoming(messageEvent) {
	var nextFunction = null;
	var chromeCallback = null;

		console.log("START MESSAGE");
		console.log(messageEvent.data);
		console.log("END MESSAGE");
	if (messageEvent.data.target != "cackey") {
		return;
	}

	if (GoogleSmartCard.IS_DEBUG_BUILD) {
		console.log("START MESSAGE");
		console.log(messageEvent.data);
719
720
721
722
723
724
725

726
727
728
729
730
731
732
733
			"smartcardManagerAppId": "khpfeaanjngmcnplbdlpegiifgpfgdco"
		}
	);

	/*
	 * Initialize the PCSC NaCl interface
	 */

	cackeyPCSCHandle = new GoogleSmartCard.PcscNacl(cackeyHandle);

	console.log("[cackey] cackeyInitPCSC() complete");

	return;
}

/*







>
|







722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
			"smartcardManagerAppId": "khpfeaanjngmcnplbdlpegiifgpfgdco"
		}
	);

	/*
	 * Initialize the PCSC NaCl interface
	 */
	new GoogleSmartCard.NaclModule(cackeyHandle);
	cackeyPCSCHandle = new GoogleSmartCard.PcscLiteClient.NaclClientBackend(cackeyHandle.messageChannel, "CACKey", "khpfeaanjngmcnplbdlpegiifgpfgdco"); 

	console.log("[cackey] cackeyInitPCSC() complete");

	return;
}

/*
812
813
814
815
816
817
818
819

820
821
822
823
824
825
826
827
828
829
830


831

832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
	chrome.app.runtime.onLaunched.addListener(function() {
		chrome.app.window.create('ui.html', {
			"id": "cackeyUI",
			"focused": true,
			"innerBounds": {
				"width": 350,
				"minWidth": 350,
				"height": 135,

				"minHeight": 135
			}
		}, function(uiWindow) {
			if (!uiWindow) {
				return;
			}

			uiWindow.contentWindow.parentWindow = window;
		});
	});



	/*

	 * Register a handler for dealing with the PCSC port being disconnected
	 */
	oldOnPortDisconnectedFunction = GoogleSmartCard.Pcsc.prototype.onPortDisconnected_;
	GoogleSmartCard.Pcsc.prototype.onPortDisconnected_ = function() {
		oldOnPortDisconnectedFunction.apply(this);

		cackeyInitPCSCCompleted("failure");

		cackeyRestart();

		return;
	};

	/*
	 * Register a handler for dealing with the PCSC port being available
	 */
	oldPCSCInitializationCallback = GoogleSmartCard.PcscNacl.prototype.pcscInitializationCallback_;
	GoogleSmartCard.PcscNacl.prototype.pcscInitializationCallback_ = function(requestId, instanceId, instance, error) {
		oldPCSCInitializationCallback.apply(this, [requestId, instanceId, instance, error]);

		return;
	};

	/*
	 * Initialize global state
	 */
	cackeyInitGlobalState();

	return;
}

/* Initialize CACKey */
cackeyAppInit();
cackeyInit();







|
>











>
>
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|











816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
	chrome.app.runtime.onLaunched.addListener(function() {
		chrome.app.window.create('ui.html', {
			"id": "cackeyUI",
			"focused": true,
			"innerBounds": {
				"width": 350,
				"minWidth": 350,
				"height": 136,

				"minHeight": 135
			}
		}, function(uiWindow) {
			if (!uiWindow) {
				return;
			}

			uiWindow.contentWindow.parentWindow = window;
		});
	});

// Google got rid of all of the code we were using to interface with PCSC... 
// This needs to be rewritten to use the new interface
//
//	/*
//	 * Register a handler for dealing with the PCSC port being disconnected
//	 */
//	oldOnPortDisconnectedFunction = GoogleSmartCard.Pcsc.prototype.onPortDisconnected_;
//	GoogleSmartCard.Pcsc.prototype.onPortDisconnected_ = function() {
//		oldOnPortDisconnectedFunction.apply(this);
//
//		cackeyInitPCSCCompleted("failure");
//
//		cackeyRestart();
//
//		return;
//	};
//
//	/*
//	 * Register a handler for dealing with the PCSC port being available
//	 */
//	oldPCSCInitializationCallback = GoogleSmartCard.PcscNacl.prototype.pcscInitializationCallback_;
//	GoogleSmartCard.PcscNacl.prototype.pcscInitializationCallback_ = function(requestId, instanceId, instance, error) {
//		oldPCSCInitializationCallback.apply(this, [requestId, instanceId, instance, error]);
//
//		return;
//	};
//
	/*
	 * Initialize global state
	 */
	cackeyInitGlobalState();

	return;
}

/* Initialize CACKey */
cackeyAppInit();
cackeyInit();