Better MD5 support with test vectors, speed test and libcrypto fast implementation.

This commit is contained in:
Andrea Mazzoleni 2011-03-25 21:04:46 +01:00
parent 26c0e26a33
commit face268eb1
14 changed files with 182 additions and 53 deletions

13
state.c
View file

@ -37,11 +37,6 @@ void state_init(struct snapraid_state* state)
state->parity[0] = 0;
tommy_array_init(&state->diskarr);
tommy_list_init(&state->excludelist);
if (sizeof(off_t) < sizeof(uint64_t)) {
fprintf(stderr, "Missing support for large files\n");
exit(EXIT_FAILURE);
}
}
void state_done(struct snapraid_state* state)
@ -260,7 +255,7 @@ void state_read(struct snapraid_state* state)
/* set the hash only if present */
if (*hash != 0) {
e = strdechex(block->hash, HASH_MAX, hash);
e = strdechex(block->hash, MD5_SIZE, hash);
if (e) {
fprintf(stderr, "Invalid 'blk' specification in '%s' at line %u\n", path, line);
exit(EXIT_FAILURE);
@ -465,9 +460,9 @@ void state_write(struct snapraid_state* state)
}
if (bit_has(block->flag, BLOCK_HAS_HASH)) {
char s_hash[HASH_MAX*2+1];
strenchex(s_hash, block->hash, HASH_MAX);
s_hash[HASH_MAX*2] = 0;
char s_hash[MD5_SIZE*2+1];
strenchex(s_hash, block->hash, MD5_SIZE);
s_hash[MD5_SIZE*2] = 0;
ret = fprintf(f, "%s %u %s\n", tag, block->parity_pos, s_hash);
} else {
ret = fprintf(f, "%s %u\n", tag, block->parity_pos);