06.11.2014 Views

A User Centric Security Model for Tamper-Resistant Devices

A User Centric Security Model for Tamper-Resistant Devices

A User Centric Security Model for Tamper-Resistant Devices

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C.9 Plat<strong>for</strong>m Binding Protocol<br />

221 i n i t i a l P o i n t e r = U t i l . arrayCopyNonAtomic ( this . ModulusTag ,<br />

222 ( short ) 0 , this . SCACertificate , ( short ) ( i n i t i a l P o i n t e r ) ,<br />

223 ( short ) this . ModulusTag . l e n g t h ) ;<br />

224 kLen = myPublic . getModulus ( this . SCACertificate , ( short )<br />

225 ( i n i t i a l P o i n t e r + ( short ) 2) ) ;<br />

226 this . shortToBytes ( this . SCACertificate , i n i t i a l P o i n t e r , kLen ) ;<br />

227 this . SCACertificate [6]++;<br />

228 } catch ( Exception cE ) {<br />

229 ISOException . throwIt ( ( short ) 0 x6666 ) ;<br />

230 }<br />

231 }<br />

232 public void p r o c e s s (APDU apdu )throws ISOException {<br />

233 byte [ ] apduBuffer = apdu . g e t B u f f e r ( ) ;<br />

234 i f ( s e l e c t i n g A p p l e t ( ) ) {<br />

235 return ;<br />

236 }<br />

237 i f ( apduBuffer [ ISO7816 .OFFSET_CLA] != CLA) {<br />

238 ISOException . throwIt (SW_CLASSNOTSUPPORTED) ;<br />

239 }<br />

240 i f ( apduBuffer [ ISO7816 .OFFSET_INS] == I n i t i a t i o n P r o t o c o l ) {<br />

241 this . i n i t i a l i s e P r o t o c o l ( ) ;<br />

242 return ;<br />

243 }<br />

244 r e c e i v i n g B u f f e r = null ;<br />

245 b y t e s L e f t = 0 ;<br />

246 b y t e s L e f t = apdu . getIncomingLength ( ) ;<br />

247 r e c e i v i n g B u f f e r = JCSystem . makeTransientByteArray ( bytesLeft ,<br />

248 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

249 readCount = ( short ) ( ( short ) apdu . setIncomingAndReceive ( ) ) ;<br />

250 rCount = 0 ;<br />

251 i f ( b y t e s L e f t > 0) {<br />

252 rCount = U t i l . arrayCopyNonAtomic ( apduBuffer ,<br />

253 ISO7816 .OFFSET_EXT_CDATA, r e c e i v i n g B u f f e r , rCount , readCount ) ;<br />

254 b y t e s L e f t −= readCount ;<br />

255 }<br />

256 while ( b y t e s L e f t > 0) {<br />

257 try {<br />

258 readCount = apdu . r e c e i v e B y t e s ( ( short ) 0) ;<br />

259 rCount = U t i l . arrayCopyNonAtomic ( apduBuffer , ( short ) 0 ,<br />

260 r e c e i v i n g B u f f e r , rCount , readCount ) ;<br />

261 b y t e s L e f t −= readCount ;<br />

262 } catch ( Exception aE) {<br />

263 ISOException . throwIt ( ( short ) 0x7AAA) ;<br />

264 }<br />

265 }<br />

266 try {<br />

267 parseMessage ( r e c e i v i n g B u f f e r ) ;<br />

268 } catch ( Exception cE ) {<br />

269 ISOException . throwIt ( ( short ) 0xA112 ) ;<br />

270 }<br />

271 i f ( this . r e c e i v i n g B u f f e r [ 3 ] == this . MessageHandlerTagOne [ 3 ] ) {<br />

409

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!