LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File libdiscid-no-crypto.patch of Package libdiscid (Project multimedia:libs)

diff --git a/src/Makefile.am b/src/Makefile.am
index c8fbee3..62a27f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,13 +21,13 @@
 #
 lib_LTLIBRARIES = libdiscid.la
 
-libdiscid_la_SOURCES = base64.c sha1.c disc.c
+libdiscid_la_SOURCES = base64.c disc.c
 EXTRA_libdiscid_la_SOURCES = \
 	disc_linux.c disc_win32.c disc_win32_new.c \
 	disc_darwin.c disc_freebsd.c disc_solaris.c disc_openbsd.c
 
 AM_CPPFLAGS = -include $(top_builddir)/config.h -I$(top_srcdir)/include
-libdiscid_la_LIBADD = @DISC_OS_OBJ@
+libdiscid_la_LIBADD = @DISC_OS_OBJ@ -lcrypto
 libdiscid_la_DEPENDENCIES = @DISC_OS_OBJ@
 
 # Here are a set of rules to help you update your library version information:
diff --git a/src/disc.c b/src/disc.c
index f6cb3dd..d6de86b 100644
--- a/src/disc.c
+++ b/src/disc.c
@@ -25,8 +25,8 @@
 --------------------------------------------------------------------------- */
 #include <string.h>
 #include <assert.h>
+#include <openssl/evp.h>
 
-#include "sha1.h"
 #include "base64.h"
 
 #include "discid/discid.h"
@@ -260,35 +260,38 @@ char* discid_get_track_isrc(DiscId *d, int i) {
  * The DiscID is placed in the provided string buffer.
  */
 static void create_disc_id(mb_disc_private *d, char buf[]) {
-	SHA_INFO	sha;
-	unsigned char	digest[20], *base64;
-	unsigned long	size;
+	unsigned char	*base64;
+	unsigned long 	size;
+	unsigned char	digest[EVP_MAX_MD_SIZE];
 	char		tmp[17]; /* for 8 hex digits (16 to avoid trouble) */
 	int		i;
+	EVP_MD_CTX 	*sha;
+	unsigned int 	sha_len;
 
 	assert( d != NULL );
 
-	sha_init(&sha);
+	sha = EVP_MD_CTX_create();
+	EVP_DigestInit_ex(sha, EVP_sha1(), NULL);
 
 	sprintf(tmp, "%02X", d->first_track_num);
-	sha_update(&sha, (unsigned char *) tmp, strlen(tmp));
+	EVP_DigestUpdate(sha, (unsigned char *) tmp, strlen(tmp));
 
 	sprintf(tmp, "%02X", d->last_track_num);
-	sha_update(&sha, (unsigned char *) tmp, strlen(tmp));
+	EVP_DigestUpdate(sha, (unsigned char *) tmp, strlen(tmp));
 
 	for (i = 0; i < 100; i++) {
 		sprintf(tmp, "%08X", d->track_offsets[i]);
-		sha_update(&sha, (unsigned char *) tmp, strlen(tmp));
+		EVP_DigestUpdate(sha, (unsigned char *) tmp, strlen(tmp));
 	}
 
-	sha_final(digest, &sha);
-
-	base64 = rfc822_binary(digest, sizeof(digest), &size);
+	EVP_DigestFinal_ex(sha, digest, &sha_len);
+	EVP_MD_CTX_destroy(sha);
 
+	base64 = rfc822_binary(digest, sha_len , &size);
 	memcpy(buf, base64, size);
 	buf[size] = '\0';
-
 	free(base64);
+
 }