CM_RDCFG.c 947 B

12345678910111213141516171819202122232425262728293031323334
  1. // Read Configuration Zone
  2. //
  3. // CryptoMemory Library Include Files
  4. #include "CM_LIB.h"
  5. #include "CM_I2C.h"
  6. #include "CM_I2C_L.h"
  7. #include "CM_GPA.h"
  8. // Read Configuration Zone
  9. uint8_t cm_ReadConfigZone(uint8_t ucCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount)
  10. {
  11. uint8_t ucReturn, ucEncrypt;
  12. ucCM_InsBuff[0] = 0xb6;
  13. ucCM_InsBuff[1] = 0x00;
  14. ucCM_InsBuff[2] = ucCryptoAddr;
  15. ucCM_InsBuff[3] = ucCount;
  16. // Three bytes of the command must be included in the polynominals
  17. cm_GPAcmd2(ucCM_InsBuff);
  18. // Do the read
  19. if ((ucReturn = cm_ReadCommand(ucCM_InsBuff, pucBuffer, ucCount)) != SUCCESS) return ucReturn;
  20. // Only password zone is ever encrypted
  21. ucEncrypt = ((ucCryptoAddr>= CM_PSW) && ucCM_Encrypt);
  22. // Include the data in the polynominals and decrypt if required
  23. cm_GPAdecrypt(ucEncrypt, pucBuffer, ucCount);
  24. // Done
  25. return SUCCESS;
  26. }