當前位置:首頁 > 嵌入式 > 嵌入式硬件

#include <p16f877.inc>
  ;
  global decrypt
  global key0,key1,key2,key3,key4,key5,key6,key7
  global csr0,csr1,csr2,csr3,csr4,csr5,csr6,csr7,csr8
  ;
  #define hop1 csr0 ; ﹚竡 hop1~4 單? csr1~4
  #define hop2 csr1
  #define hop3 csr2
  #define hop4 csr3
  #define max_code_length .72
  #define code_length .66
  ;
  udata_shr ; difine csr0:csr7 on share memory
  csr0 res 1 ; hopping code 鋇μ?纗??既?竟 (lsb)
  csr1 res 1
  csr2 res 1
  csr3 res 1
  csr4 res 1
  csr5 res 1
  csr6 res 1
  csr7 res 1
  csr8 res 1 ; hopping code 鋇μ?纗??既?竟 (msb)
  ;
  encrypt_data udata 0x20
  key0 res 1 ; 64-bit 稈盞じン戈? (lsb)
  key1 res 1
  key2 res 1
  key3 res 1
  key4 res 1
  key5 res 1
  key6 res 1
  key7 res 1
  ;
  udata
  cnt0 res 1
  cnt1 res 1
  hop_length res 1
  mask res 1
  keeloq_temp res 1
  ;
  ;
  keeloq_code code
  ;
  ;*****************************************************
  ;**** rotate csrs register right 1 bit
  ;*****************************************************
  rot_csrs
  rrf csr8,f
  rrf csr7,f
  rrf csr6,f
  rrf csr5,f
  rrf csr4,f
  rrf csr3,f
  rrf csr2,f
  rrf csr1,f
  rrf csr0,f
  return
  ;
  ;
  ;
  ;
  ;****************************************************************
  ;
  ; function : decrypt ()
  ;
  ; description : decrypts 32 bit [hop1:hop4] using [csr0:csr7]
  ;
  ;****************************************************************
  decrypt
  banksel cnt1
  movlw (.11+1) ; outer loop 11+1 times
  movwf cnt1 ; outer loop 11+1 times
  decrypt_outer
  movlw .48 ; inner loop 48 times
  movwf cnt0 ; inner loop 48 times
  decrypt_inner
  clrwdt ; reset watchdog timer
  movfw cnt1 ; last 48 loops restore the key
  xorlw .1 ; last 48 loops restore the key
  btfsc status,z ; last 48 loops restore the key
  goto rotate_key ; last 48 loops restore the key
  ; the lookup table is compressed into in 4 bytes to save space
  ; use the 3 low index bits to make up an 8-bit bit mask
  ; use the 2 high index bits to look up the value in the table
  ; use the bit mask to isolate the correct bit in the byte
  ; part of the reason for this scheme is because normal table
  ; lookup requires an additional stack level
  bcf status,c ; clear carry (for the left shift)
  movlw .1 ; initialise mask = 1
  btfsc hop3,3 ; shift mask 4x if bit 2 set
  movlw b"00010000" ; shift mask 4x if bit 2 set
  movwf mask ; initialise mask = 1
  btfss hop2,0 ; shift mask another 2x if bit 1 set
  goto $+3
  rlf mask,f
  rlf mask,f
  btfsc hop1,0 ; shift mask another 1x if bit 0 set
  rlf mask,f
  ; mask has now been shifted 0-7 times according to bits 2:1:0
  movlw high table
  movwf pclath
  movlw low table
  movwf keeloq_temp
  movlw 0 ; table index = 0
  btfsc hop4,1
  iorlw .2 ; if bit 3 set add 2 to the table index
  btfsc hop4,6
  iorlw .4 ; if bit 4 set add 4 to the table index
  addwf keeloq_temp,w
  btfsc status,c
  incf pclath,f
  movwf pcl ; add the index to the program counter
  ; [ must be in lower half of page ]
  table
  movlw 0x2e ; bits 4:3 were 00
  goto table_end ; end of lookup
  movlw 0x74 ; bits 4:3 were 01
  goto table_end ; end of lookup
  movlw 0x5c ; bits 4:3 were 10
  goto table_end ; end of lookup
  movlw 0x3a ; bits 4:3 were 11
  table_end
  andwf mask,1 ; isolate the correct bit
  movlw 0 ; copy the bit to bit 7
  btfss status,z ; copy the bit to bit 7
  movlw b"1000

本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內容侵犯您的權益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或將催生出更大的獨角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉型技術解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術公司SODA.Auto推出其旗艦產品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關鍵字: 汽車 人工智能 智能驅動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務中斷的風險,如企業(yè)系統(tǒng)復雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務連續(xù)性,提升韌性,成...

關鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網易近期正在縮減他們對日本游戲市場的投資。

關鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產業(yè)博覽會開幕式在貴陽舉行,華為董事、質量流程IT總裁陶景文發(fā)表了演講。

關鍵字: 華為 12nm EDA 半導體

8月28日消息,在2024中國國際大數(shù)據(jù)產業(yè)博覽會上,華為常務董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權最終是由生態(tài)的繁榮決定的。

關鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應對環(huán)境變化,經營業(yè)績穩(wěn)中有升 落實提質增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務引領增長 以科技創(chuàng)新為引領,提升企業(yè)核心競爭力 堅持高質量發(fā)展策略,塑強核心競爭優(yōu)勢...

關鍵字: 通信 BSP 電信運營商 數(shù)字經濟

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術學會聯(lián)合牽頭組建的NVI技術創(chuàng)新聯(lián)盟在BIRTV2024超高清全產業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術創(chuàng)新聯(lián)...

關鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(集團)股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關鍵字: BSP 信息技術
關閉
關閉