全部博文(685)
分类: LINUX
2014-09-16 20:04:43
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;
}