aboutsummaryrefslogtreecommitdiffstats
path: root/digest.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-10 15:58:27 +0100
committerMattias Andrée <maandree@kth.se>2019-02-10 15:58:27 +0100
commit6b7209128ee0a7aa22126ed7f4cc3d0c2fee267b (patch)
tree05bea4079bdd0ebc5f0dba72ac77dd568f40d8f4 /digest.c
parentMinor fixes and tests (diff)
downloadlibsha2-6b7209128ee0a7aa22126ed7f4cc3d0c2fee267b.tar.gz
libsha2-6b7209128ee0a7aa22126ed7f4cc3d0c2fee267b.tar.bz2
libsha2-6b7209128ee0a7aa22126ed7f4cc3d0c2fee267b.tar.xz
Use lowest bits rather than highest bits in complete byte, document this, and add tests
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--digest.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/digest.c b/digest.c
index 5dc1600..0b4f474 100644
--- a/digest.c
+++ b/digest.c
@@ -24,6 +24,7 @@ libsha2_digest(struct libsha2_state *restrict state, const char *message, size_t
off = (state->message_size / 8) % state->chunk_size;
if (msglen) {
state->chunk[off] = (unsigned char)*message;
+ state->chunk[off] <<= 8 - msglen;
state->chunk[off] |= (unsigned char)(1 << (7 - msglen));
state->chunk[off] &= (unsigned char)~((1 << (7 - msglen)) - 1);
state->message_size += msglen;