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

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

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

242 apdu . setOutgoing ( ) ;<br />

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

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

245 copyPointer ) ;<br />

246 } else i f ( this . r e c e i v i n g B u f f e r [ 3 ] ==<br />

247 this . MessageHandlerTagTwo [ 3 ] ) {<br />

422

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

Saved successfully!

Ooh no, something went wrong!