Forum Stats

  • 3,816,111 Users
  • 2,259,142 Discussions
  • 7,893,390 Comments

Discussions

pre-personalization JCOP3

59987095-691a-4f4b-bcd7-773b62fb6d28
edited Dec 5, 2019 6:47AM in Java Card

i want to pre-personalization JCOP3 SECID P60 but always there is error in boot command

  1. #---------------------------
  2. #
  3. #----Pre-personalization script----
  4. #
  5. #Script folder can be set using /set-var shell command (e.g. /set-var path c:/JCShellScripts).
  6. #The JCShell always searches the current directory for script files.
  7. #To execute a script, just type the name of the file (without extension) in the JCShell command line.
  8. #---------------------------
  9. #-------VARIABLES-----------
  10. /set-var Kt                 __INSERT_YOUR_TRANSPORT_KEY__
  11. /set-var chanel             0
  12. /set-var OK_resp            9000
  13. #Card manager lifecycle
  14. /set-var CM_LIFECYCLE_size        02
  15. /set-var CM_OP_READY          FE01
  16. /set-var CM_INITILIZED          F807
  17. /set-var CM_SECURED                  F00F
  18. /set-var CM_CARD_LOCKED          807F
  19. /set-var CM_TERMINATED          00FF
  20. /set-var CM_LIFECYCLE          ${CM_OP_READY}
  21. #Card manager default keys:
  22. /set-var DES_key_size          10
  23. /set-var DES_key_keyset          FF
  24. /set-var DES_keyset_size     01
  25. /set-var DES_K1           0123456789ABCDEF0123456789ABCDEF
  26. /set-var DES_K2           0123456789ABCDEF0123456789ABCDEF
  27. /set-var DES_K3           0123456789ABCDEF0123456789ABCDEF
  28. #size of GPIN_size is 01, size of GPIN_format is 01 and sizes used in functions without pre-defined constants
  29. /set-var GPIN                 3132333435
  30. /set-var GPIN_size             05
  31. /set-var GPIN_format           01
  32. #-------COMANDS-------------
  33. /set-var BOOT                   00F00000
  34. /set-var PROTECT                00100000
  35. /set-var FUSE                   00000000
  36. /set-var AUTH                   00880000
  37. /set-var ADMINEXEC              00200000
  38. /set-var READ                   B0
  39. /set-var WRITE                  D6
  40. #-------ADRESSES------------
  41. #     From: 188730_JCOPV2_4_1R3_admi.pdf
  42. /set-var A2_addr                C0
  43. /set-var CM_Lifecycle_addr      029A
  44. /set-var DES_K1_addr            0305
  45. /set-var DES_K2_addr            0321
  46. /set-var DES_K3_addr            033D
  47. /set-var DES_K1_type_addr       0301
  48. /set-var DES_K2_type_addr       031D
  49. /set-var DES_K3_type_addr       0339
  50. /set-var GPIN_addr              0412
  51. /set-var GPIN_size_addr         0407
  52. /set-var GPIN_format_addr       0409
  53. #==============================
  54. #connect to card
  55. #===============
  56. /terminal
  57. /atr
  58. #select root applet with Transport key (Kt), and chanel 0
  59. /select ${Kt} ${chanel}
  60. #boot applet
  61. #===========
  62. /echo BOOT ROOT APPLET:
  63. /send ${BOOT}
  64. #setup CM lifecycle
  65. /echo setup CM lifecycle
  66. /send "${A2_addr}${WRITE}${CM_Lifecycle_addr} ${CM_LIFECYCLE_size} ${CM_LIFECYCLE}"
  67. #check it
  68. /send "${A2_addr}${READ}${CM_Lifecycle_addr}${CM_LIFECYCLE_size}"
  69. /set-var chk ${CM_LIFECYCLE}${OK_resp}
  70. if ${response} != ${chk}
  71.    throw "ERROR: CM_LIFECYCLE not set"
  72. end
  73. #setup DES keys SET UP DES KEYS: 10.4.2
  74. #======================================
  75. /echo SETUP DES KEY:
  76. /send "${A2_addr}${WRITE}${DES_K1_addr} ${DES_key_size} ${DES_K1}"
  77. /send "${A2_addr}${WRITE}${DES_K2_addr} ${DES_key_size} ${DES_K2}"
  78. /send "${A2_addr}${WRITE}${DES_K3_addr} ${DES_key_size} ${DES_K3}"
  79. #
  80. #check it:
  81. #
  82. /echo CHECK DES KEYS:
  83. /send  ${A2_addr}${READ}${DES_K1_addr}${DES_key_size}
  84. /set-var chk ${DES_K1}${OK_resp}
  85. if ${response} != ${chk}
  86.    throw "ERROR: DES_K1 not equal"
  87. end
  88. /send  ${A2_addr}${READ}${DES_K2_addr}${DES_key_size}
  89. /set-var chk ${DES_K2}${OK_resp}
  90. if ${response} != ${chk}
  91.    throw "ERROR: DES_K2 not equal"
  92. end
  93. /send  ${A2_addr}${READ}${DES_K3_addr}${DES_key_size}
  94. /set-var chk ${DES_K3}${OK_resp}
  95. if ${response} != ${chk}
  96.    throw "ERROR: DES_K3 not equal"
  97. end
  98. #set key type
  99. #============
  100. /echo SET KEY TYPE = ${DES_key_keyset}:
  101. /send "${A2_addr}${WRITE}${DES_K1_type_addr}${DES_keyset_size}${DES_key_keyset}"
  102. /send "${A2_addr}${WRITE}${DES_K2_type_addr}${DES_keyset_size}${DES_key_keyset}"
  103. /send "${A2_addr}${WRITE}${DES_K3_type_addr}${DES_keyset_size}${DES_key_keyset}"
  104. #check it:
  105. #=========
  106. /echo CHECK KEY TYPE:
  107. /send  ${A2_addr}${READ}${DES_K1_type_addr}${DES_keyset_size}
  108. /set-var chk ${DES_key_keyset}${OK_resp}
  109. if ${response} != ${chk}
  110.    throw "ERROR: DES_K1_keyset not equal"
  111. end
  112. /send ${A2_addr}${READ}${DES_K2_type_addr}${DES_keyset_size}
  113. if ${response} != ${chk}
  114.    throw "ERROR: DES_K2_keyset not equal"
  115. end
  116. /send ${A2_addr}${READ}${DES_K3_type_addr}${DES_keyset_size}
  117. if ${response} != ${chk}
  118.    throw "ERROR: DES_K3_keyset not equal"
  119. end
  120. #set pin 12345 -(hex)->31 32 33 34 35
  121. #====================================
  122. /echo SETUP GLOBAL PIN (12345:5:ASCII):
  123. /send "${A2_addr}${WRITE}${GPIN_addr} ${GPIN_size} ${GPIN}"
  124. #set pin size 5 byte
  125. /send "${A2_addr}${WRITE}${GPIN_size_addr} 01 ${GPIN_size}"
  126. #set pin format ASCII
  127. /send "${A2_addr}${WRITE}${GPIN_format_addr} 01 ${GPIN_format}"
  128. #check set pin:
  129. /send "${A2_addr}${READ}${GPIN_addr} ${GPIN_size}"
  130. /set-var chk ${GPIN}${OK_resp}
  131. if ${response} != ${chk}
  132.    throw "ERROR: GPIN not equal"
  133. end
  134. #pin size:
  135. /send "${A2_addr}${READ}${GPIN_size_addr} 01"
  136. /set-var chk ${GPIN_size}${OK_resp}
  137. if ${response} != ${chk}
  138.    throw "ERROR: GPIN_size not equal"
  139. end
  140. #pin format:
  141. /send "${A2_addr}${READ}${GPIN_format_addr} 01"
  142. /set-var chk ${GPIN_format}${OK_resp}
  143. if ${response} != ${chk}
  144.    throw "ERROR: GPIN_format not equal"
  145. end
  146. #need to send protect
  147. /echo PROTECT
  148. /send ${PROTECT}
  149. if ${response} != '9000'
  150.      throw "ERROR IN PROTECT:" ${last.error} "Card can`t be fuse..."
  151. end
  152. #fuse:
  153. #
  154. /echo FUSE STEP:
  155. /send ${FUSE}
  156. if ${response} != '9000'
  157. throw "ERROR in FUSE" ${last.error}
  158. #end
  159. /clos