diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:35 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-17 21:02:35 +0200 |
| commit | b5e063d63ecd3dbed1b68b1ea6961137d4f3f153 (patch) | |
| tree | fe2a848ab3208e9de8b362ba769535483472dbd6 /hmac_unmarshal.c | |
| parent | Update year (diff) | |
| download | libsha1-1.1.6.tar.gz libsha1-1.1.6.tar.bz2 libsha1-1.1.6.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'hmac_unmarshal.c')
| -rw-r--r-- | hmac_unmarshal.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hmac_unmarshal.c b/hmac_unmarshal.c index 30e6f78..5f5c2ee 100644 --- a/hmac_unmarshal.c +++ b/hmac_unmarshal.c @@ -5,16 +5,18 @@ size_t libsha1_hmac_unmarshal(struct libsha1_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 @@ libsha1_hmac_unmarshal(struct libsha1_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], sizeof(state->ipad)); |
