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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C.6 Application Acquisition and Contractual Agreement Protocol<br />

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

277 }<br />

278 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 />

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

280 return ;<br />

281 }<br />

282 i f ( apduBuffer [ ISO7816 .OFFSET_INS] == PhaseTwo ) {<br />

283 this . AppDownloadCompleted ( apdu ) ;<br />

284 }<br />

285 i f ( apduBuffer [ ISO7816 .OFFSET_INS] == PhaseThree ) {<br />

286 r e c e i v i n g B u f f e r = JCSystem . makeTransientByteArray ( ( short ) 568 ,<br />

287 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

288 this . SCTSMChargeRequest ( apdu ) ;<br />

289 JCSystem . r e q u e s t O b j e c t D e l e t i o n ( ) ;<br />

290 apdu . setOutgoing ( ) ;<br />

291 apdu . setOutgoingLength ( ( short ) copyPointer ) ;<br />

292 apdu . sendBytesLong ( r e c e i v i n g B u f f e r , ( short ) 0 , ( short ) copyPointer ) ;<br />

293 JCSystem . r e q u e s t O b j e c t D e l e t i o n ( ) ;<br />

294 return ;<br />

295 }<br />

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

297 i f ( b y t e s L e f t > 255) {<br />

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

299 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

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

301 rCount = 0 ;<br />

302 short bytesRead = 0 ;<br />

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

304 try {<br />

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

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

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

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

309 readCount = apdu<br />

. r e c e i v e B y t e s ( ( short ) ISO7816 .OFFSET_EXT_CDATA)<br />

310 ;<br />

311 }<br />

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

313 ISOException . throwIt ( ( short ) bytesRead ) ;<br />

314 }<br />

315 }<br />

316 } else {<br />

317 try {<br />

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

319 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

320 U t i l . arrayCopyNonAtomic ( apduBuffer , ISO7816 .OFFSET_CDATA,<br />

321 this . r e c e i v i n g B u f f e r , ( short ) 0 , ( short )<br />

322 this . r e c e i v i n g B u f f e r . l e n g t h ) ;<br />

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

324 ISOException . throwIt ( ( short ) apduBuffer . l e n g t h ) ;<br />

325 }<br />

339

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

Saved successfully!

Ooh no, something went wrong!