関数 | |
uint32 | get_checksum1 (char *buf1, int32 len) |
void | get_checksum2 (char *buf, int32 len, char *sum) |
void | file_checksum (char *fname, char *sum, OFF_T size) |
void | sum_init (int seed) |
void | sum_update (char *p, int32 len) |
Feed data into an MD4 accumulator, md. | |
void | sum_end (char *sum) |
変数 | |
int | csum_length = 2 |
int | checksum_seed |
int | protocol_version |
static int32 | sumresidue |
static char | sumrbuf [CSUM_CHUNK] |
static struct mdfour | md |
uint32 get_checksum1 | ( | char * | buf1, | |
int32 | len | |||
) |
checksum.c の 33 行で定義されています。
参照先 buf.
参照元 generate_and_send_sums()・hash_search().
00034 { 00035 int32 i; 00036 uint32 s1, s2; 00037 schar *buf = (schar *)buf1; 00038 00039 s1 = s2 = 0; 00040 for (i = 0; i < (len-4); i+=4) { 00041 s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] + 00042 10*CHAR_OFFSET; 00043 s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET); 00044 } 00045 for (; i < len; i++) { 00046 s1 += (buf[i]+CHAR_OFFSET); s2 += s1; 00047 } 00048 return (s1 & 0xffff) + (s2 << 16); 00049 }
void get_checksum2 | ( | char * | buf, | |
int32 | len, | |||
char * | sum | |||
) |
checksum.c の 52 行で定義されています。
参照先 checksum_seed・m・mdfour_begin()・mdfour_result()・mdfour_update()・out_of_memory()・protocol_version.
参照元 generate_and_send_sums()・hash_search().
00053 { 00054 int32 i; 00055 static char *buf1; 00056 static int32 len1; 00057 struct mdfour m; 00058 00059 if (len > len1) { 00060 if (buf1) 00061 free(buf1); 00062 buf1 = new_array(char, len+4); 00063 len1 = len; 00064 if (!buf1) 00065 out_of_memory("get_checksum2"); 00066 } 00067 00068 mdfour_begin(&m); 00069 00070 memcpy(buf1,buf,len); 00071 if (checksum_seed) { 00072 SIVAL(buf1,len,checksum_seed); 00073 len += 4; 00074 } 00075 00076 for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) { 00077 mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK); 00078 } 00079 /* 00080 * Prior to version 27 an incorrect MD4 checksum was computed 00081 * by failing to call mdfour_tail() for block sizes that 00082 * are multiples of 64. This is fixed by calling mdfour_update() 00083 * even when there are no more bytes. 00084 */ 00085 if (len - i > 0 || protocol_version >= 27) { 00086 mdfour_update(&m, (uchar *)(buf1+i), (len-i)); 00087 } 00088 00089 mdfour_result(&m, (uchar *)sum); 00090 }
void file_checksum | ( | char * | fname, | |
char * | sum, | |||
OFF_T | size | |||
) |
checksum.c の 93 行で定義されています。
参照先 buf・do_open()・map_struct::fd・m・map_file()・map_ptr()・mdfour_begin()・mdfour_result()・mdfour_update()・protocol_version・unmap_file().
参照元 make_file()・unchanged_file().
00094 { 00095 OFF_T i; 00096 struct map_struct *buf; 00097 int fd; 00098 OFF_T len = size; 00099 struct mdfour m; 00100 00101 memset(sum,0,MD4_SUM_LENGTH); 00102 00103 fd = do_open(fname, O_RDONLY, 0); 00104 if (fd == -1) 00105 return; 00106 00107 buf = map_file(fd, size, MAX_MAP_SIZE, CSUM_CHUNK); 00108 00109 mdfour_begin(&m); 00110 00111 for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) { 00112 mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK), 00113 CSUM_CHUNK); 00114 } 00115 00116 /* Prior to version 27 an incorrect MD4 checksum was computed 00117 * by failing to call mdfour_tail() for block sizes that 00118 * are multiples of 64. This is fixed by calling mdfour_update() 00119 * even when there are no more bytes. */ 00120 if (len - i > 0 || protocol_version >= 27) 00121 mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i); 00122 00123 mdfour_result(&m, (uchar *)sum); 00124 00125 close(fd); 00126 unmap_file(buf); 00127 }
void sum_init | ( | int | seed | ) |
checksum.c の 134 行で定義されています。
参照先 md・mdfour_begin()・sum_update()・sumresidue.
参照元 gen_challenge()・generate_hash()・match_sums()・receive_data().
00135 { 00136 char s[4]; 00137 mdfour_begin(&md); 00138 sumresidue = 0; 00139 SIVAL(s, 0, seed); 00140 sum_update(s, 4); 00141 }
void sum_update | ( | char * | p, | |
int32 | len | |||
) |
Feed data into an MD4 accumulator, md.
The results may be retrieved using sum_end(). md is used for different purposes at different points during execution.
checksum.c の 151 行で定義されています。
参照先 md・mdfour_update()・sumrbuf・sumresidue.
参照元 gen_challenge()・generate_hash()・match_sums()・matched()・receive_data()・sum_init().
00152 { 00153 if (len + sumresidue < CSUM_CHUNK) { 00154 memcpy(sumrbuf + sumresidue, p, len); 00155 sumresidue += len; 00156 return; 00157 } 00158 00159 if (sumresidue) { 00160 int32 i = CSUM_CHUNK - sumresidue; 00161 memcpy(sumrbuf + sumresidue, p, i); 00162 mdfour_update(&md, (uchar *)sumrbuf, CSUM_CHUNK); 00163 len -= i; 00164 p += i; 00165 } 00166 00167 while (len >= CSUM_CHUNK) { 00168 mdfour_update(&md, (uchar *)p, CSUM_CHUNK); 00169 len -= CSUM_CHUNK; 00170 p += CSUM_CHUNK; 00171 } 00172 00173 sumresidue = len; 00174 if (sumresidue) 00175 memcpy(sumrbuf, p, sumresidue); 00176 }
void sum_end | ( | char * | sum | ) |
checksum.c の 178 行で定義されています。
参照先 md・mdfour_result()・mdfour_update()・protocol_version・sumrbuf・sumresidue.
参照元 gen_challenge()・generate_hash()・receive_data().
00179 { 00180 if (sumresidue || protocol_version >= 27) 00181 mdfour_update(&md, (uchar *)sumrbuf, sumresidue); 00182 00183 mdfour_result(&md, (uchar *)sum); 00184 }
int csum_length = 2 |
checksum.c の 22 行で定義されています。
参照元 generate_files()・read_sum_head()・recv_files()・send_files()・sum_sizes_sqroot().
int checksum_seed |
int protocol_version |
int32 sumresidue [static] |
char sumrbuf[CSUM_CHUNK] [static] |