Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Nov 2018 21:09:41 +0000 (UTC)
From:      Tobias Kortkamp <tobik@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r484222 - in head/mail/libdomainkeys: . files
Message-ID:  <201811052109.wA5L9f22029571@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tobik
Date: Mon Nov  5 21:09:41 2018
New Revision: 484222
URL: https://svnweb.freebsd.org/changeset/ports/484222

Log:
  mail/libdomainkeys: Unbreak with OpenSSL 1.1.1 [1]
  
  - Hook up the test suite
  - Stop installing the test script which is useless beyond port
    testing, and calls a dktest binary that is never installed
    or built normally
  - Cleanup/remove post-patch
  
  PR:		232133
  Submitted by:	Nathan <ndowens@yahoo.com> [1] (based on)
  Obtained from:	PLD Linux [1] (based on)

Added:
  head/mail/libdomainkeys/files/patch-domainkeys.c   (contents, props changed)
Modified:
  head/mail/libdomainkeys/Makefile
  head/mail/libdomainkeys/files/Makefile
  head/mail/libdomainkeys/pkg-plist

Modified: head/mail/libdomainkeys/Makefile
==============================================================================
--- head/mail/libdomainkeys/Makefile	Mon Nov  5 20:34:30 2018	(r484221)
+++ head/mail/libdomainkeys/Makefile	Mon Nov  5 21:09:41 2018	(r484222)
@@ -3,6 +3,7 @@
 
 PORTNAME=	libdomainkeys
 PORTVERSION=	0.69
+PORTREVISION=	1
 CATEGORIES=	mail
 MASTER_SITES=	SF/domainkeys/${PORTNAME}/${PORTVERSION}
 
@@ -14,13 +15,11 @@ USE_LDCONFIG=	yes
 SHLIB_MAJOR=	3
 PLIST_SUB=	SHLIB_MAJOR="${SHLIB_MAJOR}"
 MAKE_ENV=	SHLIB_MAJOR="${SHLIB_MAJOR}"
+MAKEFILE=	${FILESDIR}/Makefile
+TEST_TARGET=	check
 
-post-patch:
-	@${CP} ${FILESDIR}/Makefile ${WRKSRC}/Makefile
-
 post-install:
 	@${MKDIR} ${STAGEDIR}${DATADIR}
 	${INSTALL_SCRIPT} ${WRKSRC}/dknewkey ${STAGEDIR}${DATADIR}
-	${INSTALL_SCRIPT} ${WRKSRC}/test ${STAGEDIR}${DATADIR}/dktest
 
 .include <bsd.port.mk>

Modified: head/mail/libdomainkeys/files/Makefile
==============================================================================
--- head/mail/libdomainkeys/files/Makefile	Mon Nov  5 20:34:30 2018	(r484221)
+++ head/mail/libdomainkeys/files/Makefile	Mon Nov  5 21:09:41 2018	(r484222)
@@ -11,6 +11,12 @@ LDFLAGS+=	-lcrypto -L${OPENSSLBASE}/lib
 
 NO_PROFILE=
 
+dktest: dktest.c
+	${CC} ${CFLAGS} -I. dktest.c -o dktest libdomainkeys.a ${LDFLAGS}
+
+check: dktest
+	./test
+
 makeheader: makeheader.c
 	${CC} ${CFLAGS} makeheader.c -o makeheader
 

