[xmlsec] gnutls dependency trouble

Aleksey Sanin aleksey at aleksey.com
Sat Jan 10 19:11:05 PST 2004


The support for gnutls < 1.0 is restored (i.e. now xmlsec supports 
*both* old gnutls >= 0.8.0
and new gnutls >= 1.0.0). The attached patch is checked in CVS.

Aleksey

-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/gnome/xmlsec/configure.in,v
retrieving revision 1.104
diff -u -r1.104 configure.in
--- configure.in	5 Jan 2004 21:02:15 -0000	1.104
+++ configure.in	11 Jan 2004 03:01:26 -0000
@@ -401,7 +401,8 @@
 dnl ==========================================================================
 GNUTLS_CONFIG="libgnutls-config"
 XMLSEC_NO_GNUTLS="1"
-GNUTLS_MIN_VERSION="1.0.4"
+GNUTLS_MIN_VERSION="0.8.1"
+GNUTLS_NEW_MIN_VERSION="1.0.0"
 GNUTLS_VERSION=""
 GNUTLS_CFLAGS=""
 GNUTLS_LIBS=""
@@ -413,9 +414,16 @@
     AC_MSG_RESULT(no)
     GNUTLS_FOUND="without"
 elif test "z$with_gnutls" = "z" -a "z$PKG_CONFIG_ENABLED" = "zyes" ; then
