diff options
-rw-r--r-- | lgl/Makefile.am | 2 | ||||
-rw-r--r-- | lgl/m4/md4.m4 | 5 | ||||
-rw-r--r-- | lgl/m4/md5.m4 | 5 | ||||
-rw-r--r-- | lgl/m4/sha1.m4 | 5 | ||||
-rw-r--r-- | lgl/m4/unistd_h.m4 | 4 | ||||
-rw-r--r-- | lgl/md2.c | 12 | ||||
-rw-r--r-- | lgl/md2.h | 12 | ||||
-rw-r--r-- | lgl/md4.c | 30 | ||||
-rw-r--r-- | lgl/md4.h | 12 | ||||
-rw-r--r-- | lgl/md5.c | 30 | ||||
-rw-r--r-- | lgl/md5.h | 12 | ||||
-rw-r--r-- | lgl/sha1.c | 32 | ||||
-rw-r--r-- | lgl/sha1.h | 15 | ||||
-rw-r--r-- | lgl/unistd.in.h | 14 |
14 files changed, 81 insertions, 109 deletions
diff --git a/lgl/Makefile.am b/lgl/Makefile.am index d63b3dd98f..a545762b05 100644 --- a/lgl/Makefile.am +++ b/lgl/Makefile.am @@ -646,7 +646,6 @@ unistd.h: unistd.in.h -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ - -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ @@ -658,7 +657,6 @@ unistd.h: unistd.in.h -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ - -e 's|@''HAVE_DECL_GETHOSTNAME''@|$(HAVE_DECL_GETHOSTNAME)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ diff --git a/lgl/m4/md4.m4 b/lgl/m4/md4.m4 index 22a7bdee3e..dda2b1b911 100644 --- a/lgl/m4/md4.m4 +++ b/lgl/m4/md4.m4 @@ -1,5 +1,5 @@ -# md4.m4 serial 2 -dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# md4.m4 serial 3 +dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,4 +10,5 @@ AC_DEFUN([gl_MD4], dnl Prerequisites of lib/md4.c. AC_REQUIRE([AC_C_BIGENDIAN]) + AC_REQUIRE([AC_C_INLINE]) ]) diff --git a/lgl/m4/md5.m4 b/lgl/m4/md5.m4 index 5a1f8755a0..e4d00f3fee 100644 --- a/lgl/m4/md5.m4 +++ b/lgl/m4/md5.m4 @@ -1,5 +1,5 @@ -# md5.m4 serial 9 -dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# md5.m4 serial 10 +dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,5 +10,6 @@ AC_DEFUN([gl_MD5], dnl Prerequisites of lib/md5.c. AC_REQUIRE([AC_C_BIGENDIAN]) + AC_REQUIRE([AC_C_INLINE]) : ]) diff --git a/lgl/m4/sha1.m4 b/lgl/m4/sha1.m4 index c6e6184b2c..12711fae26 100644 --- a/lgl/m4/sha1.m4 +++ b/lgl/m4/sha1.m4 @@ -1,5 +1,5 @@ -# sha1.m4 serial 7 -dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# sha1.m4 serial 8 +dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,5 +10,6 @@ AC_DEFUN([gl_SHA1], dnl Prerequisites of lib/sha1.c. AC_REQUIRE([AC_C_BIGENDIAN]) + AC_REQUIRE([AC_C_INLINE]) : ]) diff --git a/lgl/m4/unistd_h.m4 b/lgl/m4/unistd_h.m4 index daf7677886..4b8857ca5b 100644 --- a/lgl/m4/unistd_h.m4 +++ b/lgl/m4/unistd_h.m4 @@ -1,5 +1,5 @@ # unistd_h.m4 serial 10 -dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -37,7 +37,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) - GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) @@ -50,7 +49,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) - HAVE_DECL_GETHOSTNAME=1;AC_SUBST([HAVE_DECL_GETHOSTNAME]) HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) @@ -1,6 +1,6 @@ /* Functions to compute MD2 message digest of files or memory blocks. according to the definition of MD2 in RFC 1319 from April 1992. - Copyright (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006 + Copyright (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006,2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -53,10 +53,7 @@ md2_init_ctx (struct md2_ctx *ctx) } /* Put result from CTX in first 16 bytes following RESBUF. The result - must be in little endian byte order. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + must be in little endian byte order. */ void * md2_read_ctx (const struct md2_ctx *ctx, void *resbuf) { @@ -66,10 +63,7 @@ md2_read_ctx (const struct md2_ctx *ctx, void *resbuf) } /* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + prolog according to the standard and write the result to RESBUF. */ void * md2_finish_ctx (struct md2_ctx *ctx, void *resbuf) { @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for MD2 sum library functions. - Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2005, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -52,19 +52,13 @@ extern void md2_process_bytes (const void *buffer, size_t len, /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF be correctly - aligned for a 32 bits value. */ + ASCII representation of the message digest. */ extern void *md2_finish_ctx (struct md2_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + to the wanted ASCII representation of the message digest. */ extern void *md2_read_ctx (const struct md2_ctx *ctx, void *resbuf); @@ -1,6 +1,6 @@ /* Functions to compute MD4 message digest of files or memory blocks. according to the definition of MD4 in RFC 1320 from April 1992. - Copyright (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006 + Copyright (C) 1995,1996,1997,1999,2000,2001,2002,2003,2005,2006,2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -64,27 +64,31 @@ md4_init_ctx (struct md4_ctx *ctx) ctx->buflen = 0; } -/* Put result from CTX in first 16 bytes following RESBUF. The result - must be in little endian byte order. +/* Copy the 4 byte value from v into the memory location pointed to by *cp, + If your architecture allows unaligned access this is equivalent to + * (uint32_t *) cp = v */ +static inline void +set_uint32 (char *cp, uint32_t v) +{ + memcpy (cp, &v, sizeof v); +} - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ +/* Put result from CTX in first 16 bytes following RESBUF. The result + must be in little endian byte order. */ void * md4_read_ctx (const struct md4_ctx *ctx, void *resbuf) { - ((uint32_t *) resbuf)[0] = SWAP (ctx->A); - ((uint32_t *) resbuf)[1] = SWAP (ctx->B); - ((uint32_t *) resbuf)[2] = SWAP (ctx->C); - ((uint32_t *) resbuf)[3] = SWAP (ctx->D); + char *r = resbuf; + set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); + set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); + set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); + set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + prolog according to the standard and write the result to RESBUF. */ void * md4_finish_ctx (struct md4_ctx *ctx, void *resbuf) { @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for MD4 sum library functions. - Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2005, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -58,19 +58,13 @@ extern void md4_process_bytes (const void *buffer, size_t len, /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF be correctly - aligned for a 32 bits value. */ + ASCII representation of the message digest. */ extern void *md4_finish_ctx (struct md4_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + to the wanted ASCII representation of the message digest. */ extern void *md4_read_ctx (const struct md4_ctx *ctx, void *resbuf); @@ -1,6 +1,6 @@ /* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. - Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006 + Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -80,27 +80,31 @@ md5_init_ctx (struct md5_ctx *ctx) ctx->buflen = 0; } -/* Put result from CTX in first 16 bytes following RESBUF. The result - must be in little endian byte order. +/* Copy the 4 byte value from v into the memory location pointed to by *cp, + If your architecture allows unaligned access this is equivalent to + * (uint32_t *) cp = v */ +static inline void +set_uint32 (char *cp, uint32_t v) +{ + memcpy (cp, &v, sizeof v); +} - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32-bit value. */ +/* Put result from CTX in first 16 bytes following RESBUF. The result + must be in little endian byte order. */ void * md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { - ((uint32_t *) resbuf)[0] = SWAP (ctx->A); - ((uint32_t *) resbuf)[1] = SWAP (ctx->B); - ((uint32_t *) resbuf)[2] = SWAP (ctx->C); - ((uint32_t *) resbuf)[3] = SWAP (ctx->D); + char *r = resbuf; + set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); + set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); + set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); + set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32-bit value. */ + prolog according to the standard and write the result to RESBUF. */ void * md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { @@ -1,6 +1,6 @@ /* Declaration of functions and data types used for MD5 sum computing library functions. - Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006 + Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -93,19 +93,13 @@ extern void __md5_process_bytes (const void *buffer, size_t len, /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. - - IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit - boundary. */ + ASCII representation of the message digest. */ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. - - IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit - boundary. */ + to the wanted ASCII representation of the message digest. */ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; diff --git a/lgl/sha1.c b/lgl/sha1.c index d4f38775c2..62c96ecd71 100644 --- a/lgl/sha1.c +++ b/lgl/sha1.c @@ -1,7 +1,7 @@ /* sha1.c - Functions to compute SHA1 message digest of files or memory blocks according to the NIST specification FIPS-180-1. - Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software + Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -67,28 +67,32 @@ sha1_init_ctx (struct sha1_ctx *ctx) ctx->buflen = 0; } -/* Put result from CTX in first 20 bytes following RESBUF. The result - must be in little endian byte order. +/* Copy the 4 byte value from v into the memory location pointed to by *cp, + If your architecture allows unaligned access this is equivalent to + * (uint32_t *) cp = v */ +static inline void +set_uint32 (char *cp, uint32_t v) +{ + memcpy (cp, &v, sizeof v); +} - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32-bit value. */ +/* Put result from CTX in first 20 bytes following RESBUF. The result + must be in little endian byte order. */ void * sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) { - ((uint32_t *) resbuf)[0] = SWAP (ctx->A); - ((uint32_t *) resbuf)[1] = SWAP (ctx->B); - ((uint32_t *) resbuf)[2] = SWAP (ctx->C); - ((uint32_t *) resbuf)[3] = SWAP (ctx->D); - ((uint32_t *) resbuf)[4] = SWAP (ctx->E); + char *r = resbuf; + set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); + set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); + set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); + set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); + set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E)); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32-bit value. */ + prolog according to the standard and write the result to RESBUF. */ void * sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) { diff --git a/lgl/sha1.h b/lgl/sha1.h index ed0de2b4e8..8877b12503 100644 --- a/lgl/sha1.h +++ b/lgl/sha1.h @@ -1,6 +1,7 @@ /* Declarations of functions and data types used for SHA1 sum library functions. - Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -22,6 +23,8 @@ # include <stdio.h> # include <stdint.h> +#define SHA1_DIGEST_SIZE 20 + /* Structure to save state of computation between the single steps. */ struct sha1_ctx { @@ -57,19 +60,13 @@ extern void sha1_process_bytes (const void *buffer, size_t len, /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF be correctly - aligned for a 32 bits value. */ + ASCII representation of the message digest. */ extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); /* Put result from CTX in first 20 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. - - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + to the wanted ASCII representation of the message digest. */ extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); diff --git a/lgl/unistd.in.h b/lgl/unistd.in.h index ae6919cd50..10678f4c99 100644 --- a/lgl/unistd.in.h +++ b/lgl/unistd.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around <unistd.h>. - Copyright (C) 2004-2008 Free Software Foundation, Inc. + Copyright (C) 2004-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -156,18 +156,6 @@ extern char * getcwd (char *buf, size_t size); getcwd (b, s)) #endif -#if @GNULIB_GETHOSTNAME@ -# if !@HAVE_DECL_GETHOSTNAME@ -# include <stddef.h> - extern int gethostname (char *name, size_t size); -# endif -#elif defined GNULIB_POSIXCHECK -# undef gethostname -# define gethostname(n,s) \ - (GL_LINK_WARNING ("gethostname is unportable - " \ - "use gnulib module gethostname for portability"), \ - gethostname (n, s)) -#endif #if @GNULIB_GETLOGIN_R@ /* Copies the user's login name to NAME. |