From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Thu, 18 Apr 2013 18:39:29 +0200 Subject: [U-Boot] [PATCH] crc32: Correct endianness of crc32 result In-Reply-To: <20130418143909.192F720019A@gemini.denx.de> References: <1365203470-9099-1-git-send-email-sjg@chromium.org> <20130406070429.381092002D9@gemini.denx.de> <20130417054047.9D5692001AD@gemini.denx.de> <20130417212326.4f803bfb@lilith> <20130418082027.4b5ea191@lilith> <20130418103600.8E7FB20019A@gemini.denx.de> <20130418131810.38c916b8@lilith> <20130418143909.192F720019A@gemini.denx.de> Message-ID: <20130418183929.4ec73ae3@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, On Thu, 18 Apr 2013 16:39:09 +0200, Wolfgang Denk wrote: > > So how about changing the element type of output in the definition of > > hash_func_ws, adapting the corresponding implementations sha1_csum_wd, > > sha256_csum_wd and crc32_wd_buf, and adapting the output argument > > of the sole call to hash_func_ws, that is, the local "u8 > > output[HASH_MAX_DIGEST_SIZE];" in hash.c? Then we'be done with > > alignment. > > OK, but that would be a totally different approach (which appears to > be a good one, here). Indeed; I would suggest splitting this change in two independent ones: - fix the endianness issue: change the endianness of crc through the use of htonl() but leave the existing memcpy() in place as it is, even though it is not speed-optimized. That's what Simon's patch does if the HOSTCC part is ignored; - fix the unalignment issue by changing parameter 'output' of function type 'hash_func_ws' from u8* to u32* and adjusting the rest of the code accordingly -- which would lead to replacing the crc32 final memcpy() with a single indirect assignment. These two changes could be submitted either separately, or as a series. Amicalement, -- Albert.