123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #ifndef __CM_LIB_H__
- #define __CM_LIB_H__
- #include "com_IPMIDefs.h"
- #ifndef FALSE
- #define FALSE (0)
- #define TRUE (!FALSE)
- #endif
- #ifndef NULL
- #define NULL ((void *)0)
- #endif
- #define DCR_ADDR (0x18)
- #define DCR_SME (0x80)
- #define DCR_UCR (0x40)
- #define DCR_UAT (0x20)
- #define DCR_ETA (0x10)
- #define DCR_CS (0x0F)
- #define CM_Ci (0x50)
- #define CM_Sk (0x58)
- #define CM_G (0x90)
- #define CM_FAB (0x06)
- #define CM_CMA (0x04)
- #define CM_PER (0x00)
- #define CM_PSW (0xB0)
- #define CM_PWREAD (1)
- #define CM_PWWRITE (0)
- #define SUCCESS (0)
- #define FAILED (1)
- #define FAIL_CMDSTART (2)
- #define FAIL_CMDSEND (3)
- #define FAIL_WRDATA (4)
- #define FAIL_RDDATA (5)
- void cm_InitTwiPio(void);
- void cm_RestorPio(void);
- uint8_t cm_SelectChip(uint8_t ucChipId);
- uint8_t cm_ActiveSecurity(uint8_t ucKeySet, uint8_t * pucKey, uint8_t * pucRandom, uint8_t ucEncrypt);
- uint8_t cm_DeactiveSecurity(void);
- uint8_t cm_VerifyPassword(uint8_t * pucPassword, uint8_t ucSet, uint8_t ucRW);
- uint8_t cm_ResetPassword(void);
- #define cm_VerifySecureCode(CM_PW) cm_VerifyPassword(CM_PW, 7, CM_PWWRITE)
- uint8_t cm_ReadConfigZone(uint8_t ucCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount);
- uint8_t cm_WriteConfigZone(uint8_t ucCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount, uint8_t ucAntiTearing);
- uint8_t cm_SetUserZone(uint8_t ucZoneNumber, uint8_t ucAntiTearing);
- uint8_t cm_ReadLargeZone(uint32_t uiCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount);
- uint8_t cm_ReadSmallZone(uint8_t ucCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount);
- char cm_WriteLargeZone(uint32_t uiCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount);
- uint8_t cm_WriteSmallZone(uint8_t ucCryptoAddr, uint8_t * pucBuffer, uint8_t ucCount);
- uint8_t cm_SendChecksum(uint8_t * pucChkSum);
- uint8_t cm_ReadChecksum(uint8_t * pucChkSum);
- uint8_t cm_ReadFuse(uint8_t * pucFuze);
- uint8_t cm_BurnFuse(uint8_t ucFuze);
- void cm_InitTwiPio(void);
- void cm_RestorPio(void);
- void cm_InitCmVar(unsigned char Num);
- int cm_Auth_Encrp(void);
- typedef struct{
- uint8_t (*Carddetect)(void);
- void (*PowerOff)(void);
- void (*PowerOn)(void);
- uint8_t (*SendCommand)(uint8_t * pucCommandBuffer);
- uint8_t (*ReceiveRet)(uint8_t * pucReceiveData, uint8_t ucLength);
- uint8_t (*SendData)(uint8_t * pucSendData, uint8_t ucLength);
- void (*RandomGen)(uint8_t * pucRandomData);
- void (*WaitClock)(uint8_t ucLoop);
- uint8_t (*SendCmdByte)(uint8_t ucCommand);
- } cm_low_level;
- typedef struct{
- uint8_t ucChipSelect;
- uint8_t ucClockPort;
- uint8_t ucClockPin;
- uint8_t ucDataPort;
- uint8_t ucDataPin;
- uint8_t ucCardSensePort;
- uint8_t ucCardSensePin;
- uint8_t ucCardSensePolarity;
- uint8_t ucPowerPort;
- uint8_t ucPowerPin;
- uint8_t ucPowerPolarity;
- uint8_t ucDelayCount;
- uint8_t ucStartTries;
- } cm_port_cfg;
- extern cm_low_level CM_LOW_LEVEL;
- extern cm_port_cfg CM_PORT_CFG;
- extern uint8_t ucCM_Encrypt;
- extern uint8_t ucCM_Authenticate;
- extern uint8_t ucCM_UserZone;
- extern uint8_t ucCM_AntiTearing;
- extern uint8_t ucCM_InsBuff[4];
- uint8_t cm_Auth_Encrp_Init(uint8_t authMode,uint8_t pswMode,uint8_t encryptFlag);
- uint8_t test_cryptomem(void);
- uint8_t cm_Auth_Encrp_Write(uint8_t userZone,uint8_t startInZone,uint8_t* writeData,uint8_t writeLen);
- uint8_t cm_Auth_Encrp_Read(uint8_t userZone,uint8_t startInZone,uint8_t* readData,uint8_t readLen);
- uint8_t cm_Auth_Encrp_Personal(uint8_t pswMode,uint8_t authMode);
- #endif
|