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.11 Implementation Helper Classes<br />

26 ( byte ) 0xB0 , ( byte ) 0xFF , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x01 ,<br />

( byte ) 0xAA} ;<br />

27 private s t a t i c CommandAPDU SELECT_APDU = new CommandAPDU<br />

28 (CMD_APPLICATION_SELECT) ;<br />

29 private s t a t i c CommandAPDU Application_INITIALISATION = new CommandAPDU<br />

30 (CMD_APPLICATION_INITIALISATION) ;<br />

31 byte [ ] r e s p o n s e ;<br />

32 public Terminal ( ) {}<br />

33 public void TerminalConnection ( ) {<br />

34 try {<br />

35 l i s t T e r m i n a l = myCardTerminals . l i s t ( ) ;<br />

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

37 System . out . p r i n t l n ( " Error L i s t i n g Attached Terminals : " +<br />

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

38 }<br />

39 L i s t I t e r a t o r t e r m i n a l I t e r a t o r = l i s t T e r m i n a l . l i s t I t e r a t o r ( ) ;<br />

40 while ( t e r m i n a l I t e r a t o r . hasNext ( ) ) {<br />

41 t e r m i n a l I t e r a t o r . next ( ) ;<br />

42 }<br />

43 myCardTerminal = myCardTerminals . getTerminal ( "OMNIKEY CardMan 3x21<br />

0" ) ;<br />

44 try {<br />

45 try {<br />

46 myCard = myCardTerminal . connect ( "T=1" ) ;<br />

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

48 System . out . p r i n t l n ( " Terminal Disconnected " ) ;<br />

49 }<br />

50 myCardChannel = myCard . getBasicChannel ( ) ;<br />

51 i f ( ResponseTest ( myCardChannel . transmit (SELECT_APDU) ) ) {}<br />

52 else {<br />

53 System . out . p r i n t l n ( " A p p l i c a t i o n Not S e l e c t e d " ) ;<br />

54 }<br />

55 } catch ( Exception eX) {<br />

56 System . out . p r i n t l n ( " Error " + eX . g e t C l a s s ( ) + "\n" +<br />

eX . getMessage ( ) ) ;<br />

57 }<br />

58 }<br />

59 private boolean ResponseTest ( ResponseAPDU resAPDU) {<br />

60 byte [ ] t e s t B y t e s = resAPDU . getBytes ( ) ;<br />

61 return ( t e s t B y t e s [ t e s t B y t e s . l e n g t h − 2 ] == ( byte ) 0x90 &&<br />

62 t e s t B y t e s [ t e s t B y t e s . l e n g t h − 1 ] == ( byte ) 0x00 ) ;<br />

63 }<br />

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

65 byte [ ] HEX_CHAR_TABLE = {<br />

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

( byte )<br />

67 ' 6 ' , ( byte ) ' 7 ' , ( byte ) ' 8 ' , ( byte ) ' 9 ' , ( byte ) ' a ' , ( byte ) ' b ' ,<br />

( byte ) ' c ' ,<br />

68 ( byte ) ' d ' , ( byte ) ' e ' , ( byte ) ' f '<br />

69 } ;<br />

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

440

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

Saved successfully!

Ooh no, something went wrong!