Skip to content
Snippets Groups Projects
Commit 9fdbf217 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #27096: iax: use union instead of dereferencing type-punned pointer

parent 1a4a7f37
Branches
Tags
No related merge requests found
...@@ -116,7 +116,7 @@ void IAX_MD5Update(struct IAX_MD5Context *ctx, uint8_t const *buf, unsigned int ...@@ -116,7 +116,7 @@ void IAX_MD5Update(struct IAX_MD5Context *ctx, uint8_t const *buf, unsigned int
} }
memcpy(p, buf, t); memcpy(p, buf, t);
IAX_byteReverse(ctx->in, 16); IAX_byteReverse(ctx->in, 16);
IAX_MD5Transform(ctx->buf, (uint32_t *) ctx->in); IAX_MD5Transform(ctx->buf, ctx->in_32);
buf += t; buf += t;
len -= t; len -= t;
} }
...@@ -171,10 +171,10 @@ void IAX_MD5Final(uint8_t digest[16], struct IAX_MD5Context *ctx) ...@@ -171,10 +171,10 @@ void IAX_MD5Final(uint8_t digest[16], struct IAX_MD5Context *ctx)
IAX_byteReverse(ctx->in, 14); IAX_byteReverse(ctx->in, 14);
/* Append length in bits and transform */ /* Append length in bits and transform */
((uint32_t *) ctx->in)[14] = ctx->bits[0]; ctx->in_32[14] = ctx->bits[0];
((uint32_t *) ctx->in)[15] = ctx->bits[1]; ctx->in_32[15] = ctx->bits[1];
IAX_MD5Transform(ctx->buf, (uint32_t *) ctx->in); IAX_MD5Transform(ctx->buf, ctx->in_32);
IAX_byteReverse((uint8_t *) ctx->buf, 4); IAX_byteReverse((uint8_t *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16); memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
......
...@@ -11,7 +11,10 @@ typedef unsigned char uint8_t; ...@@ -11,7 +11,10 @@ typedef unsigned char uint8_t;
struct IAX_MD5Context { struct IAX_MD5Context {
uint32_t buf[4]; uint32_t buf[4];
uint32_t bits[2]; uint32_t bits[2];
union {
uint8_t in[64]; uint8_t in[64];
uint32_t in_32[16];
};
}; };
void IAX_MD5Init(struct IAX_MD5Context *context); void IAX_MD5Init(struct IAX_MD5Context *context);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment