atsha204a加密ic02

The Atmel® ATSHA204 is a full turnkey security device. It includes a 4.5Kb EEPROM divided into 16 slots. This array can be used for storage of keys, miscellaneous read/write, read-only, password or secret data, and consumption tracking. Access to the various sections of memory can be restricted in a variety of ways and then the configuration locked to prevent changes.

Access to the chip is through a standard I²C interface at speeds up to 1Mb/sec. The chip also supports a single-wire interface that can reduce the number of GPIOs required on the system processor and/or reduce the number of pins on connectors. It is compatible with most UART or serial I/O controllers. System integration is eased with a wide supply voltage range and an ultra-low sleep current of less than 100nA.

複製代碼
參數                                值
Operating Voltage (Vcc):            2.0 to 5.5
Interface Type:                     Single-wire; I2C
Density:                            4.5Kb
Algorithm Type:                     NIST SHA-256
Key Size:                           256
Zones:                              16
複製代碼

http://www.atmel.com/zh/cn/Images/Atmel-8740-CryptoAuth-ATSHA204-Datasheet.pdf

愛特梅爾公司(Atmel Corporation)發佈具有增強的硬件安全特性和更大靈活性的易於使用的新型加密認證(cryptographic authentication) 器件。

具有超低功耗的Atmel ATSHA204是首款帶有4.5Kbit EEPROM和硬件SHA-256加速器的經優化的交鑰匙認證器件,

其經過全面測試的ASF軟件庫可用於基於Atmel AVR  和 ARM的微控制器 ,並集成在全新集成式開發環境AVR Studio 5 中。

ATSHA204器件是工業、消費電子、電力抄表、家庭自動化、計算和醫療應用的理想選擇。

全新愛特梅爾 CryptoAuthentication器件具有保護EEPROM內容的增強安全特性,包括有源金屬護罩、內存加密、安全測試模式、

干擾保護(glitch protection)和電壓篡改檢測。其設計採用與愛特梅爾Common Criteria Certified TPM相同的方法和組件,並內置高質量隨機數據發生器,

可用於加密協議以防止重放攻擊(replay attack)。ATSHA204還結合了許多其它的內部硬件保護特性,極大地增加了針對OEM電池、

遊戲控制檯、打印機墨盒、經授權附件等裝置中安全器件進行硬件攻擊而得逞的難度。

愛特梅爾CryptoAuthentication系列 的新成員具有專門設計的經優化的硬件安全特性,以鑑別目標、控制OEM供應鏈、防止軟件或其它知識產權(IP)的盜竊。

這款器件能夠安全地生成、存儲或傳送安全密鑰,因而可與微控制器系統中的AES加速器理想配合。

由於新器件具有256位密鑰,安全度超過市場上的其它任何認證器件,系統設計人員能夠有信心保證其設計在系統的整個壽命週期中安全可靠。

愛特梅爾公司加密產品業務部總監Kerry Maletsky表示:“愛特梅爾致力於提供易於使用,且集成最新NIST加密算法以實現具最高級別可靠性的加密產品。

這些產品填補了大多數微控制器和ASIC解決方案的安全存儲缺失的空白,可用於組件確認、固件完整性檢查、專有和保密數據的安全存儲等。

而且,這些器件的使用非常方便,應用開發人員無需具備加密知識,也能夠自信地實現認證檢查功能。”

價格和供貨

愛特梅爾公司提供採用行業標準SOT-3、SOIC-8、UDFN-8和TSSOP-8封裝的ATSHA204器件,帶有單線或I2C接口。訂購1000片的單價爲0.41美元。

 

 

ATSHA204 加密認證芯片數據格式

http://www.andlogic.net/news_con.asp?ID=76

Atmel ATSHA204是帶有4.5Kbit EEPROM和硬件SHA-256加速器的安全認證器件,包括有源金屬護罩、內存加密、安全測試模式、

干擾保護(glitch protection)和電壓篡改檢測。其設計採用與愛特梅爾Common Criteria Certified TPM相同的方法和組件,

並內置高質量隨機數據發生器,可用於加密協議以防止重放攻擊(replay attack)。

由於該芯片技術文檔對命令和響應的數據格式沒有說明,只能從demo程序中分析出來,總結如下:

IIC總線設備地址:TWIAddress:0xc8

喚醒

ATSHA204芯片被喚醒信號觸發後,需要讀取其狀態,只有在喚醒狀態才能進行進一步操作,讀取喚醒狀態命令格式和波形:
0xc9,0x04,0x11,0x33,0x43

完整的寫命令舉例 

C9,04,11,33,43 {C9:讀,04:count11wake token 33,43Checksum }

C8,03,0B,12,00,00,00,00,00,00,00,A7,BF {C8:寫,03Command ,0b:count, 12:write , A7,BF: Checksum }

C9,04,03,83,42 {C9:讀,04:count03Parse Error, 83,42Checksum }

C8,02 {C8:寫,02Idle }

 

 

