diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-09 21:30:06 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-09 21:30:06 +0100 |
commit | ae42e15f211feb8625450e5dcc899ae29d885ba7 (patch) | |
tree | bddb7469da7d1f32502df31e0d7c0d57aee66fde /digest.c | |
parent | Improve makefile: mv LIBEXT and LIBFLAGS to config.mk (diff) | |
download | libsha2-ae42e15f211feb8625450e5dcc899ae29d885ba7.tar.gz libsha2-ae42e15f211feb8625450e5dcc899ae29d885ba7.tar.bz2 libsha2-ae42e15f211feb8625450e5dcc899ae29d885ba7.tar.xz |
Fix warnings
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'digest.c')
-rw-r--r-- | digest.c | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -16,10 +16,10 @@ libsha2_digest(struct libsha2_state *restrict state, const char *restrict messag char *appendix; size_t i, j, k, n; - if (msglen & ~7) { - libsha2_update(state, message, msglen & ~7); - message += msglen & ~7; - msglen &= 7; + if (msglen & ~(size_t)7) { + libsha2_update(state, message, msglen & ~(size_t)7); + message += msglen & ~(size_t)7; + msglen &= (size_t)7; } k = 8 * state->chunk_size; @@ -31,36 +31,31 @@ libsha2_digest(struct libsha2_state *restrict state, const char *restrict messag if (msglen) { j = 7 - msglen; *appendix = *message; - *appendix |= 1 << j; - *appendix &= ~((1 << j) - 1); + *appendix |= (char)(1 << j); + *appendix &= (char)~((1 << j) - 1); } else { - *appendix = (unsigned char)128; + *appendix = (char)128; } k = state->message_size + msglen; i = state->chunk_size / 8; appendix += n + i - 1; for (i = i < sizeof(size_t) ? i : sizeof(size_t); i--;) - *(appendix - i) = (unsigned char)((k >> (i * 8)) & 255); + *(appendix - i) = (char)((k >> (i * 8)) & 255); n += state->chunk_size; libsha2_update(state, state->appendix, n); n = libsha2_algorithm_output_size(state->algorithm); - switch (state->algorithm) { - case LIBSHA2_224: - case LIBSHA2_256: + if (state->algorithm <= LIBSHA2_256) { for (i = 0; i < 8; i++) for (j = 0; j < (state->chunk_size / 16); j++) if (k = (i + 1) * (state->chunk_size / 16) - j - 1, k < n) output[k] = (char)((state->h.b32[i] >> (8 * j)) & 255); - break; - - default: + } else { for (i = 0; i < 8; i++) for (j = 0; j < (state->chunk_size / 16); j++) if (k = (i + 1) * (state->chunk_size / 16) - j - 1, k < n) output[k] = (char)((state->h.b64[i] >> (8 * j)) & 255); - break; } } |