Added: head/mail/libdomainkeys/files/patch-domainkeys.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/libdomainkeys/files/patch-domainkeys.c	Mon Nov  5 21:09:41 2018	(r484222)
@@ -0,0 +1,192 @@
+Adapted from
+http://git.pld-linux.org/?p=packages/libdomainkeys.git;a=blob;f=openssl.patch;h=a79c3f6b9431bb339b21937a54ce42c944f67090;hb=0b35df2ead77bfee132c88109c001ba079da27cd
+
+--- domainkeys.c.orig	2008-03-31 22:50:39 UTC
++++ domainkeys.c
+@@ -120,7 +120,11 @@ typedef struct
+ {
+ /* STARTPRIV */
+   int dkmarker;     /* in case somebody casts in */
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+   EVP_MD_CTX mdctx;   /* the hash */
++#else
++  EVP_MD_CTX *mdctx;  /* the hash */
++#endif
+   int signing;      /* our current signing/verifying state */
+   int in_headers;   /* true if we're still processing headers */
+   char *header;     /* points to a malloc'ed block for header. */
+@@ -503,7 +507,24 @@ DK *dk_sign(DK_LIB *dklib, DK_STAT *statp, int canon)
+     return NULL;
+   }
+   dk->canon = canon; /* TC13-simple, TC13-nofws */
+-  EVP_SignInit(&dk->mdctx, dklib->md);
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
++  if (!EVP_SignInit(&dk->mdctx, dklib->md)) {
++    if (statp)
++    {
++      *statp = DKERR(DK_STAT_NORESOURCE);
++    }
++    return NULL;
++  }
++#else
++  dk->mdctx = EVP_MD_CTX_create();
++  if (!dk->mdctx || !EVP_SignInit(dk->mdctx, dklib->md)) {
++    if (statp)
++    {
++      *statp = DKERR(DK_STAT_NORESOURCE);
++    }
++    return NULL;
++  }
++#endif
+ 
+   if (statp)
+   {
+@@ -541,7 +562,24 @@ DK *dk_verify(DK_LIB *dklib, DK_STAT *statp)
+     }
+     return NULL;
+   }
+-  EVP_VerifyInit(&dk->mdctx, dklib->md);
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
++  if (!EVP_VerifyInit(&dk->mdctx, dklib->md)) {
++    if (statp)
++    {
++      *statp = DKERR(DK_STAT_NORESOURCE);
++    }
++    return NULL;
++  }
++#else
++  dk->mdctx = EVP_MD_CTX_create();
++  if (!dk->mdctx || !EVP_VerifyInit(dk->mdctx, dklib->md)) {
++    if (statp)
++    {
++      *statp = DKERR(DK_STAT_NORESOURCE);
++    }
++    return NULL;
++  }
++#endif
+ 
+   if (statp)
+   {
+@@ -928,14 +966,22 @@ static void dkhash(DK *dk, const unsigned char *ptr)
+     {
+ 
+ #ifndef DK_HASH_BUFF
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+       EVP_DigestUpdate(&dk->mdctx, "\r\n", 2);
+ #else
++      EVP_DigestUpdate(dk->mdctx, "\r\n", 2);
++#endif
++#else
+       /* buffer hack */
+       dk->hash_buff[dk->hash_buff_len++] = '\r';
+       dk->hash_buff[dk->hash_buff_len++] = '\n';
+       if (dk->hash_buff_len >= (DK_BLOCK - 1))
+       {
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+         EVP_DigestUpdate(&dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#else
++        EVP_DigestUpdate(dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#endif
+         dk->hash_buff_len = 0;
+       }
+       /* buffer hack */
+@@ -955,13 +1001,21 @@ static void dkhash(DK *dk, const unsigned char *ptr)
+       if (dk->canon == DK_CANON_SIMPLE)//if nofws we ignore \r
+       {
+ #ifndef DK_HASH_BUFF
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+         EVP_DigestUpdate(&dk->mdctx, "\r", 1);
+ #else
++        EVP_DigestUpdate(dk->mdctx, "\r", 1);
++#endif
++#else
+         /* buffer hack */
+         dk->hash_buff[dk->hash_buff_len++] = '\r';
+         if (dk->hash_buff_len >= (DK_BLOCK - 1))
+         {
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+           EVP_DigestUpdate(&dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#else
++          EVP_DigestUpdate(dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#endif
+           dk->hash_buff_len = 0;
+         }
+         /* buffer hack */
+@@ -977,13 +1031,21 @@ static void dkhash(DK *dk, const unsigned char *ptr)
+       dk->state --;
+     }
+ #ifndef DK_HASH_BUFF
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+     EVP_DigestUpdate(&dk->mdctx, ptr, 1);
+ #else
++    EVP_DigestUpdate(dk->mdctx, ptr, 1);
++#endif
++#else
+     /* buffer hack */
+     dk->hash_buff[dk->hash_buff_len++] = *ptr;
+     if (dk->hash_buff_len >= (DK_BLOCK - 1))
+     {
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+       EVP_DigestUpdate(&dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#else
++      EVP_DigestUpdate(dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#endif
+       dk->hash_buff_len = 0;
+     }
+     /* buffer hack */
+@@ -1746,11 +1808,19 @@ DK_STAT dk_end(DK *dk, DK_FLAGS *dkf)
+     //clean out hash buffer
+     dk->hash_buff[dk->hash_buff_len++] = '\r';
+     dk->hash_buff[dk->hash_buff_len++] = '\n';
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+     EVP_DigestUpdate(&dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#else
++    EVP_DigestUpdate(dk->mdctx, dk->hash_buff, dk->hash_buff_len);
++#endif
+     dk->hash_buff_len = 0;
+ #else
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+     EVP_DigestUpdate(&dk->mdctx, "\r\n", 2);
++#else
++    EVP_DigestUpdate(dk->mdctx, "\r\n", 2);
+ #endif
++#endif
+ #ifdef DK_DEBUG
+     fprintf(stderr,"\r\n");
+ #endif
+@@ -1949,7 +2019,11 @@ DK_STAT dk_end(DK *dk, DK_FLAGS *dkf)
+       }
+ 
+       /* using that key, verify that the digest is properly signed */
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+       i = EVP_VerifyFinal(&dk->mdctx, md_value, md_len, publickey);
++#else
++      i = EVP_VerifyFinal(dk->mdctx, md_value, md_len, publickey);
++#endif
+ 
+       if (i > 0)
+       {
+@@ -2058,7 +2132,11 @@ DK_STAT dk_getsig(DK *dk, void *privatekey, unsigned c
+ 
+       siglen = EVP_PKEY_size(pkey);
+       sig = (unsigned char*) OPENSSL_malloc(siglen);
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+       EVP_SignFinal(&dk->mdctx, sig, &siglen, pkey);
++#else
++      EVP_SignFinal(dk->mdctx, sig, &siglen, pkey);
++#endif
+       EVP_PKEY_free(pkey);
+ 
+       bio = BIO_new(BIO_s_mem());
+@@ -2152,7 +2230,11 @@ DK_STAT dk_free(DK *dk, int doClearErrState)
+ #ifdef DK_HASH_BUFF
+   DK_MFREE(dk->hash_buff);
+ #endif
++#if OPENSSL_VERSION_NUMBER < 0x1010000fL
+   EVP_MD_CTX_cleanup(&dk->mdctx);
++#else
++  EVP_MD_CTX_free(dk->mdctx);
++#endif
+   DK_MFREE(dk->header);   /* alloc'ing dk->header is not optional. */
+   dk->dkmarker = ~DKMARK;
+   DK_MFREE(dk);

Modified: head/mail/libdomainkeys/pkg-plist
==============================================================================
--- head/mail/libdomainkeys/pkg-plist	Mon Nov  5 20:34:30 2018	(r484221)
+++ head/mail/libdomainkeys/pkg-plist	Mon Nov  5 21:09:41 2018	(r484222)
@@ -4,4 +4,3 @@ lib/libdomainkeys.a
 lib/libdomainkeys.so
 lib/libdomainkeys.so.%%SHLIB_MAJOR%%
 %%DATADIR%%/dknewkey
-%%DATADIR%%/dktest



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811052109.wA5L9f22029571>