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.4 Secure and Trusted Channel Protocol Service Provider<br />

220 ( short ) 0 , this . S C C e r t i f i c a t e ,<br />

( short ) ( i n i t i a l P o i n t e r ) , ( short )<br />

221 this . ModulusTag . l e n g t h ) ;<br />

222 kLen = myPublic . getModulus ( this . S C C e r t i f i c a t e , ( short )<br />

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

224 this . shortToBytes ( this . S C C e r t i f i c a t e , i n i t i a l P o i n t e r , kLen ) ;<br />

225 this . S C C e r t i f i c a t e [6]++;<br />

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

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

228 }<br />

229 }<br />

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

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

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

233 return ;<br />

234 }<br />

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

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

237 }<br />

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

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

240 return ;<br />

241 }<br />

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

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

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

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

246 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

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

248 rCount = 0 ;<br />

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

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

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

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

253 }<br />

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

255 try {<br />

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

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

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

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

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

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

262 }<br />

263 }<br />

264 try {<br />

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

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

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

268 }<br />

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

295

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

Saved successfully!

Ooh no, something went wrong!