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

184 i f ( Counter == 1) {<br />

185 this . S C P r o t o c o l I n i t i a t o r . s e t B y t e s T l v R e p r e s e n t a t i o n ( inMessage , 0 ,<br />

186 22) ;<br />

187 } else<br />

188 i f ( Counter == 2) {<br />

189 this . MessageHandler . r e s e t ( ) ;<br />

190 this . EncryptedData . r e s e t ( ) ;<br />

191 this . MessageHandler . s e t B y t e s T l v R e p r e s e n t a t i o n ( inMessage , 0 ,<br />

192 inMessage . l e n g t h − 2) ;<br />

193 this . childExtractionFromCTLV ( this . MessageHandler ) ;<br />

194 GenerateKeys ( this . SCDHChallenge . getValueBytes ( ) ) ;<br />

195 byte [ ] temp = new byte [ 1 6 ] ;<br />

196 this . myProtocolHelperObject . GenerateMac<br />

197 ( this . EncryptedData . getValueBytes ( ) , 0 ,<br />

198 this . EncryptedData . getValueBytes ( ) . length , temp , 0 ,<br />

199 this . mySessionMacKey ) ;<br />

200 i f ( Arrays . e q u a l s ( this . MACedData . getValueBytes ( ) , temp ) ) {}<br />

201 else {<br />

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

203 " I n t e g r i t y Check F a i l u r e : ERROR at<br />

ProtocolHandler . inMessageProcessing \n" ) ;<br />

204 System . e x i t ( 0 ) ;<br />

205 }<br />

206 this . myProtocolHelperObject . GenerateDecryption<br />

207 ( this . EncryptedData . getValueBytes ( ) , 0 ,<br />

208 this . EncryptedData . getValueBytes ( ) . length ,<br />

209 this . EncryptedData . getBytesTlvRepresentation ( ) , 7 ,<br />

210 this . mySessionEncryptionKey ) ;<br />

211 this . childExtractionFromCTLV ( EncryptedData ) ;<br />

212 i f ( Arrays . e q u a l s ( Plat<strong>for</strong>mHashPreset ,<br />

213 this . Plat<strong>for</strong>mHash . getValueBytes ( ) ) ) {}<br />

214 else {<br />

215 System . out . p r i n t l n ( " Plat<strong>for</strong>m Digest Not V e r i f i e d " ) ;<br />

216 }<br />

217 childExtractionFromCTLV ( this . S C C e r t i f i c a t e ) ;<br />

218 B i g I n t e g e r SCpublicExponent = new B i g I n t e g e r ( byteToString<br />

219 ( this . PublicExponent . getValueBytes ( ) ) , 16) ;<br />

220 B i g I n t e g e r SCpublicModulus = new B i g I n t e g e r ( byteToString<br />

221 ( this . PublicModulus . getValueBytes ( ) ) , 16) ;<br />

222 KeyFactory f a c t o r y = KeyFactory . g e t I n s t a n c e ( "RSA" ) ;<br />

223 SCVerificationKey = ( PublicKey ) f a c t o r y . g e n e r a t e P u b l i c (new<br />

224 RSAPublicKeySpec ( SCpublicModulus ,<br />

225 SCpublicExponent ) ) ;<br />

226 temp = new byte [ ( this . Plat<strong>for</strong>mHash . getTagLength ( ) +<br />

227 this . SCIdentity . getTagLength ( ) +<br />

228 this . SCRandomNumber . getTagLength ( ) +<br />

229 this . SPRandomNumber . getTagLength ( ) ) ] ;<br />

230 System . arraycopy ( this . EncryptedData . getBytesTlvRepresentation ( ) ,<br />

7 ,<br />

231 temp , 0 , temp . l e n g t h ) ;<br />

232 i f ( this . myProtocolHelperObject . SignatureMethod ( temp , 0 ,<br />

329

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

Saved successfully!

Ooh no, something went wrong!