|
@@ -0,0 +1,43 @@
|
|
|
|
|
+#include <glib.h>
|
|
|
|
|
+#include <gio/gio.h>
|
|
|
|
|
+#include "iridium-crypto.h"
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+test_hexlify (void)
|
|
|
|
|
+{
|
|
|
|
|
+ guint8 data[] = { 'A', '1', 'x', ';' };
|
|
|
|
|
+ gchar *hexlified = iridium_crypto_hexlify (data, 4);
|
|
|
|
|
+ g_assert_cmpstr (hexlified, ==, "4131783b");
|
|
|
|
|
+ g_free (hexlified);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+test_unhexlify (void)
|
|
|
|
|
+{
|
|
|
|
|
+ gchar *hexlified = "466f6f62617221";
|
|
|
|
|
+ guint8 *data = iridium_crypto_unhexlify (hexlified, strlen (hexlified));
|
|
|
|
|
+ g_assert_cmpstr ((gchar *) data, ==, "Foobar!");
|
|
|
|
|
+ g_free (data);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+test_decrypt_003 (void)
|
|
|
|
|
+{
|
|
|
|
|
+ GBytes *data;
|
|
|
|
|
+
|
|
|
|
|
+ data = g_resources_lookup_data ("/net/bloerg/Test/dumps/003.json",
|
|
|
|
|
+ G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
|
|
|
|
+ g_assert_nonnull (data);
|
|
|
|
|
+ g_bytes_unref (data);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+int
|
|
|
|
|
+main (int argc, char * argv[])
|
|
|
|
|
+{
|
|
|
|
|
+ g_test_init (&argc, &argv, NULL);
|
|
|
|
|
+ g_test_add_func ("/crypto/hexlify", test_hexlify);
|
|
|
|
|
+ g_test_add_func ("/crypto/unhexlify", test_unhexlify);
|
|
|
|
|
+ g_test_add_func ("/crypto/decrypt/003", test_decrypt_003);
|
|
|
|
|
+
|
|
|
|
|
+ return g_test_run ();
|
|
|
|
|
+}
|