[shotwell] Remove external hmac_sha1
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Remove external hmac_sha1
- Date: Thu, 2 Jun 2016 20:22:12 +0000 (UTC)
commit 0ddee1cb2c13278a5354dd702f2519cef30b005e
Author: Jens Georg <mail jensge org>
Date: Wed Jun 1 22:19:50 2016 +0200
Remove external hmac_sha1
Instead of relying on librest leaking the hmac_sha1 symbol, port the
implementation of librest to Vala
Signed-off-by: Jens Georg <mail jensge org>
plugins/common/RESTSupport.vala | 16 ++++++++++++++++
.../TumblrPublishing.vala | 3 +--
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 7a12c5f..08e4e15 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -6,6 +6,22 @@
namespace Publishing.RESTSupport {
+// Ported from librest
+// https://git.gnome.org/browse/librest/tree/rest/sha1.c?id=e412da58080eec2e771482e7e4c509b9e71477ff#n38
+
+internal const int SHA1_HMAC_LENGTH = 20;
+
+public string hmac_sha1(string key, string message) {
+ uint8 buffer[SHA1_HMAC_LENGTH];
+ size_t len = SHA1_HMAC_LENGTH;
+
+ var mac = new Hmac (ChecksumType.SHA1, key.data);
+ mac.update (message.data);
+ mac.get_digest (buffer, ref len);
+
+ return Base64.encode (buffer[0:len]);
+}
+
public abstract class Session {
private string? endpoint_url = null;
private Soup.Session soup_session = null;
diff --git a/plugins/shotwell-publishing-extras/TumblrPublishing.vala
b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
index 6bafb21..0d6fbfb 100644
--- a/plugins/shotwell-publishing-extras/TumblrPublishing.vala
+++ b/plugins/shotwell-publishing-extras/TumblrPublishing.vala
@@ -6,7 +6,6 @@
*/
-extern string hmac_sha1(string key, string message);
public class TumblrService : Object, Spit.Pluggable, Spit.Publishing.Service {
private const string ICON_FILENAME = "tumblr.png";
@@ -1105,7 +1104,7 @@ internal class Session : Publishing.RESTSupport.Session {
debug("signing key = '%s'", signing_key);
// compute the signature
- string signature = hmac_sha1(signing_key, signature_base_string);
+ string signature = Publishing.RESTSupport.hmac_sha1(signing_key, signature_base_string);
debug("signature = '%s'", signature);
signature = Soup.URI.encode(signature, ENCODE_RFC_3986_EXTRA);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]