btrfs-progs: tests: fssum, switch from MD5 to SHA256
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4ddd6055c3
commit
b5d4b3cef3
5
Makefile
5
Makefile
|
@ -466,10 +466,9 @@ library-test.static: library-test.c messages.static.o $(libs_static)
|
|||
@echo " [TEST CLEAN] $@"
|
||||
$(Q)$(RM) -rf -- $(TMPD)
|
||||
|
||||
fssum: tests/fssum.c
|
||||
fssum: tests/fssum.c tests/sha224-256.c
|
||||
@echo " [LD] $@"
|
||||
# FIXME: no configure-time check for libcrypto from SSL
|
||||
$(Q)$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) -lcrypto
|
||||
$(Q)$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test-build: test-build-pre test-build-real
|
||||
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include "tests/sha.h"
|
||||
|
||||
#define CS_SIZE 16
|
||||
#define CS_SIZE 32
|
||||
#define CHUNKS 128
|
||||
|
||||
#ifndef SEEK_DATA
|
||||
|
@ -47,8 +47,8 @@ struct excludes {
|
|||
};
|
||||
|
||||
typedef struct _sum {
|
||||
MD5_CTX md5;
|
||||
unsigned char out[16];
|
||||
SHA256Context sha;
|
||||
unsigned char out[CS_SIZE];
|
||||
} sum_t;
|
||||
|
||||
typedef int (*sum_file_data_t)(int fd, sum_t *dst);
|
||||
|
@ -173,19 +173,19 @@ alloc(size_t sz)
|
|||
void
|
||||
sum_init(sum_t *cs)
|
||||
{
|
||||
MD5_Init(&cs->md5);
|
||||
SHA256Reset(&cs->sha);
|
||||
}
|
||||
|
||||
void
|
||||
sum_fini(sum_t *cs)
|
||||
{
|
||||
MD5_Final(cs->out, &cs->md5);
|
||||
SHA256Result(&cs->sha, cs->out);
|
||||
}
|
||||
|
||||
void
|
||||
sum_add(sum_t *cs, void *buf, int size)
|
||||
{
|
||||
MD5_Update(&cs->md5, buf, size);
|
||||
SHA256Input(&cs->sha, buf, size);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue