Skip to contentSkip to conversation

lib/crypto: md5: remove unused header

PATCH Superseded Mohamad Raizudeen 2 participants 3 messages Oct 15 – Oct 16

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib/crypto: md5: remove unused header

The <linux/unaligned.h> header is included but never actually used. The code handles memory accesses using direct pointer casts and functions like 'cpu_to_le64()' instead of the unaligned helpers.

Remove this unused header to avoid false dependencies.

---
Changes in v2:
- Drop the addition of bitops.h as it is already included by kernel.h.

 lib/crypto/md5.c | 1 -
 1 file changed, 1 deletion(-)
lib/crypto/md5.c +0 -1
index 3d2b017a0525..ded7ccd1a5fc 100644
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/string.h>
-#include <linux/unaligned.h>
 #include <linux/wordpart.h>
 
 static const struct md5_block_state md5_iv = {
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 2 lines · Mohamad Raizudeen

The code handles memory accesses using direct pointer casts and functions like 'cpu_to_le64()' instead of the unaligned helpers.

This should say "using memcpy() instead of the unaligned helpers". The actual unaligned accesses in lib/crypto/md5.c are the following:

        memcpy(in, data, MD5_BLOCK_SIZE);
        le32_to_cpu_array(in, ARRAY_SIZE(in));

    and:

        cpu_to_le32_array(ctx->state.h, ARRAY_SIZE(ctx->state.h));
        memcpy(out, ctx->state.h, MD5_DIGEST_SIZE);

- Eric

#2 lore raw
Quoted 15 lines · Eric Biggers
Quoted 2 lines · Mohamad Raizudeen

The code handles memory accesses using direct pointer casts and functions like 'cpu_to_le64()' instead of the unaligned helpers.

This should say "using memcpy() instead of the unaligned helpers". The actual unaligned accesses in lib/crypto/md5.c are the following:

        memcpy(in, data, MD5_BLOCK_SIZE);
        le32_to_cpu_array(in, ARRAY_SIZE(in));

    and:

        cpu_to_le32_array(ctx->state.h, ARRAY_SIZE(ctx->state.h));
        memcpy(out, ctx->state.h, MD5_DIGEST_SIZE);
Quoted 1 line

- Eric

You are right, the main data block accesses use memcpy().

The reason I mentioned "direct pointer access" because of the *(__le64 *) cast used for the bitcount padding in __md5_final() and hmac_md5_final(). But I agree that mentioning memcpy() is more accurate for the whole file.

I will update the commit message and send a v3 soon.

Thanks,
Mohamad Raizudeen