ATSHA204

http://blog.csdn.net/sannik/article/details/8022186

主要特性:
1,SHA-256 Hash算法
2,有保證的唯一的72-bit序列號; 不僅有軟件加密,內部還有高質量硬件加密。
3,16個槽口的4kbits EEPROM:  4Kbits / 8 = 512Bytes 每個槽口32bytes
4,I2C接口, 單線接口
5, 和Atmel AT88SA102S,AT88SA10HS
6, i2c 地址默認爲0xc8; 還可以configuration zone改變地址。

開發環境: s5pv210 linux,  imx51 linux

操作流程:

==>燒錄工具:研究燒錄工具的使用,能夠更快的熟悉芯片功能。

芯片使用之前可導入個性化文件,配置slot/otp data的讀寫權限以及驗證方式。配置完成後再lock住 config zone和data zone;

這樣對芯片的個性化配置完成了,從此芯片就會按照你的意圖辦事拉。

SlotConfig (32bytes,  2bytes per slot):

       ReadKey - 該slot數據的讀,用指定ReadKey的slot加密起來;

       CheckOnly - 該slot是否只適用CheckMac and GenDig Command;

       SingleUse - single-use keys,若enable,使用次數限制後會返回出錯;

       EncryptRead, slotconfig.IsSecret都爲0,此slot才能被讀寫。然後OTP/data zone必須locked,才能讀寫。

       UseFlag  -  對應single-use keys, 表示該key可以使用多少次;只針對keys #0~7設置。

OTPmode = 0xAA, OTP zone locked: 寫被禁止,讀任意。


==>代碼部分:

1, wakeup device: 6.1.1 -- chip is asleep.  

和芯片通信之前要確保它是awake。只能當chip asleep才能喚醒,芯片處於awake時忽略喚醒命令。

sha204c_wakeup() 

具體喚醒芯片有兩種方式: 

         1),將SDA配成gpio口,給出60us低,然後拉高2.5ms;條件是clk較高:samsung 400KHz

         2),利用標準i2c發送函數,發送0x00 byte給出60us,然後延時2.5ms;條件是clk較低:imx51 200KHz

sleep sequence:  sha204c_sleep()  已驗證;

 

2,  read write:

讀寫要確保芯片的各個區是否有相應的權限。

config zone一直有讀的權限,OTP zone通過設置也可任意讀;

slot data由slotconfig決定讀寫的權限。可以直接讀,認證讀,認證寫 ...

 Read Command:
* read config zone簡單,config zone的內容一直可讀的;
* 讀取data slots的內容有條件:(此步驟由燒錄工具完成)
先通過lock command設置slotconfig unlocked 和 data zone locked;
然後通過write command配置SlotConfig(config zone的20~51字節,每個slot佔用2個字節);
讀寫data zone的權限都是要設置slotconfig的。

 

Write Command:
* 通過寫SlotConfig來設置讀寫data zone的權限。同時,寫config zone的slotconfig區間前,
  需要確定slotconfig是unlocked(看Lock Command)。(此步驟由燒錄工具完成)
* 寫data slot;

 

Lock Command: (此命令由燒錄工具調用的,驅動代碼中無需調用)
* 設置slotconfig區間的寫權限;寫:unlocked詳見config zone的 87 byte
* 設置OTP zone和data zone的寫權限。讀:locked;寫:unlocked 詳見config zone的 86 byte
只能unlocked -> locked,所以要先write,再read data zone。

 

Config zone: 88bytes   
格式: cnt + data + CRC
0~31: 參數 -- 0x80, 0x0000
1 23 6c 3e 0 4 5 0 94 9d e4 d2 ee 55 1 0 c8 0 55 0 |8f| 80 80 a1 82 e0 a3 60 94 40 a0 85
32~63:參數 -- 0x80, 0x0008
86 40 87 7 f 0 89 f2 8a 7a b 8b c 4c dd 4d c2 42 af 8f ff 0 ff 0 ff 0 ff 0 ff 0 ff 0
63~87:只能4-bytes讀,不能一次讀32-bytes。
84~87byte:參數 -- 0x00 0x0015
0 0 55 55

 

OTP zone:64bytes

它的讀寫權限由OTPmode控制。0xAA -- read-only mode。 可以通過READ COMMAND讀出。

 

Data zone:16 * 32bytes


3,i2c sync:

系統如果芯片response不正確,要做一次reset!  

sha204c_resync()。

目前此步驟在imx51,s5pv210平臺均未實現;採取的是足夠的延時(不同的命令,芯片的反應時間也不同)來保證芯片sync。

如何發送9clock的高電平呢?


4, 認證:   

MAC Command

* sha204m_execute() mode 決定了參與計算MAC的各種參數:

第一個32bytes:Key[KeyID] or TempKey,  第二個32bytes:user input challenge or Tempkey.

 

(1) 隨機數認證:

mode=0, Key[KeyID] + challenge; 直接執行MAC Command命令; 得到SHA-256 MAC值。

