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.5 Secure and Trusted Channel Protocol Smart Card<br />

331 }<br />

332 }<br />

333 void GenerateKeys ( byte [ ] i n b u f f ) {<br />

334 byte [ ] DHSecretKey = null ;<br />

335 try {<br />

336 DHSecretKey =<br />

337 this . myProtocolHelperObject . GenerateDHSessionKeyMaterial ( i n b u f f ,<br />

0 ,<br />

338 i n b u f f . l e n g t h ) ;<br />

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

340 System . out . p r i n t l n (<br />

341 " Exception At P r o t o c o l H e l p e r C l a s s . GenerateKeys :<br />

" + cE . g e t C l a s s ( ) . getName ( ) ) ;<br />

342 }<br />

343 byte [ ] keyGenKey = new byte [ 1 6 ] ;<br />

344 System . arraycopy ( DHSecretKey , 0 , keyGenKey , 0 , keyGenKey . l e n g t h ) ;<br />

345 byte [ ] macInputValue = new byte [ 6 4 ] ;<br />

346 System . arraycopy ( this . SPRandomNumber . getValueBytes ( ) , 0 ,<br />

macInputValue ,<br />

347 0 , 16) ;<br />

348 System . arraycopy ( this . SCRandomNumber . getValueBytes ( ) , 0 ,<br />

macInputValue ,<br />

349 16 , 16) ;<br />

350 System . arraycopy ( DHSecretKey , 16 , macInputValue , 32 , 16) ;<br />

351 <strong>for</strong> ( int i = 4 8 ; i < 6 4 ; i ++) {<br />

352 macInputValue [ i ] = ( byte ) 0x02 ;<br />

353 }<br />

354 try {<br />

355 this . myProtocolHelperObject . GenerateMac ( macInputValue , 0 ,<br />

356 macInputValue . length , this . mySessionEncryptionKey , 0 , keyGenKey ) ;<br />

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

358 System . out . p r i n t l n ( " Exception at ProtocolHandler . GenerateKeys : " +<br />

359 cE . g e t C l a s s ( ) . getName ( ) ) ;<br />

360 }<br />

361 <strong>for</strong> ( int i = 4 8 ; i < 6 4 ; i ++) {<br />

362 macInputValue [ i ] = ( byte ) 0x03 ;<br />

363 }<br />

364 try {<br />

365 this . myProtocolHelperObject . GenerateMac ( macInputValue , 0 ,<br />

366 macInputValue . length , this . mySessionMacKey , 0 , keyGenKey ) ;<br />

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

368 System . out . p r i n t l n ( " Exception at ProtocolHandler . GenerateKeys : " +<br />

369 cE . g e t C l a s s ( ) . getName ( ) ) ;<br />

370 }<br />

371 }<br />

372 }<br />

332

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

Saved successfully!

Ooh no, something went wrong!