This shows you the differences between two versions of the page.
people:solar:software:public-domain-source-code:md4 [2016/06/15 22:39] solar put MD4's two additive constants into "const MD4_u32plus" instead of listing them by value each time |
people:solar:software:public-domain-source-code:md4 [2016/06/16 01:08] (current) solar Documented in a comment a possible C strict aliasing rules violation if the caller's data buffer has effective type that cannot be aliased by MD5_u32plus |
||
---|---|---|---|
Line 75: | Line 75: | ||
/* | /* | ||
- | * SET reads 4 input bytes in little-endian byte order and stores them | + | * SET reads 4 input bytes in little-endian byte order and stores them in a |
- | * in a properly aligned word in host byte order. | + | * properly aligned word in host byte order. |
* | * | ||
- | * The check for little-endian architectures that tolerate unaligned | + | * The check for little-endian architectures that tolerate unaligned memory |
- | * memory accesses is just an optimization. Nothing will break if it | + | * accesses is just an optimization. Nothing will break if it fails to detect |
- | * doesn't work. | + | * a suitable architecture. |
+ | * | ||
+ | * Unfortunately, this optimization may be a C strict aliasing rules violation | ||
+ | * if the caller's data buffer has effective type that cannot be aliased by | ||
+ | * MD4_u32plus. In practice, this problem may occur if these MD4 routines are | ||
+ | * inlined into a calling function, or with future and dangerously advanced | ||
+ | * link-time optimizations. For the time being, keeping these MD4 routines in | ||
+ | * their own translation unit avoids the problem. | ||
*/ | */ | ||
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) | #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) | ||
Line 99: | Line 106: | ||
/* | /* | ||
- | * This processes one or more 64-byte data blocks, but does NOT update | + | * This processes one or more 64-byte data blocks, but does NOT update the bit |
- | * the bit counters. There are no alignment requirements. | + | * counters. There are no alignment requirements. |
*/ | */ | ||
static const void *body(MD4_CTX *ctx, const void *data, unsigned long size) | static const void *body(MD4_CTX *ctx, const void *data, unsigned long size) |