CM_TEST.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. #include <stdio.h>
  2. #define CM_LIB_GLOBALES
  3. #define EXTERNMACRO 2
  4. #include "CM_LIB.h"
  5. #include "CM_I2C.h"
  6. #include "CM_I2C_L.h"
  7. #include <string.h>
  8. #include <stdio.h>
  9. uint8_t ucData[16], ucCi[8], ucSk[8];
  10. // Zone Data
  11. uint8_t ucCM_UserZone;
  12. uint8_t ucCM_AntiTearing;
  13. // Chip state
  14. uint8_t ucCM_Encrypt;
  15. uint8_t ucCM_Authenticate;
  16. // Global data
  17. uint8_t ucCM_InsBuff[4];
  18. uint8_t authenticationModeFlag = 0;
  19. uint8_t passwordModeFlag = 0;
  20. uint8_t encryptModeFlag = 0;
  21. uint8_t errorGlobalFlag = 0;
  22. //default : four user zone use Secret Seed G1 and password write/read 1(all use set 1)
  23. //Secret Seed : it's used by cm_ActiveSecurity
  24. uint8_t ucG[8] = {0x22,0x23,0x34,0x45,0x56,0x67,0x78,0x89};
  25. //passworkd for write : it's used by cm_VerifyPassword
  26. uint8_t psword_w[3] = {0x22,0x34,0x56};
  27. //passworkd for read : it's used by cm_VerifyPassword
  28. uint8_t psword_r[3] = {0x88,0x9a,0xbc};
  29. uint8_t psword_7[3] = {0xDD, 0x77, 0x99};
  30. uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode)
  31. {
  32. uint8_t ucReturn;
  33. uint8_t pwData[8] = {0};
  34. uint8_t seedData[8] = {0};
  35. uint8_t fab_id = 0x06;
  36. uint8_t cma_id = 0x04;
  37. uint8_t per_id = 0x00;
  38. uint8_t fuseData;
  39. int i;
  40. uint8_t configAll[240] = {0};
  41. printf("---> cm_Auth_Encrp_Personal start...\n");
  42. //read fuse
  43. cm_ReadFuse(&fuseData);
  44. if (ucReturn != SUCCESS)
  45. {
  46. printf("cm_ReadFuse is error\n");
  47. errorGlobalFlag = 12;
  48. }
  49. if(fuseData == 0x00)
  50. {
  51. printf("FAB,CMA,PER------three fuse has burnned! Exit cm_Auth_Encrp_Personal!\n");
  52. return 0;
  53. }
  54. printf("---> fuseData %#x\n", fuseData);
  55. uint8_t pwwr7[3] = {0xDD, 0x42, 0x97};
  56. ucReturn = cm_VerifySecureCode(pwwr7);
  57. if (ucReturn != SUCCESS)
  58. {
  59. ucReturn = cm_VerifySecureCode(psword_7);
  60. if (ucReturn != SUCCESS)
  61. {
  62. printf("cm_VerifySecureCode 1 is error\n");
  63. errorGlobalFlag = 15;
  64. /************ Read all configs *******************/
  65. memset(configAll, 0, 240);
  66. ucReturn = cm_ReadConfigZone(0x00,configAll,240);
  67. if (ucReturn != SUCCESS)
  68. {
  69. printf("cm_ReadConfigZone all is error\n");
  70. errorGlobalFlag = 13;
  71. }
  72. else
  73. {
  74. printf("======== Configure Memory =========");
  75. for(i=0;i<240;i++)
  76. {
  77. if(i%8 == 0) printf("\n%04x: ", i);
  78. printf("%02X ", configAll[i]);
  79. }
  80. printf("\n");
  81. }
  82. return -1;
  83. }
  84. printf("---> used psword_7: %#x %#x %#x\n", psword_7[0], psword_7[1], psword_7[2]);
  85. }
  86. // ----------------------------------------------write card mfg code 0x50 30 30 31
  87. usleep(100);
  88. uint8_t cmc[4] = {0x50,0x30,0x30,0x31};
  89. ucReturn = cm_WriteConfigZone(0x0C, cmc, 4, FALSE);
  90. if (ucReturn != SUCCESS)
  91. {
  92. printf("cm_WriteConfigZone 0x0C is error\n");
  93. errorGlobalFlag = 2;
  94. return -1;
  95. }
  96. // ----------------------------------------------Write Identification Number = 00000000012345
  97. usleep(100);
  98. uint8_t idnum[7] = {0x00,0x00,0x00,0x00,0x01,0x23,0x45};
  99. ucReturn = cm_WriteConfigZone(0x19, idnum, 7, FALSE);
  100. if (ucReturn != SUCCESS)
  101. {
  102. printf("cm_WriteConfigZone 0x19 is error\n");
  103. errorGlobalFlag = 3;
  104. return -1;
  105. }
  106. // ----------------------------------------------Write Issuer Code = STATION 035
  107. usleep(100);
  108. uint8_t issue[16] = {0x53,0x54,0x41,0x54,0x49,0x4F,0x4E,0x20,0x30,0x33,0x35,0x00,0x00,0x00,0x00,0x00};
  109. ucReturn = cm_WriteConfigZone(0x40, issue, 16, FALSE);
  110. if (ucReturn != SUCCESS)
  111. {
  112. printf("cm_WriteConfigZone 0x40 is error\n");
  113. errorGlobalFlag = 4;
  114. return -1;
  115. }
  116. //---------------------------------------------config all user zone use the same password/seed of the set 1
  117. // ---------------------------------------------Write Control for user zone 0
  118. usleep(100);
  119. ucData[0] = ((pswMode & 0x03) << 6) | ((authMode & 0x3) << 4) | 0x07; // AR[0-3] = 0101 0111 ---->
  120. //01 ----> after Authentication successful ,then write correct password
  121. //01 ----> the read and write need to Authentication
  122. //1 ----> the host access(read/write) user zone use encryption mode(set 0 lead to unlock config zone error,i dont know why?)
  123. //111----> the default data
  124. ucData[1] = 0x51;//Authentication set 1, POM set 1, Key 1 //PR[0-3] = 0101 0001
  125. //01 ----> the secret seed select set 1(secret seed zone)
  126. //01 ----> the POK select set 1(secret seed zone)
  127. //0001 ----> the password select set 1(password zone)
  128. ucReturn = cm_WriteConfigZone(0x20, ucData, 2, FALSE);
  129. if (ucReturn != SUCCESS)
  130. {
  131. printf("cm_WriteConfigZone 0x20 is error\n");
  132. errorGlobalFlag = 5;
  133. return -1;
  134. }
  135. // ---------------------------------------------Write Control for user zone 1
  136. usleep(100);
  137. ucReturn = cm_WriteConfigZone(0x22, ucData, 2, FALSE);
  138. if (ucReturn != SUCCESS)
  139. {
  140. printf("cm_WriteConfigZone 0x22 is error\n");
  141. errorGlobalFlag = 6;
  142. return -1;
  143. }
  144. // ---------------------------------------------Write Control for user zone 2
  145. usleep(100);
  146. ucReturn = cm_WriteConfigZone(0x24, ucData, 2, FALSE);
  147. if (ucReturn != SUCCESS)
  148. {
  149. printf("cm_WriteConfigZone 0x24 is error\n");
  150. errorGlobalFlag = 7;
  151. return -1;
  152. }
  153. // ---------------------------------------------Write Control for user zone 3
  154. usleep(100);
  155. ucReturn = cm_WriteConfigZone(0x26, ucData, 2, FALSE);
  156. if (ucReturn != SUCCESS)
  157. {
  158. printf("cm_WriteConfigZone 0x26 is error\n");
  159. errorGlobalFlag = 8;
  160. return -1;
  161. }
  162. //----------------------------------------------Set DCR to allow unlimited checksum reads
  163. usleep(100);
  164. ucData[0] = 0xff;//after finish personal chip , must recover to the default
  165. // ucData[0] = 0xbf;//set unlimited checksum reads, Unlimited Authentication Trials,Eight Trials Allowed during debug for avoid the chip lock dead (why config 0x8f is error)
  166. ucReturn = cm_WriteConfigZone(0x18, ucData, 1, FALSE);
  167. if (ucReturn != SUCCESS)
  168. {
  169. printf("cm_WriteConfigZone 0x18 is error\n");
  170. errorGlobalFlag = 9;
  171. return -1;
  172. }
  173. //---------------------------------------------- Write Ci1
  174. usleep(100);
  175. ucCi[0] = 0xFF;
  176. ucCi[1] = 0x01;
  177. ucCi[2] = 0x02;
  178. ucCi[3] = 0x03;
  179. ucCi[4] = 0x04;
  180. ucCi[5] = 0x05;
  181. ucCi[6] = 0x06;
  182. ucCi[7] = 0x07;
  183. ucReturn = cm_WriteConfigZone(0x60, ucCi, 8, FALSE);
  184. if (ucReturn != SUCCESS)
  185. {
  186. printf("cm_WriteConfigZone 0x60 is error\n");
  187. errorGlobalFlag = 10;
  188. return -1;
  189. }
  190. // ------------------------------------------------Write G1
  191. usleep(100);
  192. // user must set and remember this secret for Secret Seed,then must be same whih cm_Auth_Encrp_rw before access to user zone for write or read .
  193. seedData[0] = ucG[0];
  194. seedData[1] = ucG[1];
  195. seedData[2] = ucG[2];
  196. seedData[3] = ucG[3];
  197. seedData[4] = ucG[4];
  198. seedData[5] = ucG[5];
  199. seedData[6] = ucG[6];
  200. seedData[7] = ucG[7];
  201. ucReturn = cm_WriteConfigZone(0x98, seedData, 8, FALSE);
  202. if (ucReturn != SUCCESS)
  203. {
  204. printf("cm_WriteConfigZone 0x98 is error\n");
  205. errorGlobalFlag = 11;
  206. return -1;
  207. }
  208. //--------------------------------------------- Write PSW1 (both Write and Read)
  209. usleep(100);
  210. // user must set and remember this secret for password for write/read.then must be same whih cm_Auth_Encrp_rw before access to user zone for write or read .
  211. pwData[0] = 0xFF;
  212. pwData[1] = psword_w[0];
  213. pwData[2] = psword_w[1];
  214. pwData[3] = psword_w[2];
  215. pwData[4] = 0xFF;
  216. pwData[5] = psword_r[0];
  217. pwData[6] = psword_r[1];
  218. pwData[7] = psword_r[2];
  219. ucReturn = cm_WriteConfigZone(0xB8, pwData, 8, FALSE);
  220. if (ucReturn != SUCCESS)
  221. {
  222. printf("cm_WriteConfigZone 0xB8 is error\n");
  223. errorGlobalFlag = 12;
  224. return -1;
  225. }
  226. //--------------------------------------------- Write PSW7 (only Write)
  227. usleep(100);
  228. pwData[0] = 0xFF;
  229. pwData[1] = psword_7[0];
  230. pwData[2] = psword_7[1];
  231. pwData[3] = psword_7[2];
  232. ucReturn = cm_WriteConfigZone(0xE8, pwData, 4, FALSE);
  233. if (ucReturn != SUCCESS)
  234. {
  235. printf("cm_WriteConfigZone 0xE8 is error\n");
  236. errorGlobalFlag = 13;
  237. return -1;
  238. }
  239. #if 1
  240. usleep(1000);
  241. ucReturn = cm_BurnFuse(fab_id);
  242. if (ucReturn != SUCCESS)
  243. {
  244. printf("cm_BurnFuse fab_id is error\n");
  245. errorGlobalFlag = 12;
  246. }
  247. usleep(1000);
  248. ucReturn = cm_BurnFuse(cma_id);
  249. if (ucReturn != SUCCESS)
  250. {
  251. printf("cm_BurnFuse cma_id is error\n");
  252. errorGlobalFlag = 12;
  253. }
  254. usleep(1000);
  255. ucReturn = cm_BurnFuse(per_id);
  256. if (ucReturn != SUCCESS)
  257. {
  258. printf("cm_BurnFuse per_id is error\n");
  259. errorGlobalFlag = 12;
  260. }
  261. #endif
  262. usleep(1000);
  263. //read fuse
  264. cm_ReadFuse(&fuseData);
  265. if (ucReturn != SUCCESS)
  266. {
  267. printf("cm_ReadFuse is error\n");
  268. errorGlobalFlag = 12;
  269. }
  270. if(fuseData == 0x00)
  271. {
  272. printf("FAB,CMA,PER------three fuse are burnned successful\n");
  273. }
  274. /************ Read all configs *******************/
  275. memset(configAll, 0, 240);
  276. ucReturn = cm_ReadConfigZone(0x00,configAll,240);
  277. if (ucReturn != SUCCESS)
  278. {
  279. printf("cm_ReadConfigZone all is error\n");
  280. errorGlobalFlag = 13;
  281. }
  282. else
  283. {
  284. printf("======== Configure Memory =========");
  285. for(i=0;i<240;i++)
  286. {
  287. if(i%8 == 0) printf("\n%04x: ", i);
  288. printf("%02X ", configAll[i]);
  289. }
  290. printf("\n");
  291. }
  292. if(errorGlobalFlag != 0)
  293. return FAILED;
  294. printf("---> cm_Auth_Encrp_Personal successful!\n");
  295. return SUCCESS;
  296. }
  297. /*
  298. *FUNC: To init the chip of AT88SCxxx
  299. *
  300. *PARAM:
  301. * authMode :
  302. * 3 : close Authentication mode;
  303. * 2 : write Authentication mode;
  304. * 1 : normal Authentication mode;
  305. * 0 : dual access mode;
  306. *
  307. * pswMode :
  308. * 3 : close password mode;
  309. * 2 : write password mode;
  310. * 0/1 : read and write password mode;
  311. *
  312. * encryptFlag :
  313. * TRUE : enable encrypt mode
  314. * FALSE : disable encrypt mode
  315. *
  316. */
  317. uint8_t cm_Auth_Encrp_Init(uint8_t authMode,uint8_t pswMode,uint8_t encryptFlag)
  318. {
  319. uint8_t ucReturn;
  320. uint8_t fuseData;
  321. int i;
  322. uint8_t ucData[4] = {0};
  323. uint8_t configAll[240] = {0};
  324. #if 0
  325. //init I2C pin
  326. GPIO_InitTypeDef GPIO_InitStruct;
  327. GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_5;
  328. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
  329. GPIO_InitStruct.Pull = GPIO_PULLUP;
  330. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  331. stm32_gpio_init(GPIOE, &GPIO_InitStruct);
  332. #endif
  333. if(pswMode == 0x0 || pswMode == 0x1)
  334. passwordModeFlag = 1;
  335. else if(pswMode == 0x2)
  336. passwordModeFlag = 2;
  337. else
  338. passwordModeFlag = 0;
  339. if(authMode == 0)
  340. authenticationModeFlag = 0;
  341. else if(authMode == 1)
  342. authenticationModeFlag = 1;
  343. else if(authMode == 2)
  344. authenticationModeFlag = 2;
  345. else if(authMode == 3)
  346. authenticationModeFlag = 3;
  347. if(encryptFlag == TRUE)
  348. encryptModeFlag = 1;
  349. else
  350. encryptModeFlag = 0;
  351. cm_PowerOn();
  352. /**************** Check AT88SC0104C Present******************/
  353. ucData[0] = 0x5A;
  354. ucData[1] = 0xA5;
  355. ucReturn = cm_WriteConfigZone(0x0A, ucData, 2, FALSE);
  356. if (ucReturn != SUCCESS)
  357. {
  358. printf("cm_WriteConfigZone 0x0a is error\n");
  359. errorGlobalFlag = 1;
  360. }
  361. usleep(100); //这个延时很重要,AT88SC0104C处理数据相当的慢。
  362. // Read back data
  363. ucData[0] = 0x00;
  364. ucData[1] = 0x00;
  365. ucReturn = cm_ReadConfigZone(0x0A, ucData, 2);
  366. if (ucReturn != SUCCESS)
  367. {
  368. printf("cm_ReadConfigZone 0x0a is error\n");
  369. errorGlobalFlag = 1;
  370. }
  371. if ((ucData[0]!= 0x5A) || (ucData[1]!= 0xA5) )
  372. {
  373. printf("read back data is not same\n");
  374. errorGlobalFlag = 1;
  375. }
  376. if(errorGlobalFlag != 0)
  377. {
  378. printf("there is a error and the flag = %d,the poweroff\n",errorGlobalFlag);
  379. cm_PowerOff();
  380. return FAILED;
  381. }
  382. return ucReturn;
  383. }
  384. /*
  385. *cm_WR:
  386. * 0 : read
  387. * 1 : write
  388. *userZone:
  389. * select need to access the index of user zone in range of 0-3
  390. *startInZone:
  391. * the start location in user zone for user operation of write/read,and the default data is 0
  392. *pData:
  393. * the data buffer for store the write/read data
  394. *dataLen:
  395. * the byte number of write/read
  396. *
  397. */
  398. uint8_t cm_Auth_Encrp_rw(uint8_t cm_WR,uint8_t userZone,uint8_t startInZone,uint8_t *pData,uint8_t dataLen)
  399. {
  400. uint8_t ucReturn;
  401. int i;
  402. uint8_t userZoneTemp = userZone & 0x03;
  403. uint8_t seedSet = 1;//which set of Secret Seed
  404. uint8_t pwset = 1;//which set of password for write/read
  405. //if(authenticationModeFlag == 0 || authenticationModeFlag == 1 || authenticationModeFlag == 2 || authenticationModeFlag == 3)//all to authenticate
  406. {
  407. if(encryptModeFlag == 1)
  408. {
  409. ucReturn = cm_ActiveSecurity(seedSet, ucG, NULL, TRUE);
  410. }
  411. else
  412. {
  413. ucReturn = cm_ActiveSecurity(seedSet, ucG, NULL, FALSE);
  414. }
  415. }
  416. if (ucReturn != SUCCESS)
  417. {
  418. printf("cm_ActiveSecurity is error\n");
  419. return FAILED;
  420. }
  421. ucReturn = cm_SetUserZone(userZoneTemp, FALSE);
  422. if (ucReturn != SUCCESS)
  423. {
  424. printf("cm_SetUserZone is error\n");
  425. return FAILED;
  426. }
  427. if(passwordModeFlag == 3)
  428. {
  429. if(cm_WR==0)
  430. {
  431. // Read back data
  432. for (i = 0; i < dataLen; ++i)
  433. pData[i] = 0x00; //clear pData
  434. ucReturn = cm_ReadSmallZone(startInZone, pData, dataLen);
  435. if (ucReturn != SUCCESS)
  436. {
  437. printf("cm_ReadSmallZone is error\n");
  438. return FAILED;
  439. }
  440. }
  441. else
  442. {
  443. // Write data to user zone
  444. ucReturn = cm_WriteSmallZone(startInZone, pData, dataLen);
  445. if (ucReturn != SUCCESS)
  446. {
  447. printf("cm_WriteSmallZone is error\n");
  448. return FAILED;
  449. }
  450. // Send checksum
  451. ucReturn = cm_SendChecksum(NULL);
  452. if (ucReturn != SUCCESS)
  453. {
  454. printf("cm_SendChecksum is error\n");
  455. return FAILED;
  456. }
  457. }
  458. }
  459. else //(passwordModeFlag == 1 || passwordModeFlag == 2)
  460. {
  461. ucCM_Authenticate = TRUE;
  462. if(cm_WR==0)
  463. {
  464. // Read back data, firstly verify the read password
  465. ucReturn=cm_VerifyPassword(psword_r,pwset,CM_PWREAD);
  466. if (ucReturn != SUCCESS)
  467. {
  468. printf("cm_VerifyPassword is error\n");
  469. return FAILED;
  470. }
  471. for (i = 0; i < dataLen; ++i)
  472. pData[i] = 0x00; //clear pData
  473. ucReturn = cm_ReadSmallZone(startInZone, pData, dataLen);
  474. if (ucReturn != SUCCESS)
  475. {
  476. printf("cm_ReadSmallZone is error\n");
  477. return FAILED;
  478. }
  479. ucReturn =cm_ReadChecksum(NULL);
  480. if (ucReturn != SUCCESS)
  481. {
  482. printf("cm_ReadChecksum is error\n");
  483. return FAILED;
  484. }
  485. }
  486. else
  487. {
  488. // Write data to user zone,firstly verify the write password
  489. ucReturn=cm_VerifyPassword(psword_w,pwset,CM_PWWRITE);
  490. if (ucReturn != SUCCESS)
  491. {
  492. printf("cm_VerifyPassword is error\n");
  493. return FAILED;
  494. }
  495. ucReturn = cm_WriteSmallZone(startInZone, pData, dataLen);
  496. if (ucReturn != SUCCESS)
  497. {
  498. printf("cm_WriteSmallZone is error\n");
  499. return FAILED;
  500. }
  501. // Send checksum
  502. ucReturn = cm_SendChecksum(NULL);
  503. if (ucReturn != SUCCESS)
  504. {
  505. printf("cm_SendChecksum is error\n");
  506. return FAILED;
  507. }
  508. }
  509. }
  510. ucReturn = cm_DeactiveSecurity();
  511. if (ucReturn != SUCCESS)
  512. {
  513. printf("cm_DeactiveSecurity is error\n");
  514. return FAILED;
  515. }
  516. return SUCCESS;
  517. }
  518. uint8_t cm_Auth_Encrp_Read(uint8_t userZone,uint8_t startInZone,uint8_t* readData,uint8_t readLen)
  519. {
  520. uint8_t returnData = 0;
  521. returnData = cm_Auth_Encrp_rw(0,userZone,startInZone,readData,readLen);
  522. if(returnData != SUCCESS)
  523. return FAILED;
  524. else
  525. return SUCCESS;
  526. }
  527. uint8_t cm_Auth_Encrp_Write(uint8_t userZone,uint8_t startInZone,uint8_t* writeData,uint8_t writeLen)
  528. {
  529. uint8_t returnData = 0;
  530. returnData = cm_Auth_Encrp_rw(1,userZone,startInZone,writeData,writeLen);
  531. if(returnData != SUCCESS)
  532. return FAILED;
  533. else
  534. return SUCCESS;
  535. }
  536. uint8_t test_cryptomem(void)
  537. {
  538. uint8_t readData[16] = {0};
  539. uint8_t readLen = 16;
  540. uint8_t writeData[16] = {0};
  541. uint8_t writeLen = 16;
  542. uint8_t i;
  543. uint8_t returnData;
  544. uint8_t userZone = 1;//user need to access the index of user zone
  545. uint8_t startInZone = 0;//the start location of x user zone for write/read
  546. // returnData = cm_Auth_Encrp_Init(1,1,TRUE);
  547. // if(returnData != SUCCESS)
  548. // {
  549. // printf("cm_Auth_Encrp_Init is error\n");
  550. // return FAILED;
  551. // }
  552. // printf("Write: \n");
  553. for(i=0;i<writeLen;i++)
  554. {
  555. writeData[i] = '6' + i;
  556. // printf("%#x ", writeData[i]);
  557. }
  558. // printf("\n");
  559. returnData = cm_Auth_Encrp_Write(userZone,startInZone,writeData,writeLen);
  560. if(returnData != SUCCESS)
  561. {
  562. printf("cm_Auth_Encrp_Read is error\n");
  563. return FAILED;
  564. }
  565. usleep(100);
  566. returnData = cm_Auth_Encrp_Read(userZone,startInZone,readData,readLen);
  567. if(returnData != SUCCESS)
  568. {
  569. printf("cm_Auth_Encrp_Read is error\n");
  570. return FAILED;
  571. }
  572. printf("Crypto Check ok!\n");
  573. return SUCCESS;
  574. }