Cryptography Reference
In-Depth Information
119 next_val: ;
120
}
121
}
122 /* ---------------------------------------------- */
123 /* print result */
124 static void print_result(period)
125
{
126
static unsigned char found_keys[MAXKEYS][MAXPERIOD];
127
static char *kd="key dump: ";
128
static found = 0, periods[MAXKEYS];
129
int n, m, c;
130
/* test if key is of form old_keyold_keyold_key... */
131
for(n=found; n--;)
132
if(!(period%periods[n]) &&
133
!memcmp(found_keys[n], key, periods[n]))
134
{
135
for(m = period/periods[n]; m--;)
136
if(memcmp(found_keys[n], key + m*periods[n],
periods[n]))
137
break;
138
if(m < 0) return;
139
}
140
/* store key */
141
if(found < MAXKEYS)
142
{
143
memcpy(found_keys[found], key, period);
144
periods[found++] = period;
145
}
146
/* print */
Figure 3.15:
(
continued
)