aboutsummaryrefslogtreecommitdiffstats
path: root/hmac_unmarshal.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-17 21:02:39 +0200
committerMattias Andrée <m@maandree.se>2026-05-17 21:02:39 +0200
commit5fb2a5fe67521a452463e6b91cee406ec14c35a0 (patch)
treef6be3a0c9086ef7122a7d5789818bdc7c0bb1081 /hmac_unmarshal.c
parentUpdate year (diff)
downloadlibsha2-b5a4c67f7b6cb0ba294eafcba7ae4e3cb91f60dd.tar.gz
libsha2-b5a4c67f7b6cb0ba294eafcba7ae4e3cb91f60dd.tar.bz2
libsha2-b5a4c67f7b6cb0ba294eafcba7ae4e3cb91f60dd.tar.xz
Fix mistakesHEAD1.1.5master
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'hmac_unmarshal.c')
-rw-r--r--hmac_unmarshal.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hmac_unmarshal.c b/hmac_unmarshal.c
index 197ea32..5ce2a5e 100644
--- a/hmac_unmarshal.c
+++ b/hmac_unmarshal.c
@@ -5,16 +5,18 @@
size_t
libsha2_hmac_unmarshal(struct libsha2_hmac_state *restrict state, const void *restrict buf_, size_t bufsize)
{
- const char *restrict buf = buf_;
+ const unsigned char *restrict buf = buf_;
size_t off = 0;
size_t r;
+ int version;
if (bufsize < sizeof(int)) {
errno = EINVAL;
return 0;
}
- if (*(const int *)buf) { /* version */
+ memcpy(&version, buf, sizeof(int));
+ if (version != 0) {
errno = EINVAL;
return 0;
}
@@ -30,10 +32,10 @@ libsha2_hmac_unmarshal(struct libsha2_hmac_state *restrict state, const void *re
return 0;
}
- state->outsize = *(const size_t *)&buf[off];
+ memcpy(&state->outsize, &buf[off], sizeof(size_t));
off += sizeof(size_t);
- state->inited = *(const unsigned char *)&buf[off];
+ state->inited = buf[off];
off += sizeof(unsigned char);
memcpy(state->ipad, &buf[off], state->sha2_state.chunk_size);