From b4635e3fa83ac97c7ccf1af1d619973b046cbef3 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Tue, 23 Feb 2016 15:33:27 +0900
Subject: [PATCH 5/9] Move sha1.c to src/common

This set of routines taken from pgcrypto will be used on both backend
and frontend for authentication purposes.
---
 contrib/pgcrypto/Makefile                       | 4 ++--
 contrib/pgcrypto/internal.c                     | 2 +-
 src/common/Makefile                             | 3 ++-
 {contrib/pgcrypto => src/common}/sha1.c         | 4 ++--
 {contrib/pgcrypto => src/include/common}/sha1.h | 2 +-
 src/tools/msvc/Mkvcbuild.pm                     | 2 +-
 6 files changed, 9 insertions(+), 8 deletions(-)
 rename {contrib/pgcrypto => src/common}/sha1.c (99%)
 rename {contrib/pgcrypto => src/include/common}/sha1.h (98%)

diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile
index 18bad1a..bb5118e 100644
--- a/contrib/pgcrypto/Makefile
+++ b/contrib/pgcrypto/Makefile
@@ -1,6 +1,6 @@
 # contrib/pgcrypto/Makefile
 
-INT_SRCS = md5.c sha1.c sha2.c internal.c internal-sha2.c blf.c rijndael.c \
+INT_SRCS = md5.c sha2.c internal.c internal-sha2.c blf.c rijndael.c \
 		fortuna.c random.c pgp-mpi-internal.c imath.c
 INT_TESTS = sha2
 
@@ -30,7 +30,7 @@ DATA = pgcrypto--1.2.sql pgcrypto--1.1--1.2.sql pgcrypto--1.0--1.1.sql \
 	pgcrypto--unpackaged--1.0.sql
 PGFILEDESC = "pgcrypto - cryptographic functions"
 
-REGRESS = init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \
+REGRESS = init md5 hmac-md5 hmac-sha1 blowfish rijndael \
 	$(CF_TESTS) \
 	crypt-des crypt-md5 crypt-blowfish crypt-xdes \
 	pgp-armor pgp-decrypt pgp-encrypt $(CF_PGP_TESTS) \
diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c
index cb8ba26..9f42955 100644
--- a/contrib/pgcrypto/internal.c
+++ b/contrib/pgcrypto/internal.c
@@ -35,7 +35,7 @@
 
 #include "px.h"
 #include "md5.h"
-#include "sha1.h"
+#include "common/sha1.h"
 #include "blf.h"
 #include "rijndael.h"
 #include "fortuna.h"
diff --git a/src/common/Makefile b/src/common/Makefile
index f7a4a4d..16052de 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -37,7 +37,8 @@ override CPPFLAGS += -DVAL_LDFLAGS_SL="\"$(LDFLAGS_SL)\""
 override CPPFLAGS += -DVAL_LIBS="\"$(LIBS)\""
 
 OBJS_COMMON = config_info.o controldata_utils.o exec.o pg_lzcompress.o \
-	pgfnames.o psprintf.o relpath.o rmtree.o string.o username.o wait_error.o
+	pgfnames.o psprintf.o relpath.o rmtree.o sha1.o string.o username.o \
+	wait_error.o
 
 OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o restricted_token.o
 
diff --git a/contrib/pgcrypto/sha1.c b/src/common/sha1.c
similarity index 99%
rename from contrib/pgcrypto/sha1.c
rename to src/common/sha1.c
index 0e753ce..4d9a325 100644
--- a/contrib/pgcrypto/sha1.c
+++ b/src/common/sha1.c
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * contrib/pgcrypto/sha1.c
+ * src/common/sha1.c
  */
 /*
  * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
@@ -40,7 +40,7 @@
 
 #include <sys/param.h>
 
-#include "sha1.h"
+#include "common/sha1.h"
 
 /* constant table */
 static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
diff --git a/contrib/pgcrypto/sha1.h b/src/include/common/sha1.h
similarity index 98%
rename from contrib/pgcrypto/sha1.h
rename to src/include/common/sha1.h
index 2f61e45..3cccc76 100644
--- a/contrib/pgcrypto/sha1.h
+++ b/src/include/common/sha1.h
@@ -1,4 +1,4 @@
-/*	contrib/pgcrypto/sha1.h */
+/*	src/include/common/sha1.h */
 /*	   $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $    */
 
 /*
diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
index 949077a..f7e803b 100644
--- a/src/tools/msvc/Mkvcbuild.pm
+++ b/src/tools/msvc/Mkvcbuild.pm
@@ -107,7 +107,7 @@ sub mkvcbuild
 
 	our @pgcommonallfiles = qw(
 	  config_info.c controldata_utils.c exec.c pg_lzcompress.c pgfnames.c
-	  psprintf.c relpath.c rmtree.c string.c username.c wait_error.c);
+	  psprintf.c relpath.c rmtree.c sha1.c string.c username.c wait_error.c);
 
 	our @pgcommonfrontendfiles = (
 		@pgcommonallfiles, qw(fe_memutils.c
-- 
2.7.3

