bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] crypto: omit stream ops Emacs doesn’t need


From: Paul Eggert
Subject: [PATCH] crypto: omit stream ops Emacs doesn’t need
Date: Mon, 21 May 2018 10:36:01 -0700

* lib/md5.c (md5_stream):
* lib/sha1.c (sha1_stream):
* lib/sha256.c (shaxxx_stream, sha256_stream, sha224_stream):
* lib/sha512.c (shaxxx_stream, sha512_stream, sha384_stream):
Compile stream functions only if GL_COMPILE_CRYPTO_STREAM is
defined.  Emacs needs this, as it does not use the stream
operations and doesn’t need all the af_alg stuff we’ve recently
added.  Perhaps a similar change is needed to the other crypto
modules, but this patch changes only those needed for Emacs.
* modules/crypto/md5-buffer, modules/crypto/sha1-buffer:
* modules/crypto/sha256-buffer, modules/crypto/sha512-buffer:
New modules, used by Emacs.
* modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256:
* modules/crypto/sha512: Rewrite to depend on the new modules.
---
 ChangeLog                    | 18 ++++++++++++++++++
 lib/md5.c                    |  7 +++++--
 lib/sha1.c                   |  7 +++++--
 lib/sha256.c                 |  7 +++++--
 lib/sha512.c                 |  7 +++++--
 modules/crypto/md5           | 13 ++-----------
 modules/crypto/md5-buffer    | 32 ++++++++++++++++++++++++++++++++
 modules/crypto/sha1          | 13 ++-----------
 modules/crypto/sha1-buffer   | 32 ++++++++++++++++++++++++++++++++
 modules/crypto/sha256        | 13 ++-----------
 modules/crypto/sha256-buffer | 32 ++++++++++++++++++++++++++++++++
 modules/crypto/sha512        | 14 ++------------
 modules/crypto/sha512-buffer | 33 +++++++++++++++++++++++++++++++++
 13 files changed, 175 insertions(+), 53 deletions(-)
 create mode 100644 modules/crypto/md5-buffer
 create mode 100644 modules/crypto/sha1-buffer
 create mode 100644 modules/crypto/sha256-buffer
 create mode 100644 modules/crypto/sha512-buffer

diff --git a/ChangeLog b/ChangeLog
index 78f2ee911..daa6c2b9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2018-05-21  Paul Eggert  <address@hidden>
+
+       crypto: omit stream ops Emacs doesn’t need
+       * lib/md5.c (md5_stream):
+       * lib/sha1.c (sha1_stream):
+       * lib/sha256.c (shaxxx_stream, sha256_stream, sha224_stream):
+       * lib/sha512.c (shaxxx_stream, sha512_stream, sha384_stream):
+       Compile stream functions only if GL_COMPILE_CRYPTO_STREAM is
+       defined.  Emacs needs this, as it does not use the stream
+       operations and doesn’t need all the af_alg stuff we’ve recently
+       added.  Perhaps a similar change is needed to the other crypto
+       modules, but this patch changes only those needed for Emacs.
+       * modules/crypto/md5-buffer, modules/crypto/sha1-buffer:
+       * modules/crypto/sha256-buffer, modules/crypto/sha512-buffer:
+       New modules, used by Emacs.
+       * modules/crypto/md5, modules/crypto/sha1, modules/crypto/sha256:
+       * modules/crypto/sha512: Rewrite to depend on the new modules.
+
 2018-05-20  Pádraig Brady  <address@hidden>
 
        fts: avoid a memory leak edge case
diff --git a/lib/md5.c b/lib/md5.c
index 9b414aaf8..b276a4545 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -32,8 +32,6 @@
 #include <string.h>
 #include <sys/types.h>
 
-#include "af_alg.h"
-
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -136,6 +134,10 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
 }
 #endif
 
+#if defined _LIBC || defined GL_COMPILE_CRYPTO_STREAM
+
+#include "af_alg.h"
+
 /* Compute MD5 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 16 bytes
    beginning at RESBLOCK.  */
@@ -212,6 +214,7 @@ process_partial_block:
   free (buffer);
   return 0;
 }
+#endif
 
 #if ! HAVE_OPENSSL_MD5
 /* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
diff --git a/lib/sha1.c b/lib/sha1.c
index 847e452b7..bb370f3ff 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -33,8 +33,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "af_alg.h"
-
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -124,6 +122,10 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
 }
 #endif
 
+#ifdef GL_COMPILE_CRYPTO_STREAM
+
+#include "af_alg.h"
+
 /* Compute SHA1 message digest for bytes read from STREAM.  The
    resulting message digest number will be written into the 20 bytes
    beginning at RESBLOCK.  */
