⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disk1.lst

📁 用于Slave I2C得读写,此代码针对特定得芯片,但对其他得芯片也有借鉴作用.
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.02b   DISK1                                                                03/16/2006 13:52:41 PAGE 1   


C51 COMPILER V7.02b, COMPILATION OF MODULE DISK1
OBJECT MODULE PLACED IN .\output\disk1.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE disk1.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\output\disk1.lst) OBJECT(.\
                    -output\disk1.obj)

stmt level    source

   1          /*
   2          **********************************************************************************************
   3          * Project:      T8Lib
   4          * File:         des.c
   5          * Contents: 
   6          *           The des module c file
   7          *
   8          * $Date: 10/13/05    Michal    T8R01LIB v0.1  initial
   9          * $Date: 11/29/05    Michal    T8R01LIB v0.2  test finish  both 51 and MCF5249
  10          * $Date: 11/30/05    Michal    T8R01LIB v0.3  make lib OK  on  MCF5249
  11          * $Date: 12/01/05    Michal    T8R01LIB v0.4  Add HW_IIC ,HW_SPI macro  
  12          * $Date: 12/02/05    Michal    T8R01LIB v0.5  Add  function below 
  13          *                 static void DoXX(BYTE* out ,BYTE* in,BYTE len,BOOL mode)
  14          *                 static BOOL DoComunication(BYTE* array, BYTE len,BOOL mode)
  15          *
  16          *                 BOOL  GetCustomIdWriteStatusCmd(); 
  17          *                 BOOL  GetCustomIdResponseCmd(); 
  18          *                 BOOL  ChallengeCustomIdCmd(BYTE * CId,BYTE len,BYTE Nvmoffset); 
  19          *                 BOOL  IsCustomIdResponseCmd(); 
  20          *                 BOOL WriteCustomIdCmd(BYTE * CId,BYTE len,BYTE Nvmoffset)  ;   
  21          *                 BOOL IsWriteCustomIdReadyCmd();         
  22          *                 BOOL IsWriteCustomIdNotReadyCmd();  
  23          *
  24          *                Moidfy some *Cmd Fuction and Reply() function
  25          * $Date: 12/05/05    Michal    T8R02LIB v0.1  Add errcode1 to identify T8 off i2c bus state 
  26          * $Date: 12/29/05 Michal T8R02LIB v0.2
  27                               Modify InitezT8(BOOL mode ) to BOOL  InitezT8Lib(BOOL ComMod,BYTE I2cSlvAdr,BOOL I2cIsHigh,B
             -YTE SpiCLkMod,WORD SpiRate,BYTE *key);
  28                                  void I2c_Init( ); void I2c_Sel( BYTE  SlvAdr, BOOL isHigh)  to void I2c_Init(BYTE 
             - SlvAdr, BOOL isHigh);
  29                                  void  Spi_Init();BOOL  Spi_ClkSel(BYTE mode, WORD rate);  To void  Spi_Init(BYTE m
             -ode, WORD rate);
  30                           Delete void SpiClkSelOpr(BYTE mode, WORD rate) ;
  31                                  void I2c_Sel( BYTE  SlvAdr, BOOL isHigh);  
  32                                  void SetXXKey(BYTE* key); 
  33          * $Date: 12/29/05 Michal T8R02LIB v0.5 test communiction at 400khz speed  is OK  
  34          * Copyright (c) 2005 Fameg, Inc. All rights reserved
  35          ***********************************************************************************************
  36          */
  37          
  38          
  39          /* DESC.C - Data Encryption Standard routines for RSAREF
  40               Based on "Karn/Hoey/Outerbridge" implementation (KHODES)
  41           */
  42          #include <string.h>
  43          #include "ezT8i.h"
  44          #include "des.h"
  45          
  46          /*const unsigned char des_weak_key[16][8] = {
  47              // weak keys 
  48              {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
  49              {0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe},
  50              {0x1f,0x1f,0x1f,0x1f,0x0e,0x0e,0x0e,0x0e},
  51              {0xe0,0xe0,0xe0,0xe0,0xf1,0xf1,0xf1,0xf1},
C51 COMPILER V7.02b   DISK1                                                                03/16/2006 13:52:41 PAGE 2   

  52              // semi-weak 
  53              {0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe},
  54              {0xfe,0x01,0xfe,0x01,0xfe,0x01,0xfe,0x01},
  55              {0x1f,0xe0,0x1f,0xe0,0x0e,0xf1,0x0e,0xf1},
  56              {0xe0,0x1f,0xe0,0x1f,0xf1,0x0e,0xf1,0x0e},
  57              {0x01,0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1},
  58              {0xe0,0x01,0xe0,0x01,0xf1,0x01,0xf1,0x01},
  59              {0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e,0xfe},
  60              {0xfe,0x1f,0xfe,0x1f,0xfe,0x0e,0xfe,0x0e},
  61              {0x01,0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e},
  62              {0x1f,0x01,0x1f,0x01,0x0e,0x01,0x0e,0x01},
  63              {0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1,0xfe},
  64              {0xfe,0xe0,0xfe,0xe0,0xfe,0xf1,0xfe,0xf1}
  65          };
  66          */
  67          static const WORD code BYTE_BIT[8] = {
  68            0200, 0100, 040, 020, 010, 04, 02, 01
  69          };
  70          
  71          static const DWORD code BIG_BYTE[24] = {
  72            0x800000L, 0x400000L, 0x200000L, 0x100000L,
  73            0x80000L,  0x40000L,  0x20000L,  0x10000L,
  74            0x8000L,   0x4000L,   0x2000L,   0x1000L,
  75            0x800L,    0x400L,    0x200L,    0x100L,
  76            0x80L,     0x40L,     0x20L,     0x10L,
  77            0x8L,      0x4L,      0x2L,      0x1L
  78          };
  79          
  80          static const unsigned char code PC1[56] = {
  81            56, 48, 40, 32, 24, 16,  8,      0, 57, 49, 41, 33, 25, 17,
  82             9,  1, 58, 50, 42, 34, 26,     18, 10,  2, 59, 51, 43, 35,
  83            62, 54, 46, 38, 30, 22, 14,      6, 61, 53, 45, 37, 29, 21,
  84            13,  5, 60, 52, 44, 36, 28,     20, 12,  4, 27, 19, 11,  3
  85          };
  86          
  87          static const unsigned char code TOTAL_ROTATIONS[16] = {
  88            1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
  89          };
  90          
  91          static const unsigned char code PC2[48] = {
  92            13, 16, 10, 23,  0,  4,  2, 27, 14,  5, 20,  9,
  93            22, 18, 11,  3, 25,  7, 15,  6, 26, 19, 12,  1,
  94            40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
  95            43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31
  96          };
  97          
  98          static const DWORD code SP1[64] = {
  99            0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
 100            0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
 101            0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
 102            0x01000404L, 0x01010004L, 0x01000000L, 0x00000004L,
 103            0x00000404L, 0x01000400L, 0x01000400L, 0x00010400L,
 104            0x00010400L, 0x01010000L, 0x01010000L, 0x01000404L,
 105            0x00010004L, 0x01000004L, 0x01000004L, 0x00010004L,
 106            0x00000000L, 0x00000404L, 0x00010404L, 0x01000000L,
 107            0x00010000L, 0x01010404L, 0x00000004L, 0x01010000L,
 108            0x01010400L, 0x01000000L, 0x01000000L, 0x00000400L,
 109            0x01010004L, 0x00010000L, 0x00010400L, 0x01000004L,
 110            0x00000400L, 0x00000004L, 0x01000404L, 0x00010404L,
 111            0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
 112            0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
 113            0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
C51 COMPILER V7.02b   DISK1                                                                03/16/2006 13:52:41 PAGE 3   

 114            0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L
 115          };
 116          
 117          static const DWORD code SP2[64] = {
 118            0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
 119            0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
 120            0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
 121            0x80008000L, 0x00100000L, 0x00000020L, 0x80100020L,
 122            0x00108000L, 0x00100020L, 0x80008020L, 0x00000000L,
 123            0x80000000L, 0x00008000L, 0x00108020L, 0x80100000L,
 124            0x00100020L, 0x80000020L, 0x00000000L, 0x00108000L,
 125            0x00008020L, 0x80108000L, 0x80100000L, 0x00008020L,
 126            0x00000000L, 0x00108020L, 0x80100020L, 0x00100000L,
 127            0x80008020L, 0x80100000L, 0x80108000L, 0x00008000L,
 128            0x80100000L, 0x80008000L, 0x00000020L, 0x80108020L,
 129            0x00108020L, 0x00000020L, 0x00008000L, 0x80000000L,
 130            0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
 131            0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
 132            0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
 133            0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L
 134          };
 135          
 136          static const DWORD code SP3[64] = {
 137            0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
 138            0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
 139            0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
 140            0x08020208L, 0x00020008L, 0x08020000L, 0x00000208L,
 141            0x08000000L, 0x00000008L, 0x08020200L, 0x00000200L,
 142            0x00020200L, 0x08020000L, 0x08020008L, 0x00020208L,
 143            0x08000208L, 0x00020200L, 0x00020000L, 0x08000208L,
 144            0x00000008L, 0x08020208L, 0x00000200L, 0x08000000L,
 145            0x08020200L, 0x08000000L, 0x00020008L, 0x00000208L,
 146            0x00020000L, 0x08020200L, 0x08000200L, 0x00000000L,
 147            0x00000200L, 0x00020008L, 0x08020208L, 0x08000200L,
 148            0x08000008L, 0x00000200L, 0x00000000L, 0x08020008L,
 149            0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
 150            0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
 151            0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
 152            0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L
 153          };
 154          
 155          static const DWORD code SP4[64] = {
 156            0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
 157            0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
 158            0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
 159            0x00000081L, 0x00000000L, 0x00800080L, 0x00800001L,
 160            0x00000001L, 0x00002000L, 0x00800000L, 0x00802001L,
 161            0x00000080L, 0x00800000L, 0x00002001L, 0x00002080L,
 162            0x00800081L, 0x00000001L, 0x00002080L, 0x00800080L,
 163            0x00002000L, 0x00802080L, 0x00802081L, 0x00000081L,
 164            0x00800080L, 0x00800001L, 0x00802000L, 0x00802081L,
 165            0x00000081L, 0x00000000L, 0x00000000L, 0x00802000L,
 166            0x00002080L, 0x00800080L, 0x00800081L, 0x00000001L,
 167            0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
 168            0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
 169            0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
 170            0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
 171            0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L
 172          };
 173          
 174          static const DWORD code SP5[64] = {
 175            0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
C51 COMPILER V7.02b   DISK1                                                                03/16/2006 13:52:41 PAGE 4   

 176            0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
 177            0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
 178            0x42000100L, 0x42080000L, 0x00080100L, 0x40000000L,
 179            0x02000000L, 0x40080000L, 0x40080000L, 0x00000000L,
 180            0x40000100L, 0x42080100L, 0x42080100L, 0x02000100L,
 181            0x42080000L, 0x40000100L, 0x00000000L, 0x42000000L,
 182            0x02080100L, 0x02000000L, 0x42000000L, 0x00080100L,
 183            0x00080000L, 0x42000100L, 0x00000100L, 0x02000000L,
 184            0x40000000L, 0x02080000L, 0x42000100L, 0x40080100L,
 185            0x02000100L, 0x40000000L, 0x42080000L, 0x02080100L,
 186            0x40080100L, 0x00000100L, 0x02000000L, 0x42080000L,
 187            0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
 188            0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
 189            0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
 190            0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L
 191          };
 192          
 193          static const DWORD code SP6[64] = {
 194            0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
 195            0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
 196            0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
 197            0x00400010L, 0x20004000L, 0x20000000L, 0x00004010L,
 198            0x00000000L, 0x00400010L, 0x20004010L, 0x00004000L,
 199            0x00404000L, 0x20004010L, 0x00000010L, 0x20400010L,
 200            0x20400010L, 0x00000000L, 0x00404010L, 0x20404000L,
 201            0x00004010L, 0x00404000L, 0x20404000L, 0x20000000L,
 202            0x20004000L, 0x00000010L, 0x20400010L, 0x00404000L,
 203            0x20404010L, 0x00400000L, 0x00004010L, 0x20000010L,
 204            0x00400000L, 0x20004000L, 0x20000000L, 0x00004010L,
 205            0x20000010L, 0x20404010L, 0x00404000L, 0x20400000L,
 206            0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
 207            0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
 208            0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
 209            0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L
 210          };
 211          
 212          static const DWORD code SP7[64] = {
 213            0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
 214            0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
 215            0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
 216            0x00000002L, 0x04000000L, 0x04200002L, 0x00000802L,
 217            0x04000800L, 0x00200802L, 0x00200002L, 0x04000800L,
 218            0x04000002L, 0x04200000L, 0x04200800L, 0x00200002L,
 219            0x04200000L, 0x00000800L, 0x00000802L, 0x04200802L,
 220            0x00200800L, 0x00000002L, 0x04000000L, 0x00200800L,
 221            0x04000000L, 0x00200800L, 0x00200000L, 0x04000802L,
 222            0x04000802L, 0x04200002L, 0x04200002L, 0x00000002L,
 223            0x00200002L, 0x04000000L, 0x04000800L, 0x00200000L,
 224            0x04200800L, 0x00000802L, 0x00200802L, 0x04200800L,
 225            0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
 226            0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
 227            0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
 228            0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L
 229          };
 230          
 231          static const DWORD code SP8[64] = {
 232            0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
 233            0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
 234            0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
 235            0x10041000L, 0x00041040L, 0x00001000L, 0x00000040L,
 236            0x10040000L, 0x10000040L, 0x10001000L, 0x00001040L,
 237            0x00041000L, 0x00040040L, 0x10040040L, 0x10041000L,
C51 COMPILER V7.02b   DISK1                                                                03/16/2006 13:52:41 PAGE 5   

 238            0x00001040L, 0x00000000L, 0x00000000L, 0x10040040L,
 239            0x10000040L, 0x10001000L, 0x00041040L, 0x00040000L,
 240            0x00041040L, 0x00040000L, 0x10041000L, 0x00001000L,
 241            0x00000040L, 0x10040040L, 0x00001000L, 0x00041040L,
 242            0x10001000L, 0x00000040L, 0x10000040L, 0x10040000L,
 243            0x10040040L, 0x10000000L, 0x00040000L, 0x10001040L,
 244            0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
 245            0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
 246            0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
 247            0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L
 248          };
 249          
 250          static void Unpack (unsigned char *, DWORD *);
 251          static void Pack (DWORD *, unsigned char *);
 252          static void DoLock (DWORD *, unsigned char *, int); //DESKey
 253          static void UnLock (DWORD *, DWORD *, int); //CookKey
 254          static void Function (DWORD *, DWORD *);   //DESFunction
 255          
 256          /* Initialize context.  Caller must zeroize the context when finished.
 257           */
 258          void Disk2_Init (context, key, iv, encrypt)    //DES_CBCInit
 259          DES_CBC_CTX *context;                                            /* context */
 260          unsigned char key[8];                                                /* key */
 261          unsigned char  iv[8];                                 /* initializing vector */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -