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.8 Application Binding Protocol - Distributed<br />

190 }<br />

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

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

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

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

195 return ;<br />

196 }<br />

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

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

199 }<br />

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

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

202 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

203 generateResponse ( ( short ) 1) ;<br />

204 apdu . setOutgoing ( ) ;<br />

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

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

207 copyPointer ) ;<br />

208 return ;<br />

209 }<br />

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

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

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

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

214 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

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

216 rCount = 0 ;<br />

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

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

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

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

221 }<br />

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

223 try {<br />

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

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

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

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

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

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

230 }<br />

231 }<br />

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

233 try {<br />

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

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

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

237 }<br />

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

239 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

240 generateResponse ( ( short ) 2) ;<br />

396

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

Saved successfully!

Ooh no, something went wrong!