Skip to contentSkip to conversation

blktap - Don't link against libcrypto

PATCH In review Bastian Blank 2 participants 2 messages Jun 28, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blktap - Don't link against libcrypto

Hi folks

tapdisk, part of blktap, links against libcrypto. tapdisk includes GPLv2 (tapaio.c) and other licensed code (block-qcow.c). The license of OpenSSL is considered incompatible with the GPL by many people. This patch changes them to link against libgcrypt, which is LGPL.

tools/blktap/drivers/Makefile +1 -1
diff -r 3da148fb7d9b tools/blktap/drivers/Makefile
@@ -18,7 +18,7 @@ DEPS      = .*.d
 DEPS      = .*.d
 
 LDFLAGS_blktapctrl := $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore) -L../lib -lblktap
-LDFLAGS_img := $(LIBAIO_DIR)/libaio.a -lcrypto -lpthread -lz
+LDFLAGS_img := $(LIBAIO_DIR)/libaio.a -lgcrypt -lpthread -lz
 
 BLK-OBJS-y  := block-aio.o
 BLK-OBJS-y  += block-sync.o
tools/blktap/drivers/block-qcow.c +4 -13
diff -r 3da148fb7d9b tools/blktap/drivers/block-qcow.c
@@ -33,7 +33,7 @@
 #include <zlib.h>
 #include <inttypes.h>
 #include <libaio.h>
-#include <openssl/md5.h>
+#include <gcrypt.h>
 #include "bswap.h"
 #include "aes.h"
 #include "tapdisk.h"
@@ -149,31 +149,22 @@ static uint32_t gen_cksum(char *ptr, int
 static uint32_t gen_cksum(char *ptr, int len)
 {
 	int i;
-	unsigned char *md;
-	uint32_t ret;
+	uint32_t md[4];
 
-	md = malloc(MD5_DIGEST_LENGTH);
-
-	if(!md) return 0;
-	
 	/* Convert L1 table to big endian */
 	for(i = 0; i < len / sizeof(uint64_t); i++) {
 		cpu_to_be64s(&((uint64_t*) ptr)[i]);
 	}
 
 	/* Generate checksum */
-	if (MD5((unsigned char *)ptr, len, md) != md)
-		ret = 0;
-	else
-		memcpy(&ret, md, sizeof(uint32_t));
+	gcry_md_hash_buffer(GCRY_MD_MD5, md, ptr, len);
 
 	/* Convert L1 table back to native endianess */
 	for(i = 0; i < len / sizeof(uint64_t); i++) {
 		be64_to_cpus(&((uint64_t*) ptr)[i]);
 	}
 
-	free(md);
-	return ret;
+	return md[0];
 }
 
 static int get_filesize(char *filename, uint64_t *size, struct stat *st)
Signature · 2 lines
War is never imperative.
		-- McCoy, "Balance of Terror", stardate 1709.2
#1 lore raw
Quoted 6 lines · Bastian Blank

Hi folks

tapdisk, part of blktap, links against libcrypto. tapdisk includes GPLv2 (tapaio.c) and other licensed code (block-qcow.c). The license of OpenSSL is considered incompatible with the GPL by many people. This patch changes them to link against libgcrypt, which is LGPL.

This is good - we already link against gcrypt / gnutls for the QEMU ioemu code, so its also good to standardize on these libraries, rather than linking to two different libs for the same class of crypto functions.

Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|