diff --git a/include/u-boot/md5.h b/include/u-boot/md5.h
index 08924cce3cf0b520d64f922dcb61953c9fa9f58a..e09c16a6e3fe1e10ca539a6bee5cbba6cf304546 100644
--- a/include/u-boot/md5.h
+++ b/include/u-boot/md5.h
@@ -11,7 +11,10 @@
 struct MD5Context {
 	__u32 buf[4];
 	__u32 bits[2];
-	unsigned char in[64];
+	union {
+		unsigned char in[64];
+		__u32 in32[16];
+	};
 };
 
 /*
diff --git a/lib/md5.c b/lib/md5.c
index 81a09e3f904f3226f52c704b63bd7dc6aa28f3f1..2ae4a06319c4828c9210d79bb031a129a974684f 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -153,8 +153,8 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
 	byteReverse(ctx->in, 14);
 
 	/* Append length in bits and transform */
-	((__u32 *) ctx->in)[14] = ctx->bits[0];
-	((__u32 *) ctx->in)[15] = ctx->bits[1];
+	ctx->in32[14] = ctx->bits[0];
+	ctx->in32[15] = ctx->bits[1];
 
 	MD5Transform(ctx->buf, (__u32 *) ctx->in);
 	byteReverse((unsigned char *) ctx->buf, 4);