搜索
bottom↓
回复: 12

ATSHA204 加密码IC驱动程序

  [复制链接]

出0入0汤圆

发表于 2014-4-15 17:12:14 | 显示全部楼层 |阅读模式
ATSHA204 加密码IC驱动程序

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出30入16汤圆

发表于 2021-9-22 13:56:37 来自手机 | 显示全部楼层
这个加密芯片应该对单片机没什么用,因为密码也要放到单片机里面。只要单片机一旦被解,加密芯片就没用了。

出0入0汤圆

发表于 2021-9-22 13:16:46 | 显示全部楼层
我也来学习一下,非常感谢

出0入0汤圆

发表于 2016-8-25 19:50:46 | 显示全部楼层
同志们,我们公司专门承接204A的烧录工作,量大优惠,呵呵    深圳   13530108906

出0入0汤圆

发表于 2016-1-7 14:56:25 | 显示全部楼层
公司刚要用这颗加密芯片,不知道破解容易吗?安全性怎么样。

出0入0汤圆

发表于 2015-10-22 09:57:07 | 显示全部楼层
guxingganyue 发表于 2014-4-15 20:23
Lz用这个芯片多久了呢

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

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

出0入0汤圆

发表于 2015-10-22 09:54:34 | 显示全部楼层
你好,我用stm32单片机作驱动,用了你的ATSHA204加密IC操作类,读不出数据,需要唤醒操作吗?

出0入4汤圆

发表于 2015-1-18 19:52:47 | 显示全部楼层
最近刚好要用到,谢谢。

出0入0汤圆

发表于 2014-12-30 16:24:51 | 显示全部楼层
不错,正在弄这个

出0入0汤圆

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

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

你的这个是自己写的?



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

顺便上传一个AES132的库:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

 楼主| 发表于 2014-4-16 14:20:50 | 显示全部楼层
guxingganyue 发表于 2014-4-15 20:23
Lz用这个芯片多久了呢

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

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

出0入0汤圆

发表于 2014-4-15 20:23:38 | 显示全部楼层
本帖最后由 guxingganyue 于 2014-4-15 20:25 编辑

Lz用这个芯片多久了呢

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

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



  1. void evaluate_ret_code(uint8_t ret_code)
  2. {
  3.   if ((ret_code == SHA204_PARSE_ERROR)
  4.         || (ret_code == SHA204_CMD_FAIL)
  5.         || (ret_code == SHA204_RX_FAIL))
  6.     // We got some kind of response. Return codes of
  7.     // SHA204_PARSE_ERROR and SHA204_CMD_FAIL indicate
  8.     // a consistent response whereas SHA204_RX_FAIL
  9.     // just indicates that we received some bytes,
  10.     // possibly garbled. In all these cases we put
  11.     // the device to sleep.
  12.     (void) sha204p_sleep();
  13. }


  14. /** \brief This function serves as an example for
  15. *         the SHA204 MAC command.
  16. *
  17. *         In an infinite loop, it issues the same command
  18. *         sequence using the Command Marshaling layer of
  19. *         the SHA204 library.
  20. * \return exit status of application
  21. */
  22. int main()
  23. {
  24.   volatile unsigned int i;
  25.   volatile unsigned no_exit = 1;
  26.   unsigned int loop_counter = 0;

  27.   // declared as "volatile" for easier debugging
  28.   volatile uint8_t ret_code;

  29.   // Make the command buffer the size of the MAC command.
  30.   static uint8_t command[MAC_COUNT_LONG];

  31.   // Make the response buffer the size of a MAC response.
  32.   static uint8_t response[MAC_RSP_SIZE];

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

  43.   // data for challenge in MAC mode 0 command
  44.   const uint8_t challenge[MAC_CHALLENGE_SIZE] =
  45.   {
  46.     0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
  47.     0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
  48.     0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
  49.     0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
  50.   };


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

  55.   // Initialize the hardware interface.
  56.   sha204p_init();

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

  63.     for (i = 0; i < sizeof(response); i++)
  64.       response[i] = 0;

  65.     // Wake up the device.
  66.     printf("\nLoop counter: %u\nWakeup\n", loop_counter++);
  67.     ret_code = sha204c_wakeup(&response[0]);
  68.     if (ret_code != SHA204_SUCCESS)
  69.     {
  70.       fputs("No response\n", stdout);
  71.       continue;
  72.     }
  73.     fputs("Response: ", stdout);
  74.     TRACE_DumpFrame(&response[0], response[SHA204_COUNT_IDX]);

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

  78.     fputs("Command: ", stdout);
  79.     TRACE_DumpFrame(&command[0], command[SHA204_COUNT_IDX]);
  80.     fputs("Response ", stdout);

  81.     if (ret_code != SHA204_SUCCESS)
  82.     {
  83.       fputs(" error: ", stdout);
  84.       if (response[SHA204_COUNT_IDX] > 0)
  85.         TRACE_DumpFrame(&response[0], response[SHA204_COUNT_IDX]);
  86.       else
  87.         fputs("\n", stdout);
  88.       evaluate_ret_code(ret_code);
  89.       continue;
  90.     }
  91.     fputs(": ", stdout);
  92.     TRACE_DumpFrame(&response[0], response[SHA204_COUNT_IDX]);

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

  96.     // Compare returned MAC with expected one.
  97.     ret_code = SHA204_SUCCESS;
  98.     for (i = 0; i < SHA204_RSP_SIZE_MAX; i++)
  99.     {
  100.       if (response[i] != mac_mode0_response_expected[i])
  101.       {
  102.         fputs("Response does not match expected response: ", stdout);
  103.         TRACE_DumpFrame((uint8_t *) &mac_mode0_response_expected[0], mac_mode0_response_expected[SHA204_COUNT_IDX]);
  104.         ret_code = SHA204_GEN_FAIL;
  105.       }
  106.     }

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

复制代码

出0入0汤圆

发表于 2014-4-15 18:29:24 | 显示全部楼层
学习学习、、、
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 18:40

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表