diff options
author | Sam Hartman <hartmans@debian.org> | 2023-09-11 14:10:02 -0600 |
---|---|---|
committer | Sam Hartman <hartmans@debian.org> | 2023-09-11 14:10:02 -0600 |
commit | 42408448b00a7a2150b5853dc4f63296b6827e0e (patch) | |
tree | f2d801e728b41563b77ebe89a3d560319ff37d31 /modules/pam_unix/md5.c | |
parent | b99a4f53dcf4725e4b3b861fd8a28c0156a8a147 (diff) | |
parent | e9aa2ef52a423a3a33299bf7e8715eb5bd76ea67 (diff) | |
download | pam-42408448b00a7a2150b5853dc4f63296b6827e0e.tar.gz pam-42408448b00a7a2150b5853dc4f63296b6827e0e.tar.bz2 pam-42408448b00a7a2150b5853dc4f63296b6827e0e.zip |
Update upstream source from tag 'upstream/1.5.3'
Update to upstream version '1.5.3'
with Debian dir 6b9d9dfb8a4ca02d4557097ee59960e72a6a4a29
Diffstat (limited to 'modules/pam_unix/md5.c')
-rw-r--r-- | modules/pam_unix/md5.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/modules/pam_unix/md5.c b/modules/pam_unix/md5.c index 593d6dc3..95b8de4c 100644 --- a/modules/pam_unix/md5.c +++ b/modules/pam_unix/md5.c @@ -21,26 +21,27 @@ #include <string.h> #include "md5.h" +#include "pam_inline.h" + #ifndef HIGHFIRST #define byteReverse(buf, len) /* Nothing */ #else -typedef unsigned char PAM_ATTRIBUTE_ALIGNED(4) uint8_aligned; - -static void byteReverse(uint8_aligned *buf, unsigned longs); +static void byteReverse(uint32 *buf, unsigned longs); #ifndef ASM_MD5 /* * Note: this code is harmless on little-endian machines. */ -static void byteReverse(uint8_aligned *buf, unsigned longs) +static void byteReverse(uint32 *buf, unsigned longs) { uint32 t; do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; + unsigned char *p = (unsigned char *) buf; + t = (uint32) ((unsigned) p[3] << 8 | p[2]) << 16 | + ((unsigned) p[1] << 8 | p[0]); + *buf = t; + ++buf; } while (--longs); } #endif @@ -89,7 +90,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign return; } memcpy(p, buf, t); - byteReverse(ctx->in.c, 16); + byteReverse(ctx->in.i, 16); MD5Name(MD5Transform)(ctx->buf.i, ctx->in.i); buf += t; len -= t; @@ -98,7 +99,7 @@ void MD5Name(MD5Update)(struct MD5Context *ctx, unsigned const char *buf, unsign while (len >= 64) { memcpy(ctx->in.c, buf, 64); - byteReverse(ctx->in.c, 16); + byteReverse(ctx->in.i, 16); MD5Name(MD5Transform)(ctx->buf.i, ctx->in.i); buf += 64; len -= 64; @@ -133,7 +134,7 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); - byteReverse(ctx->in.c, 16); + byteReverse(ctx->in.i, 16); MD5Name(MD5Transform)(ctx->buf.i, ctx->in.i); /* Now fill the next block with 56 bytes */ @@ -142,15 +143,15 @@ void MD5Name(MD5Final)(unsigned char digest[16], struct MD5Context *ctx) /* Pad block to 56 bytes */ memset(p, 0, count - 8); } - byteReverse(ctx->in.c, 14); + byteReverse(ctx->in.i, 14); /* Append length in bits and transform */ memcpy(ctx->in.i + 14, ctx->bits, 2*sizeof(uint32)); MD5Name(MD5Transform)(ctx->buf.i, ctx->in.i); - byteReverse(ctx->buf.c, 4); + byteReverse(ctx->buf.i, 4); memcpy(digest, ctx->buf.c, 16); - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ + pam_overwrite_object(ctx); /* In case it's sensitive */ } #ifndef ASM_MD5 |