Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/mty-makai/mty.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by chapuni, Fri Mar 9 06:49:26 2007 UTC revision 15 by chapuni, Fri Mar 9 11:18:28 2007 UTC
# Line 70  typedef __m128 DQWORD_T; Line 70  typedef __m128 DQWORD_T;
70  typedef uint64_t        WS_T;  typedef uint64_t        WS_T;
71  typedef uint32_t        ALU_T;  typedef uint32_t        ALU_T;
72    
73    #define CRYPT64_CLOBBER /* "%ecx", "%edx", */
74    
75  #elif defined(USE_64)   /* 64-bit ALU */  #elif defined(USE_64)   /* 64-bit ALU */
76    
77  #define N_STRIDE 6  #define N_STRIDE 6
# Line 82  typedef uint64_t       ALU_T; Line 84  typedef uint64_t       ALU_T;
84  typedef DQWORD_T        WS_T;  typedef DQWORD_T        WS_T;
85  typedef uint64_t        ALU_T;  typedef uint64_t        ALU_T;
86    
87    #define CRYPT64_CLOBBER /* "%rcx", "%rdx",*/
88                                      
89  #else   /* XMM */  #else   /* XMM */
90    
91  #define N_STRIDE 7  #define N_STRIDE 7
92  typedef DQWORD_T        WS_T;  typedef DQWORD_T        WS_T;
93  typedef uint32_t        ALU_T;  typedef uint32_t        ALU_T;
94    
95    #define CRYPT64_CLOBBER /* "%ecx", "%edx", */
96    
97  #endif  #endif
98    
99  #define N_I             (sizeof(WS_T) / sizeof(uint32_t))  #define N_I             (sizeof(WS_T) / sizeof(uint32_t))
# Line 121  static int const tr_fp[64 + 2] = Line 127  static int const tr_fp[64 + 2] =
127    64, 64,    64, 64,
128  };  };
129    
130    /* 鍵シフトスケジュール
131       KEY::k[2] を贅沢に用いて取り出しの簡素化を図る */
132    static int ks_ls[] =
133    {
134      1, 1, 2, -1,
135      2, -1, 2, -1,
136      2, -1, 2, -1,
137      2, -1, 1, 2,
138      -1, 2, -1, 2,
139      -1, 2, -1, 2,
140      -1, 2, -1, 1 - 28,
141    };
142    
143  /* 1ビット分 */  /* 1ビット分 */
144  typedef union SLICE  typedef union SLICE
145  {  {
# Line 138  struct PARAM Line 157  struct PARAM
157    SLICE hiti[10][26];    SLICE hiti[10][26];
158  };  };
159    
160  /* 鍵はLR と、そのコピーが必要 */  /* 鍵はLR と、そのコピーが必要
161       KEY::k[0]                    LR
162       KEY::k[1]                    LRのコピー(剰余を省くため)
163       KEY::k[2][0][i].a[0] 次鍵への増分 */
164  struct KEY  struct KEY
165  {  {
166    SLICE k[2][2][28];    SLICE k[2][2][28];
167      SLICE ks[28];
168  };  };
169    
170  /* 漢字クラス表 */  /* 漢字クラス表 */
# Line 968  disp_rm(signed char *pc, Line 991  disp_rm(signed char *pc,
991          }          }
992  }  }
993    
994  #define PTR_T   6       /* SI */  #define PTR_T   7       /* DI(LR+16) */
995    #define OFS_T   (64 + 32 - 16)
996    
997  #ifdef USE_64   /* ALU 64 */  #ifdef USE_64   /* ALU 64 */
998    
# Line 1178  expr_make(signed char *iptr, Line 1202  expr_make(signed char *iptr,
1202                                                             oop,                                                             oop,
1203                                                             1,           /* MM1/R9 */                                                             1,           /* MM1/R9 */
1204                                                             PTR_T,                                                             PTR_T,
1205                                                             sizeof(WS_T) * ((64 * ofs + j) + 32 - 16));                                                             sizeof(WS_T) * (OFS_T + (64 * ofs + j)));
1206                                  oop = OP_OR;                                  oop = OP_OR;
1207                            }                            }
1208                    if (oop != OP_OR)                    if (oop != OP_OR)
# Line 1208  expr_make(signed char *iptr, Line 1232  expr_make(signed char *iptr,
1232                                                   op,                                                   op,
1233                                                   0,             /* MM0/R8 */                                                   0,             /* MM0/R8 */
1234                                                   PTR_T,                                                   PTR_T,
1235                                                   sizeof(WS_T) * ((64 * ofs + c) + 32 - 16));                                                   sizeof(WS_T) * (OFS_T + (64 * ofs + c)));
1236                    op = OP_AND;                    op = OP_AND;
1237                    ofs++;                    ofs++;
1238                  }                  }
# Line 1315  expr_parse(signed char *iptr, Line 1339  expr_parse(signed char *iptr,
1339                                   OP_STOR,                                   OP_STOR,
1340                                   7,     /* MM7/R15 */                                   7,     /* MM7/R15 */
1341                                   PTR_T,                                   PTR_T,
1342                                   sizeof(WS_T) * (31 - 16));                                   sizeof(WS_T) * (64 + 31 - 16));
1343  }  }
1344    
1345  static  static
# Line 1424  main(int argc, char *argv[]) Line 1448  main(int argc, char *argv[])
1448                  }                  }
1449          }          }
1450    
1451      /* キースケジュールをここに押し込めておく
1452             従来は crypt64.S 内で完結するように引いていた */
1453      for (i = 0; i < 28; i++)
1454            key64.ks[i].a[0] = sizeof(WS_T) * ks_ls[i];
1455    
1456    /* Saltを加味しない場合は、コード領域を    /* Saltを加味しない場合は、コード領域を
1457           writable 領域に展開しなくてもよい。           writable 領域に展開しなくてもよい。
1458           [XXX] OSによっては、書込&実行可能領域を専用のサーヴィスで           [XXX] OSによっては、書込&実行可能領域を専用のサーヴィスで
# Line 1514  main(int argc, char *argv[]) Line 1543  main(int argc, char *argv[])
1543                                     : "c"(key64.k), "d"(param64.lr),                                     : "c"(key64.k), "d"(param64.lr),
1544                                     "m"(code)                                     "m"(code)
1545                                     //"m"(crypt64_sta)                                     //"m"(crypt64_sta)
1546                                     :                                     : CRYPT64_CLOBBER "memory");
 #if 0  
                                    "%rbx",  
                                    //"%rcx", "%rdx",  
                                    "%r8","%r9","%r10","%r11",  
 #endif  
                                    "memory");  
1547  #else  #else
1548            cnt = (*d_crypt64)(key64.k[0][0][0].a, param64.lr[0][0].a);            cnt = (*d_crypt64)(key64.k[0][0][0].a, param64.lr[0][0].a);
1549  #endif  #endif

Legend:
Removed from v.14  
changed lines
  Added in v.15

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26