@@ -200,6 +202,7 @@ sha1_stream (FILE *stream, void *resblock)
   free (buffer);
   return 0;
 }
+#endif
 
 #if ! HAVE_OPENSSL_SHA1
 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
diff --git a/lib/sha256.c b/lib/sha256.c
index 5503c209f..a036befca 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -32,8 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "af_alg.h"
-
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -171,6 +169,10 @@ sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
 }
 #endif
 
+#ifdef GL_COMPILE_CRYPTO_STREAM
+
+#include "af_alg.h"
+
 /* Compute message digest for bytes read from STREAM using algorithm ALG.
    Write the message digest into RESBLOCK, which contains HASHLEN bytes.
    The initial and finishing operations are INIT_CTX and FINISH_CTX.
@@ -264,6 +266,7 @@ sha224_stream (FILE *stream, void *resblock)
   return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
                         sha224_init_ctx, sha224_finish_ctx);
 }
+#endif
 
 #if ! HAVE_OPENSSL_SHA256
 /* Compute SHA256 message digest for LEN bytes beginning at BUFFER.  The
diff --git a/lib/sha512.c b/lib/sha512.c
index 852c43495..e175e705f 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -32,8 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "af_alg.h"
-
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -179,6 +177,10 @@ sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
 }
 #endif
 
+#ifdef GL_COMPILE_CRYPTO_STREAM
+
+#include "af_alg.h"
+
 /* Compute message digest for bytes read from STREAM using algorithm ALG.
    Write the message digest into RESBLOCK, which contains HASHLEN bytes.
    The initial and finishing operations are INIT_CTX and FINISH_CTX.
@@ -272,6 +274,7 @@ sha384_stream (FILE *stream, void *resblock)
   return shaxxx_stream (stream, "sha384", resblock, SHA384_DIGEST_SIZE,
                         sha384_init_ctx, sha384_finish_ctx);
 }
+#endif
 
 #if ! HAVE_OPENSSL_SHA512
 /* Compute SHA512 message digest for LEN bytes beginning at BUFFER.  The
diff --git a/modules/crypto/md5 b/modules/crypto/md5
index 7d8b3fa1c..4c0e165c0 100644
--- a/modules/crypto/md5
+++ b/modules/crypto/md5
@@ -2,29 +2,20 @@ Description:
 Compute MD5 checksum.
 
 Files:
-lib/gl_openssl.h
-lib/md5.h
-lib/md5.c
-m4/gl-openssl.m4
-m4/md5.m4
 
 Depends-on:
 crypto/af_alg
-extern-inline
-stdalign
-stdint
+crypto/md5-buffer
 
 configure.ac:
-gl_MD5
+AC_DEFINE([GL_COMPILE_CRYPTO_STREAM], 1, [Compile Gnulib crypto stream ops.])
 
 Makefile.am:
-lib_SOURCES += md5.c
 
 Include:
 "md5.h"
 
 Link:
-$(LIB_CRYPTO)
 
 License:
 LGPLv2+
diff --git a/modules/crypto/md5-buffer b/modules/crypto/md5-buffer
new file mode 100644
index 000000000..e5fb39ced
--- /dev/null
+++ b/modules/crypto/md5-buffer
@@ -0,0 +1,32 @@
+Description:
+Compute MD5 checksum.
+
+Files:
+lib/gl_openssl.h
+lib/md5.h
+lib/md5.c
+m4/gl-openssl.m4
+m4/md5.m4
+
+Depends-on:
+extern-inline
+stdalign
+stdint
+
+configure.ac:
+gl_MD5
+
+Makefile.am:
+lib_SOURCES += md5.c
+
+Include:
+"md5.h"
+
+Link:
+$(LIB_CRYPTO)
+
+License:
+LGPLv2+
+
+Maintainer:
+Jim Meyering, glibc
diff --git a/modules/crypto/sha1 b/modules/crypto/sha1
index e9fc83afc..27ca39427 100644
--- a/modules/crypto/sha1
+++ b/modules/crypto/sha1
@@ -2,29 +2,20 @@ Description:
 Compute SHA1 checksum.
 
 Files:
-lib/gl_openssl.h
-lib/sha1.h
-lib/sha1.c
-m4/gl-openssl.m4
-m4/sha1.m4
 
 Depends-on:
 crypto/af_alg
-extern-inline
-stdalign
-stdint
+crypto/sha1-buffer
 
 configure.ac:
-gl_SHA1
+AC_DEFINE([GL_COMPILE_CRYPTO_STREAM], 1, [Compile Gnulib crypto stream ops.])
 
 Makefile.am:
-lib_SOURCES += sha1.c
 
 Include:
 "sha1.h"
 
 Link:
-$(LIB_CRYPTO)
 
 License:
 LGPLv2+
diff --git a/modules/crypto/sha1-buffer b/modules/crypto/sha1-buffer
new file mode 100644
index 000000000..d65f99418
--- /dev/null
+++ b/modules/crypto/sha1-buffer
@@ -0,0 +1,32 @@
+Description:
+Compute SHA1 checksum.
+
+Files:
+lib/gl_openssl.h
+lib/sha1.h
+lib/sha1.c
+m4/gl-openssl.m4
+m4/sha1.m4
+
+Depends-on:
+extern-inline
+stdalign
+stdint
+
+configure.ac:
+gl_SHA1
+
+Makefile.am:
+lib_SOURCES += sha1.c
+
+Include:
+"sha1.h"
+
+Link:
+$(LIB_CRYPTO)
+
+License:
+LGPLv2+
+
+Maintainer:
+Jim Meyering
diff --git a/modules/crypto/sha256 b/modules/crypto/sha256
index 2343940cc..6a7528015 100644
--- a/modules/crypto/sha256
+++ b/modules/crypto/sha256
@@ -2,29 +2,20 @@ Description:
 Compute SHA224 and SHA256 checksums.
 
 Files:
-lib/gl_openssl.h
-lib/sha256.h
-lib/sha256.c
-m4/gl-openssl.m4
-m4/sha256.m4
 
 Depends-on:
 crypto/af_alg
-extern-inline
-stdalign
-stdint
+crypto/sha256-buffer
 
 configure.ac:
-gl_SHA256
+AC_DEFINE([GL_COMPILE_CRYPTO_STREAM], 1, [Compile Gnulib crypto stream ops.])
 
 Makefile.am:
-lib_SOURCES += sha256.c
 
 Include:
 "sha256.h"
 
 Link:
-$(LIB_CRYPTO)
 
 License:
 LGPLv2+
diff --git a/modules/crypto/sha256-buffer b/modules/crypto/sha256-buffer
new file mode 100644
index 000000000..37fabfd90
--- /dev/null
+++ b/modules/crypto/sha256-buffer
@@ -0,0 +1,32 @@
+Description:
+Compute SHA224 and SHA256 checksums.
+
+Files:
+lib/gl_openssl.h
+lib/sha256.h
+lib/sha256.c
+m4/gl-openssl.m4
+m4/sha256.m4
+
+Depends-on:
+extern-inline
+stdalign
+stdint
+
+configure.ac:
+gl_SHA256
+
+Makefile.am:
+lib_SOURCES += sha256.c
+
+Include:
+"sha256.h"
+
+Link:
+$(LIB_CRYPTO)
+
+License:
+LGPLv2+
+
+Maintainer:
+Jim Meyering
diff --git a/modules/crypto/sha512 b/modules/crypto/sha512
index 127e67c92..da45e816b 100644
--- a/modules/crypto/sha512
+++ b/modules/crypto/sha512
@@ -2,30 +2,20 @@ Description:
 Compute SHA384 and SHA512 checksums.
 
 Files:
-lib/gl_openssl.h
-lib/sha512.h
-lib/sha512.c
-m4/gl-openssl.m4
-m4/sha512.m4
 
 Depends-on:
 crypto/af_alg
-extern-inline
-stdalign
-stdint
-u64
+crypto/sha512-buffer
 
 configure.ac:
-gl_SHA512
+AC_DEFINE([GL_COMPILE_CRYPTO_STREAM], 1, [Compile Gnulib crypto stream ops.])
 
 Makefile.am:
-lib_SOURCES += sha512.c
 
 Include:
 "sha512.h"
 
 Link:
-$(LIB_CRYPTO)
 
 License:
 LGPLv2+
diff --git a/modules/crypto/sha512-buffer b/modules/crypto/sha512-buffer
new file mode 100644
index 000000000..4c97604cd
--- /dev/null
+++ b/modules/crypto/sha512-buffer
@@ -0,0 +1,33 @@
+Description:
+Compute SHA384 and SHA512 checksums.
+
+Files:
+lib/gl_openssl.h
+lib/sha512.h
+lib/sha512.c
+m4/gl-openssl.m4
+m4/sha512.m4
+
+Depends-on:
+extern-inline
+stdalign
+stdint
+u64
+
+configure.ac:
+gl_SHA512
+
+Makefile.am:
+lib_SOURCES += sha512.c
+
+Include:
+"sha512.h"
+
+Link:
+$(LIB_CRYPTO)
+
+License:
+LGPLv2+
+
+Maintainer:
+Jim Meyering
-- 
2.17.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]