aboutsummaryrefslogtreecommitdiffstats
path: root/init.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 20:57:56 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 20:57:56 +0100
commit15f132722cae63775dd7b2fef866d477c54c7b8e (patch)
tree27359241e0a1a0b6f304060bc0a9e7c9287efd06 /init.c
parentFirst commit (diff)
downloadlibsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.gz
libsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.bz2
libsha1-15f132722cae63775dd7b2fef866d477c54c7b8e.tar.xz
Implement SHA-0 and remove .chunk_size1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'init.c')
-rw-r--r--init.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/init.c b/init.c
index 4e31556..556f6a8 100644
--- a/init.c
+++ b/init.c
@@ -3,16 +3,9 @@
/**
- * Initial state for SHA-0
+ * Initial state for SHA-1 and SHA-0
*/
-static const uint32_t H_0[] = {
- 0, 0, 0, 0, 0
-};
-
-/**
- * Initial state for SHA_1
- */
-static const uint32_t H_1[] = {
+static const uint32_t H[] = {
0x67452301UL, 0xEFCDAB89UL, 0x98BADCFEUL, 0x10325476UL, 0xC3D2E1F0UL
};
@@ -33,14 +26,13 @@ libsha1_init(struct libsha1_state *restrict state, enum libsha1_algorithm algori
/* Set initial hash values. */
switch (algorithm) {
- case LIBSHA1_0: memcpy(state->h, H_0, sizeof(H_0)); break;
- case LIBSHA1_1: memcpy(state->h, H_1, sizeof(H_1)); break;
+ case LIBSHA1_0:
+ case LIBSHA1_1:
+ memcpy(state->h, H, sizeof(H)); break;
default:
errno = EINVAL;
return -1;
}
- state->chunk_size = 64;
-
return 0;
}