user 通過SHA-256算法計算出的MAC和上述MAC對比來認證。

e.g.> MAC Command Sent: 27 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BB 97

MacCommand Received: 23 84 09 C2 A7 31 81 83 51 16 EE E1 AD 5F 59 4B EC 63 B8 5E E6 D7 8A 3F EE 26 5E 90 AD 15 B7 D0 0A DC 60

/* user驗證 */ 計算MAC並比較:slot data + challenge => MAC

 

(2) Tempkey認證: mode = 1 & tempkey.SourceFlag.Key[KeyID] + Tempkey

須先要執行Nonce Command生成Tempkey。然後執行MAC Command;得到SHA-256 MAC值。

 

Nonce Command:  

user input challenge + chip internal Randout  => Tempkey

Tempkey register: 32bytes Data + Tempkey Config [ 理解SourceFlag ,  Valid 意義]

tempkey.SourceFlag 標誌着; Tempkey.Valid 表示其是否可用:

nonce命令執行後,該標誌爲1;tempkey被用過之後,標誌變成了0.

  

CheckMac Command:

e.g. >Nonce Command Sent:   1B 16 00 00 00 54 79 70 65 20 43 68 61 6C 6C 65 6E 67 65 20 48 65 72 65 00 17 13 //執行Nonce command

NonceCommand Received:  23 A6 5A D5 07 A9 81 D7 E1 B0 5F 2D 73 44 72 94 74 AE E6 BC BB 94 BF 73 47 5F 65 F8 A4 6B 47 B8 FB 59 06 //返回芯片內部的Randout; 此時,Tempkey已經生成

MAC Command Sent:     07 08 01 00 00 06 67 //執行MAC command:mode=1,keyid=0(slot0 data + tempkey)
MacCommand Received:  23 98 80 4C 73 13 2E 0F 89 BD A7 7C 69 28 C5 47 D1 BC DC 60 9A C1 A3 09 87 36 26 7C E9 D6 8B 19 10 56 F5 //返回SHA-256 MAC值

/* 下面的驗證部分,實際需要由user完成的 */
CheckMac Command Sent: //執行CheckMac command驗證   (方便分析,將數據分割下)


54 28 00 00 00   //mode=0, keyid=0
64 46 F3 95 6E FC 47 AF AC E6 E6 A8 67 09 16 F6 5B E1 F8 3A A0 4E 7B 79 67 9B A3 94 FF ED 9F B5      //user input challenge, 就是tempkey
98 80 4C 73 13 2E 0F 89 BD A7 7C 69 28 C5 47 D1 BC DC 60 9A C1 A3 09 87 36 26 7C E9 D6 8B 19 10  //sha-256 MAC
08 01 00 00 00 00 00 00 00 00 00 00 00  //other data:  和MAC command發送的“07 08 01 00 00 06 67” I/O block相同,補全13字節。
9E C6
CheckMacCommand Received: //返回匹配結果
04 00 03 40
##注意CheckMac命令格式##

/* user 驗證 */

計算Tempkey: Nonce 命令的輸入challenge(20bytes) + 其返回值Randout  => Tempkey

計算MAC並比較:slot data + tempkey => MAC

 

===>   疑問: 不知道slot 的配置是否影響到上述兩種認證方式。 

目前驗證,隨機數的認證不受slotconfig的影響。

* Personalize the device as follows:

*- Slot 0  = Store read-only information e.g. model number, product name, product ID, manufacturer name, or ?? (teach me how).    <可用read command直接讀到>
*- Slot 1  = Store authentication/encryption key.
*- Slot 2  = Store authentication/encryption key.
*- Slot 3  = Store fixed key with "single use" restrictions having 5 maximum uses.
*- Slot 4  = Store key that can be created in the field with 3 maximum authenticated updates. Use KeyID 1 for authentication
*- Slot 5  = Store key that can be rolled in the field with 6 maximum authenticated updates. Use KeyID 2 for authentication
*- Slot 6  = Store content that requires encrypted read/write using KeyID 3 for READ and KeyID 4 for write
*- Slot 7  = Make this slot write-only (Suggest possible use for this?)
*- Slot 8  = Make this a scratch pad e.g. unrestricted reads/writes
*- Slot 9  = Store content that requires encrypted reads using KeyID 1 but clear writes.
*- Slot 10 = Store content that requires encrypted writes using KeyID 2 but clear reads. 
*- Slot 11 = Store key that can be created in the field with MAC required for creation. Use KeyID 2 as parent key.
*- Slot 12 = Store key that can be created in the field by anybody i.e. without requiring MAC 
*- Slot 13 = Store key that can be rolled in the field with MAC required for rolling. Use KeyID 2 as parent key.
*- Slot 14 = Store key that can be rolled in the field by anybody i.e. without requiring MAC
*- Slot 15 = Store key with 33 maximum uses controlled by UseFlags.  Make it a CheckOnly Key

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章