-    PKG_CHECK_MODULES(GNUTLS, libgnutls >= $GNUTLS_MIN_VERSION,
+    PKG_CHECK_MODULES(GNUTLS, libgnutls >= $GNUTLS_NEW_MIN_VERSION,
 	[GNUTLS_FOUND=yes],
 	[GNUTLS_FOUND=no])
+
+    if test "z$GNUTLS_FOUND" = "zno" ; then 
+	PKG_CHECK_MODULES(GNUTLS, libgnutls >= $GNUTLS_MIN_VERSION,
+	    [GNUTLS_FOUND=yes],
+	    [GNUTLS_FOUND=no])
+	GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DXMLSEC_GNUTLS_OLD=1"
+    fi
 fi
 
 if test "z$GNUTLS_FOUND" = "zno" ; then 
@@ -436,6 +444,11 @@
 	    GNUTLS_CFLAGS="$GNUTLS_CFLAGS `$GNUTLS_CONFIG --cflags`"
     	    GNUTLS_LIBS="$GNUTLS_LIBS `$GNUTLS_CONFIG --libs`"
 	    GNUTLS_FOUND=yes
+	
+	    new_minvers=`echo $GNUTLS_NEW_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+	    if test "$vers" -lt "$new_minvers" ; then
+		GNUTLS_CFLAGS="$GNUTLS_CFLAGS -DXMLSEC_GNUTLS_OLD=1"
+	    fi    
 	    AC_MSG_RESULT(yes)
 	else
     	    AC_MSG_ERROR(You need at least gnutls $GNUTLS_MIN_VERSION for this version of $PACKAGE)
Index: src/gnutls/ciphers.c
===================================================================
RCS file: /cvs/gnome/xmlsec/src/gnutls/ciphers.c,v
retrieving revision 1.19
diff -u -r1.19 ciphers.c
--- src/gnutls/ciphers.c	5 Jan 2004 20:45:51 -0000	1.19
+++ src/gnutls/ciphers.c	11 Jan 2004 03:01:27 -0000
@@ -446,7 +446,9 @@
 static int 
 xmlSecGnuTLSBlockCipherInitialize(xmlSecTransformPtr transform) {
     xmlSecGnuTLSBlockCipherCtxPtr ctx;
+#ifndef XMLSEC_GNUTLS_OLD
     gpg_err_code_t ret;
+#endif /* XMLSEC_GNUTLS_OLD */
     
     xmlSecAssert2(xmlSecGnuTLSBlockCipherCheckId(transform), -1);
     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGnuTLSBlockCipherSize), -1);
@@ -488,9 +490,14 @@
 		    XMLSEC_ERRORS_NO_MESSAGE);
 	return(-1);
     }        
-    
+
+#ifndef XMLSEC_GNUTLS_OLD
     ret = gcry_cipher_open(&ctx->cipherCtx, ctx->cipher, ctx->mode, GCRY_CIPHER_SECURE); /* we are paranoid */
     if(ret != GPG_ERR_NO_ERROR) {
+#else /* XMLSEC_GNUTLS_OLD */ 
+    ctx->cipherCtx = gcry_cipher_open(ctx->cipher, ctx->mode, GCRY_CIPHER_SECURE); /* we are paranoid */
+    if(ctx->cipherCtx == NULL) {
+#endif /* XMLSEC_GNUTLS_OLD */
 	xmlSecError(XMLSEC_ERRORS_HERE, 
 		    xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
 		    "gcry_cipher_open",
Index: src/gnutls/digests.c
===================================================================
RCS file: /cvs/gnome/xmlsec/src/gnutls/digests.c,v
retrieving revision 1.11
diff -u -r1.11 digests.c
--- src/gnutls/digests.c	5 Jan 2004 20:45:51 -0000	1.11
+++ src/gnutls/digests.c	11 Jan 2004 03:01:28 -0000
@@ -74,7 +74,9 @@
 static int 
 xmlSecGnuTLSDigestInitialize(xmlSecTransformPtr transform) {
     xmlSecGnuTLSDigestCtxPtr ctx;
+#ifndef XMLSEC_GNUTLS_OLD
     gpg_err_code_t ret;
+#endif /* XMLSEC_GNUTLS_OLD */
 
     xmlSecAssert2(xmlSecGnuTLSDigestCheckId(transform), -1);
     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGnuTLSDigestSize), -1);
@@ -100,8 +102,13 @@
 	return(-1);
     }
     
+#ifndef XMLSEC_GNUTLS_OLD
     ret = gcry_md_open(&ctx->digestCtx, ctx->digest, GCRY_MD_FLAG_SECURE); /* we are paranoid */
     if(ret != GPG_ERR_NO_ERROR) {
+#else /* XMLSEC_GNUTLS_OLD */
+    ctx->digestCtx = gcry_md_open(ctx->digest, GCRY_MD_FLAG_SECURE); /* we are paranoid */
+    if(ctx->digestCtx == NULL) {
+#endif /* XMLSEC_GNUTLS_OLD */
 	xmlSecError(XMLSEC_ERRORS_HERE, 
 		    xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
 		    "gcry_md_open",
Index: src/gnutls/hmac.c
===================================================================
RCS file: /cvs/gnome/xmlsec/src/gnutls/hmac.c,v
retrieving revision 1.13
diff -u -r1.13 hmac.c
--- src/gnutls/hmac.c	5 Jan 2004 20:45:51 -0000	1.13
+++ src/gnutls/hmac.c	11 Jan 2004 03:01:28 -0000
@@ -74,7 +74,9 @@
 static int 
 xmlSecGnuTLSHmacInitialize(xmlSecTransformPtr transform) {
     xmlSecGnuTLSHmacCtxPtr ctx;
+#ifndef XMLSEC_GNUTLS_OLD
     gpg_err_code_t ret;
+#endif /* XMLSEC_GNUTLS_OLD */
 
     xmlSecAssert2(xmlSecGnuTLSHmacCheckId(transform), -1);
     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGnuTLSHmacSize), -1);
@@ -98,8 +100,13 @@
 	return(-1);
     }
     
+#ifndef XMLSEC_GNUTLS_OLD
     ret = gcry_md_open(&ctx->digestCtx, ctx->digest, GCRY_MD_FLAG_HMAC | GCRY_MD_FLAG_SECURE); /* we are paranoid */
     if(ret != GPG_ERR_NO_ERROR) {
+#else /* XMLSEC_GNUTLS_OLD */
+    ctx->digestCtx = gcry_md_open(ctx->digest, GCRY_MD_FLAG_HMAC | GCRY_MD_FLAG_SECURE); /* we are paranoid */
+    if(ctx->digestCtx == NULL) {
+#endif /* XMLSEC_GNUTLS_OLD */
 	xmlSecError(XMLSEC_ERRORS_HERE, 
 		    xmlSecErrorsSafeString(xmlSecTransformGetName(transform)),
 		    "gcry_md_open",


More information about the xmlsec mailing list