From: Theodore Ts'o Date: Sun, 8 Mar 2015 22:19:05 +0000 (-0400) Subject: libext2fs: fix up ext2fs_sha256() and ext2fs_sha512() X-Git-Tag: v1.43-WIP-2015-05-18~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a5bdaf73d8f8e707910cf9aaba01cc5d582625c;p=thirdparty%2Fe2fsprogs.git libext2fs: fix up ext2fs_sha256() and ext2fs_sha512() Add const annotation to the input pointers; also run the tst_sha256 and tst_sha512 unit tests on a "make check". Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in index 63aab4646..367f440f3 100644 --- a/lib/ext2fs/Makefile.in +++ b/lib/ext2fs/Makefile.in @@ -579,7 +579,7 @@ clean:: tst_bitops tst_types tst_icount tst_super_size tst_csum \ tst_bitmaps tst_bitmaps_out tst_extents tst_inline \ tst_inline_data tst_inode_size tst_bitmaps_cmd.c \ - tst_digest_encode \ + tst_digest_encode tst_sha256 tst_sha512 \ ext2_tdbtool mkjournal debug_cmds.c tst_cmds.c extent_cmds.c \ ../libext2fs.a ../libext2fs_p.a ../libext2fs_chk.a \ crc32c_table.h gen_crc32ctable tst_crc32c tst_libext2fs \ diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index e9d919835..0f83efc52 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1577,13 +1577,15 @@ extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, /* res_gdt.c */ extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs); +/*sha256.c */ +#define EXT2FS_SHA256_LENGTH 32 +extern void ext2fs_sha256(const unsigned char *in, unsigned long in_size, + unsigned char out[EXT2FS_SHA256_LENGTH]); + /* sha512.c */ #define EXT2FS_SHA512_LENGTH 64 -extern void ext2fs_sha512(unsigned char *in, unsigned long in_size, +extern void ext2fs_sha512(const unsigned char *in, unsigned long in_size, unsigned char out[EXT2FS_SHA512_LENGTH]); -#define EXT2FS_SHA256_LENGTH 32 -void ext2fs_sha256(unsigned char *in, unsigned long in_size, - unsigned char out[EXT2FS_SHA256_LENGTH]); /* swapfs.c */ extern errcode_t ext2fs_dirent_swab_in2(ext2_filsys fs, char *buf, size_t size, diff --git a/lib/ext2fs/sha256.c b/lib/ext2fs/sha256.c index 8f3e1f612..103c33876 100644 --- a/lib/ext2fs/sha256.c +++ b/lib/ext2fs/sha256.c @@ -195,7 +195,7 @@ static void sha256_done(struct hash_state * md, unsigned char *out) } } -void ext2fs_sha256(unsigned char *in, unsigned long in_size, +void ext2fs_sha256(const unsigned char *in, unsigned long in_size, unsigned char out[EXT2FS_SHA256_LENGTH]) { struct hash_state md; diff --git a/lib/ext2fs/sha512.c b/lib/ext2fs/sha512.c index e23cdd0c1..3539c281f 100644 --- a/lib/ext2fs/sha512.c +++ b/lib/ext2fs/sha512.c @@ -204,7 +204,7 @@ static void sha512_done(struct hash_state * md, unsigned char *out) #define MIN(x, y) ( ((x)<(y))?(x):(y) ) #define SHA512_BLOCKSIZE 512 static void sha512_process(struct hash_state * md, - unsigned char *in, + const unsigned char *in, unsigned long inlen) { unsigned long n; @@ -231,7 +231,7 @@ static void sha512_process(struct hash_state * md, } } -void ext2fs_sha512(unsigned char *in, unsigned long in_size, +void ext2fs_sha512(const unsigned char *in, unsigned long in_size, unsigned char out[EXT2FS_SHA512_LENGTH]) { struct hash_state md;