[grilo-plugins] vimeo: Remove libgcrypt dependency
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] vimeo: Remove libgcrypt dependency
- Date: Fri, 11 Apr 2014 07:53:24 +0000 (UTC)
commit 5a0369d9227ced7b15738de76f248ec8aade368c
Author: Bastien Nocera <hadess hadess net>
Date: Wed Apr 9 16:08:11 2014 +0200
vimeo: Remove libgcrypt dependency
Use GHmac as provided by GLib to sign the messages instead.
https://bugzilla.gnome.org/show_bug.cgi?id=727899
configure.ac | 12 +++---------
src/vimeo/gvimeo.c | 31 +++++++++++++------------------
2 files changed, 16 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a613210..57804a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,9 +180,6 @@ PKG_CHECK_MODULES([TRACKER_SPARQL], [ ${trackerpkg} ],
HAVE_TRACKER_SPARQL=no)
-AM_PATH_LIBGCRYPT(,HAVE_GCRYPT=yes, HAVE_GCRYPT=no)
-
-
# ----------------------------------------------------------
# CHECK GOA
# ----------------------------------------------------------
@@ -938,9 +935,6 @@ AC_ARG_ENABLE(vimeo,
if test "x$HAVE_XML" = "xno"; then
AC_MSG_ERROR([libxml-2.0 not found, install it or use --disable-vimeo])
fi
- if test "x$HAVE_GCRYPT" = "xno"; then
- AC_MSG_ERROR([libgcrypt not found, install it or use --disable-vimeo])
- fi
if test "x$HAVE_TOTEM_PL_PARSER" = "xno"; then
AC_MSG_ERROR([totem-plparser >= 3.4.1 not found, install it or use
--disable-vimeo])
fi
@@ -948,7 +942,7 @@ AC_ARG_ENABLE(vimeo,
esac
],
[
- if test "x$HAVE_GRLNET" = "xyes" -a "x$HAVE_XML" = "xyes" -a "x$HAVE_GCRYPT" = "xyes" -a
"x$HAVE_TOTEM_PL_PARSER" = "xyes"; then
+ if test "x$HAVE_GRLNET" = "xyes" -a "x$HAVE_XML" = "xyes" -a "x$HAVE_TOTEM_PL_PARSER" =
"xyes"; then
enable_vimeo=yes
else
enable_vimeo=no
@@ -966,9 +960,9 @@ VIMEO_PLUGIN_ID="grl-vimeo"
AC_SUBST(VIMEO_PLUGIN_ID)
AC_DEFINE_UNQUOTED([VIMEO_PLUGIN_ID], ["$VIMEO_PLUGIN_ID"], [Vimeo plugin ID])
-DEPS_VIMEO_CFLAGS="$DEPS_CFLAGS $GRLNET_CFLAGS $XML_CFLAGS $LIBGCRYPT_CFLAGS $TOTEM_PL_PARSER_CFLAGS"
+DEPS_VIMEO_CFLAGS="$DEPS_CFLAGS $GRLNET_CFLAGS $XML_CFLAGS $TOTEM_PL_PARSER_CFLAGS"
AC_SUBST(DEPS_VIMEO_CFLAGS)
-DEPS_VIMEO_LIBS="$DEPS_LIBS $GRLNET_LIBS $XML_LIBS $LIBGCRYPT_LIBS $TOTEM_PL_PARSER_LIBS"
+DEPS_VIMEO_LIBS="$DEPS_LIBS $GRLNET_LIBS $XML_LIBS $TOTEM_PL_PARSER_LIBS"
AC_SUBST(DEPS_VIMEO_LIBS)
# ----------------------------------------------------------
diff --git a/src/vimeo/gvimeo.c b/src/vimeo/gvimeo.c
index 16cc5b2..9762f3f 100644
--- a/src/vimeo/gvimeo.c
+++ b/src/vimeo/gvimeo.c
@@ -24,7 +24,8 @@
#include "gvimeo.h"
-#include <gcrypt.h>
+#include <glib.h>
+#include <string.h>
#include <net/grl-net.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
@@ -205,28 +206,22 @@ get_videos_search_params (GVimeo *vimeo, const gchar *text, gint page) {
return params;
}
+/* From gchecksum.c in glib */
+#define SHA1_DIGEST_LEN 20
+
static gchar *
sign_string (gchar *message, gchar *key)
{
- gchar *signed_message = NULL;
- gcry_md_hd_t digest_obj;
- unsigned char *hmac_digest;
- guint digest_len;
-
- gcry_md_open(&digest_obj,
- GCRY_MD_SHA1,
- GCRY_MD_FLAG_SECURE | GCRY_MD_FLAG_HMAC);
- gcry_md_setkey(digest_obj, key, strlen (key));
- gcry_md_write (digest_obj, message, strlen (message));
- gcry_md_final (digest_obj);
- hmac_digest = gcry_md_read (digest_obj, 0);
-
- digest_len = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
- signed_message = g_base64_encode (hmac_digest, digest_len);
+ GHmac *hmac;
+ guint8 buffer[SHA1_DIGEST_LEN];
+ gsize buffer_len = SHA1_DIGEST_LEN;
- gcry_md_close (digest_obj);
+ hmac = g_hmac_new (G_CHECKSUM_SHA1, (guchar *) key, strlen (key));
+ g_hmac_update (hmac, (guchar *) message, strlen (message));
+ g_hmac_get_digest (hmac, buffer, &buffer_len);
+ g_hmac_unref (hmac);
- return signed_message;
+ return g_base64_encode (buffer, buffer_len);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]