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.6 Application Acquisition and Contractual Agreement Protocol<br />

178 this . myProtocolHelperObject . GenerateMac<br />

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

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

181 this . myLongTermMacKey) ;<br />

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

183 else {<br />

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

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

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

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

187 }<br />

188 this . myProtocolHelperObject . GenerateDecryption<br />

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

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

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

192 this . myLongTermEncryptionKey ) ;<br />

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

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

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

196 " Error i n ProtocolHandler . inMessageProcessing :<br />

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

197 }<br />

198 return true ;<br />

199 }<br />

200 public s t a t i c S t r i n g byteToString ( byte [ ] inArray ) {<br />

201 byte [ ] HEX_CHAR_TABLE = {<br />

202 ( byte ) ' 0 ' , ( byte ) ' 1 ' , ( byte ) ' 2 ' , ( byte ) ' 3 ' , ( byte ) ' 4 ' , ( byte )<br />

203 ' 5 ' , ( byte ) ' 6 ' , ( byte ) ' 7 ' , ( byte ) ' 8 ' , ( byte ) ' 9 ' , ( byte ) ' a ' ,<br />

204 ( byte ) ' b ' , ( byte ) ' c ' , ( byte ) ' d ' , ( byte ) ' e ' , ( byte ) ' f '<br />

205 } ;<br />

206 byte [ ] hex = new byte [ 2 ∗ inArray . l e n g t h ] ;<br />

207 int index = 0 ;<br />

208 <strong>for</strong> ( byte b : inArray ) {<br />

209 int v = b & 0xFF ;<br />

210 hex [ index++] = HEX_CHAR_TABLE[ v >>> 4 ] ;<br />

211 hex [ index++] = HEX_CHAR_TABLE[ v & 0xF ] ;<br />

212 }<br />

213 try {<br />

214 return new S t r i n g ( hex , "ASCII" ) ;<br />

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

216 System . out . p r i n t l n ( " Exception in bytesToString : " +<br />

217 cE . getMessage ( ) + "\n" + cE . getStackTrace ( )<br />

218 . t o S t r i n g ( ) ) ;<br />

219 }<br />

220 return " Error " ;<br />

221 }<br />

222 void childExtractionFromCTLV ( ConstructedTLV inCTLV) {<br />

223 try {<br />

224 int c h i l d s = inCTLV . getChildNumbers ( ) ;<br />

225 PrimitiveTLV pTemp = null ;<br />

226 ConstructedTLV cTemp = null ;<br />

363

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

Saved successfully!

Ooh no, something went wrong!