--- xmms-1.2.7/configure.in	2002-03-04 16:50:26.000000000 -0500
+++ xmms-1.2.7-ssl/configure.in	2003-01-10 14:18:47.000000000 -0500
@@ -76,11 +76,19 @@
     AC_DEFINE(XF86VIDMODE,1,[XF86VidMode extension is present])
         VM_LIBS="-lXxf86vm"],,
     -L$x_libraries -lXext)
-
 CFLAGS=$CFLAGS_save
 LIBS=$LIBS_save
 AC_SUBST(VM_LIBS)
 
+AC_CHECK_LIB(ssl, SSL_new,, USE_SSL=)
+if test "$USE_SSL"; then 
+    SSL_LIBS="-lssl"
+else
+    SSL_LIBS=""
+fi
+AC_SUBST(USE_SSL)
+AC_SUBST(SSL_LIBS)
+
 PTHREAD_LIBS=error
 AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
 AC_EGREP_CPP(yes,
--- xmms-1.2.7/xmms/Makefile.am	2001-06-14 08:30:33.000000000 -0400
+++ xmms-1.2.7-ssl/xmms/Makefile.am	2003-01-10 14:49:09.000000000 -0500
@@ -5,7 +5,7 @@
 bin_PROGRAMS = xmms
 
 xmms_LDFLAGS = -export-dynamic
-xmms_LDADD += @GTK_LIBS@ @PTHREAD_LIBS@ @SM_LIBS@ @VM_LIBS@ \
+xmms_LDADD += @GTK_LIBS@ @PTHREAD_LIBS@ @SM_LIBS@ @VM_LIBS@ @SSL_LIBS@ \
 @POSIX_LIBS@ $(top_builddir)/libxmms/libxmms.la @INTLLIBS@
 
 INCLUDES = @GTK_CFLAGS@ @XMMS_DEFINES@ @ARCH_DEFINES@ -I$(top_builddir)/intl
--- xmms-1.2.7/xmms/playlist.c	2002-02-20 09:17:31.000000000 -0500
+++ xmms-1.2.7-ssl/xmms/playlist.c	2003-01-10 14:19:11.000000000 -0500
@@ -23,6 +23,9 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+/* include OpenSSL PRNG */
+#include <openssl/rand.h>
+
 GList *playlist = NULL;
 GList *shuffle_list = NULL;
 static gboolean playlist_get_info_scan_active = FALSE;
@@ -1374,16 +1377,33 @@
 	gint len = g_list_length(list);
 	gint i, j;
 	GList *node, **ptrs;
+  gint *rand_bytes = NULL;
 
 	if (!len)
 		return NULL;
 
+#ifdef HAVE_LIBSSL
+  rand_bytes = g_new(gint, len);
+  if (!rand_bytes)
+    return NULL;
+
+  if (!RAND_bytes((char*) rand_bytes, sizeof(gint) * len)) {
+    fprintf(stderr, "%s: Error generating random bytes.\n", PACKAGE);
+    return NULL;
+  }
+#endif /* HAVE_LIBSSL */
+  
 	ptrs = g_new(GList *, len);
 
 	for (node = list, i = 0; i < len; node = g_list_next(node), i++)
 		ptrs[i] = node;
 
+#ifdef HAVE_LIBSSL
+	j = rand_bytes[i] % len;
+#else
 	j = random() % len;
+#endif /* HAVE_LIBSSL */
+
 	list = ptrs[j];
 	ptrs[j]->next = NULL;
 	ptrs[j] = ptrs[0];
@@ -1399,6 +1419,9 @@
 	list->prev = NULL;
 
 	g_free(ptrs);
+#ifdef HAVE_LIBSSL
+  g_free(rand_bytes);
+#endif /* HAVE_LIBSSL */
 
 	return list;
 }

