• R/O
  • SSH
  • HTTPS

naniya: Commit


Commit MetaInfo

Revision258 (tree)
Zeit2011-01-07 18:02:08
Autornotanpe

Log Message

残念キーは生キーで表示。
全空間モードを追加。

Ändern Zusammenfassung

Diff

--- branches/mty-makai/mty.c (revision 257)
+++ branches/mty-makai/mty.c (revision 258)
@@ -59,6 +59,13 @@
5959 #define YOUSUMI 6 /* STS_PAN * YOUSUMI 秒様子見 */
6060 int lCntMax;
6161
62+/* 塩固定 */
63+char fixedSalt[3]; /* log_print で使うので大域変数 */
64+#define NUMSC 64 /* 塩の文字種数 */
65+static char saltChar[NUMSC] = "abcdefghijklmnopqrstuvwxyz"
66+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
67+ "0123456789./";
68+
6269 static HANDLE mutex_key;
6370
6471 /* CRYPT64 記述子 */
@@ -408,9 +415,14 @@
408415
409416 OLDPRINT( "n_cpus %d\n", n_cpus );
410417 ploop = &loop_cpu[n_cpus++];
418+ lc = 0;
411419
420+ OLDPRINT( "(unsigned)th %u\n", (unsigned)th );
421+ OLDPRINT( "param->seed %u\n", param->seed );
422+ /* th はスレッドが違っても同じ値になってる */
412423 srand(usec() ^ param->seed ^ (unsigned)th);
413424 key_init(&key);
425+
414426 ReleaseMutex(mutex_key);
415427
416428 #ifdef thread_set_priority
@@ -417,7 +429,50 @@
417429 thread_set_priority(th, param->pri);
418430 #endif
419431
420- lc = 0;
432+ if ( fixedSalt[0] != '\0' ) {
433+ int ki;
434+
435+ key.key[1] = fixedSalt[0];
436+ key.key[2] = fixedSalt[1];
437+ set_salt(code, crypt64_descs[0], key.key);
438+ key.key[7] = '\0';
439+ key.key[8] = '\0';
440+ for ( ;; ) {
441+ for ( ki = 0; ki < 4; ki++ ) {
442+ key.key[ki] = rand() % 0x7f + 1;
443+ key_set64(&pkt->key64, ki, key.key[ki], key.key[ki] ^ pkt->uk.key[ki], 0);
444+ pkt->uk.key[ki] = key.key[ki];
445+ }
446+ for ( key.key[4] = 0x01; key.key[4] <= 0x7f; key.key[4]++ ) {
447+ key_set64(&pkt->key64, 4, key.key[4], key.key[4] ^ pkt->uk.key[4], 0);
448+ pkt->uk.key[4] = key.key[4];
449+ for ( key.key[5] = 0x01; key.key[5] <= 0x7f; key.key[5]++ ) {
450+ key_set64(&pkt->key64, 5, key.key[5], key.key[5] ^ pkt->uk.key[5], 0);
451+ pkt->uk.key[5] = key.key[5];
452+ for ( key.key[6] = 0x01; key.key[6] <= 0x7f; key.key[6]++ ) {
453+ key_set64(&pkt->key64, 6, key.key[6], key.key[6] ^ pkt->uk.key[6], 0);
454+ pkt->uk.key[6] = key.key[6];
455+ CALL_CRYPT64(code, &pkt->key64, &pkt->param64);
456+ CALL_CMP64(cmp, pkt->param64.hit, pkt->param64.lr);
457+ check_hit(pkt, pkt->param64.hit);
458+ (*ploop)++;
459+#ifdef ENABLE_GEAR
460+ lc++;
461+ if ( lCntMax != 0 ) {
462+ if ( lc > lCntMax ) {
463+ OLDPRINT( "before %I64u\n", usec() );
464+ Sleep( (DWORD)GEAR_SLEEP );
465+ OLDPRINT( "after %I64u\n", usec() );
466+ lc = 0;
467+ }
468+ }
469+#endif /* ENABLE_GEAR */
470+ }
471+ }
472+ }
473+ }
474+ }
475+
421476 for (;;)
422477 {
423478 do
@@ -491,7 +546,7 @@
491546
492547 myName = bname( path );
493548 printf( "まあ、待て屋。魔改造版 (%s)\n", KIND );
494- printf( "%s [-h] [-v] [-p num] [-t num|-m mask] [-g num]\n", myName );
549+ printf( "%s [-h] [-v] [-p num] [-t num|-m mask] [-g num] [-z]\n", myName );
495550 printf( " -h : これを表示\n" );
496551 printf( " -v : 冗長メッセージ\n" );
497552 printf( " -p num : 優先度の設定 ( %d ≦ num ≦ %d, デフォルトは %d )\n",
@@ -506,6 +561,7 @@
506561 printf( " -m mask : 実行する CPU を指定するマスク ( 1 ビット ≦ mask のビット数 ≦ %d ビット )\n",
507562 THREAD_MAX );
508563 printf( " -g num : がんばりぐあい ( %d (やる気なし) ≦ num ≦ %d (フルパワー), デフォルトは、%d )\n", GEAR_MIN, GEAR_MAX, GEAR_DEF );
564+ printf( " -z : 全空間モード\n" );
509565 }
510566
511567 /***************************************************************
@@ -545,6 +601,15 @@
545601 } status;
546602 uint64_t curTime;
547603
604+#ifdef USECTEST
605+{
606+ int i;
607+ for ( i = 0; i < USECTEST; i++ ) {
608+ printf( "%I64u\n", usec() );
609+ }
610+}
611+#endif /* USECTEST */
612+
548613 if (!cpuid_issupported())
549614 {
550615 fprintf(stderr, "この環境で走らせることが想定されていません。\n");
@@ -569,10 +634,11 @@
569634 pmask = 0;
570635 verbose = 0;
571636 gear = GEAR_DEF;
637+ fixedSalt[0] = fixedSalt[1] = fixedSalt[2] = '\0';
572638
573- /* abcdef ijkl no qrs u wxyz 未使用 */
574- /* gh m p t v 使用済み */
575- while ( (optChar = getopt(argc, argv, "g:hm:p:t:v")) != EOF ) {
639+ /* abcdef ijkl no qrs u wxy 未使用 */
640+ /* gh m p t v z 使用済み */
641+ while ( (optChar = getopt(argc, argv, "g:hm:p:t:vz")) != EOF ) {
576642 switch ( optChar ) {
577643 case 'g':
578644 #ifdef ENABLE_GEAR
@@ -629,6 +695,11 @@
629695 case 'v':
630696 verbose = 1;
631697 break;
698+ case 'z':
699+ srand( usec() );
700+ fixedSalt[0] = saltChar[rand() % NUMSC];
701+ fixedSalt[1] = saltChar[rand() % NUMSC];
702+ break;
632703 default:
633704 usage( argv[0] );
634705 exit( 1 );
@@ -663,6 +734,7 @@
663734 }
664735
665736 if ( gear != GEAR_MAX ) {
737+ /* CPU 使用率が正しく見えるように、秘孔をついてみる */
666738 TIMECAPS tc;
667739 if ( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) == MMSYSERR_NOERROR ) {
668740 timeBeginPeriod( tc.wPeriodMin );
@@ -693,6 +765,9 @@
693765 } else {
694766 printf( "CPU を %d 割ぐらい使用\n", gear );
695767 }
768+ if ( fixedSalt[0] != '\0' ) {
769+ printf( "全空間モード (salt:%c%c)\n", fixedSalt[0], fixedSalt[1] );
770+ }
696771 }
697772
698773 #ifdef WIN32
@@ -838,7 +913,7 @@
838913 maxSrchCnt = 0;
839914 for ( ;; ) {
840915 uint64_t diffTime;
841- uint64_t spanLoop;
916+ uint64_t spanLoop;
842917
843918 Sleep(STS_SPAN);
844919
@@ -871,7 +946,7 @@
871946 if ( spanSpeed > bestSpeed ) {
872947 bestSpeed = spanSpeed;
873948 if ( gear != GEAR_MAX ) {
874- tmplCntMax = ((maxSrchCnt / (N_ALU * ALU_BITS)) * gear / 10) / ((STS_SPAN - (STS_SPAN * gear / 10)) / GEAR_SLEEP) / nThread;
949+ tmplCntMax = ((maxSrchCnt / (N_ALU * ALU_BITS)) * gear / 10) / ((STS_SPAN - (STS_SPAN * gear / 10)) / GEAR_SLEEP) / nThread;
875950 }
876951 }
877952
--- branches/mty-makai/log.c (revision 257)
+++ branches/mty-makai/log.c (revision 258)
@@ -66,6 +66,7 @@
6666 {
6767 struct timeb tb;
6868 struct tm *plt;
69+ extern char fixedSalt[2];
6970
7071 /* ヒット時刻; 魔改造とちょっと違う */
7172 ftime(&tb);
@@ -73,7 +74,7 @@
7374
7475 WaitForSingleObject(mutex_log, INFINITE);
7576
76- if (full)
77+ if (full && fixedSalt[0] == '\0')
7778 {
7879 log_printf("◆%s #%s"
7980 "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
@@ -93,10 +94,20 @@
9394 }
9495 else
9596 {
96- log_printf("◆%s\t\t\t\t\t(%02X %02X %02X %02X %02X %02X %02X %02X )\n",
97+ log_printf("◆%s ##%02x%02x%02x%02x%02x%02x%02x%02x%s"
98+ "\t%04d/%02d/%02d %02d:%02d:%02d.%03d"
99+ "\t \n", /* ……。ま、いっか */
97100 hash,
98101 key[0], key[1], key[2], key[3],
99- key[4], key[5], key[6], key[7]);
102+ key[4], key[5], key[6], key[7],
103+ fixedSalt,
104+ plt->tm_year + 1900,
105+ plt->tm_mon + 1,
106+ plt->tm_mday,
107+ plt->tm_hour,
108+ plt->tm_min,
109+ plt->tm_sec,
110+ tb.millitm);
100111 }
101112 ReleaseMutex(mutex_log);
102113 }
Show on old repository browser