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.7 Application Binding Protocol - Local<br />

98 } catch ( Exception e ) {<br />

99 ISOException . throwIt ( ( short ) 0 x0001 ) ;<br />

100 }<br />

101 try {<br />

102 v e r i f ySignedData ( ( short ) 116 , ( short ) 64) ;<br />

103 } catch ( Exception e ) {<br />

104 ISOException . throwIt ( ( short ) 0 x0002 ) ;<br />

105 }<br />

106 try {<br />

107 generatedDecryptedData ( ( short ) 116 , ( short ) 32 ,<br />

108 myClientAppServerKey ) ;<br />

109 } catch ( Exception e ) {<br />

110 ISOException . throwIt ( ( short ) 0 x0003 ) ;<br />

111 }<br />

112 U t i l . arrayCopyNonAtomic ( pMessage , ( short ) 116 , TokenValue , ( short )<br />

113 0 , ( short ) TokenValue . l e n g t h ) ;<br />

114 pMessage [ 0 ] = ( byte ) U t i l . arrayCopyNonAtomic ( C l i e n t I d e n t i t y ,<br />

115 ( short ) 0 , pMessage , i n i t i a l T a b , ( short )<br />

116 C l i e n t I d e n t i t y . l e n g t h ) ;<br />

117 pMessage [ 0 ] = ( byte ) U t i l . arrayCopyNonAtomic ( S e r v e r I d e n t i t y ,<br />

118 ( short ) 0 , pMessage , pMessage [ 0 ] , ( short )<br />

119 S e r v e r I d e n t i t y . l e n g t h ) ;<br />

120 pMessage [ 2 ] = pMessage [ 0 ] ;<br />

121 pMessage [ 0 ] = ( byte ) U t i l . arrayCopyNonAtomic ( TokenValue , ( short ) 0 ,<br />

122 pMessage , pMessage [ 0 ] , ( short ) TokenValue . l e n g t h ) ;<br />

123 pMessage [ 0 ] = ( byte ) U t i l . arrayCopyNonAtomic ( clientR , ( short ) 0 ,<br />

124 pMessage , pMessage [ 0 ] , ( short ) c l i e n t R . l e n g t h ) ;<br />

125 pMessage [ 0 ] = ( byte ) ( pMessage [ 0 ] − pMessage [ 2 ] ) ;<br />

126 try {<br />

127 encryptData ( ( short ) 4 , ( short ) 30 , myClientAppServerKey ) ;<br />

128 } catch ( Exception e ) {<br />

129 ISOException . throwIt ( ( short ) 0 x0004 ) ;<br />

130 }<br />

131 try {<br />

132 myServerAppRef . protocolManager ( ( short ) 2 , pMessage ) ;<br />

133 } catch ( Exception e ) {<br />

134 ISOException . throwIt ( ( short ) 0x00A5 ) ;<br />

135 }<br />

136 return TokenValue ;<br />

137 }<br />

138 public void protocolManager ( byte [ ] pMessage ) {}<br />

139 protected void generateEncryptionData (AESKey Key) {<br />

140 pMessage [ 3 ] += ( short ) ( pMessage [ 0 ] − 4) ;<br />

141 AESCipher . i n i t (Key , Cipher .MODE_ENCRYPT) ;<br />

142 short paddingbytes = ( short ) (16 −(( pMessage [ 0 ] % 16) − ( short ) 4) ) ;<br />

143 i f ( paddingbytes != 0) {<br />

144 <strong>for</strong> ( short i = 0 ; i < paddingbytes ; i ++) {<br />

145 pMessage [ ( short ) ( pMessage [ 0 ] + i ) ] = ( byte ) 0xFF ;<br />

146 }<br />

147 }<br />

148 pMessage [ 0 ] += ( byte ) paddingbytes ;<br />

367

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

Saved successfully!

Ooh no, something went wrong!