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.1 Oine Attestation Mechanism<br />

143 S i g n a t u r e phSign ;<br />

144 PrngSHA256 myPrngHMAC;<br />

145<br />

146 private S e l f t e s t O f f l i n e ( ) {<br />

147 phSign = S i g n a t u r e . g e t I n s t a n c e ( S i g n a t u r e .ALG_RSA_SHA_PKCS1, f a l s e ) ;<br />

148 phSCKeyPair = new KeyPair ( KeyPair .ALG_RSA, KeyBuilder .LENGTH_RSA_512) ;<br />

149 cipherKey = (AESKey) KeyBuilder . buildKey<br />

150 ( KeyBuilder .TYPE_AES_TRANSIENT_DESELECT,<br />

151 KeyBuilder .LENGTH_AES_128, f a l s e ) ;<br />

152 syCipher = Cipher . g e t I n s t a n c e ( Cipher .ALG_AES_BLOCK_128_CBC_NOPAD,<br />

153 f a l s e ) ;<br />

154 myPrngHmac = new PrngSHA256 ( ) ;<br />

155 pkCipher = Cipher . g e t I n s t a n c e ( Cipher .ALG_RSA_NOPAD, f a l s e ) ;<br />

156 phSCKeyPair . genKeyPair ( ) ;<br />

157 SHA256 = MessageDigest . g e t I n s t a n c e ( MessageDigest .ALG_SHA_256,<br />

158 f a l s e ) ;<br />

159 }<br />

160 public s t a t i c void i n s t a l l ( byte bArray [ ] , short bOffset , byte bLength )<br />

161 throws ISOException {<br />

162 new S e l f t e s t O f f l i n e ( ) . r e g i s t e r ( ) ;<br />

163 }<br />

164<br />

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

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

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

168 this . i n i t i a l i s e ( ) ;<br />

169 return ;<br />

170 }<br />

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

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

173 }<br />

174 i f ( apduBuffer [ ISO7816 .OFFSET_INS] == s e l f t e s t ) {<br />

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

176 JCSystem .MEMORY_TYPE_TRANSIENT_DESELECT) ;<br />

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

178 apdu . setOutgoing ( ) ;<br />

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

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

181 return ;<br />

182 }<br />

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

184 }<br />

185<br />

186 void s e l f t e s t P r o c e s s ( ) {<br />

187 byte [ ] memoryWordRead = new byte [ 4 ] ;<br />

188 byte rcount = ( byte ) 0x00 ;<br />

189 while ( rcount < MemoryContents . l e n g t h ) {<br />

190 U t i l . arrayCopyNonAtomic ( MemoryContents ,<br />

191 rcount , memoryWordRead , ( short ) 0 , memoryWordRead . l e n g t h ) ;<br />

192 generateSeed (memoryWordRead , tempSeed ) ;<br />

193 rcount += ( byte ) ( rcount+(short ) 4) ;<br />

256

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

Saved successfully!

Ooh no, something went wrong!