Skip to content

Commit

Permalink
Maint: gnulib: refresh crypto/md5 module (after ~7 years, bit overdue)
Browse files Browse the repository at this point in the history
Also avoid potentially arising dependency on OpenSSL -- people are
free to require that using --with-openssl, but let's keep that out
by default (as used to be the case before).

Moreover, "nutritious" dependency on kernel-provided crypto (requires
dozen of other Gnulib modoles) has explicitly been cut off as of
preceding commit.

Gnulib version used for the rebootstrap: a18f7ce3c.
  • Loading branch information
jnpkrn committed Mar 28, 2019
1 parent 3726686 commit 4f4a839
Showing 23 changed files with 709 additions and 1,874 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -94,6 +94,8 @@ AC_PROG_CC_STDC
AC_PROG_CXX dnl C++ is not needed for build, just maintainer utilities

gl_EARLY
# We expressly don't want to introduce OpenSSL dependency by default.
gl_SET_CRYPTO_CHECK_DEFAULT([no])
gl_INIT

LT_INIT([dlopen])
104 changes: 46 additions & 58 deletions lib/gnu/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
# Copyright (C) 2002-2019 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,17 +13,31 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
# along with this file. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License,
# this file may be distributed as part of a program that
# contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --lgpl=2 --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files crypto/md5

AUTOMAKE_OPTIONS = 1.5 gnits
# Reproduce by:
# gnulib-tool --import \
# --lib=libgnu \
# --source-base=lib/gnu \
# --m4-base=m4 \
# --doc-base=doc \
# --tests-base=tests \
# --aux-dir=. \
# --lgpl=2 \
# --no-conditional-dependencies \
# --no-libtool \
# --macro-prefix=gl \
# --no-vc-files \
# --avoid=stdint \
# crypto/md5-buffer

AUTOMAKE_OPTIONS = 1.11 gnits

SUBDIRS =
noinst_HEADERS =
@@ -37,6 +51,7 @@ MOSTLYCLEANDIRS =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
# No GNU Make output.

AM_CPPFLAGS =
AM_CFLAGS =
@@ -48,13 +63,36 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES =

## begin gnulib module crypto/md5
## begin gnulib module byteswap

BUILT_SOURCES += $(BYTESWAP_H)

# We need the following in order to create <byteswap.h> when the system
# doesn't have one.
if GL_GENERATE_BYTESWAP_H
byteswap.h: byteswap.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
cat $(srcdir)/byteswap.in.h; \
} > $@-t && \
mv -f $@-t $@
else
byteswap.h: $(top_builddir)/config.status
rm -f $@
endif
MOSTLYCLEANFILES += byteswap.h byteswap.h-t

EXTRA_DIST += byteswap.in.h

## end gnulib module byteswap

## begin gnulib module crypto/md5-buffer

libgnu_a_SOURCES += md5.c

EXTRA_DIST += md5.h
EXTRA_DIST += gl_openssl.h md5.h

## end gnulib module crypto/md5
## end gnulib module crypto/md5-buffer

## begin gnulib module stdalign

@@ -79,56 +117,6 @@ EXTRA_DIST += stdalign.in.h

## end gnulib module stdalign

## begin gnulib module stdint

BUILT_SOURCES += $(STDINT_H)

# We need the following in order to create <stdint.h> when the system
# doesn't have one that works with the given compiler.
if GL_GENERATE_STDINT_H
stdint.h: stdint.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
-e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
-e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
-e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
-e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
-e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
-e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
-e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
-e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
-e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
-e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
-e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
-e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
< $(srcdir)/stdint.in.h; \
} > $@-t && \
mv $@-t $@
else
stdint.h: $(top_builddir)/config.status
rm -f $@
endif
MOSTLYCLEANFILES += stdint.h stdint.h-t

EXTRA_DIST += stdint.in.h

## end gnulib module stdint


mostlyclean-local: mostlyclean-generic
@for dir in '' $(MOSTLYCLEANDIRS); do \
44 changes: 44 additions & 0 deletions lib/gnu/byteswap.in.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* byteswap.h - Byte swapping
Copyright (C) 2005, 2007, 2009-2019 Free Software Foundation, Inc.
Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
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 Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */

#ifndef _GL_BYTESWAP_H
#define _GL_BYTESWAP_H

/* Given an unsigned 16-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
(((x) & 0xFF00) >> 8))

/* Given an unsigned 32-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
(((x) & 0x0000FF00) << 8) | \
(((x) & 0x00FF0000) >> 8) | \
(((x) & 0xFF000000) >> 24))

/* Given an unsigned 64-bit argument X, return the value corresponding to
X with reversed byte order. */
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
(((x) & 0x000000000000FF00ULL) << 40) | \
(((x) & 0x0000000000FF0000ULL) << 24) | \
(((x) & 0x00000000FF000000ULL) << 8) | \
(((x) & 0x000000FF00000000ULL) >> 8) | \
(((x) & 0x0000FF0000000000ULL) >> 24) | \
(((x) & 0x00FF000000000000ULL) >> 40) | \
(((x) & 0xFF00000000000000ULL) >> 56))

#endif /* _GL_BYTESWAP_H */
116 changes: 116 additions & 0 deletions lib/gnu/gl_openssl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
Copyright (C) 2013-2019 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 Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */

/* Written by Pádraig Brady */

#ifndef GL_OPENSSL_NAME
# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
#endif

#ifndef _GL_INLINE_HEADER_BEGIN
# error "Please include config.h first."
#endif
_GL_INLINE_HEADER_BEGIN
#ifndef GL_OPENSSL_INLINE
# define GL_OPENSSL_INLINE _GL_INLINE
#endif

/* Concatenate two preprocessor tokens. */
#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)

#if GL_OPENSSL_NAME == 5
# define OPENSSL_ALG md5
#else
# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
#endif

/* Context type mappings. */
#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
# undef BASE_OPENSSL_TYPE
# if GL_OPENSSL_NAME == 224
# define BASE_OPENSSL_TYPE 256
# elif GL_OPENSSL_NAME == 384
# define BASE_OPENSSL_TYPE 512
# endif
# define md5_CTX MD5_CTX
# define sha1_CTX SHA_CTX
# define sha224_CTX SHA256_CTX
# define sha224_ctx sha256_ctx
# define sha256_CTX SHA256_CTX
# define sha384_CTX SHA512_CTX
# define sha384_ctx sha512_ctx
# define sha512_CTX SHA512_CTX
# undef _gl_CTX
# undef _gl_ctx
# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type. */
# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type. */

struct _gl_ctx { _gl_CTX CTX; };
#endif

/* Function name mappings. */
#define md5_prefix MD5
#define sha1_prefix SHA1
#define sha224_prefix SHA224
#define sha256_prefix SHA256
#define sha384_prefix SHA384
#define sha512_prefix SHA512
#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)

GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }

/* These were never exposed by gnulib. */
#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }

GL_OPENSSL_INLINE void
GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
#endif

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *res)
{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *res)
{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }

GL_OPENSSL_INLINE void *
GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *res)
{
/* Assume any unprocessed bytes in ctx are not to be ignored. */
_gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
return res;
}

/* Undef so we can include multiple times. */
#undef GL_CRYPTO_FN
#undef OPENSSL_FN
#undef _GLCRYPTO_PREFIX
#undef OPENSSL_ALG
#undef GL_OPENSSL_NAME

_GL_INLINE_HEADER_END
Loading

0 comments on commit 4f4a839

Please sign in to comment.