把Xilinx的IPCORE解密成源代码的方法

把Xilinx的IPCORE解密成源代码的方法

 
1.加密的文件格式
以can_v1_5/can_tl_bsp.vhd为例子
a)前8个字节XlxV38EB是加密的版本号,没研究过其他加密版本,不知道有什么不同
后面的fa00不知道做什么用
b)第二行前8字节是这段密文长度,表示过3230H字节后是下一个加密段
c)从18h开始是明文经过Zlib压缩后DES加密的
                    ----------------------    
00000000h: 58 6C 78 56 33 38 45 42 20 20 20 20 66 61 30 30 ; XlxV38EB    fa00
00000010h: 20 20 20 20 33 32 33 30 39 1E 5F B2 14 42 33 C1 ;     32309._?B3?
00000020h: 82 40 EA 28 A0 8D 8C E9 8B 75 8B 0E 7C C4 6E BA ; 侤?爫岄媢?|膎?
00000030h: B0 2F 08 7C 51 C0 B0 45 01 D5 BD B8 73 A1 A1 09 ; ?.|Q腊E.战竤 .
00000040h: 71 2A 81 FA A7 9E 99 CA 9C BE 15 7C 44 D1 E9 C1 ; q*侜櫴溇.|D验?
00000050h: D5 A8 81 9B 1E 3A 19 47 4A 49 AA 87 1C E2 E2 46 ; 炸仜.:.GJI獓.忖F
。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。
00003220h: 0F DD 81 68 7A B1 C5 92 FD 7C 77 FB 73 96 46 82 ; .輥hz迸掿|w鹲朏?
00003230h: A4 63 0B F1 64 17 1D D5 18 19 B2 E8 1D 23 DF 0F ; .馾..?.茶.#?
00003240h: 24 11 C2 D4 D0 90 38 7D 58 6C 78 56 33 38 45 42 ; $.略袗8}XlxV38EB
00003250h: 20 20 20 20 36 38 64 37 20 20 20 20 31 34 66 63 ;     68d7    14fc
00003260h: D5 F9 A3 5C F9 7D D7 4A 72 09 19 86 03 62 C4 2C ; 争鶀譐r..?b?
00003270h: FE DC 28 58 7E 1F 91 2F 0F CD A8 DB 8E A0 FF 37 ; (X~.?.通蹘?7
00003280h: 01 F4 62 07 CE BA 6E 3C BB 67 4C B0 D9 E8 AE E3 ; .鬮.魏n<籫L百璁

2.解密方法
1)先用DES还原被加密的文件,每8字节为一组。
如果密文长度不能被8整除,剩余的字节不处理。
2)Xilinx的IPCORE所用DES的Key是固定的8f c2 d3 a0 XX XX  XX XX,可以用下面这组值穷举出来。
39 1E 5F B2 14 42 33 C1 解密为75 41 73 32 dd 59 ea 0c
3)再与异或初始值0d 9b 9e 4f b6 2a f1 37异或
4)得到结果 78 73 32 dd xx xx xx xx
5)异或初始值替换为上8个字节39 1E 5F B2 14 42 33 C1,解密下8个字节,
6)重复第五步解密直到结束
7)将各个解密段拼成一个文件

3.从 http://www.zlib.net/下载Zlib压缩库,调用其中的解压缩函数
1)假设解密后的文件是compfile调用这个函数inf(compfile,tfile);
2)这个tfile文件既是源码文件

-- $Id: can_tl_bsp.vhd,v 1.1.2.2 2007/05/28 13:39:29 snori Exp $
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Copyright(C) 2007 by Xilinx, Inc. All rights reserved.
-- This text/file contains proprietary, confidential
-- information of Xilinx, Inc., is distributed under
-- license from Xilinx, Inc., and may be used, copied
-- and/or disclosed only pursuant to the terms of a valid
-- license agreement with Xilinx, Inc. Xilinx hereby

。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。

smcomb: process(state, RXE_COUNTER_I, SM_STUFFBIT_PD,SM_STUFFBIT,
       BSOFF_COUNTER_I,  TEC_INC8_I, EMU_TEC_BOFF_LT1,
       EMU_REC_ERRACT,BTL_RXBIT,IC_MSR_LBACK,IC_MSR_SLEEP,
       TX_HPB_EMPTY,TX_FIFO_EMPTY) 
  begin
    
    -- Enable Stuff Module when State = ID and after the 3rd bit 
    -- after SOF been received.
    if (state = ID and RXE_COUNTER_I = C3) then
      RXE_SM_EN <= '1';
    else
      RXE_SM_EN <= '0';
    end if;

    -- Reset CRC when State = EOF 
    -- When RXE_CRC_RST = '1', the CRC register is reset.
    -- Reset when State = EOF and RXE_COUNTER_I = CO 
    -- (After ACK field) 
    -- Reset when in ERRACT and ERRPASS and RXE_COUNTER_I = C0. It is possible
    -- that Reset could be asserted for multiple cycles.
    
    if ((state = EOF and RXE_COUNTER_I = C0) or
       ((state = ERRACT or state = ERRPASS) and RXE_COUNTER_I = C1)
         or state = BOFF) then
      RXE_CRC_RST <= '1';
    else
      RXE_CRC_RST <= '0';
    end if;
    
    -- CRC Enable is '1' ID, CTL and DATA states
    if (state = ID or state = CTL or state = DATA) then
      RXE_CRC_EN <= '1';
    else
      RXE_CRC_EN <= '0';
    end if;           
    
    -- Stuff Module reset when Error or when State = CRC and the 15th bit has 
    -- been received and the next bit is not a stuff bit.
    if (( state = CRC and RXE_COUNTER_I = C15 and SM_STUFFBIT_PD = '0')
      or (( state = ERRACT or state = ERRPASS or state = BOFF)
       and RXE_COUNTER_I = C0 )) then
      RXE_SM_RST <= '1';
    else
      RXE_SM_RST <='0';
    end if;
  • 11
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值