Whamcloud - gitweb
libext2fs: fix up ext2fs_sha256() and ext2fs_sha512()
authorTheodore Ts'o <tytso@mit.edu>
Sun, 8 Mar 2015 22:19:05 +0000 (18:19 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 8 Mar 2015 22:19:05 +0000 (18:19 -0400)
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 <tytso@mit.edu>
lib/ext2fs/Makefile.in
lib/ext2fs/ext2fs.h
lib/ext2fs/sha256.c
lib/ext2fs/sha512.c

index 63aab46..367f440 100644 (file)
@@ -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 \
index e9d9198..0f83efc 100644 (file)
@@ -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,
index 8f3e1f6..103c338 100644 (file)
@@ -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;
index e23cdd0..3539c28 100644 (file)
@@ -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;