xiechenglin 发表于 2014-4-15 17:12:14

ATSHA204 加密码IC驱动程序

ATSHA204 加密码IC驱动程序

洞洞幺 发表于 2021-9-22 13:56:37

这个加密芯片应该对单片机没什么用,因为密码也要放到单片机里面。只要单片机一旦被解,加密芯片就没用了。

happy429 发表于 2021-9-22 13:16:46

我也来学习一下,非常感谢

897152237 发表于 2016-8-25 19:50:46

同志们,我们公司专门承接204A的烧录工作,量大优惠,呵呵    深圳   13530108906

jerry_chao 发表于 2016-1-7 14:56:25

公司刚要用这颗加密芯片,不知道破解容易吗?安全性怎么样。

sober 发表于 2015-10-22 09:57:07

guxingganyue 发表于 2014-4-15 20:23
Lz用这个芯片多久了呢

最近发现密码有时校验不过去,连续多次都不行,然后断电后再试就可以了


能分享下吗,我也正在做,用的是stm32单片机。

sober 发表于 2015-10-22 09:54:34

你好,我用stm32单片机作驱动,用了你的ATSHA204加密IC操作类,读不出数据,需要唤醒操作吗?

cnshibo 发表于 2015-1-18 19:52:47

最近刚好要用到,谢谢。

linuxmake 发表于 2014-12-30 16:24:51

不错,正在弄这个

guxingganyue 发表于 2014-4-16 18:36:43

xiechenglin 发表于 2014-4-16 14:20
有两年了,一直没有总是,你可以用我附件中的代码测试一下,我用的也是IO口模拟I2C,有两个DELAY函数要准 ...

嗯,我看了你的函数,好像和官方给的库不一样。

你的这个是自己写的?



下面是ATSHA204官方给的库+例程:

顺便上传一个AES132的库:

xiechenglin 发表于 2014-4-16 14:20:50

guxingganyue 发表于 2014-4-15 20:23
Lz用这个芯片多久了呢

最近发现密码有时校验不过去,连续多次都不行,然后断电后再试就可以了


有两年了,一直没有总是,你可以用我附件中的代码测试一下,我用的也是IO口模拟I2C,有两个DELAY函数要准确。

guxingganyue 发表于 2014-4-15 20:23:38

本帖最后由 guxingganyue 于 2014-4-15 20:25 编辑

Lz用这个芯片多久了呢

最近发现密码有时校验不过去,连续多次都不行,然后断电后再试就可以了

IIC用的模拟的,下面是测试代码,官方给的。



void evaluate_ret_code(uint8_t ret_code)
{
if ((ret_code == SHA204_PARSE_ERROR)
      || (ret_code == SHA204_CMD_FAIL)
      || (ret_code == SHA204_RX_FAIL))
    // We got some kind of response. Return codes of
    // SHA204_PARSE_ERROR and SHA204_CMD_FAIL indicate
    // a consistent response whereas SHA204_RX_FAIL
    // just indicates that we received some bytes,
    // possibly garbled. In all these cases we put
    // the device to sleep.
    (void) sha204p_sleep();
}


/** \brief This function serves as an example for
*         the SHA204 MAC command.
*
*         In an infinite loop, it issues the same command
*         sequence using the Command Marshaling layer of
*         the SHA204 library.
* \return exit status of application
*/
int main()
{
volatile unsigned int i;
volatile unsigned no_exit = 1;
unsigned int loop_counter = 0;

// declared as "volatile" for easier debugging
volatile uint8_t ret_code;

// Make the command buffer the size of the MAC command.
static uint8_t command;

// Make the response buffer the size of a MAC response.
static uint8_t response;

   // expected MAC response in mode 0
static const uint8_t mac_mode0_response_expected =
{
    MAC_RSP_SIZE,                                 // count
    0x06, 0x67, 0x00, 0x4F, 0x28, 0x4D, 0x6E, 0x98,
    0x62, 0x04, 0xF4, 0x60, 0xA3, 0xE8, 0x75, 0x8A,
    0x59, 0x85, 0xA6, 0x79, 0x96, 0xC4, 0x8A, 0x88,
    0x46, 0x43, 0x4E, 0xB3, 0xDB, 0x58, 0xA4, 0xFB,
    0xE5, 0x73                                       // CRC
};

// data for challenge in MAC mode 0 command
const uint8_t challenge =
{
    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
    0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
    0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
};


TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
printf("-- SHA204 Library Example Derived from Basic TWI EEPROM Project %s --\n\r", SOFTPACK_VERSION);
printf("-- %s\n\r", BOARD_NAME);
printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

// Initialize the hardware interface.
sha204p_init();

while (no_exit)
{
    // The following code sequence wakes up the device,
    // issues a MAC command in mode 0
    // using the Command Marshaling layer, and puts
    // the device to sleep.

    for (i = 0; i < sizeof(response); i++)
      response = 0;

    // Wake up the device.
    printf("\nLoop counter: %u\nWakeup\n", loop_counter++);
    ret_code = sha204c_wakeup(&response);
    if (ret_code != SHA204_SUCCESS)
    {
      fputs("No response\n", stdout);
      continue;
    }
    fputs("Response: ", stdout);
    TRACE_DumpFrame(&response, response);

    // Mac command with mode = 0.
    ret_code = sha204m_execute(SHA204_MAC, 0, 0, MAC_CHALLENGE_SIZE, (uint8_t *) challenge,
          0, NULL, 0, NULL, sizeof(command), &command, sizeof(response), &response);

    fputs("Command: ", stdout);
    TRACE_DumpFrame(&command, command);
    fputs("Response ", stdout);

    if (ret_code != SHA204_SUCCESS)
    {
      fputs(" error: ", stdout);
      if (response > 0)
      TRACE_DumpFrame(&response, response);
      else
      fputs("\n", stdout);
      evaluate_ret_code(ret_code);
      continue;
    }
    fputs(": ", stdout);
    TRACE_DumpFrame(&response, response);

    // Put device to sleep.
    ret_code = sha204p_sleep();
    fputs("Sleep\n", stdout);

    // Compare returned MAC with expected one.
    ret_code = SHA204_SUCCESS;
    for (i = 0; i < SHA204_RSP_SIZE_MAX; i++)
    {
      if (response != mac_mode0_response_expected)
      {
      fputs("Response does not match expected response: ", stdout);
      TRACE_DumpFrame((uint8_t *) &mac_mode0_response_expected, mac_mode0_response_expected);
      ret_code = SHA204_GEN_FAIL;
      }
    }

    // Wait for some time so trace data are not just flying by.
    for (i = 0; i < 4; i++)
      delay_ms(250);
}
return (int) ret_code;
}

湛泸骏驰 发表于 2014-4-15 18:29:24

学习学习、、、
页: [1]
查看完整版本: ATSHA204 加密码IC驱动程序