shill: Base64 encode/decode crypto_util arguments
Initially, I thought this would be easier to do in the shim, where
things might play nicely with OpenSSL. However, it turns out that the
OpenSSL API for base64 encoding/decoding is far more painful that it's
worth. Add a convenient wrapper around the raw GLib calls so that
people have less opportunity to shoot themselves in the foot.
BUG=chromium-os:221168
TEST=Unit tests pass.
Change-Id: I69732af03fdf729519783a3440213ef6adf8a630
Reviewed-on: https://gerrit.chromium.org/gerrit/46049
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/glib.h b/glib.h
index b2777bc..6e8e2cd 100644
--- a/glib.h
+++ b/glib.h
@@ -24,6 +24,11 @@
virtual guchar *Base64Decode(const gchar *text, gsize *out_len);
// g_base64_encode
virtual gchar *Base64Encode(const guchar *data, gsize len);
+
+ // Thin wrappers around Base64Decode/Encode. Return true on success.
+ virtual bool B64Decode(const std::string &input, std::string *output);
+ virtual bool B64Encode(const std::string &input, std::string *output);
+
// g_bus_unwatch_name
virtual void BusUnwatchName(guint watcher_id);
// g_bus_watch_name