Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3115220
  • 博文数量: 685
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5303
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-19 14:17
个人简介

文章分类

全部博文(685)

文章存档

2015年(116)

2014年(569)

分类: LINUX

2014-09-16 20:04:43

#include
#include

 

int main(void)
{
    uint8_t slot2_key[32] = {0};
    uint8_t slot4_val[32] = {0};

    DECRYPT(des_key, slot2_key, slot2_key_enc, 32);
    DECRYPT(des_key, slot4_val, slot4_val_enc, 32);

    uint8_t lock_stat[2];
    atsha204_lock_statue(lock_stat);
    if((lock_stat[0] != 0x00) || (lock_stat[1] != 0x00)){
        //printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ATSHA204 unlocked, cannot read data...\n");
        //内核在启动过程中是无法用printf打印出信息的。
       system("echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ATSHA204 unlocked, cannot read data... > /dev/console");
        goto reboot;
    }

    int ret = 0;
 int loop = 0;
    uint8_t data[32] = {0};
 for(loop=0;loop<20;loop++)
 {
  ret = atsha204_data_encrypted_read(SLOT_4_ADDRESS, KEY_ID_2, slot2_key, data);
  if(memcmp(slot4_val, data, 32) != 0)
   continue;
  if(loop <= 20)
   break;
 }
 if(loop >= 20)
 {
  system("echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!read slot4 data failed! > /dev/console");
  loop = 0;
        goto reboot;
 }
 
 loop = 0;
    printf("ATSHA204 encrypted...\n");
    return 0;

reboot:
 system("echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!reboot because of hw enc > /dev/console");
    system("reboot");
    return -1;
}

阅读(1528) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~