|
发表于 2009-12-8 19:53:59
|
显示全部楼层
保护知识产权,与国于民是有利的,从长远来说也是必须的,看过CCTV大国崛起中"英国"这一篇,就有这个感觉。
该芯片用于AVR加密:
CryptoMemory Development Library for AVR core (WinAVR-20090313) (2 MB)
For AVR core (WinAVR-20090313).
下载
http://www.atmel.com/dyn/resources/prod_documents/lib_CM-WinAVR20090313-090513.exe
安装后的文件列表
C:\Atmel\EmbeddedCrypto\DevLib\AVR\WinAVR-20090313 的目录
2009-12-08 16:39 <DIR> .
2009-12-08 16:39 <DIR> ..
2007-12-04 10:33 300,318 Cmem.ico
2009-05-12 10:07 3,406 Example.c
2009-12-08 16:39 <DIR> libref
2009-05-13 09:40 25,050 lib_CM.a
2009-05-12 09:02 56,791 lib_Crypto.h
2009-05-12 09:02 19,397 lib_Support.c
2008-12-19 15:50 8,821 ll_port.c
2008-12-19 15:49 2,826 ll_port.h
2009-05-13 11:22 1,263 README-AVR.txt
8 个文件 417,872 字节
这是其中的Example.c
#include <stdio.h>
#include "ll_port.h"
#include <lib_Crypto.h>
#define DEFAULT_ADDRESS 0xb ///< Default address for CryptoMemory devices
void main(void){
unsigned char ucData[16], ucG[8];
unsigned char i;
RETURN_CODE ucReturn;
ll_PowerOn();
if( cm_Init() == SUCCESS) // Initialize the CM
printf("CM Init Success...\n");
else
printf("CM Init Failed !!!\n");
printf("Library Version is: %s\n", getLibVersNum());
printf("\n");
// Test write config zone
ucData[0] = 0x5A;
ucData[1] = 0xA5;
printf("Write MTZ\n");
ucReturn = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x0A, ucData, 2, FALSE);
if (ucReturn != SUCCESS) printf("fail\n");
// Test Read config zone
ucData[0] = 0x00;
ucData[1] = 0x00;
printf("Read MTZ\n");
ucReturn = cm_ReadConfigZone(DEFAULT_ADDRESS, 0x0A, ucData, 2);
if (ucReturn != SUCCESS) printf("fail\n");
// Test write config zone w/a-t
ucData[0] = 0x5A;
ucData[1] = 0xA5;
printf("Write MTZ w/a-t\n");
ucReturn = cm_WriteConfigZone(DEFAULT_ADDRESS, 0x0A, ucData, 2, TRUE);
if (ucReturn != SUCCESS) printf("fail\n");
// Verify Read password 0
for (i = 0; i < 3; ++i) ucData = 0xFF;
ucReturn = cm_VerifyPassword(DEFAULT_ADDRESS, ucData,0, 1);
if (ucReturn != SUCCESS) printf("fail\n");
// Verify Write password 0
ucData[0] = 0xFF;
ucData[1] = 0xFF;
ucData[2] = 0xFF;
ucReturn = cm_VerifyPassword(DEFAULT_ADDRESS, ucData,0, 0);
if (ucReturn != SUCCESS) printf("fail\n");
// Set User Zone
ucReturn = cm_SetUserZone(DEFAULT_ADDRESS, 3, FALSE);
if (ucReturn != SUCCESS) printf("fail\n");
// Write data to user zone
for (i = 0; i < 16; ++i) ucData = 0xEE;
ucReturn = cm_WriteUserZone(DEFAULT_ADDRESS, 0, ucData, 16);
if (ucReturn != SUCCESS) printf("fail\n");
// Read user zone
for (i = 0; i < 16; ++i) ucData = 0x00;
ucReturn = cm_ReadUserZone(DEFAULT_ADDRESS, 0, ucData, 16);
if (ucReturn != SUCCESS) printf("fail\n");
// Read Device Fuse Register
ucReturn = cm_ReadFuse(DEFAULT_ADDRESS, ucData);
if (ucReturn != SUCCESS) printf("fail\n");
// Verify authentication
for (i = 0; i < 8; ++i) ucG = 0xFF;
ucReturn = cm_VerifyCrypto(DEFAULT_ADDRESS, 1, ucG, NULL, FALSE);
if (ucReturn != SUCCESS) printf("fail\n");
// Verify encryption
for (i = 0; i < 8; ++i) ucG = 0xFF;
ucReturn = cm_VerifyCrypto(DEFAULT_ADDRESS, 1, ucG, NULL, TRUE);
if (ucReturn != SUCCESS) printf("fail\n");
// Test ReadChecksum
ucReturn = cm_ReadChecksum(DEFAULT_ADDRESS, ucData);
if (ucReturn != SUCCESS) printf("fail\n");
// Set User Zone w/a-t
ucReturn = cm_SetUserZone(DEFAULT_ADDRESS, 3, TRUE);
if (ucReturn != SUCCESS) printf("fail\n");
// Try to deactivate security
ucReturn = cm_ResetCrypto(DEFAULT_ADDRESS);
if (ucReturn != SUCCESS) printf("fail\n");
while(1);
} |
|