Use GBytes instead of our own EggBytes
authorStef Walter <stefw@gnome.org>
Wed, 20 Jun 2012 06:28:55 +0000 (08:28 +0200)
committerStef Walter <stefw@gnome.org>
Wed, 20 Jun 2012 06:30:20 +0000 (08:30 +0200)
 * Bump glib minimum version to 2.32

39 files changed:
configure.ac
egg/Makefile.am
egg/egg-armor.c
egg/egg-armor.h
egg/egg-asn1x.c
egg/egg-asn1x.h
egg/egg-bytes.c [deleted file]
egg/egg-bytes.h [deleted file]
egg/egg-dn.c
egg/egg-dn.h
egg/egg-openssl.c
egg/egg-openssl.h
egg/egg-symkey.c
egg/egg-symkey.h
egg/egg-testing.h
egg/tests/test-asn1.c
egg/tests/test-asn1x.c
egg/tests/test-dn.c
egg/tests/test-openssl.c
gcr/gcr-certificate-extensions.c
gcr/gcr-certificate-extensions.h
gcr/gcr-certificate-renderer.c
gcr/gcr-certificate-request-renderer.c
gcr/gcr-certificate-request.c
gcr/gcr-certificate.c
gcr/gcr-fingerprint.c
gcr/gcr-key-renderer.c
gcr/gcr-openpgp.c
gcr/gcr-openpgp.h
gcr/gcr-openssh.c
gcr/gcr-openssh.h
gcr/gcr-parser.c
gcr/gcr-subject-public-key.c
gcr/tests/frob-openpgp.c
gcr/tests/test-fingerprint.c
gcr/tests/test-openpgp.c
gcr/tests/test-openssh.c
gcr/tests/test-pkcs11-certificate.c
gcr/tests/test-subject-public-key.c

index d17e5b1..8db4f46 100644 (file)
@@ -66,7 +66,7 @@ AM_GLIB_GNU_GETTEXT
 # GLib and GTK+ stuff
 
 PKG_CHECK_MODULES(GLIB,
-       glib-2.0 >= 2.30.0
+       glib-2.0 >= 2.32.0
        gmodule-no-export-2.0
        gthread-2.0
        gobject-2.0
index 045902f..bfc6c33 100644 (file)
@@ -30,7 +30,6 @@ libegg_la_SOURCES = \
        egg-asn1x.c egg-asn1x.h \
        egg-asn1-defs.c egg-asn1-defs.h \
        egg-buffer.c egg-buffer.h \
-       egg-bytes.c egg-bytes.h \
        egg-dh.c egg-dh.h \
        egg-dn.c egg-dn.h \
        egg-error.h \
index 473e42e..812f1aa 100644 (file)
@@ -269,7 +269,7 @@ egg_armor_headers_new (void)
 }
 
 guint
-egg_armor_parse (EggBytes *data,
+egg_armor_parse (GBytes *data,
                  EggArmorCallback callback,
                  gpointer user_data)
 {
@@ -279,14 +279,13 @@ egg_armor_parse (EggBytes *data,
        guchar *decoded = NULL;
        gsize n_decoded = 0;
        GHashTable *headers = NULL;
-       EggBytes *dec;
-       EggBytes *outer;
+       GBytes *dec;
+       GBytes *outer;
        GQuark type;
        gsize n_at;
 
        g_return_val_if_fail (data != NULL, 0);
-       at = egg_bytes_get_data (data);
-       n_at = egg_bytes_get_size (data);
+       at = g_bytes_get_data (data, &n_at);
 
        while (n_at > 0) {
 
@@ -305,15 +304,16 @@ egg_armor_parse (EggBytes *data,
                if (beg != end) {
                        if (armor_parse_block (beg, end - beg, &decoded, &n_decoded, &headers)) {
                                g_assert (outer_end > outer_beg);
-                               dec = egg_bytes_new_with_free_func (decoded, n_decoded,
-                                                                   egg_secure_free, decoded);
+                               dec = g_bytes_new_with_free_func (decoded, n_decoded,
+                                                                 egg_secure_free, decoded);
                                if (callback != NULL) {
-                                       outer = egg_bytes_new_with_free_func (outer_beg, outer_end - outer_beg,
-                                                                             egg_bytes_unref, egg_bytes_ref (data));
+                                       outer = g_bytes_new_with_free_func (outer_beg, outer_end - outer_beg,
+                                                                           (GDestroyNotify)g_bytes_unref,
+                                                                           g_bytes_ref (data));
                                        (callback) (type, dec, outer, headers, user_data);
-                                       egg_bytes_unref (outer);
+                                       g_bytes_unref (outer);
                                }
-                               egg_bytes_unref (dec);
+                               g_bytes_unref (dec);
                                ++nfound;
                                if (headers)
                                        g_hash_table_remove_all (headers);
index 586a0d2..e32d44d 100644 (file)
 
 #include <glib.h>
 
-#include <egg/egg-bytes.h>
-
 typedef void (*EggArmorCallback) (GQuark type,
-                                  EggBytes *data,
-                                  EggBytes *outer,
+                                  GBytes *data,
+                                  GBytes *outer,
                                   GHashTable *headers,
                                   gpointer user_data);
 
 GHashTable*      egg_armor_headers_new   (void);
 
-guint            egg_armor_parse         (EggBytes *data,
+guint            egg_armor_parse         (GBytes *data,
                                           EggArmorCallback callback,
                                           gpointer user_data);
 
index cea8dad..0fabb74 100644 (file)
@@ -139,7 +139,7 @@ struct _Anode {
        Atlv *tlv;
        Aenc *enc;
 
-       EggBytes *backing;
+       GBytes *backing;
        gchar* failure;
 
        gint chosen : 1;
@@ -153,12 +153,12 @@ struct _Abuf {
 
 struct _Abits {
        guint n_bits;
-       EggBytes *bits;
+       GBytes *bits;
 };
 
 /* Forward Declarations */
-static gboolean anode_decode_anything (GNode*, EggBytes*, Atlv*);
-static gboolean anode_decode_anything_for_flags (GNode *, EggBytes*, Atlv*, gint);
+static gboolean anode_decode_anything (GNode*, GBytes*, Atlv*);
+static gboolean anode_decode_anything_for_flags (GNode *, GBytes*, Atlv*, gint);
 static gboolean anode_validate_anything (GNode*, gboolean);
 static gboolean anode_encode_prepare (GNode*, gboolean want);
 
@@ -372,7 +372,7 @@ compare_tlvs (Atlv *tlva, Atlv *tlvb)
        return la < lb ? -1 : 1;
 }
 
-static inline EggBytes *
+static inline GBytes *
 anode_get_backing (GNode *node)
 {
        Anode *an = node->data;
@@ -384,25 +384,25 @@ anode_clr_backing (GNode *node)
 {
        Anode *an = node->data;
        if (an->backing)
-               egg_bytes_unref (an->backing);
+               g_bytes_unref (an->backing);
        an->backing = NULL;
 }
 
 static inline void
 anode_set_backing (GNode *node,
-                   EggBytes *backing)
+                   GBytes *backing)
 {
        Anode *an = node->data;
        if (backing)
-               egg_bytes_ref (backing);
+               g_bytes_ref (backing);
        if (an->backing)
-               egg_bytes_unref (an->backing);
+               g_bytes_unref (an->backing);
        an->backing = backing;
 }
 
 static void
 anode_set_tlv_data (GNode *node,
-                    EggBytes *backing,
+                    GBytes *backing,
                     Atlv *tlv)
 {
        Anode *an = node->data;
@@ -516,7 +516,7 @@ abits_destroy (gpointer data)
        Abits *ab = data;
        g_assert (ab != NULL);
        if (ab->bits)
-               egg_bytes_unref (ab->bits);
+               g_bytes_unref (ab->bits);
        g_slice_free (Abits, ab);
 }
 
@@ -871,7 +871,7 @@ anode_decode_tlv_for_contents (Atlv *outer, gboolean first, Atlv *tlv)
 
 static gboolean
 anode_decode_choice (GNode *node,
-                     EggBytes *backing,
+                     GBytes *backing,
                      Atlv *tlv)
 {
        gboolean have = FALSE;
@@ -929,7 +929,7 @@ anode_decode_struct_any (GNode *node, Atlv *tlv)
 
 static gboolean
 anode_decode_sequence_or_set (GNode *node,
-                              EggBytes *backing,
+                              GBytes *backing,
                               Atlv *outer)
 {
        GNode *child;
@@ -962,7 +962,7 @@ anode_decode_sequence_or_set (GNode *node,
 
 static gboolean
 anode_decode_sequence_or_set_of (GNode *node,
-                                 EggBytes *backing,
+                                 GBytes *backing,
                                  Atlv *outer)
 {
        GNode *child, *other;
@@ -1008,7 +1008,7 @@ anode_decode_sequence_or_set_of (GNode *node,
 
 static gboolean
 anode_decode_primitive (GNode *node,
-                        EggBytes *backing,
+                        GBytes *backing,
                         Atlv *tlv,
                         gint flags)
 {
@@ -1054,7 +1054,7 @@ anode_decode_primitive (GNode *node,
 
 static gboolean
 anode_decode_structured (GNode *node,
-                         EggBytes *backing,
+                         GBytes *backing,
                          Atlv *tlv,
                          gint flags)
 {
@@ -1156,7 +1156,7 @@ anode_decode_option_or_default (GNode *node, Atlv *tlv, gint flags)
 
 static gboolean
 anode_decode_anything_for_flags (GNode *node,
-                                 EggBytes *bytes,
+                                 GBytes *bytes,
                                  Atlv *tlv,
                                  gint flags)
 {
@@ -1189,7 +1189,7 @@ anode_decode_anything_for_flags (GNode *node,
 
 static gboolean
 anode_decode_anything (GNode *node,
-                       EggBytes *bytes,
+                       GBytes *bytes,
                        Atlv *tlv)
 {
        gint flags = anode_def_flags (node);
@@ -1202,7 +1202,7 @@ anode_decode_anything (GNode *node,
 
 gboolean
 egg_asn1x_decode_no_validate (GNode *asn,
-                              EggBytes *data)
+                              GBytes *data)
 {
        const guchar *dat;
        gsize size;
@@ -1213,10 +1213,9 @@ egg_asn1x_decode_no_validate (GNode *asn,
 
        egg_asn1x_clear (asn);
 
-       dat = egg_bytes_get_data (data);
+       dat = g_bytes_get_data (data, &size);
        g_return_val_if_fail (dat != NULL, FALSE);
 
-       size = egg_bytes_get_size (data);
        if (!anode_decode_tlv_for_data (dat, dat + size, &tlv))
                return anode_failure (asn, "content is not encoded properly");
 
@@ -1231,7 +1230,7 @@ egg_asn1x_decode_no_validate (GNode *asn,
 
 gboolean
 egg_asn1x_decode (GNode *asn,
-                  EggBytes *data)
+                  GBytes *data)
 {
        gboolean ret;
 
@@ -1405,7 +1404,7 @@ anode_encode_tlv_and_enc (GNode *node,
 
 static gboolean
 anode_encode_build (GNode *node,
-                    EggBytes *backing,
+                    GBytes *backing,
                     guchar *data,
                     gsize n_data)
 {
@@ -1566,9 +1565,9 @@ anode_encoder_bytes (gpointer user_data,
                      guchar *data,
                      gsize n_data)
 {
-       EggBytes *bytes = user_data;
-       g_assert (egg_bytes_get_size (bytes) >= n_data);
-       memcpy (data, egg_bytes_get_data (bytes), n_data);
+       GBytes *bytes = user_data;
+       g_assert (g_bytes_get_size (bytes) >= n_data);
+       memcpy (data, g_bytes_get_data (bytes, NULL), n_data);
        return TRUE;
 }
 
@@ -1588,7 +1587,7 @@ anode_encoder_unsigned (gpointer user_data,
                         guchar *data,
                         gsize n_data)
 {
-       EggBytes *value = user_data;
+       GBytes *value = user_data;
        gboolean sign;
        const gchar *p;
 
@@ -1598,7 +1597,7 @@ anode_encoder_unsigned (gpointer user_data,
         * byte is already calculated into n_data, see egg_asn1x_set_integer_as_usg
         */
 
-       p = egg_bytes_get_data (value);
+       p = g_bytes_get_data (value, NULL);
        g_return_val_if_fail (p != NULL, FALSE);
 
        sign = !!(p[0] & 0x80);
@@ -1693,7 +1692,7 @@ anode_encoder_bit_string (gpointer user_data,
        data += 1;
 
        /* Fill in the actual data */
-       memcpy (data, egg_bytes_get_data (ab->bits), len);
+       memcpy (data, g_bytes_get_data (ab->bits, NULL), len);
 
        /* Set the extra bits to zero */
        if (len && empty) {
@@ -1707,8 +1706,8 @@ anode_encoder_bit_string (gpointer user_data,
 static gboolean
 anode_encode_prepare_simple (GNode *node, gboolean want)
 {
-       EggBytes *backing;
-       EggBytes *bytes;
+       GBytes *backing;
+       GBytes *bytes;
        Aenc *enc;
        Atlv *tlv;
 
@@ -1723,9 +1722,11 @@ anode_encode_prepare_simple (GNode *node, gboolean want)
                if (backing == NULL)
                        return FALSE;
 
-               bytes = egg_bytes_new_with_free_func ((guchar *)tlv->buf + tlv->off, tlv->len,
-                                                     egg_bytes_unref, egg_bytes_ref (backing));
-               anode_set_enc_data (node, anode_encoder_bytes, bytes, egg_bytes_unref);
+               bytes = g_bytes_new_with_free_func ((guchar *)tlv->buf + tlv->off, tlv->len,
+                                                   (GDestroyNotify)g_bytes_unref,
+                                                   g_bytes_ref (backing));
+               anode_set_enc_data (node, anode_encoder_bytes, bytes,
+                                   (GDestroyNotify)g_bytes_unref);
        }
 
        tlv->buf = tlv->end = NULL;
@@ -1844,7 +1845,7 @@ destroy_with_allocator (gpointer data)
        g_slice_free (AllocatorClosure, closure);
 }
 
-static EggBytes *
+static GBytes *
 new_bytes_with_allocator (EggAllocator allocator,
                           guchar **data,
                           gsize length)
@@ -1858,20 +1859,20 @@ new_bytes_with_allocator (EggAllocator allocator,
                closure = g_slice_new (AllocatorClosure);
                closure->allocated = *data;
                closure->allocator = allocator;
-               return egg_bytes_new_with_free_func (*data, length,
+               return g_bytes_new_with_free_func (*data, length,
                                                     destroy_with_allocator,
                                                     closure);
        } else {
                *data = g_malloc (length);
-               return egg_bytes_new_take (*data, length);
+               return g_bytes_new_take (*data, length);
        }
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_encode (GNode *asn,
                   EggAllocator allocator)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        guchar *data;
        gsize length;
        Atlv *tlv;
@@ -1903,7 +1904,7 @@ egg_asn1x_encode (GNode *asn,
                return bytes;
        }
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        anode_encode_rollback (asn);
        return NULL;
 }
@@ -2769,10 +2770,10 @@ egg_asn1x_set_integer_as_ulong (GNode *node, gulong value)
        return TRUE;
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_integer_as_raw (GNode *node)
 {
-       EggBytes *backing;
+       GBytes *backing;
        Atlv *tlv;
 
        g_return_val_if_fail (node, FALSE);
@@ -2786,14 +2787,15 @@ egg_asn1x_get_integer_as_raw (GNode *node)
        if (backing == NULL)
                return NULL;
 
-       return egg_bytes_new_with_free_func (tlv->buf + tlv->off, tlv->len,
-                                            egg_bytes_unref, egg_bytes_ref (backing));
+       return g_bytes_new_with_free_func (tlv->buf + tlv->off, tlv->len,
+                                          (GDestroyNotify)g_bytes_unref,
+                                          g_bytes_ref (backing));
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_integer_as_usg (GNode *node)
 {
-       EggBytes *backing;
+       GBytes *backing;
        const guchar *p;
        gboolean sign;
        Atlv *tlv;
@@ -2831,22 +2833,22 @@ egg_asn1x_get_integer_as_usg (GNode *node)
                }
        }
 
-       return egg_bytes_new_with_free_func (p, n_data,
-                                            egg_bytes_unref,
-                                            egg_bytes_ref (backing));
+       return g_bytes_new_with_free_func (p, n_data,
+                                          (GDestroyNotify)g_bytes_unref,
+                                          g_bytes_ref (backing));
 }
 
 void
 egg_asn1x_set_integer_as_raw (GNode *node,
-                              EggBytes *value)
+                              GBytes *value)
 {
        g_return_if_fail (value != NULL);
-       egg_asn1x_take_integer_as_raw (node, egg_bytes_ref (value));
+       egg_asn1x_take_integer_as_raw (node, g_bytes_ref (value));
 }
 
 void
 egg_asn1x_take_integer_as_raw (GNode *node,
-                               EggBytes *value)
+                               GBytes *value)
 {
        gboolean sign;
        const guchar *p;
@@ -2856,7 +2858,7 @@ egg_asn1x_take_integer_as_raw (GNode *node,
        g_return_if_fail (anode_def_type (node) == EGG_ASN1X_INTEGER);
 
        /* Make sure the integer is properly encoded in twos complement*/
-       p = egg_bytes_get_data (value);
+       p = g_bytes_get_data (value, NULL);
        g_return_if_fail (p != NULL);
 
        sign = !!(p[0] & 0x80);
@@ -2865,21 +2867,21 @@ egg_asn1x_take_integer_as_raw (GNode *node,
                return;
        }
 
-       anode_encode_tlv_and_enc (node, egg_bytes_get_size (value), anode_encoder_bytes,
-                                 value, egg_bytes_unref);
+       anode_encode_tlv_and_enc (node, g_bytes_get_size (value), anode_encoder_bytes,
+                                 value, (GDestroyNotify)g_bytes_unref);
 }
 
 void
 egg_asn1x_set_integer_as_usg (GNode *node,
-                              EggBytes *value)
+                              GBytes *value)
 {
        g_return_if_fail (value != NULL);
-       egg_asn1x_take_integer_as_usg (node, egg_bytes_ref (value));
+       egg_asn1x_take_integer_as_usg (node, g_bytes_ref (value));
 }
 
 void
 egg_asn1x_take_integer_as_usg (GNode *node,
-                               EggBytes *value)
+                               GBytes *value)
 {
        gboolean sign;
        const guchar *p;
@@ -2890,11 +2892,10 @@ egg_asn1x_take_integer_as_usg (GNode *node,
        g_return_if_fail (anode_def_type (node) == EGG_ASN1X_INTEGER);
 
        /* Make sure the integer is properly encoded in twos complement*/
-       p = egg_bytes_get_data (value);
+       p = g_bytes_get_data (value, &len);
        g_return_if_fail (p != NULL);
 
        sign = !!(p[0] & 0x80);
-       len = egg_bytes_get_size (value);
 
        /*
         * If in two's complement this would be negative, add a zero byte so
@@ -2905,13 +2906,13 @@ egg_asn1x_take_integer_as_usg (GNode *node,
                len += 1;
 
        anode_encode_tlv_and_enc (node, len, anode_encoder_unsigned,
-                                 value, egg_bytes_unref);
+                                 value, (GDestroyNotify)g_bytes_unref);
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_element_raw (GNode *node)
 {
-       EggBytes *backing;
+       GBytes *backing;
        const guchar *p;
        gsize len;
        Atlv *tlv;
@@ -2934,19 +2935,19 @@ egg_asn1x_get_element_raw (GNode *node)
                p = tlv->buf;
        }
 
-       return egg_bytes_new_with_free_func (p, len, egg_bytes_unref,
-                                            egg_bytes_ref (backing));
+       return g_bytes_new_with_free_func (p, len, (GDestroyNotify)g_bytes_unref,
+                                          g_bytes_ref (backing));
 }
 
 gboolean
 egg_asn1x_set_element_raw (GNode *node,
-                           EggBytes *element)
+                           GBytes *element)
 {
        Atlv dtlv, *tlv;
        gint oft, flags;
        const guchar *data;
        guchar cls_type;
-       EggBytes *sub;
+       GBytes *sub;
        gsize size;
 
        g_return_val_if_fail (node != NULL, FALSE);
@@ -2955,11 +2956,9 @@ egg_asn1x_set_element_raw (GNode *node,
        anode_clear (node);
        memset (&dtlv, 0, sizeof (dtlv));
 
-       data = egg_bytes_get_data (element);
+       data = g_bytes_get_data (element, &size);
        g_return_val_if_fail (data != NULL, FALSE);
 
-       size = egg_bytes_get_size (element);
-
        /* Decode the beginning TLV */
        if (!anode_decode_tlv_for_data (data, data + size, &dtlv))
                return FALSE;
@@ -2994,18 +2993,19 @@ egg_asn1x_set_element_raw (GNode *node,
                tlv->oft = oft;
        }
 
-       sub = egg_bytes_new_with_free_func (dtlv.buf + dtlv.off, dtlv.len,
-                                           egg_bytes_unref, egg_bytes_ref (element));
+       sub = g_bytes_new_with_free_func (dtlv.buf + dtlv.off, dtlv.len,
+                                         (GDestroyNotify)g_bytes_unref,
+                                         g_bytes_ref (element));
 
        /* Setup encoding of the contents */
-       anode_set_enc_data (node, anode_encoder_bytes, sub, egg_bytes_unref);
+       anode_set_enc_data (node, anode_encoder_bytes, sub, (GDestroyNotify)g_bytes_unref);
        return TRUE;
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_raw_value (GNode *node)
 {
-       EggBytes *backing;
+       GBytes *backing;
        Atlv *tlv;
 
        g_return_val_if_fail (node, NULL);
@@ -3019,8 +3019,9 @@ egg_asn1x_get_raw_value (GNode *node)
        if (backing == NULL)
                return NULL;
 
-       return egg_bytes_new_with_free_func (tlv->buf + tlv->off, tlv->len,
-                                            egg_bytes_unref, egg_bytes_ref (backing));
+       return g_bytes_new_with_free_func (tlv->buf + tlv->off, tlv->len,
+                                          (GDestroyNotify)g_bytes_unref,
+                                          g_bytes_ref (backing));
 }
 
 guchar*
@@ -3077,7 +3078,7 @@ egg_asn1x_set_string_as_raw (GNode *node, guchar *data, gsize n_data, GDestroyNo
        return TRUE;
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_string_as_bytes (GNode *node)
 {
        gpointer raw;
@@ -3089,7 +3090,7 @@ egg_asn1x_get_string_as_bytes (GNode *node)
        if (raw == NULL)
                return NULL;
 
-       return egg_bytes_new_take (raw, length);
+       return g_bytes_new_take (raw, length);
 }
 
 gchar *
@@ -3149,10 +3150,10 @@ egg_asn1x_set_string_as_utf8 (GNode *node, gchar *data, GDestroyNotify destroy)
        return egg_asn1x_set_string_as_raw (node, (guchar*)data, n_data, destroy);
 }
 
-EggBytes *
+GBytes *
 egg_asn1x_get_bits_as_raw (GNode *node, guint *n_bits)
 {
-       EggBytes *backing;
+       GBytes *backing;
        guchar padded;
        Atlv *tlv;
 
@@ -3173,22 +3174,23 @@ egg_asn1x_get_bits_as_raw (GNode *node, guint *n_bits)
        g_return_val_if_fail (tlv->len > 1, NULL);
 
        *n_bits = ((tlv->len - 1) * 8) - padded;
-       return egg_bytes_new_with_free_func (tlv->buf + tlv->off + 1, tlv->len - 1,
-                                            egg_bytes_unref, egg_bytes_ref (backing));
+       return g_bytes_new_with_free_func (tlv->buf + tlv->off + 1, tlv->len - 1,
+                                          (GDestroyNotify)g_bytes_unref,
+                                          g_bytes_ref (backing));
 }
 
 void
 egg_asn1x_set_bits_as_raw (GNode *node,
-                           EggBytes *value,
+                           GBytes *value,
                            guint n_bits)
 {
        g_return_if_fail (value != NULL);
-       egg_asn1x_take_bits_as_raw (node, egg_bytes_ref (value), n_bits);
+       egg_asn1x_take_bits_as_raw (node, g_bytes_ref (value), n_bits);
 }
 
 void
 egg_asn1x_take_bits_as_raw (GNode *node,
-                            EggBytes *value,
+                            GBytes *value,
                             guint n_bits)
 {
        gint type;
@@ -3278,7 +3280,7 @@ egg_asn1x_set_bits_as_ulong (GNode *node, gulong bits, guint n_bits)
                data[(length - i) - 1] = (value >> i * 8) & 0xFF;
 
        ab = g_slice_new0 (Abits);
-       ab->bits = egg_bytes_new_take (data, sizeof (gulong));
+       ab->bits = g_bytes_new_take (data, sizeof (gulong));
        ab->n_bits = n_bits;
 
        anode_encode_tlv_and_enc (node, length + 1, anode_encoder_bit_string, ab, abits_destroy);
@@ -4170,7 +4172,7 @@ egg_asn1x_create_quark (const EggAsn1xDef *defs,
 GNode*
 egg_asn1x_create_and_decode (const EggAsn1xDef *defs,
                              const gchar *identifier,
-                             EggBytes *data)
+                             GBytes *data)
 {
        GNode *asn;
 
index 94d60fa..036b9ce 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <glib.h>
 
-#include "egg-bytes.h"
-
 #ifndef HAVE_EGG_ALLOCATOR
 typedef void* (*EggAllocator) (void* p, gsize);
 #define HAVE_EGG_ALLOCATOR
@@ -68,22 +66,22 @@ GNode*              egg_asn1x_create_quark           (const EggAsn1xDef *defs,
 
 GNode*              egg_asn1x_create_and_decode      (const EggAsn1xDef *defs,
                                                       const gchar *type,
-                                                      EggBytes *data);
+                                                      GBytes *data);
 
 void                egg_asn1x_dump                   (GNode *asn);
 
 void                egg_asn1x_clear                  (GNode *asn);
 
 gboolean            egg_asn1x_decode                 (GNode *asn,
-                                                      EggBytes *data);
+                                                      GBytes *data);
 
 gboolean            egg_asn1x_decode_no_validate     (GNode *asn,
-                                                      EggBytes *data);
+                                                      GBytes *data);
 
 gboolean            egg_asn1x_validate               (GNode *asn,
                                                       gboolean strict);
 
-EggBytes *          egg_asn1x_encode                 (GNode *asn,
+GBytes *          egg_asn1x_encode                 (GNode *asn,
                                                       EggAllocator allocator);
 
 const gchar*        egg_asn1x_message                (GNode *asn);
@@ -125,28 +123,28 @@ gboolean            egg_asn1x_get_integer_as_ulong   (GNode *node,
 gboolean            egg_asn1x_set_integer_as_ulong   (GNode *node,
                                                       gulong value);
 
-EggBytes *          egg_asn1x_get_integer_as_raw     (GNode *node);
+GBytes *          egg_asn1x_get_integer_as_raw     (GNode *node);
 
 void                egg_asn1x_set_integer_as_raw     (GNode *node,
-                                                      EggBytes *value);
+                                                      GBytes *value);
 
 void                egg_asn1x_take_integer_as_raw    (GNode *node,
-                                                      EggBytes *value);
+                                                      GBytes *value);
 
-EggBytes *          egg_asn1x_get_integer_as_usg     (GNode *node);
+GBytes *          egg_asn1x_get_integer_as_usg     (GNode *node);
 
 void                egg_asn1x_set_integer_as_usg     (GNode *node,
-                                                      EggBytes *value);
+                                                      GBytes *value);
 
 void                egg_asn1x_take_integer_as_usg    (GNode *node,
-                                                      EggBytes *value);
+                                                      GBytes *value);
 
-EggBytes *          egg_asn1x_get_raw_value          (GNode *node);
+GBytes *          egg_asn1x_get_raw_value          (GNode *node);
 
-EggBytes *          egg_asn1x_get_element_raw        (GNode *node);
+GBytes *          egg_asn1x_get_element_raw        (GNode *node);
 
 gboolean            egg_asn1x_set_element_raw        (GNode *node,
-                                                      EggBytes *value);
+                                                      GBytes *value);
 
 guchar*             egg_asn1x_get_string_as_raw      (GNode *node,
                                                       EggAllocator allocator,
@@ -157,17 +155,17 @@ gboolean            egg_asn1x_set_string_as_raw      (GNode *node,
                                                       gsize n_data,
                                                       GDestroyNotify destroy);
 
-EggBytes *          egg_asn1x_get_string_as_bytes    (GNode *node);
+GBytes *          egg_asn1x_get_string_as_bytes    (GNode *node);
 
-EggBytes *          egg_asn1x_get_bits_as_raw        (GNode *node,
+GBytes *          egg_asn1x_get_bits_as_raw        (GNode *node,
                                                       guint *n_bits);
 
 void                egg_asn1x_set_bits_as_raw        (GNode *node,
-                                                      EggBytes *value,
+                                                      GBytes *value,
                                                       guint n_bits);
 
 void                egg_asn1x_take_bits_as_raw       (GNode *node,
-                                                      EggBytes *value,
+                                                      GBytes *value,
                                                       guint n_bits);
 
 gboolean            egg_asn1x_get_bits_as_ulong      (GNode *node,
diff --git a/egg/egg-bytes.c b/egg/egg-bytes.c
deleted file mode 100644 (file)
index 8f58da2..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright Â© 2009, 2010 Codethink Limited
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Ryan Lortie <desrt@desrt.ca>
- */
-
-#include "config.h"
-
-#include "egg-bytes.h"
-
-#include <glib.h>
-
-#include <string.h>
-
-struct _EggBytes
-{
-  gconstpointer data;
-  gsize size;
-  gint ref_count;
-  GDestroyNotify free_func;
-  gpointer user_data;
-};
-
-/**
- * egg_bytes_new:
- * @data: (array length=size): the data to be used for the bytes
- * @size: the size of @data
- *
- * Creates a new #EggBytes from @data.
- *
- * @data is copied.
- *
- * Returns: (transfer full): a new #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_new (gconstpointer data,
-             gsize         size)
-{
-  return egg_bytes_new_take (g_memdup (data, size), size);
-}
-
-/**
- * egg_bytes_new_take:
- * @data: (transfer full) (array length=size): the data to be used for the bytes
- * @size: the size of @data
- *
- * Creates a new #EggBytes from @data.
- *
- * After this call, @data belongs to the bytes and may no longer be
- * modified by the caller.  g_free() will be called on @data when the
- * bytes is no longer in use. Because of this @data must have been created by
- * a call to g_malloc(), g_malloc0() or g_realloc() or by one of the many
- * functions that wrap these calls (such as g_new(), g_strdup(), etc).
- *
- * Returns: (transfer full): a new #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_new_take (gpointer data,
-                  gsize    size)
-{
-  return egg_bytes_new_with_free_func (data, size, g_free, data);
-}
-
-
-/**
- * egg_bytes_new_static:
- * @data: (array length=size): the data to be used for the bytes
- * @size: the size of @data
- *
- * Creates a new #EggBytes from static data.
- *
- * @data must be static (ie: never modified or freed).
- *
- * Returns: (transfer full): a new #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_new_static (gconstpointer data,
-                    gsize         size)
-{
-  return egg_bytes_new_with_free_func (data, size, NULL, NULL);
-}
-
-/**
- * egg_bytes_new_with_free_func:
- * @data: (array length=size): the data to be used for the bytes
- * @size: the size of @data
- * @free_func: the function to call to release the data
- * @user_data: data to pass to @free_func
- *
- * Creates a #EggBytes from @data.
- *
- * When the last reference is dropped, @free_func will be called with the
- * @user_data argument.
- *
- * @data must not be modified after this call is made until @free_func has
- * been called to indicate that the bytes is no longer in use.
- *
- * Returns: (transfer full): a new #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_new_with_free_func (gconstpointer  data,
-                            gsize          size,
-                            GDestroyNotify free_func,
-                            gpointer       user_data)
-{
-  EggBytes *bytes;
-
-  bytes = g_slice_new (EggBytes);
-  bytes->data = data;
-  bytes->size = size;
-  bytes->free_func = free_func;
-  bytes->user_data = user_data;
-  bytes->ref_count = 1;
-
-  return (EggBytes *)bytes;
-}
-
-/**
- * egg_bytes_new_from_bytes:
- * @bytes: a #EggBytes
- * @offset: offset which subsection starts at
- * @length: length of subsucsection
- *
- * Creates a #EggBytes which is a subsection of another #EggBytes.
- *
- * A reference to @bytes will be held by the newly created #EggBytes until
- * the byte data is no longer needed.
- *
- * Returns: (transfer full): a new #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_new_from_bytes (EggBytes  *bytes,
-                        goffset  offset,
-                        gsize    length)
-{
-  g_return_val_if_fail (bytes != NULL, NULL);
-  g_return_val_if_fail (offset <= bytes->size, NULL);
-  g_return_val_if_fail (offset + length <= bytes->size, NULL);
-
-  return egg_bytes_new_with_free_func ((gchar *)bytes->data + offset, length,
-                                     egg_bytes_unref, egg_bytes_ref (bytes));
-}
-
-/**
- * egg_bytes_get_data:
- * @bytes: a #EggBytes
- *
- * Get the byte data in the #EggBytes. This data should not be modified.
- *
- * This function will always return the same pointer for a given #EggBytes.
- *
- * Returns: a pointer to the byte data
- *
- * Since: 2.32
- */
-gconstpointer
-egg_bytes_get_data (EggBytes *bytes)
-{
-  g_return_val_if_fail (bytes != NULL, NULL);
-  return bytes->data;
-}
-
-/**
- * egg_bytes_get_size:
- * @bytes: a #EggBytes
- *
- * Get the size of the byte data in the #EggBytes.
- *
- * This function will always return the same value for a given #EggBytes.
- *
- * Returns: the size
- *
- * Since: 2.32
- */
-gsize
-egg_bytes_get_size (EggBytes *bytes)
-{
-  g_return_val_if_fail (bytes != NULL, 0);
-  return bytes->size;
-}
-
-
-/**
- * egg_bytes_ref:
- * @bytes: a #EggBytes
- *
- * Increase the reference count on @bytes.
- *
- * Returns: (transfer full): the #EggBytes
- *
- * Since: 2.32
- */
-EggBytes *
-egg_bytes_ref (EggBytes *bytes)
-{
-  g_return_val_if_fail (bytes != NULL, NULL);
-
-  g_atomic_int_inc (&bytes->ref_count);
-
-  return bytes;
-}
-
-/**
- * egg_bytes_unref:
- * @bytes: (transfer full) (type GLib.Bytes): a #EggBytes
- *
- * Releases a reference on @bytes.  This may result in the bytes being
- * freed.
- *
- * Since: 2.32
- */
-void
-egg_bytes_unref (gpointer bytes)
-{
-  EggBytes *bytes_ = bytes;
-
-  g_return_if_fail (bytes_ != NULL);
-
-  if (g_atomic_int_dec_and_test (&bytes_->ref_count))
-    {
-      if (bytes_->free_func != NULL)
-        bytes_->free_func (bytes_->user_data);
-      g_slice_free (EggBytes, bytes);
-    }
-}
-
-/**
- * egg_bytes_equal:
- * @bytes1: (type GLib.Bytes): a pointer to a #EggBytes
- * @bytes2: (type GLib.Bytes): a pointer to a #EggBytes to compare with @bytes1
- *
- * Compares the two #EggBytes values being pointed to and returns
- * %TRUE if they are equal.
- *
- * This function can be passed to g_hash_table_new() as the @key_equal_func
- * parameter, when using non-%NULL #EggBytes pointers as keys in a #GHashTable.
- *
- * Returns: %TRUE if the two keys match.
- *
- * Since: 2.32
- */
-gboolean
-egg_bytes_equal (gconstpointer bytes1,
-               gconstpointer bytes2)
-{
-  const EggBytes *b1 = bytes1;
-  const EggBytes *b2 = bytes2;
-
-  g_return_val_if_fail (bytes1 != NULL, FALSE);
-  g_return_val_if_fail (bytes2 != NULL, FALSE);
-
-  return b1->size == b2->size &&
-         memcmp (b1->data, b2->data, b1->size) == 0;
-}
-
-/**
- * egg_bytes_hash:
- * @bytes: (type GLib.Bytes): a pointer to a #EggBytes key
- *
- * Creates an integer hash code for the byte data in the #EggBytes.
- *
- * This function can be passed to g_hash_table_new() as the @key_equal_func
- * parameter, when using non-%NULL #EggBytes pointers as keys in a #GHashTable.
- *
- * Returns: a hash value corresponding to the key.
- *
- * Since: 2.32
- */
-guint
-egg_bytes_hash (gconstpointer bytes)
-{
-  const EggBytes *a = bytes;
-  const signed char *p, *e;
-  guint32 h = 5381;
-
-  g_return_val_if_fail (bytes != NULL, 0);
-
-  for (p = (signed char *)a->data, e = (signed char *)a->data + a->size; p != e; p++)
-    h = (h << 5) + h + *p;
-
-  return h;
-}
-
-/**
- * egg_bytes_compare:
- * @bytes1: (type GLib.Bytes): a pointer to a #EggBytes
- * @bytes2: (type GLib.Bytes): a pointer to a #EggBytes to compare with @bytes1
- *
- * Compares the two #EggBytes values.
- *
- * This function can be passed to g_tree_new() when using non-%NULL #EggBytes
- * pointers as keys in a #GTree.
- *
- * Returns: a negative value if bytes2 is lesser, a positive value if bytes2 is
- *          greater, and zero if bytes2 is equal to bytes1
- *
- * Since: 2.32
- */
-gint
-egg_bytes_compare (gconstpointer bytes1,
-                 gconstpointer bytes2)
-{
-  const EggBytes *b1 = bytes1;
-  const EggBytes *b2 = bytes2;
-  gint ret;
-
-  g_return_val_if_fail (bytes1 != NULL, 0);
-  g_return_val_if_fail (bytes2 != NULL, 0);
-
-  ret = memcmp (b1->data, b2->data, MIN (b1->size, b2->size));
-  if (ret == 0 && b1->size != b2->size)
-      ret = b1->size < b2->size ? -1 : 1;
-  return ret;
-}
-
-/**
- * egg_bytes_unref_to_array:
- * @bytes: (transfer full): a #EggBytes
- *
- * Unreferences the bytes, and returns a new mutable #GByteArray containing
- * the same byte data.
- *
- * As an optimization, the byte data is transferred to the array without copying
- * if: this was the last reference to bytes and bytes was created with
- * egg_bytes_new(), egg_bytes_new_take() or g_byte_array_free_to_bytes(). In all
- * other cases the data is copied.
- *
- * Returns: (transfer full): a new mutable #GByteArray containing the same byte data
- *
- * Since: 2.32
- */
-GByteArray *
-egg_bytes_unref_to_array (EggBytes *bytes)
-{
-  GByteArray *result = NULL;
-#if 0
-  gpointer data;
-  gsize size;
-#endif
-
-  g_return_val_if_fail (bytes != NULL, NULL);
-
-#if 0
-  data = egg_bytes_try_steal_and_unref (bytes, NULL, &size);
-  if (data != NULL)
-    {
-      /*
-       * Optimal path: if this is was the last reference, then we can have
-       * the GByteArray assume the data from this EggBytes without copying.
-       */
-      result = g_byte_array_new_take (data, size);
-    }
-  else
-#endif
-    {
-      /*
-       * Copy: Non g_malloc (or compatible) allocator, or static memory,
-       * so we have to copy, and then unref.
-       */
-      result = g_byte_array_append (g_byte_array_new (), bytes->data, bytes->size);
-      egg_bytes_unref (bytes);
-    }
-
-  return result;
-}
-
-/*
- * The behavior of this function with regards to references cannot be easily
- * modeled by most gobject-introspection consumers, so we use (skip).
- */
-
-/**
- * egg_bytes_try_steal_and_unref: (skip)
- * @bytes: a #EggBytes
- * @free_func: the function data is freed with, or %NULL for default
- * @size: location to return the length of the data
- *
- * This is an advanced function, and seldom used.
- *
- * Try to take ownership of the data in the byte array. This is only successful
- * if this is the last reference and @free_func matches the function that would
- * have been used to free the data. This is to demonstrate that the caller
- * is aware of the how the data in the #EggBytes was allocated. If %NULL is passed
- * for @free_func this represents the standard Glib allocation routines.
- *
- * You should use %NULL instead of passing g_free() for @free_func. This is
- * because the actual address of g_free() varies depending on how the calling
- * application and library was linked.
- *
- * If the attempt to take ownership of the byte data is successful according to
- * the above criteria, then the data is returned and @size is set to the length
- * of the data. The #EggBytes is unreferenced and is no longer valid.
- *
- * If the attempt to take ownership of the byte data is unsuccessful, %NULL is
- * returned. The #EggBytes is not unreferenced, and the caller must unreference
- * the #EggBytes elsewhere.
- *
- * It is always incorrect to ignore the return value from this function.
- *
- * Returns: the stolen data, or %NULL if attempt failed
- *
- * Since: 2.32
- */
-gpointer
-egg_bytes_try_steal_and_unref (EggBytes         *bytes,
-                             GDestroyNotify  free_func,
-                             gsize          *size)
-{
-  gpointer result;
-
-  g_return_val_if_fail (bytes != NULL, NULL);
-  g_return_val_if_fail (size != NULL, NULL);
-
-  if (free_func == NULL)
-    free_func = g_free;
-  if (bytes->free_func != free_func)
-    return NULL;
-
-  /* Are we the only reference? */
-  if (g_atomic_int_get (&bytes->ref_count) == 1)
-    {
-      *size = bytes->size;
-      result = (gpointer)bytes->data;
-      g_slice_free (EggBytes, bytes);
-      return result;
-    }
-
-  return NULL;
-}
diff --git a/egg/egg-bytes.h b/egg/egg-bytes.h
deleted file mode 100644 (file)
index d25432f..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright Â© 2009, 2010 Codethink Limited
- * Copyright Â© 2011 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the licence, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Author: Ryan Lortie <desrt@desrt.ca>
- *         Stef Walter <stefw@collabora.co.uk>
- */
-
-#ifndef __EGG_BYTES_H__
-#define __EGG_BYTES_H__
-
-#include <glib.h>
-
-/**
- * EggBytes:
- *
- * A simple refcounted data type representing an immutable byte sequence
- * from an unspecified origin.
- *
- * The purpose of a #EggBytes is to keep the memory region that it holds
- * alive for as long as anyone holds a reference to the bytes.  When
- * the last reference count is dropped, the memory is released. Multiple
- * unrelated callers can use byte data in the #EggBytes without coordinating
- * their activities, resting assured that the byte data will not change or
- * move while they hold a reference.
- *
- * A #EggBytes can come from many different origins that may have
- * different procedures for freeing the memory region.  Examples are
- * memory from g_malloc(), from memory slices, from a #GMappedFile or
- * memory from other allocators.
- *
- * #EggBytes work well as keys in #GHashTable. Use egg_bytes_equal() and
- * egg_bytes_hash() as parameters to g_hash_table_new() or g_hash_table_new_full().
- * #EggBytes can also be used as keys in a #GTree by passing the egg_bytes_compare()
- * function to g_tree_new().
- *
- * The data pointed to by this bytes must not be modified. For a mutable
- * array of bytes see #GByteArray. Use egg_bytes_unref_to_array() to create a
- * mutable array for a #EggBytes sequence. To create an immutable #EggBytes from
- * a mutable #GByteArray, use the g_byte_array_free_to_bytes() function.
- *
- * Since: 2.32
- **/
-
-typedef struct _EggBytes EggBytes;
-
-EggBytes *        egg_bytes_new                     (gconstpointer   data,
-                                                 gsize           size);
-
-EggBytes *        egg_bytes_new_take                (gpointer        data,
-                                                 gsize           size);
-
-EggBytes *        egg_bytes_new_static              (gconstpointer   data,
-                                                 gsize           size);
-
-EggBytes *        egg_bytes_new_with_free_func      (gconstpointer   data,
-                                                 gsize           size,
-                                                 GDestroyNotify  free_func,
-                                                 gpointer        user_data);
-
-EggBytes *        egg_bytes_new_from_bytes          (EggBytes         *bytes,
-                                                 goffset         offset,
-                                                 gsize           length);
-
-gconstpointer   egg_bytes_get_data                (EggBytes         *bytes);
-
-gsize           egg_bytes_get_size                (EggBytes         *bytes);
-
-EggBytes *        egg_bytes_ref                     (EggBytes         *bytes);
-
-void            egg_bytes_unref                   (gpointer        bytes);
-
-GByteArray *    egg_bytes_unref_to_array          (EggBytes         *bytes);
-
-gpointer        egg_bytes_try_steal_and_unref     (EggBytes         *bytes,
-                                                 GDestroyNotify  free_func,
-                                                 gsize          *size);
-
-guint           egg_bytes_hash                    (gconstpointer   bytes);
-
-gboolean        egg_bytes_equal                   (gconstpointer   bytes1,
-                                                 gconstpointer   bytes2);
-
-gint            egg_bytes_compare                 (gconstpointer   bytes1,
-                                                 gconstpointer   bytes2);
-
-#endif /* __EGG_BYTES_H__ */
index 2ec5751..e3b092e 100644 (file)
 static const char HEXC[] = "0123456789ABCDEF";
 
 static gchar*
-dn_print_hex_value (EggBytes *val)
+dn_print_hex_value (GBytes *val)
 {
-       const gchar *data = egg_bytes_get_data (val);
-       gsize size = egg_bytes_get_size (val);
+       const gchar *data = g_bytes_get_data (val, NULL);
+       gsize size = g_bytes_get_size (val);
        GString *result = g_string_sized_new (size * 2 + 1);
        gsize i;
 
@@ -52,10 +52,10 @@ dn_print_hex_value (EggBytes *val)
 static gchar*
 dn_print_oid_value_parsed (GQuark oid,
                            guint flags,
-                           EggBytes *val)
+                           GBytes *val)
 {
        GNode *asn1, *node;
-       EggBytes *value;
+       GBytes *value;
        const gchar *data;
        gsize size;
        gchar *result;
@@ -82,8 +82,7 @@ dn_print_oid_value_parsed (GQuark oid,
                node = asn1;
 
        value = egg_asn1x_get_raw_value (node);
-       data = egg_bytes_get_data (value);
-       size = egg_bytes_get_size (value);
+       data = g_bytes_get_data (value, &size);
 
        /*
         * Now we make sure it's UTF-8.
@@ -100,7 +99,7 @@ dn_print_oid_value_parsed (GQuark oid,
                result = g_strndup (data, size);
        }
 
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        egg_asn1x_destroy (asn1);
 
        return result;
@@ -109,7 +108,7 @@ dn_print_oid_value_parsed (GQuark oid,
 static gchar*
 dn_print_oid_value (GQuark oid,
                     guint flags,
-                    EggBytes *val)
+                    GBytes *val)
 {
        gchar *value;
 
@@ -130,7 +129,7 @@ dn_parse_rdn (GNode *asn)
        const gchar *name;
        guint flags;
        GQuark oid;
-       EggBytes *value;
+       GBytes *value;
        gchar *display;
        gchar *result;
 
@@ -150,7 +149,7 @@ dn_parse_rdn (GNode *asn)
                              "=", display, NULL);
        g_free (display);
 
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        return result;
 }
 
@@ -201,7 +200,7 @@ egg_dn_read_part (GNode *asn, const gchar *match)
 {
        gboolean done = FALSE;
        const gchar *name;
-       EggBytes *value;
+       GBytes *value;
        GNode *node;
        GQuark oid;
        gint i, j;
@@ -238,7 +237,7 @@ egg_dn_read_part (GNode *asn, const gchar *match)
                        g_return_val_if_fail (value, NULL);
 
                        result = dn_print_oid_value (oid, egg_oid_get_flags (oid), value);
-                       egg_bytes_unref (value);
+                       g_bytes_unref (value);
                        return result;
                }
        }
@@ -251,7 +250,7 @@ egg_dn_parse (GNode *asn, EggDnCallback callback, gpointer user_data)
 {
        gboolean done = FALSE;
        GNode *node;
-       EggBytes *value;
+       GBytes *value;
        GQuark oid;
        guint i, j;
 
@@ -285,7 +284,7 @@ egg_dn_parse (GNode *asn, EggDnCallback callback, gpointer user_data)
                        if (callback)
                                (callback) (i, oid, value, user_data);
 
-                       egg_bytes_unref (value);
+                       g_bytes_unref (value);
                }
        }
 
@@ -294,7 +293,7 @@ egg_dn_parse (GNode *asn, EggDnCallback callback, gpointer user_data)
 
 gchar *
 egg_dn_print_value (GQuark oid,
-                    EggBytes *value)
+                    GBytes *value)
 {
        g_return_val_if_fail (oid != 0, NULL);
        g_return_val_if_fail (value != NULL, NULL);
@@ -337,7 +336,7 @@ egg_dn_add_string_part (GNode *asn,
                         GQuark oid,
                         const gchar *string)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *node;
        GNode *value;
        GNode *val;
@@ -384,5 +383,5 @@ egg_dn_add_string_part (GNode *asn,
                g_return_if_reached ();
 
        egg_asn1x_destroy (value);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
index 08251ec..a75e73d 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <glib.h>
 
-#include "egg/egg-bytes.h"
-
 gchar*             egg_dn_read                            (GNode *node);
 
 gchar*             egg_dn_read_part                       (GNode *node,
@@ -35,7 +33,7 @@ gchar*             egg_dn_read_part                       (GNode *node,
 
 typedef void       (*EggDnCallback)                       (guint index,
                                                            GQuark oid,
-                                                           EggBytes *value,
+                                                           GBytes *value,
                                                            gpointer user_data);
 
 gboolean           egg_dn_parse                           (GNode *node,
@@ -43,7 +41,7 @@ gboolean           egg_dn_parse                           (GNode *node,
                                                            gpointer user_data);
 
 gchar*             egg_dn_print_value                     (GQuark oid,
-                                                           EggBytes *value);
+                                                           GBytes *value);
 
 void               egg_dn_add_string_part                 (GNode *node,
                                                            GQuark oid,
index 2433f07..5515be1 100644 (file)
@@ -206,7 +206,7 @@ guchar *
 egg_openssl_decrypt_block (const gchar *dekinfo,
                            const gchar *password,
                            gssize n_password,
-                           EggBytes *data,
+                           GBytes *data,
                            gsize *n_decrypted)
 {
        gcry_cipher_hd_t ch;
@@ -245,12 +245,12 @@ egg_openssl_decrypt_block (const gchar *dekinfo,
        g_free (iv);
 
        /* Allocate output area */
-       *n_decrypted = egg_bytes_get_size (data);
+       *n_decrypted = g_bytes_get_size (data);
        decrypted = egg_secure_alloc (*n_decrypted);
 
        gcry = gcry_cipher_decrypt (ch, decrypted, *n_decrypted,
-                                   egg_bytes_get_data (data),
-                                   egg_bytes_get_size (data));
+                                   g_bytes_get_data (data, NULL),
+                                   g_bytes_get_size (data));
        if (gcry) {
                egg_secure_free (decrypted);
                g_return_val_if_reached (NULL);
@@ -265,7 +265,7 @@ guchar *
 egg_openssl_encrypt_block (const gchar *dekinfo,
                            const gchar *password,
                            gssize n_password,
-                           EggBytes *data,
+                           GBytes *data,
                            gsize *n_encrypted)
 {
        gsize n_overflow, n_batch, n_padding;
@@ -305,8 +305,7 @@ egg_openssl_encrypt_block (const gchar *dekinfo,
        g_return_val_if_fail (!gcry, NULL);
        g_free (iv);
 
-       dat = egg_bytes_get_data (data);
-       n_data = egg_bytes_get_size (data);
+       dat = g_bytes_get_data (data, &n_data);
 
        /* Allocate output area */
        n_overflow = (n_data % ivlen);
index 642d906..6c94a7b 100644 (file)
 
 #include <glib.h>
 
-#include <egg/egg-bytes.h>
-
 int              egg_openssl_parse_algo        (const gchar *name, int *mode);
 
 guchar *         egg_openssl_encrypt_block     (const gchar *dekinfo,
                                                 const gchar *password,
                                                 gssize n_password,
-                                                EggBytes *data,
+                                                GBytes *data,
                                                 gsize *n_encrypted);
 
 guchar *         egg_openssl_decrypt_block     (const gchar *dekinfo,
                                                 const gchar *password,
                                                 gssize n_password,
-                                                EggBytes *data,
+                                                GBytes *data,
                                                 gsize *n_decrypted);
 
 const gchar*     egg_openssl_get_dekinfo       (GHashTable *headers);
index 3d402d3..d5459a5 100644 (file)
@@ -662,12 +662,12 @@ read_cipher_pkcs5_pbe (int cipher_algo,
                        int hash_algo,
                        const gchar *password,
                        gsize n_password,
-                       EggBytes *data,
+                       GBytes *data,
                        gcry_cipher_hd_t *cih)
 {
        GNode *asn = NULL;
        gcry_error_t gcry;
-       EggBytes *salt = NULL;
+       GBytes *salt = NULL;
        gsize n_block, n_key;
        gulong iterations;
        guchar *key = NULL;
@@ -703,7 +703,7 @@ read_cipher_pkcs5_pbe (int cipher_algo,
        n_block = gcry_cipher_get_algo_blklen (cipher_algo);
 
        if (!egg_symkey_generate_pbe (cipher_algo, hash_algo, password, n_password,
-                                     egg_bytes_get_data (salt), egg_bytes_get_size (salt),
+                                     g_bytes_get_data (salt, NULL), g_bytes_get_size (salt),
                                      iterations, &key, n_block > 1 ? &iv : NULL))
                goto done;
 
@@ -722,7 +722,7 @@ read_cipher_pkcs5_pbe (int cipher_algo,
 done:
        g_free (iv);
        if (salt != NULL)
-               egg_bytes_unref (salt);
+               g_bytes_unref (salt);
        egg_secure_free (key);
        egg_asn1x_destroy (asn);
 
@@ -730,12 +730,12 @@ done:
 }
 
 static gboolean
-setup_pkcs5_rc2_params (EggBytes *data,
+setup_pkcs5_rc2_params (GBytes *data,
                         gcry_cipher_hd_t cih)
 {
        GNode *asn = NULL;
        gcry_error_t gcry;
-       EggBytes *iv = NULL;
+       GBytes *iv = NULL;
        gulong version;
        gboolean ret = FALSE;
 
@@ -754,9 +754,9 @@ setup_pkcs5_rc2_params (EggBytes *data,
        if (!iv)
                goto done;
 
-       gcry = gcry_cipher_setiv (cih, egg_bytes_get_data (iv), egg_bytes_get_size (iv));
+       gcry = gcry_cipher_setiv (cih, g_bytes_get_data (iv, NULL), g_bytes_get_size (iv));
        if (gcry != 0) {
-               g_message ("couldn't set %lu byte iv on cipher", (gulong)egg_bytes_get_size (iv));
+               g_message ("couldn't set %lu byte iv on cipher", (gulong)g_bytes_get_size (iv));
                goto done;
        }
 
@@ -764,18 +764,18 @@ setup_pkcs5_rc2_params (EggBytes *data,
 
 done:
        if (iv != NULL)
-               egg_bytes_unref (iv);
+               g_bytes_unref (iv);
        egg_asn1x_destroy (asn);
        return ret;
 }
 
 static gboolean
-setup_pkcs5_des_params (EggBytes *data,
+setup_pkcs5_des_params (GBytes *data,
                         gcry_cipher_hd_t cih)
 {
        GNode *asn = NULL;
        gcry_error_t gcry;
-       EggBytes *iv;
+       GBytes *iv;
        gboolean ret;
 
        g_assert (data);
@@ -792,22 +792,22 @@ setup_pkcs5_des_params (EggBytes *data,
        if (!iv)
                return FALSE;
 
-       gcry = gcry_cipher_setiv (cih, egg_bytes_get_data (iv), egg_bytes_get_size (iv));
+       gcry = gcry_cipher_setiv (cih, g_bytes_get_data (iv, NULL), g_bytes_get_size (iv));
        if (gcry != 0) {
-               g_message ("couldn't set %lu byte iv on cipher", (gulong)egg_bytes_get_size (iv));
+               g_message ("couldn't set %lu byte iv on cipher", (gulong)g_bytes_get_size (iv));
                ret = FALSE;
        } else {
                ret = TRUE;
        }
 
-       egg_bytes_unref (iv);
+       g_bytes_unref (iv);
        return ret;
 }
 
 static gboolean
 setup_pkcs5_pbkdf2_params (const gchar *password,
                            gsize n_password,
-                           EggBytes *data,
+                           GBytes *data,
                            int cipher_algo,
                            gcry_cipher_hd_t cih)
 {
@@ -815,7 +815,7 @@ setup_pkcs5_pbkdf2_params (const gchar *password,
        gboolean ret;
        gcry_error_t gcry;
        guchar *key = NULL;
-       EggBytes *salt = NULL;
+       GBytes *salt = NULL;
        gsize n_key;
        gulong iterations;
 
@@ -835,7 +835,7 @@ setup_pkcs5_pbkdf2_params (const gchar *password,
                goto done;
 
        if (!egg_symkey_generate_pbkdf2 (cipher_algo, GCRY_MD_SHA1, password, n_password,
-                                        egg_bytes_get_data (salt), egg_bytes_get_size (salt),
+                                        g_bytes_get_data (salt, NULL), g_bytes_get_size (salt),
                                         iterations, &key, NULL))
                goto done;
 
@@ -852,7 +852,7 @@ setup_pkcs5_pbkdf2_params (const gchar *password,
 
 done:
        if (salt != NULL)
-               egg_bytes_unref (salt);
+               g_bytes_unref (salt);
        egg_secure_free (key);
        egg_asn1x_destroy (asn);
        return ret;
@@ -861,13 +861,13 @@ done:
 static gboolean
 read_cipher_pkcs5_pbes2 (const gchar *password,
                          gsize n_password,
-                         EggBytes *data,
+                         GBytes *data,
                          gcry_cipher_hd_t *cih)
 {
        GNode *asn = NULL;
        gboolean r, ret;
        GQuark key_deriv_algo, enc_oid;
-       EggBytes *params = NULL;
+       GBytes *params = NULL;
        gcry_error_t gcry;
        int algo, mode;
 
@@ -941,7 +941,7 @@ read_cipher_pkcs5_pbes2 (const gchar *password,
                goto done;
        }
 
-       egg_bytes_unref (params);
+       g_bytes_unref (params);
        params = egg_asn1x_get_element_raw (egg_asn1x_node (asn, "keyDerivationFunc", "parameters", NULL));
        if (!params)
                goto done;
@@ -955,7 +955,7 @@ done:
        }
 
        if (params != NULL)
-               egg_bytes_unref (params);
+               g_bytes_unref (params);
        egg_asn1x_destroy (asn);
        return ret;
 }
@@ -965,13 +965,13 @@ read_cipher_pkcs12_pbe (int cipher_algo,
                         int cipher_mode,
                         const gchar *password,
                         gsize n_password,
-                        EggBytes *data,
+                        GBytes *data,
                         gcry_cipher_hd_t *cih)
 {
        GNode *asn = NULL;
        gcry_error_t gcry;
        gboolean ret;
-       EggBytes *salt = NULL;
+       GBytes *salt = NULL;
        gsize n_block, n_key;
        gulong iterations;
        guchar *key = NULL;
@@ -1003,7 +1003,7 @@ read_cipher_pkcs12_pbe (int cipher_algo,
 
        /* Generate IV and key using salt read above */
        if (!egg_symkey_generate_pkcs12 (cipher_algo, GCRY_MD_SHA1, password, n_password,
-                                        egg_bytes_get_data (salt), egg_bytes_get_size (salt),
+                                        g_bytes_get_data (salt, NULL), g_bytes_get_size (salt),
                                         iterations, &key, n_block > 1 ? &iv : NULL))
                goto done;
 
@@ -1026,7 +1026,7 @@ done:
        }
 
        if (salt != NULL)
-               egg_bytes_unref (salt);
+               g_bytes_unref (salt);
        g_free (iv);
        egg_secure_free (key);
        egg_asn1x_destroy (asn);
@@ -1037,7 +1037,7 @@ static gboolean
 read_mac_pkcs12_pbe (int hash_algo,
                      const gchar *password,
                      gsize n_password,
-                     EggBytes *data,
+                     GBytes *data,
                      gcry_md_hd_t *mdh,
                      gsize *digest_len)
 {
@@ -1045,7 +1045,7 @@ read_mac_pkcs12_pbe (int hash_algo,
        gcry_error_t gcry;
        gboolean ret;
        gsize n_key;
-       EggBytes *salt = NULL;
+       GBytes *salt = NULL;
        gulong iterations;
        guchar *key = NULL;
 
@@ -1074,7 +1074,7 @@ read_mac_pkcs12_pbe (int hash_algo,
 
        /* Generate IV and key using salt read above */
        if (!egg_symkey_generate_pkcs12_mac (hash_algo, password, n_password,
-                                            egg_bytes_get_data (salt), egg_bytes_get_size (salt),
+                                            g_bytes_get_data (salt, NULL), g_bytes_get_size (salt),
                                             iterations, &key))
                goto done;
 
@@ -1097,7 +1097,7 @@ done:
        }
 
        if (salt != NULL)
-               egg_bytes_unref (salt);
+               g_bytes_unref (salt);
        egg_secure_free (key);
        egg_asn1x_destroy (asn);
        return ret;
@@ -1107,7 +1107,7 @@ gboolean
 egg_symkey_read_cipher (GQuark oid_scheme,
                         const gchar *password,
                         gsize n_password,
-                        EggBytes *data,
+                        GBytes *data,
                         gcry_cipher_hd_t *cih)
 {
        gboolean ret = FALSE;
@@ -1175,7 +1175,7 @@ gboolean
 egg_symkey_read_mac (GQuark oid_scheme,
                      const gchar *password,
                      gsize n_password,
-                     EggBytes *data,
+                     GBytes *data,
                      gcry_md_hd_t *mdh,
                      gsize *digest_len)
 {
index 92defef..8498613 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <gcrypt.h>
 
-#include <egg/egg-bytes.h>
-
 gboolean                 egg_symkey_generate_simple             (int cipher_algo,
                                                                  int hash_algo,
                                                                  const gchar *password,
@@ -79,13 +77,13 @@ gboolean                 egg_symkey_generate_pbkdf2             (int cipher_algo
 gboolean                 egg_symkey_read_cipher                 (GQuark oid_scheme,
                                                                  const gchar *password,
                                                                  gsize n_password,
-                                                                 EggBytes *data,
+                                                                 GBytes *data,
                                                                  gcry_cipher_hd_t *cih);
 
 gboolean                 egg_symkey_read_mac                    (GQuark oid_scheme,
                                                                  const gchar *password,
                                                                  gsize n_password,
-                                                                 EggBytes *data,
+                                                                 GBytes *data,
                                                                  gcry_md_hd_t *mdh,
                                                                  gsize *digest_len);
 
index d6cfbe5..a058e09 100644 (file)
 
 #define egg_assert_cmpbytes(a, cmp, b, nb) \
        do { gpointer __p1 = (gpointer)(a); gconstpointer __p2 = (b); gsize __n2 = (nb); \
-            if (egg_bytes_get_size (__p1) cmp __n2 && memcmp (egg_bytes_get_data (__p1), __p2, __n2) cmp 0) ; else \
+            if (g_bytes_get_size (__p1) cmp __n2 && memcmp (g_bytes_get_data (__p1, NULL), __p2, __n2) cmp 0) ; else \
                egg_assertion_message_cmpmem (G_LOG_DOMAIN, __FILE__, __LINE__, \
                    G_STRFUNC, #a " " #cmp " " #b, \
-                    egg_bytes_get_data (__p1), egg_bytes_get_size(__p1), #cmp, __p2, __n2); } while (0)
+                   g_bytes_get_data (__p1, NULL), g_bytes_get_size(__p1), #cmp, __p2, __n2); } while (0)
 
 void       egg_assertion_message_cmpmem        (const char *domain, const char *file,
                                                 int line, const char *func,
index 7844c92..95667de 100644 (file)
@@ -61,7 +61,7 @@ const gchar ENUM_THREE[] =           "\x0A\x01\x03";
 static void
 test_boolean (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        gboolean value;
 
@@ -75,24 +75,24 @@ test_boolean (void)
                g_assert_not_reached ();
 
        /* Decode a false */
-       bytes = egg_bytes_new_static (BFALSE, XL (BFALSE));
+       bytes = g_bytes_new_static (BFALSE, XL (BFALSE));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
        value = TRUE;
        if (!egg_asn1x_get_boolean (asn, &value))
                g_assert_not_reached ();
        g_assert (value == FALSE);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        /* Decode a true */
-       bytes = egg_bytes_new_static (BTRUE, XL (BTRUE));
+       bytes = g_bytes_new_static (BTRUE, XL (BTRUE));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
        value = FALSE;
        if (!egg_asn1x_get_boolean (asn, &value))
                g_assert_not_reached ();
        g_assert (value == TRUE);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        egg_asn1x_clear (asn);
 
@@ -107,7 +107,7 @@ static void
 test_null (void)
 {
        GNode *asn;
-       EggBytes *data;
+       GBytes *data;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestNull");
        g_assert (asn);
@@ -118,13 +118,13 @@ test_null (void)
                g_assert_not_reached ();
 
        data = egg_asn1x_encode (asn, g_realloc);
-       egg_assert_cmpmem (NULL_TEST, XL (NULL_TEST), ==, egg_bytes_get_data (data), egg_bytes_get_size (data));
+       egg_assert_cmpmem (NULL_TEST, XL (NULL_TEST), ==, g_bytes_get_data (data, NULL), g_bytes_get_size (data));
 
        if (!egg_asn1x_decode (asn, data))
                g_assert_not_reached ();
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 }
 
 static void
@@ -132,7 +132,7 @@ test_integer (void)
 {
        GNode *asn;
        gulong value;
-       EggBytes *bytes;
+       GBytes *bytes;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
        g_assert (asn);
@@ -144,13 +144,13 @@ test_integer (void)
                g_assert_not_reached ();
 
        /* Should suceed now */
-       bytes = egg_bytes_new_static (I33, XL (I33));
+       bytes = g_bytes_new_static (I33, XL (I33));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
        if (!egg_asn1x_get_integer_as_ulong (asn, &value))
                g_assert_not_reached ();
        g_assert (value == 42);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        egg_asn1x_clear (asn);
 
@@ -166,10 +166,10 @@ test_unsigned (void)
 {
        GNode *asn;
        gulong value;
-       EggBytes *check;
+       GBytes *check;
        guchar val;
-       EggBytes *bytes;
-       EggBytes *usg;
+       GBytes *bytes;
+       GBytes *usg;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
        g_assert (asn);
@@ -177,13 +177,13 @@ test_unsigned (void)
        g_assert_cmpint (EGG_ASN1X_INTEGER, ==, egg_asn1x_type (asn));
 
        /* Check with ulong */
-       bytes = egg_bytes_new_static (I253, XL (I253));
+       bytes = g_bytes_new_static (I253, XL (I253));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
        if (!egg_asn1x_get_integer_as_ulong (asn, &value))
                g_assert_not_reached ();
        g_assert (value == 253);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        egg_asn1x_clear (asn);
 
@@ -191,28 +191,28 @@ test_unsigned (void)
                g_assert_not_reached ();
 
        check = egg_asn1x_encode (asn, NULL);
-       egg_assert_cmpmem (I253, XL (I253), ==, egg_bytes_get_data (check), egg_bytes_get_size (check));
-       egg_bytes_unref (check);
+       egg_assert_cmpmem (I253, XL (I253), ==, g_bytes_get_data (check, NULL), g_bytes_get_size (check));
+       g_bytes_unref (check);
 
        /* Now check with usg */
-       bytes = egg_bytes_new_static (I253, XL (I253));
+       bytes = g_bytes_new_static (I253, XL (I253));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        val = 0xFD; /* == 253 */
        usg = egg_asn1x_get_integer_as_usg (asn);
-       egg_assert_cmpmem (&val, 1, ==, egg_bytes_get_data (usg), egg_bytes_get_size (usg));
-       egg_bytes_unref (usg);
+       egg_assert_cmpmem (&val, 1, ==, g_bytes_get_data (usg, NULL), g_bytes_get_size (usg));
+       g_bytes_unref (usg);
 
        egg_asn1x_clear (asn);
 
-       egg_asn1x_take_integer_as_usg (asn, egg_bytes_new_static (&val, 1));
+       egg_asn1x_take_integer_as_usg (asn, g_bytes_new_static (&val, 1));
 
        check = egg_asn1x_encode (asn, NULL);
-       egg_assert_cmpsize (egg_bytes_get_size (check), ==, XL (I253));
-       egg_assert_cmpmem (I253, XL (I253), ==, egg_bytes_get_data (check), egg_bytes_get_size (check));
-       egg_bytes_unref (check);
+       egg_assert_cmpsize (g_bytes_get_size (check), ==, XL (I253));
+       egg_assert_cmpmem (I253, XL (I253), ==, g_bytes_get_data (check, NULL), g_bytes_get_size (check));
+       g_bytes_unref (check);
 
        egg_asn1x_destroy (asn);
 }
@@ -222,7 +222,7 @@ test_octet_string (void)
 {
        GNode *asn;
        gchar *value;
-       EggBytes *bytes;
+       GBytes *bytes;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestOctetString");
        g_assert (asn);
@@ -234,10 +234,10 @@ test_octet_string (void)
                g_assert_not_reached ();
 
        /* Should work */
-       bytes = egg_bytes_new_static (SFARNSWORTH, XL (SFARNSWORTH));
+       bytes = g_bytes_new_static (SFARNSWORTH, XL (SFARNSWORTH));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        value = egg_asn1x_get_string_as_utf8 (asn, NULL);
        g_assert_cmpstr (value, ==, "farnsworth");
@@ -255,7 +255,7 @@ test_octet_string (void)
 static void
 test_generalized_time (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        glong value;
 
@@ -269,10 +269,10 @@ test_generalized_time (void)
        g_assert (value == -1);
 
        /* Should work */
-       bytes = egg_bytes_new_static (TGENERALIZED, XL (TGENERALIZED));
+       bytes = g_bytes_new_static (TGENERALIZED, XL (TGENERALIZED));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        value = egg_asn1x_get_time_as_long (asn);
        g_assert (value == 1185368728);
 
@@ -288,7 +288,7 @@ test_generalized_time (void)
 static void
 test_implicit_encode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        gchar *value;
 
@@ -296,10 +296,10 @@ test_implicit_encode (void)
        g_assert (asn);
 
        /* Should work */
-       bytes = egg_bytes_new_static (SIMPLICIT, XL (SIMPLICIT));
+       bytes = g_bytes_new_static (SIMPLICIT, XL (SIMPLICIT));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        value = egg_asn1x_get_string_as_utf8 (asn, NULL);
        g_assert_cmpstr (value, ==, "implicit");
        g_free (value);
@@ -310,7 +310,7 @@ test_implicit_encode (void)
 static void
 test_implicit_decode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestImplicit");
@@ -323,13 +323,13 @@ test_implicit_decode (void)
        egg_assert_cmpbytes (bytes, ==, SIMPLICIT, XL (SIMPLICIT));
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
 test_explicit_decode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        gchar *value;
 
@@ -337,10 +337,10 @@ test_explicit_decode (void)
        g_assert (asn);
 
        /* Should work */
-       bytes = egg_bytes_new_static (SEXPLICIT, XL (SEXPLICIT));
+       bytes = g_bytes_new_static (SEXPLICIT, XL (SEXPLICIT));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        value = egg_asn1x_get_string_as_utf8 (asn, NULL);
        g_assert_cmpstr (value, ==, "explicit");
@@ -352,7 +352,7 @@ test_explicit_decode (void)
 static void
 test_explicit_encode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestExplicit");
@@ -365,13 +365,13 @@ test_explicit_encode (void)
        egg_assert_cmpbytes (bytes, ==, SEXPLICIT, XL (SEXPLICIT));
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
 test_universal_decode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        gchar *value;
 
@@ -379,10 +379,10 @@ test_universal_decode (void)
        g_assert (asn);
 
        /* Should work */
-       bytes = egg_bytes_new_static (SUNIVERSAL, XL (SUNIVERSAL));
+       bytes = g_bytes_new_static (SUNIVERSAL, XL (SUNIVERSAL));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        value = egg_asn1x_get_string_as_utf8 (asn, NULL);
        g_assert_cmpstr (value, ==, "universal");
@@ -394,7 +394,7 @@ test_universal_decode (void)
 static void
 test_universal_encode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestUniversal");
@@ -407,15 +407,15 @@ test_universal_encode (void)
        egg_assert_cmpbytes (bytes, ==, SUNIVERSAL, XL (SUNIVERSAL));
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
 test_bit_string_decode (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
-       EggBytes *bits;
+       GBytes *bits;
        guint n_bits;
        const guchar *data;
 
@@ -425,37 +425,37 @@ test_bit_string_decode (void)
        g_assert_cmpint (EGG_ASN1X_BIT_STRING, ==, egg_asn1x_type (asn));
 
        /* Should work */
-       bytes = egg_bytes_new_static (BITS_TEST, XL (BITS_TEST));
+       bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        bits = egg_asn1x_get_bits_as_raw (asn, &n_bits);
        g_assert (bits != NULL);
        g_assert_cmpuint (n_bits, ==, 18);
-       data = egg_bytes_get_data (bits);
+       data = g_bytes_get_data (bits, NULL);
        g_assert_cmpint (data[0], ==, 0x6e);
        g_assert_cmpint (data[1], ==, 0x5d);
        g_assert_cmpint (data[2], ==, 0xc0);
 
-       egg_bytes_unref (bits);
+       g_bytes_unref (bits);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_bit_string_decode_bad (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
        g_assert (asn);
 
        /* Should not work */
-       bytes = egg_bytes_new_static (BITS_BAD, XL (BITS_BAD));
+       bytes = g_bytes_new_static (BITS_BAD, XL (BITS_BAD));
        if (egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        egg_asn1x_destroy (asn);
 }
@@ -463,7 +463,7 @@ test_bit_string_decode_bad (void)
 static void
 test_bit_string_decode_ulong (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        gulong bits;
        guint n_bits;
@@ -472,10 +472,10 @@ test_bit_string_decode_ulong (void)
        g_assert (asn);
 
        /* Should work */
-       bytes = egg_bytes_new_static (BITS_TEST, XL (BITS_TEST));
+       bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
        if (!egg_asn1x_decode (asn, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        if (!egg_asn1x_get_bits_as_ulong (asn, &bits, &n_bits))
                g_assert_not_reached ();
@@ -489,10 +489,10 @@ test_bit_string_decode_ulong (void)
 static void
 test_bit_string_encode_decode (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
        guchar bits[] = { 0x5d, 0x6e, 0x83 };
-       EggBytes *check;
+       GBytes *check;
        const guchar *ch;
        guint n_bits = 17;
        guint n_check;
@@ -500,7 +500,7 @@ test_bit_string_encode_decode (void)
        asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
        g_assert (asn);
 
-       egg_asn1x_take_bits_as_raw (asn, egg_bytes_new (bits, 3), n_bits);
+       egg_asn1x_take_bits_as_raw (asn, g_bytes_new (bits, 3), n_bits);
 
        data = egg_asn1x_encode (asn, NULL);
        g_assert (data);
@@ -508,24 +508,24 @@ test_bit_string_encode_decode (void)
        if (!egg_asn1x_decode (asn, data))
                g_assert_not_reached ();
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        check = egg_asn1x_get_bits_as_raw (asn, &n_check);
        g_assert (check != NULL);
        g_assert_cmpuint (n_check, ==, 17);
-       ch = egg_bytes_get_data (check);
+       ch = g_bytes_get_data (check, NULL);
        g_assert_cmpint (ch[0], ==, 0x5d);
        g_assert_cmpint (ch[1], ==, 0x6e);
        g_assert_cmpint (ch[2], ==, 0x80);
 
-       egg_bytes_unref (check);
+       g_bytes_unref (check);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_bit_string_encode_decode_ulong (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
        gulong check, bits = 0x0101b977;
        guint n_check, n_bits = 18;
@@ -542,7 +542,7 @@ test_bit_string_encode_decode_ulong (void)
        if (!egg_asn1x_decode (asn, data))
                g_assert_not_reached ();
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        if (!egg_asn1x_get_bits_as_ulong (asn, &check, &n_check))
                g_assert_not_reached ();
@@ -556,27 +556,27 @@ test_bit_string_encode_decode_ulong (void)
 static void
 test_bit_string_encode_decode_zero (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
        g_assert (asn);
 
-       egg_asn1x_take_bits_as_raw (asn, egg_bytes_new_static ("", 0), 0);
+       egg_asn1x_take_bits_as_raw (asn, g_bytes_new_static ("", 0), 0);
 
        data = egg_asn1x_encode (asn, NULL);
        g_assert (data);
 
-       egg_assert_cmpmem (egg_bytes_get_data (data), egg_bytes_get_size (data), ==, BITS_ZERO, XL (BITS_ZERO));
+       egg_assert_cmpmem (g_bytes_get_data (data, NULL), g_bytes_get_size (data), ==, BITS_ZERO, XL (BITS_ZERO));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_have (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestBoolean");
@@ -594,7 +594,7 @@ test_have (void)
 
        g_assert (egg_asn1x_have (asn));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
@@ -610,10 +610,10 @@ test_is_freed (gpointer unused)
 static void
 test_any_set_raw (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn, *node;
-       EggBytes *data;
-       EggBytes *check;
+       GBytes *data;
+       GBytes *check;
 
        /* ENCODED SEQUENCE ANY with OCTET STRING */
        const gchar SEQ_ENCODING[] =  "\x30\x0C\x04\x0A""farnsworth";
@@ -625,11 +625,11 @@ test_any_set_raw (void)
        node = egg_asn1x_node (asn, "contents", NULL);
        g_assert (node);
 
-       bytes = egg_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH),
+       bytes = g_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH),
                                              test_is_freed, NULL);
        if (!egg_asn1x_set_element_raw (node, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        data = egg_asn1x_encode (asn, NULL);
        g_assert (data != NULL);
@@ -641,8 +641,8 @@ test_any_set_raw (void)
 
        egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
 
-       egg_bytes_unref (data);
-       egg_bytes_unref (check);
+       g_bytes_unref (data);
+       g_bytes_unref (check);
        egg_asn1x_destroy (asn);
        g_assert (is_freed);
 }
@@ -650,10 +650,10 @@ test_any_set_raw (void)
 static void
 test_any_set_raw_explicit (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn, *node;
-       EggBytes *data;
-       EggBytes *check;
+       GBytes *data;
+       GBytes *check;
 
        /* ENCODED SEQUENCE [89] ANY with OCTET STRING */
        const gchar SEQ_ENCODING[] =  "\x30\x0F\xBF\x59\x0C\x04\x0A""farnsworth";
@@ -665,10 +665,10 @@ test_any_set_raw_explicit (void)
        node = egg_asn1x_node (asn, "contents", NULL);
        g_assert (node);
 
-       bytes = egg_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH), test_is_freed, NULL);
+       bytes = g_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH), test_is_freed, NULL);
        if (!egg_asn1x_set_element_raw (node, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        data = egg_asn1x_encode (asn, NULL);
        g_assert (data != NULL);
@@ -680,8 +680,8 @@ test_any_set_raw_explicit (void)
 
        egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
 
-       egg_bytes_unref (data);
-       egg_bytes_unref (check);
+       g_bytes_unref (data);
+       g_bytes_unref (check);
        egg_asn1x_destroy (asn);
        g_assert (is_freed);
 }
@@ -689,9 +689,9 @@ test_any_set_raw_explicit (void)
 static void
 test_choice_not_chosen (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn, *node;
-       EggBytes *data;
+       GBytes *data;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestAnyChoice");
        g_assert (asn);
@@ -701,10 +701,10 @@ test_choice_not_chosen (void)
        node = egg_asn1x_node (asn, "choiceShortTag", NULL);
        g_assert (node);
 
-       bytes = egg_bytes_new_static (SFARNSWORTH, XL (SFARNSWORTH));
+       bytes = g_bytes_new_static (SFARNSWORTH, XL (SFARNSWORTH));
        if (!egg_asn1x_set_element_raw (node, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        /* egg_asn1x_set_choice() was not called */
        data = egg_asn1x_encode (asn, NULL);
@@ -718,10 +718,10 @@ test_choice_not_chosen (void)
 static void
 perform_asn1_any_choice_set_raw (const gchar *choice, const gchar *encoding, gsize n_encoding)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn, *node;
-       EggBytes *data;
-       EggBytes *check;
+       GBytes *data;
+       GBytes *check;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestAnyChoice");
        g_assert (asn);
@@ -735,10 +735,10 @@ perform_asn1_any_choice_set_raw (const gchar *choice, const gchar *encoding, gsi
        if (!egg_asn1x_set_choice (asn, node))
                g_assert_not_reached ();
 
-       bytes = egg_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH), test_is_freed, NULL);
+       bytes = g_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH), test_is_freed, NULL);
        if (!egg_asn1x_set_element_raw (node, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        data = egg_asn1x_encode (asn, NULL);
        if (data == NULL) {
@@ -754,8 +754,8 @@ perform_asn1_any_choice_set_raw (const gchar *choice, const gchar *encoding, gsi
 
        egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
 
-       egg_bytes_unref (data);
-       egg_bytes_unref (check);
+       g_bytes_unref (data);
+       g_bytes_unref (check);
        egg_asn1x_destroy (asn);
        g_assert (is_freed);
 }
@@ -777,10 +777,10 @@ test_any_choice_set_raw_long_tag (void)
 static void
 test_append (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        GNode *child;
-       EggBytes *data;
+       GBytes *data;
 
        /* SEQUENCE OF with one INTEGER = 1 */
        const gchar SEQOF_ONE[] =  "\x30\x03\x02\x01\x01";
@@ -788,10 +788,10 @@ test_append (void)
        /* SEQUENCE OF with two INTEGER = 1, 2 */
        const gchar SEQOF_TWO[] =  "\x30\x06\x02\x01\x01\x02\x01\x02";
 
-       bytes = egg_bytes_new_static (SEQOF_ONE, XL (SEQOF_ONE));
+       bytes = g_bytes_new_static (SEQOF_ONE, XL (SEQOF_ONE));
        asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestSeqOf", bytes);
        g_assert (asn);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        g_assert_cmpint (EGG_ASN1X_SEQUENCE_OF, ==, egg_asn1x_type (asn));
 
@@ -807,14 +807,14 @@ test_append (void)
 
        egg_assert_cmpbytes (data, ==, SEQOF_TWO, XL (SEQOF_TWO));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_append_and_clear (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestSeqOf");
@@ -838,15 +838,15 @@ test_append_and_clear (void)
        g_assert_cmpuint (egg_asn1x_count (asn), ==, 0);
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 }
 
 static void
 test_setof (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
-       EggBytes *data;
+       GBytes *data;
 
        /* SEQUENCE OF with one INTEGER = 3 */
        const gchar SETOF_ONE[] =  "\x31\x03\x02\x01\x03";
@@ -854,10 +854,10 @@ test_setof (void)
        /* SET OF with two INTEGER = 1, 3, 8 */
        const gchar SETOF_THREE[] =  "\x31\x09\x02\x01\x01\x02\x01\x03\x02\x01\x08";
 
-       bytes = egg_bytes_new_static (SETOF_ONE, XL (SETOF_ONE));
+       bytes = g_bytes_new_static (SETOF_ONE, XL (SETOF_ONE));
        asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestSetOf", bytes);
        g_assert (asn != NULL);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        g_assert_cmpint (EGG_ASN1X_SET_OF, ==, egg_asn1x_type (asn));
 
@@ -877,14 +877,14 @@ test_setof (void)
 
        egg_assert_cmpbytes (data, ==, SETOF_THREE, XL (SETOF_THREE));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_setof_empty (void)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
 
        /* SEQUENCE OF with nothing */
@@ -901,22 +901,22 @@ test_setof_empty (void)
 
        egg_assert_cmpbytes (data, ==, SETOF_NONE, XL (SETOF_NONE));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_enumerated (void)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
-       EggBytes *data;
+       GBytes *data;
        GQuark value;
 
-       bytes = egg_bytes_new_static (ENUM_TWO, XL (ENUM_TWO));
+       bytes = g_bytes_new_static (ENUM_TWO, XL (ENUM_TWO));
        asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestEnumerated", bytes);
        g_assert (asn != NULL);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        g_assert_cmpint (EGG_ASN1X_ENUMERATED, ==, egg_asn1x_type (asn));
 
@@ -932,7 +932,7 @@ test_enumerated (void)
 
        egg_assert_cmpbytes (data, ==, ENUM_THREE, XL (ENUM_THREE));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
@@ -945,7 +945,7 @@ typedef struct {
 static void
 setup (Test *test, gconstpointer unused)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
 
        if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
@@ -954,10 +954,10 @@ setup (Test *test, gconstpointer unused)
        test->asn1 = egg_asn1x_create (pkix_asn1_tab, "Certificate");
        g_assert (test->asn1 != NULL);
 
-       bytes = egg_bytes_new_static (test->data, test->n_data);
+       bytes = g_bytes_new_static (test->data, test->n_data);
        if (!egg_asn1x_decode (test->asn1, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -976,7 +976,7 @@ test_node_name (Test* test, gconstpointer unused)
 static void
 test_asn1_integers (Test* test, gconstpointer unused)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn;
        gboolean ret;
        gulong val;
@@ -1017,13 +1017,13 @@ test_asn1_integers (Test* test, gconstpointer unused)
        g_assert_cmpuint (val, ==, 209384022);
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 }
 
 static void
 test_boolean_seq (Test* test, gconstpointer unused)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *asn = NULL;
        gboolean value, ret;
 
@@ -1049,7 +1049,7 @@ test_boolean_seq (Test* test, gconstpointer unused)
        ret = egg_asn1x_set_boolean (egg_asn1x_node (asn, "boolean", NULL), FALSE);
        g_assert (ret == TRUE);
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        data = egg_asn1x_encode (asn, NULL);
        g_assert (data != NULL);
 
@@ -1057,14 +1057,14 @@ test_boolean_seq (Test* test, gconstpointer unused)
        g_assert (ret);
        g_assert (value == FALSE);
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_write_value (Test* test, gconstpointer unused)
 {
-       EggBytes *encoded;
+       GBytes *encoded;
        GNode *asn = NULL;
        guchar *data;
        gsize n_data;
@@ -1084,14 +1084,14 @@ test_write_value (Test* test, gconstpointer unused)
        g_assert (memcmp (data, "SOME DATA", 9) == 0);
        g_free (data);
 
-       egg_bytes_unref (encoded);
+       g_bytes_unref (encoded);
        egg_asn1x_destroy (asn);
 }
 
 static void
 test_element_length_content (Test* test, gconstpointer unused)
 {
-       EggBytes *buffer;
+       GBytes *buffer;
        GNode *asn = NULL;
        const guchar *content;
        gsize n_content;
@@ -1107,11 +1107,11 @@ test_element_length_content (Test* test, gconstpointer unused)
        g_assert (buffer != NULL);
 
        /* Now the real test */
-       length = egg_asn1x_element_length (egg_bytes_get_data (buffer),
-                                          egg_bytes_get_size (buffer) + 1024);
+       length = egg_asn1x_element_length (g_bytes_get_data (buffer, NULL),
+                                          g_bytes_get_size (buffer) + 1024);
        g_assert_cmpint (length, ==, 13);
 
-       content = egg_asn1x_element_content (egg_bytes_get_data (buffer),
+       content = egg_asn1x_element_content (g_bytes_get_data (buffer, NULL),
                                             length, &n_content);
        g_assert (content != NULL);
        g_assert_cmpuint (n_content, ==, 11);
@@ -1130,15 +1130,15 @@ test_element_length_content (Test* test, gconstpointer unused)
        g_assert (content == NULL);
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (buffer);
+       g_bytes_unref (buffer);
 }
 
 static void
 test_read_element (Test* test, gconstpointer unused)
 {
-       EggBytes *buffer;
+       GBytes *buffer;
        GNode *asn = NULL;
-       EggBytes *data;
+       GBytes *data;
 
        asn = egg_asn1x_create (test_asn1_tab, "TestData");
        g_assert ("asn test structure is null" && asn != NULL);
@@ -1152,22 +1152,22 @@ test_read_element (Test* test, gconstpointer unused)
        /* Now the real test */
        data = egg_asn1x_get_element_raw (egg_asn1x_node (asn, "data", NULL));
        g_assert (data != NULL);
-       g_assert_cmpint (egg_bytes_get_size (data), ==, 11);
-       egg_bytes_unref (data);
+       g_assert_cmpint (g_bytes_get_size (data), ==, 11);
+       g_bytes_unref (data);
 
        data = egg_asn1x_get_raw_value (egg_asn1x_node (asn, "data", NULL));
        g_assert (data != NULL);
        egg_assert_cmpbytes (data, ==, "SOME DATA", 9);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (buffer);
+       g_bytes_unref (buffer);
 }
 
 static void
 test_oid (Test* test, gconstpointer unused)
 {
-       EggBytes *buffer;
+       GBytes *buffer;
        GNode *asn = NULL;
        GNode *node;
        GQuark oid, check;
@@ -1195,7 +1195,7 @@ test_oid (Test* test, gconstpointer unused)
        if (!egg_asn1x_set_oid_as_quark (egg_asn1x_node (asn, "oid", NULL), g_quark_from_static_string ("5.4.3.2.1678")))
                g_assert_not_reached ();
 
-       egg_bytes_unref (buffer);
+       g_bytes_unref (buffer);
        buffer = egg_asn1x_encode (asn, NULL);
        g_assert (buffer != NULL);
 
@@ -1203,7 +1203,7 @@ test_oid (Test* test, gconstpointer unused)
        g_assert (oid);
        g_assert_cmpstr (g_quark_to_string (oid), ==, "5.4.3.2.1678");
 
-       egg_bytes_unref (buffer);
+       g_bytes_unref (buffer);
        egg_asn1x_destroy (asn);
 }
 
index 720d62a..4581756 100644 (file)
@@ -69,14 +69,14 @@ test_some_asn1_stuff (const EggAsn1xDef *defs,
                       const gchar *identifier)
 {
        GNode *asn;
-       EggBytes *encoded;
+       GBytes *encoded;
        gpointer data;
        gsize n_data;
-       EggBytes *bytes;
+       GBytes *bytes;
 
        if (!g_file_get_contents (file, (gchar**)&data, &n_data, NULL))
                g_assert_not_reached ();
-       bytes = egg_bytes_new_take (data, n_data);
+       bytes = g_bytes_new_take (data, n_data);
        asn = egg_asn1x_create (defs, identifier);
        egg_asn1x_dump (asn);
 
@@ -93,8 +93,8 @@ test_some_asn1_stuff (const EggAsn1xDef *defs,
 
        egg_asn1x_clear (asn);
        egg_asn1x_destroy (asn);
-       egg_bytes_unref (bytes);
-       egg_bytes_unref (encoded);
+       g_bytes_unref (bytes);
+       g_bytes_unref (encoded);
 }
 
 int
index 929cec2..cf83dcb 100644 (file)
@@ -45,7 +45,7 @@ typedef struct {
 static void
 setup (Test *test, gconstpointer unused)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
 
        if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der",
                                  (gchar**)&test->data, &test->n_data, NULL))
@@ -54,10 +54,10 @@ setup (Test *test, gconstpointer unused)
        test->asn1 = egg_asn1x_create (pkix_asn1_tab, "Certificate");
        g_assert (test->asn1 != NULL);
 
-       bytes = egg_bytes_new_static (test->data, test->n_data);
+       bytes = g_bytes_new_static (test->data, test->n_data);
        if (!egg_asn1x_decode (test->asn1, bytes))
                g_assert_not_reached ();
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -84,23 +84,23 @@ test_dn_value (Test* test, gconstpointer unused)
 {
        const guchar value[] = { 0x13, 0x1a, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x20, 0x50, 0x72, 0x65, 0x6d, 0x69, 0x75, 0x6d, 0x20, 0x43, 0x41 };
        gsize n_value = 28;
-       EggBytes *bytes;
+       GBytes *bytes;
        GQuark oid;
        gchar *text;
 
        /* Some printable strings */
        oid = g_quark_from_static_string ("2.5.4.3");
-       bytes = egg_bytes_new_static (value, n_value);
+       bytes = g_bytes_new_static (value, n_value);
        text = egg_dn_print_value (oid, bytes);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        g_assert_cmpstr (text, ==, "Thawte Personal Premium CA");
        g_free (text);
 
        /* Unknown oid */
        oid = g_quark_from_static_string ("1.1.1.1.1.1");
-       bytes = egg_bytes_new_static (value, n_value);
+       bytes = g_bytes_new_static (value, n_value);
        text = egg_dn_print_value (oid, bytes);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        g_assert_cmpstr (text, ==, "#131A54686177746520506572736F6E616C205072656D69756D204341");
        g_free (text);
 }
@@ -110,7 +110,7 @@ static int last_index = 0;
 static void
 concatenate_dn (guint index,
                 GQuark oid,
-                EggBytes *value,
+                GBytes *value,
                 gpointer user_data)
 {
        GString *dn = user_data;
@@ -118,7 +118,7 @@ concatenate_dn (guint index,
 
        g_assert (oid);
        g_assert (value != NULL);
-       g_assert (egg_bytes_get_size (value) != 0);
+       g_assert (g_bytes_get_size (value) != 0);
 
        g_assert (index == last_index);
        ++last_index;
@@ -180,8 +180,8 @@ static void
 test_add_dn_part (Test *test,
                   gconstpointer unused)
 {
-       EggBytes *check;
-       EggBytes *dn;
+       GBytes *check;
+       GBytes *dn;
        GNode *check_dn;
        GNode *asn;
        GNode *node;
@@ -207,10 +207,10 @@ test_add_dn_part (Test *test,
        check = egg_asn1x_encode (check_dn, NULL);
        egg_asn1x_destroy (asn);
 
-       egg_assert_cmpbytes (dn, ==, egg_bytes_get_data (check), egg_bytes_get_size (check));
+       egg_assert_cmpbytes (dn, ==, g_bytes_get_data (check, NULL), g_bytes_get_size (check));
 
-       egg_bytes_unref (dn);
-       egg_bytes_unref (check);
+       g_bytes_unref (dn);
+       g_bytes_unref (check);
 }
 
 int
index 87596fd..562f200 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
-#include <egg/egg-bytes.h>
-
 EGG_SECURE_DEFINE_GLIB_GLOBALS ();
 
 typedef struct {
-       EggBytes *input;
+       GBytes *input;
        GQuark reftype;
        guchar *refenc;
        guchar *refdata;
@@ -59,13 +57,13 @@ setup (Test *test, gconstpointer unused)
        if (!g_file_get_contents (SRCDIR "/files/pem-rsa-enc.key", &contents, &length, NULL))
                g_assert_not_reached ();
 
-       test->input = egg_bytes_new_take (contents, length);
+       test->input = g_bytes_new_take (contents, length);
 }
 
 static void
 teardown (Test *test, gconstpointer unused)
 {
-       egg_bytes_unref (test->input);
+       g_bytes_unref (test->input);
        g_free (test->refenc);
        egg_secure_free (test->refdata);
        g_hash_table_destroy (test->refheaders);
@@ -79,8 +77,8 @@ copy_each_key_value (gpointer key, gpointer value, gpointer user_data)
 
 static void
 parse_reference (GQuark type,
-                 EggBytes *data,
-                 EggBytes *outer,
+                 GBytes *data,
+                 GBytes *outer,
                  GHashTable *headers,
                  gpointer user_data)
 {
@@ -91,9 +89,9 @@ parse_reference (GQuark type,
        test->reftype = type;
 
        g_assert ("no data in PEM callback" && data != NULL);
-       g_assert ("no data in PEM callback" && egg_bytes_get_size (data) > 0);
-       test->refenc = g_memdup (egg_bytes_get_data (data), egg_bytes_get_size (data));
-       test->n_refenc = egg_bytes_get_size (data);
+       g_assert ("no data in PEM callback" && g_bytes_get_size (data) > 0);
+       test->refenc = g_memdup (g_bytes_get_data (data, NULL), g_bytes_get_size (data));
+       test->n_refenc = g_bytes_get_size (data);
 
        g_assert ("no headers present in file" && headers != NULL);
        g_assert (!test->refheaders);
@@ -104,7 +102,7 @@ parse_reference (GQuark type,
 
        test->refdata = egg_openssl_decrypt_block (dekinfo, "booo", 4, data, &test->n_refdata);
        g_assert ("no data returned from openssl decrypt" && test->refdata != NULL);
-       g_assert ("invalid amount of data returned from openssl decrypt" && test->n_refdata == egg_bytes_get_size (data));
+       g_assert ("invalid amount of data returned from openssl decrypt" && test->n_refdata == g_bytes_get_size (data));
 }
 
 static void
@@ -124,7 +122,7 @@ test_write_reference (Test *test, gconstpointer unused)
        const gchar *dekinfo;
        guchar *encrypted;
        gsize n_encrypted;
-       EggBytes *data;
+       GBytes *data;
        guint num;
 
        num = egg_armor_parse (test->input, parse_reference, test);
@@ -133,9 +131,9 @@ test_write_reference (Test *test, gconstpointer unused)
        dekinfo = egg_openssl_get_dekinfo (test->refheaders);
        g_assert ("no dekinfo in headers" && dekinfo != NULL);
 
-       data = egg_bytes_new_static (test->refdata, test->n_refdata);
+       data = g_bytes_new_static (test->refdata, test->n_refdata);
        encrypted = egg_openssl_encrypt_block (dekinfo, "booo", 4, data, &n_encrypted);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        g_assert ("no data returned from openssl encrypt" && encrypted != NULL);
        g_assert ("invalid amount of data returned from openssl encrypt" && test->n_refdata <= n_encrypted);
@@ -179,7 +177,7 @@ test_openssl_roundtrip (Test *test, gconstpointer unused)
        const gchar *dekinfo;
        guchar *encrypted, *decrypted;
        gsize n_encrypted, n_decrypted;
-       EggBytes *data;
+       GBytes *data;
        int i;
        guint num;
 
@@ -188,16 +186,16 @@ test_openssl_roundtrip (Test *test, gconstpointer unused)
 
        dekinfo = egg_openssl_prep_dekinfo (test->refheaders);
 
-       data = egg_bytes_new_static (TEST_DATA, TEST_DATA_L);
+       data = g_bytes_new_static (TEST_DATA, TEST_DATA_L);
        encrypted = egg_openssl_encrypt_block (dekinfo, "password", -1, data, &n_encrypted);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        g_assert ("no data returned from openssl encrypt" && encrypted != NULL);
        g_assert ("invalid amount of data returned from openssl encrypt" && TEST_DATA_L <= n_encrypted);
 
-       data = egg_bytes_new_with_free_func (encrypted, n_encrypted, egg_secure_free, encrypted);
+       data = g_bytes_new_with_free_func (encrypted, n_encrypted, egg_secure_free, encrypted);
        decrypted = egg_openssl_decrypt_block (dekinfo, "password", 8, data, &n_decrypted);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 
        g_assert ("no data returned from openssl decrypt" && decrypted != NULL);
 
index d253315..ba16907 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <glib/gi18n-lib.h>
 
-EggBytes *
+GBytes *
 _gcr_certificate_extension_find (GNode *cert,
                                  GQuark oid,
                                  gboolean *critical)
@@ -64,7 +64,7 @@ _gcr_certificate_extension_find (GNode *cert,
 }
 
 gboolean
-_gcr_certificate_extension_basic_constraints (EggBytes *data,
+_gcr_certificate_extension_basic_constraints (GBytes *data,
                                               gboolean *is_ca,
                                               gint *path_len)
 {
@@ -102,7 +102,7 @@ _gcr_certificate_extension_basic_constraints (EggBytes *data,
 }
 
 GQuark *
-_gcr_certificate_extension_extended_key_usage (EggBytes *data)
+_gcr_certificate_extension_extended_key_usage (GBytes *data)
 {
        GNode *asn = NULL;
        GNode *node;
@@ -130,7 +130,7 @@ _gcr_certificate_extension_extended_key_usage (EggBytes *data)
 }
 
 gpointer
-_gcr_certificate_extension_subject_key_identifier (EggBytes *data,
+_gcr_certificate_extension_subject_key_identifier (GBytes *data,
                                                    gsize *n_keyid)
 {
        GNode *asn = NULL;
@@ -149,7 +149,7 @@ _gcr_certificate_extension_subject_key_identifier (EggBytes *data,
 }
 
 gboolean
-_gcr_certificate_extension_key_usage (EggBytes *data,
+_gcr_certificate_extension_key_usage (GBytes *data,
                                       gulong *key_usage)
 {
        GNode *asn = NULL;
@@ -172,7 +172,7 @@ general_name_parse_other (GNode *node, GcrGeneralName *general)
 {
        GNode *decode = NULL;
        GQuark oid;
-       EggBytes *value;
+       GBytes *value;
 
        general->type = GCR_GENERAL_NAME_OTHER;
        general->description = _("Other Name");
@@ -193,7 +193,7 @@ general_name_parse_other (GNode *node, GcrGeneralName *general)
                general->display = egg_asn1x_get_string_as_utf8 (decode, g_realloc);
        }
 
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        egg_asn1x_destroy (decode);
 }
 
@@ -260,7 +260,7 @@ general_name_parse_registered (GNode *node, GcrGeneralName *general)
 }
 
 GArray*
-_gcr_certificate_extension_subject_alt_name (EggBytes *data)
+_gcr_certificate_extension_subject_alt_name (GBytes *data)
 {
        GNode *asn = NULL;
        guint count, i;
@@ -331,7 +331,7 @@ _gcr_general_names_free (GArray *names)
        for (i = 0; names && i < names->len; i++) {
                name = &g_array_index (names, GcrGeneralName, i);
                g_free (name->display);
-               egg_bytes_unref (name->raw);
+               g_bytes_unref (name->raw);
        }
        g_array_free (names, TRUE);
 }
index cea6e54..7325df2 100644 (file)
 
 #include <glib.h>
 
-#include <egg/egg-bytes.h>
-
 G_BEGIN_DECLS
 
-EggBytes * _gcr_certificate_extension_find                    (GNode *cert,
+GBytes *   _gcr_certificate_extension_find                    (GNode *cert,
                                                                GQuark oid,
                                                                gboolean *critical);
 
-gboolean   _gcr_certificate_extension_basic_constraints       (EggBytes *data,
+gboolean   _gcr_certificate_extension_basic_constraints       (GBytes *data,
                                                                gboolean *is_ca,
                                                                gint *path_len);
 
-GQuark *   _gcr_certificate_extension_extended_key_usage      (EggBytes *data);
+GQuark *   _gcr_certificate_extension_extended_key_usage      (GBytes *data);
 
-gpointer   _gcr_certificate_extension_subject_key_identifier  (EggBytes *data,
+gpointer   _gcr_certificate_extension_subject_key_identifier  (GBytes *data,
                                                                gsize *n_keyid);
 
 typedef enum {
@@ -57,7 +55,7 @@ typedef enum {
        GCR_KEY_USAGE_CRL_SIGN = 1 << 6,
 } GcrCertificateExtensionKeyUsage;
 
-gboolean   _gcr_certificate_extension_key_usage               (EggBytes *data,
+gboolean   _gcr_certificate_extension_key_usage               (GBytes *data,
                                                                gulong *key_usage);
 
 typedef enum {
@@ -76,10 +74,10 @@ typedef struct {
        GcrGeneralNameType type;
        const gchar *description;
        gchar *display;
-       EggBytes *raw;
+       GBytes *raw;
 } GcrGeneralName;
 
-GArray *   _gcr_certificate_extension_subject_alt_name        (EggBytes *data);
+GArray *   _gcr_certificate_extension_subject_alt_name        (GBytes *data);
 
 void       _gcr_general_names_free                            (GArray *names);
 
index fce96dc..631267c 100644 (file)
@@ -105,7 +105,7 @@ calculate_label (GcrCertificateRenderer *self)
 static gboolean
 append_extension_basic_constraints (GcrRenderer *renderer,
                                     GcrDisplayView *view,
-                                    EggBytes *data)
+                                    GBytes *data)
 {
        gboolean is_ca = FALSE;
        gint path_len = -1;
@@ -130,7 +130,7 @@ append_extension_basic_constraints (GcrRenderer *renderer,
 static gboolean
 append_extension_extended_key_usage (GcrRenderer *renderer,
                                      GcrDisplayView *view,
-                                     EggBytes *data)
+                                     GBytes *data)
 {
        GQuark *oids;
        GString *text;
@@ -162,7 +162,7 @@ append_extension_extended_key_usage (GcrRenderer *renderer,
 static gboolean
 append_extension_subject_key_identifier (GcrRenderer *renderer,
                                          GcrDisplayView *view,
-                                         EggBytes *data)
+                                         GBytes *data)
 {
        gpointer keyid;
        gsize n_keyid;
@@ -194,7 +194,7 @@ static const struct {
 static gboolean
 append_extension_key_usage (GcrRenderer *renderer,
                             GcrDisplayView *view,
-                            EggBytes *data)
+                            GBytes *data)
 {
        gulong key_usage;
        GString *text;
@@ -224,7 +224,7 @@ append_extension_key_usage (GcrRenderer *renderer,
 static gboolean
 append_extension_subject_alt_name (GcrRenderer *renderer,
                                    GcrDisplayView *view,
-                                   EggBytes *data)
+                                   GBytes *data)
 {
        GArray *general_names;
        GcrGeneralName *general;
@@ -240,8 +240,8 @@ append_extension_subject_alt_name (GcrRenderer *renderer,
                general = &g_array_index (general_names, GcrGeneralName, i);
                if (general->display == NULL)
                        _gcr_display_view_append_hex (view, renderer, general->description,
-                                                     egg_bytes_get_data (general->raw),
-                                                     egg_bytes_get_size (general->raw));
+                                                     g_bytes_get_data (general->raw, NULL),
+                                                     g_bytes_get_size (general->raw));
                else
                        _gcr_display_view_append_value (view, renderer, general->description,
                                                        general->display, FALSE);
@@ -473,11 +473,11 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
        gsize n_data;
        GcrDisplayView *view;
        GcrCertificate *cert;
-       EggBytes *number;
+       GBytes *number;
        gulong version;
        guint bits, index;
        gchar *display;
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn;
        GDate date;
        GIcon *icon;
@@ -506,10 +506,10 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
        _gcr_display_view_set_icon (view, GCR_RENDERER (self), icon);
        g_object_unref (icon);
 
-       bytes = egg_bytes_new_static (data, n_data);
+       bytes = g_bytes_new_static (data, n_data);
        asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", bytes);
        g_return_if_fail (asn != NULL);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        display = calculate_label (self);
        _gcr_display_view_append_title (view, renderer, display);
@@ -555,9 +555,9 @@ gcr_certificate_renderer_render (GcrRenderer *renderer, GcrViewer *viewer)
        number = egg_asn1x_get_integer_as_raw (egg_asn1x_node (asn, "tbsCertificate", "serialNumber", NULL));
        g_return_if_fail (number != NULL);
        _gcr_display_view_append_hex (view, renderer, _("Serial Number"),
-                                     egg_bytes_get_data (number),
-                                     egg_bytes_get_size (number));
-       egg_bytes_unref (number);
+                                     g_bytes_get_data (number, NULL),
+                                     g_bytes_get_size (number));
+       g_bytes_unref (number);
 
        display = g_malloc0 (128);
        if (egg_asn1x_get_time_as_date (egg_asn1x_node (asn, "tbsCertificate", "validity", "notBefore", NULL), &date)) {
@@ -789,7 +789,7 @@ typedef struct {
 static void
 on_parsed_dn_part (guint index,
                    GQuark oid,
-                   EggBytes *value,
+                   GBytes *value,
                    gpointer user_data)
 {
        GcrRenderer *renderer = ((AppendDnClosure *)user_data)->renderer;
@@ -852,7 +852,7 @@ _gcr_certificate_renderer_append_subject_public_key (GcrRenderer *renderer,
 {
        const gchar *text;
        gchar *display;
-       EggBytes *value;
+       GBytes *value;
        guchar *raw;
        gsize n_raw;
        GQuark oid;
@@ -867,9 +867,9 @@ _gcr_certificate_renderer_append_subject_public_key (GcrRenderer *renderer,
                                                           "algorithm", "parameters", NULL));
        if (value) {
                _gcr_display_view_append_hex (view, renderer, _("Key Parameters"),
-                                             egg_bytes_get_data (value),
-                                             egg_bytes_get_size (value));
-               egg_bytes_unref (value);
+                                             g_bytes_get_data (value, NULL),
+                                             g_bytes_get_size (value));
+               g_bytes_unref (value);
        }
 
        if (key_nbits > 0) {
@@ -879,17 +879,17 @@ _gcr_certificate_renderer_append_subject_public_key (GcrRenderer *renderer,
        }
 
        value = egg_asn1x_get_element_raw (subject_public_key);
-       raw = gcr_fingerprint_from_subject_public_key_info (egg_bytes_get_data (value),
-                                                           egg_bytes_get_size (value),
+       raw = gcr_fingerprint_from_subject_public_key_info (g_bytes_get_data (value, NULL),
+                                                           g_bytes_get_size (value),
                                                            G_CHECKSUM_SHA1, &n_raw);
        _gcr_display_view_append_hex (view, renderer, _("Key SHA1 Fingerprint"), raw, n_raw);
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        g_free (raw);
 
        value = egg_asn1x_get_bits_as_raw (egg_asn1x_node (subject_public_key, "subjectPublicKey", NULL), &bits);
        _gcr_display_view_append_hex (view, renderer, _("Public Key"),
-                                     egg_bytes_get_data (value), bits / 8);
-       egg_bytes_unref (value);
+                                     g_bytes_get_data (value, NULL), bits / 8);
+       g_bytes_unref (value);
 }
 
 void
@@ -898,7 +898,7 @@ _gcr_certificate_renderer_append_signature (GcrRenderer *renderer,
                                             GNode *asn)
 {
        const gchar *text;
-       EggBytes *value;
+       GBytes *value;
        GQuark oid;
        guint bits;
 
@@ -909,15 +909,15 @@ _gcr_certificate_renderer_append_signature (GcrRenderer *renderer,
        value = egg_asn1x_get_element_raw (egg_asn1x_node (asn, "signatureAlgorithm", "parameters", NULL));
        if (value) {
                _gcr_display_view_append_hex (view, renderer, _("Signature Parameters"),
-                                             egg_bytes_get_data (value),
-                                             egg_bytes_get_size (value));
-               egg_bytes_unref (value);
+                                             g_bytes_get_data (value, NULL),
+                                             g_bytes_get_size (value));
+               g_bytes_unref (value);
        }
 
        value = egg_asn1x_get_bits_as_raw (egg_asn1x_node (asn, "signature", NULL), &bits);
        _gcr_display_view_append_hex (view, renderer, _("Signature"),
-                                     egg_bytes_get_data (value), bits / 8);
-       egg_bytes_unref (value);
+                                     g_bytes_get_data (value, NULL), bits / 8);
+       g_bytes_unref (value);
 }
 
 void
@@ -926,7 +926,7 @@ _gcr_certificate_renderer_append_extension (GcrRenderer *renderer,
                                             GNode *node)
 {
        GQuark oid;
-       EggBytes *value;
+       GBytes *value;
        gboolean critical;
        gboolean ret = FALSE;
 
@@ -952,8 +952,8 @@ _gcr_certificate_renderer_append_extension (GcrRenderer *renderer,
        /* Otherwise the default raw display */
        if (ret == FALSE)
                ret = append_extension_hex (renderer, view, oid,
-                                           egg_bytes_get_data (value),
-                                           egg_bytes_get_size (value));
+                                           g_bytes_get_data (value, NULL),
+                                           g_bytes_get_size (value));
 
        /* Critical */
        if (ret == TRUE && egg_asn1x_get_boolean (egg_asn1x_node (node, "critical", NULL), &critical)) {
index 2e1b29d..51e0a4f 100644 (file)
@@ -213,7 +213,7 @@ append_extension_request (GcrRenderer *renderer,
                           GcrDisplayView *view,
                           GNode *attribute)
 {
-       EggBytes *value;
+       GBytes *value;
        GNode *node;
        GNode *asn;
        guint i;
@@ -244,7 +244,7 @@ append_attribute (GcrRenderer *renderer,
                   GNode *attribute)
 {
        GQuark oid;
-       EggBytes *value;
+       GBytes *value;
        const gchar *text;
        GNode *node;
        gboolean ret = FALSE;
@@ -270,9 +270,9 @@ append_attribute (GcrRenderer *renderer,
                                break;
                        value = egg_asn1x_get_element_raw (node);
                        _gcr_display_view_append_hex (view, renderer, _("Value"),
-                                                     egg_bytes_get_data (value),
-                                                     egg_bytes_get_size (value));
-                       egg_bytes_unref (value);
+                                                     g_bytes_get_data (value, NULL),
+                                                     g_bytes_get_size (value));
+                       g_bytes_unref (value);
                }
        }
 }
@@ -486,7 +486,7 @@ _gcr_certificate_request_renderer_set_attributes (GcrCertificateRequestRenderer
        const GckAttribute *value;
        GNode *asn = NULL;
        gulong type = 0;
-       EggBytes *bytes;
+       GBytes *bytes;
 
        g_return_if_fail (GCR_IS_CERTIFICATE_REQUEST_RENDERER (self));
 
@@ -498,7 +498,7 @@ _gcr_certificate_request_renderer_set_attributes (GcrCertificateRequestRenderer
                        return;
                }
 
-               bytes = egg_bytes_new_with_free_func (value->value, value->length,
+               bytes = g_bytes_new_with_free_func (value->value, value->length,
                                                      gck_attributes_unref, gck_attributes_ref (attrs));
 
                asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "pkcs-10-CertificationRequest", bytes);
@@ -515,7 +515,7 @@ _gcr_certificate_request_renderer_set_attributes (GcrCertificateRequestRenderer
                        }
                }
 
-               egg_bytes_unref (bytes);
+               g_bytes_unref (bytes);
 
                if (type == 0)
                        return;
index ce355e1..81a510a 100644 (file)
@@ -300,8 +300,8 @@ gcr_certificate_request_set_cn (GcrCertificateRequest *self,
        egg_dn_add_string_part (dn, GCR_OID_NAME_CN, cn);
 }
 
-static EggBytes *
-hash_sha1_pkcs1 (EggBytes *data)
+static GBytes *
+hash_sha1_pkcs1 (GBytes *data)
 {
        const guchar SHA1_ASN[15] = /* Object ID is 1.3.14.3.2.26 */
                { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03,
@@ -318,15 +318,15 @@ hash_sha1_pkcs1 (EggBytes *data)
        memcpy (hash, SHA1_ASN, sizeof (SHA1_ASN));
 
        checksum = g_checksum_new (G_CHECKSUM_SHA1);
-       g_checksum_update (checksum, egg_bytes_get_data (data), egg_bytes_get_size (data));
+       g_checksum_update (checksum, g_bytes_get_data (data, NULL), g_bytes_get_size (data));
        g_checksum_get_digest (checksum, hash + sizeof (SHA1_ASN), &n_digest);
        g_checksum_free (checksum);
 
-       return egg_bytes_new_take (hash, n_hash);
+       return g_bytes_new_take (hash, n_hash);
 }
 
-static EggBytes *
-hash_sha1 (EggBytes *data)
+static GBytes *
+hash_sha1 (GBytes *data)
 {
        GChecksum *checksum;
        guchar *hash;
@@ -336,20 +336,20 @@ hash_sha1 (EggBytes *data)
        hash = g_malloc (n_hash);
 
        checksum = g_checksum_new (G_CHECKSUM_SHA1);
-       g_checksum_update (checksum, egg_bytes_get_data (data), egg_bytes_get_size (data));
+       g_checksum_update (checksum, g_bytes_get_data (data, NULL), g_bytes_get_size (data));
        g_checksum_get_digest (checksum, hash, &n_hash);
        g_checksum_free (checksum);
 
-       return egg_bytes_new_take (hash, n_hash);
+       return g_bytes_new_take (hash, n_hash);
 }
 
-static EggBytes *
+static GBytes *
 prepare_to_be_signed (GcrCertificateRequest *self,
                       GckMechanism *mechanism)
 {
        GNode *node;
-       EggBytes *data;
-       EggBytes *hash;
+       GBytes *data;
+       GBytes *hash;
 
        g_assert (mechanism != NULL);
 
@@ -366,12 +366,12 @@ prepare_to_be_signed (GcrCertificateRequest *self,
 
        case CKM_RSA_PKCS:
                hash = hash_sha1_pkcs1 (data);
-               egg_bytes_unref (data);
+               g_bytes_unref (data);
                return hash;
 
        case CKM_DSA:
                hash = hash_sha1 (data);
-               egg_bytes_unref (data);
+               g_bytes_unref (data);
                return hash;
 
        default:
@@ -388,7 +388,7 @@ prepare_subject_public_key_and_mechanisms (GcrCertificateRequest *self,
                                            gsize *n_mechanisms,
                                            GError **error)
 {
-       EggBytes *encoded;
+       GBytes *encoded;
        GNode *node;
        GQuark oid;
 
@@ -413,7 +413,7 @@ prepare_subject_public_key_and_mechanisms (GcrCertificateRequest *self,
                *algorithm = GCR_OID_PKIX1_SHA1_WITH_DSA;
 
        } else {
-               egg_bytes_unref (encoded);
+               g_bytes_unref (encoded);
                g_set_error (error, GCR_DATA_ERROR, GCR_ERROR_UNRECOGNIZED,
                             _("Unsupported key type for certificate request"));
                return FALSE;
@@ -423,7 +423,7 @@ prepare_subject_public_key_and_mechanisms (GcrCertificateRequest *self,
        if (!egg_asn1x_set_element_raw (node, encoded))
                g_return_val_if_reached (FALSE);
 
-       egg_bytes_unref (encoded);
+       g_bytes_unref (encoded);
        return TRUE;
 }
 
@@ -434,12 +434,12 @@ encode_take_signature_into_request (GcrCertificateRequest *self,
                                     guchar *result,
                                     gsize n_result)
 {
-       EggBytes *data;
+       GBytes *data;
        GNode *params;
        GNode *node;
 
        node = egg_asn1x_node (self->asn, "signature", NULL);
-       egg_asn1x_take_bits_as_raw (node, egg_bytes_new_take (result, n_result), n_result * 8);
+       egg_asn1x_take_bits_as_raw (node, g_bytes_new_take (result, n_result), n_result * 8);
 
        node = egg_asn1x_node (self->asn, "signatureAlgorithm", "algorithm", NULL);
        egg_asn1x_set_oid_as_quark (node, algorithm);
@@ -448,7 +448,7 @@ encode_take_signature_into_request (GcrCertificateRequest *self,
        params = egg_asn1x_node (subject_public_key, "algorithm", "parameters", NULL);
        data = egg_asn1x_encode (params, NULL);
        egg_asn1x_set_element_raw (node, data);
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
 }
 
 /**
@@ -474,7 +474,7 @@ gcr_certificate_request_complete (GcrCertificateRequest *self,
        gsize n_mechanisms;
        GckMechanism mechanism = { 0, };
        GQuark algorithm = 0;
-       EggBytes *tbs;
+       GBytes *tbs;
        GckSession *session;
        guchar *signature;
        gsize n_signature;
@@ -512,11 +512,11 @@ gcr_certificate_request_complete (GcrCertificateRequest *self,
        tbs = prepare_to_be_signed (self, &mechanism);
        session = gck_object_get_session (self->private_key);
        signature = gck_session_sign_full (session, self->private_key, &mechanism,
-                                          egg_bytes_get_data (tbs),
-                                          egg_bytes_get_size (tbs),
+                                          g_bytes_get_data (tbs, NULL),
+                                          g_bytes_get_size (tbs),
                                           &n_signature, cancellable, error);
        g_object_unref (session);
-       egg_bytes_unref (tbs);
+       g_bytes_unref (tbs);
 
        if (!signature) {
                egg_asn1x_destroy (subject_public_key);
@@ -536,7 +536,7 @@ typedef struct {
        GNode *subject_public_key;
        GckMechanism mechanism;
        GckSession *session;
-       EggBytes *tbs;
+       GBytes *tbs;
 } CompleteClosure;
 
 static void
@@ -548,7 +548,7 @@ complete_closure_free (gpointer data)
        g_clear_object (&closure->cancellable);
        g_clear_object (&closure->session);
        if (closure->tbs)
-               egg_bytes_unref (closure->tbs);
+               g_bytes_unref (closure->tbs);
        g_free (closure);
 }
 
@@ -598,8 +598,8 @@ on_mechanism_check (GObject *source,
                gck_session_sign_async (closure->session,
                                        closure->request->private_key,
                                        &closure->mechanism,
-                                       egg_bytes_get_data (closure->tbs),
-                                       egg_bytes_get_size (closure->tbs),
+                                       g_bytes_get_data (closure->tbs, NULL),
+                                       g_bytes_get_size (closure->tbs),
                                        closure->cancellable,
                                        on_certificate_request_signed,
                                        g_object_ref (res));
@@ -730,7 +730,7 @@ gcr_certificate_request_encode (GcrCertificateRequest *self,
                                 gboolean textual,
                                 gsize *length)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        gpointer encoded;
        gpointer data;
        gsize size;
@@ -745,8 +745,8 @@ gcr_certificate_request_encode (GcrCertificateRequest *self,
                return NULL;
        }
 
-       size = egg_bytes_get_size (bytes);
-       encoded = g_byte_array_free (egg_bytes_unref_to_array (bytes), FALSE);
+       size = g_bytes_get_size (bytes);
+       encoded = g_byte_array_free (g_bytes_unref_to_array (bytes), FALSE);
 
        if (textual) {
                data = egg_armor_write (encoded, size,
index 354472b..34006ac 100644 (file)
@@ -106,8 +106,8 @@ typedef struct _GcrCertificateInfo {
 
 /* Forward declarations */
 
-static EggBytes * _gcr_certificate_get_subject_const (GcrCertificate *self);
-static EggBytes * _gcr_certificate_get_issuer_const (GcrCertificate *self);
+static GBytes * _gcr_certificate_get_subject_const (GcrCertificate *self);
+static GBytes * _gcr_certificate_get_issuer_const (GcrCertificate *self);
 
 enum {
        PROP_FIRST = 0x0007000,
@@ -141,7 +141,7 @@ static GcrCertificateInfo*
 certificate_info_load (GcrCertificate *cert)
 {
        GcrCertificateInfo *info;
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *asn1;
        gconstpointer der;
        gsize n_der;
@@ -158,12 +158,12 @@ certificate_info_load (GcrCertificate *cert)
        }
 
        /* TODO: Once GBytes is public, add to GcrCertificate interface */
-       bytes = egg_bytes_new_static (der, n_der);
+       bytes = g_bytes_new_static (der, n_der);
 
        /* Cache is invalid or non existent */
        asn1 = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", bytes);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        if (asn1 == NULL) {
                g_warning ("a derived class provided an invalid or unparseable X.509 DER certificate data.");
@@ -450,7 +450,7 @@ gcr_certificate_get_issuer_part (GcrCertificate *self, const char *part)
        return egg_dn_read_part (egg_asn1x_node (info->asn1, "tbsCertificate", "issuer", "rdnSequence", NULL), part);
 }
 
-static EggBytes *
+static GBytes *
 _gcr_certificate_get_issuer_const (GcrCertificate *self)
 {
        GcrCertificateInfo *info;
@@ -479,7 +479,7 @@ guchar *
 gcr_certificate_get_issuer_raw (GcrCertificate *self,
                                 gsize *n_data)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        guchar *result;
 
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
@@ -489,9 +489,9 @@ gcr_certificate_get_issuer_raw (GcrCertificate *self,
        if (bytes == NULL)
                return NULL;
 
-       *n_data = egg_bytes_get_size (bytes);
-       result = g_memdup (egg_bytes_get_data (bytes), *n_data);
-       egg_bytes_unref (bytes);
+       *n_data = g_bytes_get_size (bytes);
+       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
+       g_bytes_unref (bytes);
 
        return result;
 }
@@ -511,8 +511,8 @@ gcr_certificate_get_issuer_raw (GcrCertificate *self,
 gboolean
 gcr_certificate_is_issuer (GcrCertificate *self, GcrCertificate *issuer)
 {
-       EggBytes *subject_dn;
-       EggBytes *issuer_dn;
+       GBytes *subject_dn;
+       GBytes *issuer_dn;
        gboolean ret;
 
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), FALSE);
@@ -524,10 +524,10 @@ gcr_certificate_is_issuer (GcrCertificate *self, GcrCertificate *issuer)
        issuer_dn = _gcr_certificate_get_issuer_const (self);
        g_return_val_if_fail (issuer_dn, FALSE);
 
-       ret = egg_bytes_equal (subject_dn, issuer_dn);
+       ret = g_bytes_equal (subject_dn, issuer_dn);
 
-       egg_bytes_unref (subject_dn);
-       egg_bytes_unref (issuer_dn);
+       g_bytes_unref (subject_dn);
+       g_bytes_unref (issuer_dn);
 
        return ret;
 }
@@ -655,7 +655,7 @@ gcr_certificate_get_subject_dn (GcrCertificate *self)
        return egg_dn_read (egg_asn1x_node (info->asn1, "tbsCertificate", "subject", "rdnSequence", NULL));
 }
 
-static EggBytes *
+static GBytes *
 _gcr_certificate_get_subject_const (GcrCertificate *self)
 {
        GcrCertificateInfo *info;
@@ -683,7 +683,7 @@ _gcr_certificate_get_subject_const (GcrCertificate *self)
 guchar *
 gcr_certificate_get_subject_raw (GcrCertificate *self, gsize *n_data)
 {
-       EggBytes *bytes;
+       GBytes *bytes;
        guchar *result;
 
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
@@ -693,10 +693,10 @@ gcr_certificate_get_subject_raw (GcrCertificate *self, gsize *n_data)
        if (bytes == NULL)
                return NULL;
 
-       *n_data = egg_bytes_get_size (bytes);
-       result = g_memdup (egg_bytes_get_data (bytes), *n_data);
+       *n_data = g_bytes_get_size (bytes);
+       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_data);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        return result;
 }
@@ -886,7 +886,7 @@ guchar *
 gcr_certificate_get_serial_number (GcrCertificate *self, gsize *n_length)
 {
        GcrCertificateInfo *info;
-       EggBytes *bytes;
+       GBytes *bytes;
        guchar *result;
 
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL);
@@ -898,10 +898,10 @@ gcr_certificate_get_serial_number (GcrCertificate *self, gsize *n_length)
        bytes = egg_asn1x_get_integer_as_raw (egg_asn1x_node (info->asn1, "tbsCertificate", "serialNumber", NULL));
        g_return_val_if_fail (bytes != NULL, NULL);
 
-       *n_length = egg_bytes_get_size (bytes);
-       result = g_memdup (egg_bytes_get_data (bytes), *n_length);
+       *n_length = g_bytes_get_size (bytes);
+       result = g_memdup (g_bytes_get_data (bytes, NULL), *n_length);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        return result;
 }
 
@@ -968,7 +968,7 @@ gcr_certificate_get_basic_constraints (GcrCertificate *self,
                                        gint *path_len)
 {
        GcrCertificateInfo *info;
-       EggBytes *value;
+       GBytes *value;
 
        g_return_val_if_fail (GCR_IS_CERTIFICATE (self), FALSE);
 
@@ -982,7 +982,7 @@ gcr_certificate_get_basic_constraints (GcrCertificate *self,
        if (!_gcr_certificate_extension_basic_constraints (value, is_ca, path_len))
                g_return_val_if_reached (FALSE);
 
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        return TRUE;
 }
 
index 60ca8ee..79343ff 100644 (file)
@@ -105,7 +105,7 @@ gcr_fingerprint_from_attributes (GckAttributes *attrs,
                                  gsize *n_fingerprint)
 {
        gpointer fingerprint = NULL;
-       EggBytes *info;
+       GBytes *info;
        GNode *asn;
 
        g_return_val_if_fail (attrs != NULL, NULL);
@@ -115,11 +115,11 @@ gcr_fingerprint_from_attributes (GckAttributes *attrs,
 
        if (asn != NULL) {
                info = egg_asn1x_encode (asn, NULL);
-               fingerprint = gcr_fingerprint_from_subject_public_key_info (egg_bytes_get_data (info),
-                                                                           egg_bytes_get_size (info),
+               fingerprint = gcr_fingerprint_from_subject_public_key_info (g_bytes_get_data (info, NULL),
+                                                                           g_bytes_get_size (info),
                                                                            checksum_type,
                                                                            n_fingerprint);
-               egg_bytes_unref (info);
+               g_bytes_unref (info);
        }
 
        egg_asn1x_destroy (asn);
index d5fd82a..722c7f5 100644 (file)
@@ -30,7 +30,6 @@
 #include "gck/gck.h"
 
 #include "egg/egg-asn1x.h"
-#include "egg/egg-bytes.h"
 
 #include <gdk/gdk.h>
 #include <glib/gi18n-lib.h>
@@ -62,7 +61,7 @@ struct _GcrKeyRendererPrivate {
        GckObject *object;
        GIcon *icon;
        gulong notify_sig;
-       EggBytes *spk;
+       GBytes *spk;
 };
 
 static void gcr_key_renderer_renderer_iface (GcrRendererIface *iface);
@@ -109,8 +108,8 @@ calculate_fingerprint (GcrKeyRenderer *self,
                        gsize *n_fingerprint)
 {
        if (self->pv->spk)
-               return gcr_fingerprint_from_subject_public_key_info (egg_bytes_get_data (self->pv->spk),
-                                                                    egg_bytes_get_size (self->pv->spk),
+               return gcr_fingerprint_from_subject_public_key_info (g_bytes_get_data (self->pv->spk, NULL),
+                                                                    g_bytes_get_size (self->pv->spk),
                                                                     algorithm, n_fingerprint);
 
        return gcr_fingerprint_from_attributes (attrs, algorithm, n_fingerprint);
@@ -179,7 +178,7 @@ on_subject_public_key (GObject *source,
 
        } else {
                if (self->pv->spk)
-                       egg_bytes_unref (self->pv->spk);
+                       g_bytes_unref (self->pv->spk);
                self->pv->spk = NULL;
 
                self->pv->spk = egg_asn1x_encode (node, NULL);
@@ -198,7 +197,7 @@ static void
 update_subject_public_key (GcrKeyRenderer *self)
 {
        if (self->pv->spk)
-               egg_bytes_unref (self->pv->spk);
+               g_bytes_unref (self->pv->spk);
        self->pv->spk = NULL;
 
        if (!self->pv->object)
@@ -232,7 +231,7 @@ gcr_key_renderer_dispose (GObject *obj)
        GcrKeyRenderer *self = GCR_KEY_RENDERER (obj);
 
        if (self->pv->spk)
-               egg_bytes_unref (self->pv->spk);
+               g_bytes_unref (self->pv->spk);
        self->pv->spk = NULL;
 
        if (self->pv->object && self->pv->notify_sig) {
index b80f560..8cd4d88 100644 (file)
@@ -1197,7 +1197,7 @@ typedef struct {
        GcrOpenpgpCallback callback;
        gpointer user_data;
        guint count;
-       EggBytes *backing;
+       GBytes *backing;
        GPtrArray *records;
 } openpgp_parse_closure;
 
@@ -1206,7 +1206,7 @@ openpgp_parse_free (gpointer data)
 {
        openpgp_parse_closure *closure = data;
        g_ptr_array_unref (closure->records);
-       egg_bytes_unref (closure->backing);
+       g_bytes_unref (closure->backing);
        g_free (closure);
 }
 
@@ -1215,7 +1215,7 @@ maybe_emit_openpgp_block (openpgp_parse_closure *closure,
                           const guchar *block,
                           const guchar *end)
 {
-       EggBytes *outer;
+       GBytes *outer;
        gsize length;
        GPtrArray *records;
 
@@ -1231,17 +1231,17 @@ maybe_emit_openpgp_block (openpgp_parse_closure *closure,
        records = closure->records;
        closure->records = g_ptr_array_new_with_free_func (_gcr_record_free);
 
-       outer = egg_bytes_new_with_free_func (block, length, egg_bytes_unref,
-                                             egg_bytes_ref (closure->backing));
+       outer = g_bytes_new_with_free_func (block, length, (GDestroyNotify)g_bytes_unref,
+                                             g_bytes_ref (closure->backing));
        if (closure->callback)
                (closure->callback) (records, outer, closure->user_data);
-       egg_bytes_unref (outer);
+       g_bytes_unref (outer);
 
        g_ptr_array_unref (records);
 }
 
 guint
-_gcr_openpgp_parse (EggBytes *data,
+_gcr_openpgp_parse (GBytes *data,
                     GcrOpenpgpParseFlags flags,
                     GcrOpenpgpCallback callback,
                     gpointer user_data)
@@ -1262,14 +1262,14 @@ _gcr_openpgp_parse (EggBytes *data,
        /* For libgcrypt */
        _gcr_initialize_library ();
 
-       at = egg_bytes_get_data (data);
-       end = at + egg_bytes_get_size (data);
+       at = g_bytes_get_data (data, NULL);
+       end = at + g_bytes_get_size (data);
        block = NULL;
 
        closure = g_new0 (openpgp_parse_closure, 1);
        closure->callback = callback;
        closure->user_data = user_data;
-       closure->backing = egg_bytes_ref (data);
+       closure->backing = g_bytes_ref (data);
        closure->records = g_ptr_array_new_with_free_func (_gcr_record_free);
 
        while (at != NULL && at != end) {
index aed7d8d..70a1855 100644 (file)
@@ -30,8 +30,6 @@
 
 #include <glib.h>
 
-#include <egg/egg-bytes.h>
-
 #include <gck/gck.h>
 
 typedef enum {
@@ -53,10 +51,10 @@ typedef enum {
 G_BEGIN_DECLS
 
 typedef void             (*GcrOpenpgpCallback)             (GPtrArray *records,
-                                                            EggBytes *outer,
+                                                            GBytes *outer,
                                                             gpointer user_data);
 
-guint                    _gcr_openpgp_parse                (EggBytes *data,
+guint                    _gcr_openpgp_parse                (GBytes *data,
                                                             GcrOpenpgpParseFlags flags,
                                                             GcrOpenpgpCallback callback,
                                                             gpointer user_data);
index c7471f7..8da18fc 100644 (file)
@@ -155,7 +155,7 @@ atoin (const char *p, gint digits)
 static GcrDataError
 parse_v1_public_line (const gchar *line,
                       gsize length,
-                      EggBytes *backing,
+                      GBytes *backing,
                       GcrOpensshPubCallback callback,
                       gpointer user_data)
 {
@@ -164,7 +164,7 @@ parse_v1_public_line (const gchar *line,
        GckBuilder builder = GCK_BUILDER_INIT;
        GckAttributes *attrs;
        gchar *label, *options;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint bits;
 
        g_assert (line);
@@ -229,11 +229,11 @@ parse_v1_public_line (const gchar *line,
        attrs = gck_attributes_ref_sink (gck_builder_end (&builder));
 
        if (callback != NULL) {
-               bytes = egg_bytes_new_with_free_func (outer, n_outer,
-                                                     egg_bytes_unref,
-                                                     egg_bytes_ref (backing));
+               bytes = g_bytes_new_with_free_func (outer, n_outer,
+                                                   (GDestroyNotify)g_bytes_unref,
+                                                   g_bytes_ref (backing));
                (callback) (attrs, label, options, bytes, user_data);
-               egg_bytes_unref (bytes);
+               g_bytes_unref (bytes);
        }
 
        gck_attributes_unref (attrs);
@@ -370,7 +370,7 @@ decode_v2_public_key (gulong algo,
 static GcrDataError
 parse_v2_public_line (const gchar *line,
                       gsize length,
-                      EggBytes *backing,
+                      GBytes *backing,
                       GcrOpensshPubCallback callback,
                       gpointer user_data)
 {
@@ -382,7 +382,7 @@ parse_v2_public_line (const gchar *line,
        gchar *label = NULL;
        const gchar *outer = line;
        gsize n_outer = length;
-       EggBytes *bytes;
+       GBytes *bytes;
        gulong algo;
 
        g_assert (line);
@@ -445,11 +445,11 @@ parse_v2_public_line (const gchar *line,
        attrs = gck_attributes_ref_sink (gck_builder_end (&builder));
 
        if (callback != NULL) {
-               bytes = egg_bytes_new_with_free_func (outer, n_outer,
-                                                     egg_bytes_unref,
-                                                     egg_bytes_ref (backing));
+               bytes = g_bytes_new_with_free_func (outer, n_outer,
+                                                   (GDestroyNotify)g_bytes_unref,
+                                                   g_bytes_ref (backing));
                (callback) (attrs, label, options, bytes, user_data);
-               egg_bytes_unref (bytes);
+               g_bytes_unref (bytes);
        }
 
        gck_attributes_unref (attrs);
@@ -459,7 +459,7 @@ parse_v2_public_line (const gchar *line,
 }
 
 guint
-_gcr_openssh_pub_parse (EggBytes *data,
+_gcr_openssh_pub_parse (GBytes *data,
                         GcrOpensshPubCallback callback,
                         gpointer user_data)
 {
@@ -472,8 +472,8 @@ _gcr_openssh_pub_parse (EggBytes *data,
 
        g_return_val_if_fail (data != NULL, FALSE);
 
-       line = egg_bytes_get_data (data);
-       length = egg_bytes_get_size (data);
+       line = g_bytes_get_data (data, NULL);
+       length = g_bytes_get_size (data);
        last = FALSE;
        num_parsed = 0;
 
index 4f4fe9e..52e8e91 100644 (file)
 
 #include <gck/gck.h>
 
-#include <egg/egg-bytes.h>
-
 G_BEGIN_DECLS
 
 typedef void             (*GcrOpensshPubCallback)          (GckAttributes *attrs,
                                                             const gchar *label,
                                                             const gchar *options,
-                                                            EggBytes *outer,
+                                                            GBytes *outer,
                                                             gpointer user_data);
 
-guint                    _gcr_openssh_pub_parse            (EggBytes *data,
+guint                    _gcr_openssh_pub_parse            (GBytes *data,
                                                             GcrOpensshPubCallback callback,
                                                             gpointer user_data);
 
index c985c12..0dc32b7 100644 (file)
@@ -124,7 +124,7 @@ struct _GcrParsed {
        GckAttributes *attrs;
        const gchar *description;
        gchar *label;
-       EggBytes *data;
+       GBytes *data;
        gboolean sensitive;
        GcrDataFormat format;
        struct _GcrParsed *next;
@@ -148,7 +148,7 @@ typedef struct {
 
 typedef struct _ParserFormat {
        gint format_id;
-       gint (*function) (GcrParser *self, EggBytes *data);
+       gint (*function) (GcrParser *self, GBytes *data);
 } ParserFormat;
 
 /* Forward declarations */
@@ -228,12 +228,12 @@ parsed_attribute (GcrParsed *parsed,
 static void
 parsed_attribute_bytes (GcrParsed *parsed,
                         CK_ATTRIBUTE_TYPE type,
-                        EggBytes *data)
+                        GBytes *data)
 {
        g_assert (parsed != NULL);
        gck_builder_add_data (&parsed->builder, type,
-                             egg_bytes_get_data (data),
-                             egg_bytes_get_size (data));
+                             g_bytes_get_data (data, NULL),
+                             g_bytes_get_size (data));
 }
 
 static gboolean
@@ -242,7 +242,7 @@ parsed_asn1_number (GcrParsed *parsed,
                     const gchar *part,
                     CK_ATTRIBUTE_TYPE type)
 {
-       EggBytes *value;
+       GBytes *value;
 
        g_assert (asn);
        g_assert (parsed);
@@ -252,7 +252,7 @@ parsed_asn1_number (GcrParsed *parsed,
                return FALSE;
 
        parsed_attribute_bytes (parsed, type, value);
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        return TRUE;
 }
 
@@ -262,7 +262,7 @@ parsed_asn1_element (GcrParsed *parsed,
                      const gchar *part,
                      CK_ATTRIBUTE_TYPE type)
 {
-       EggBytes *value;
+       GBytes *value;
 
        g_assert (asn);
        g_assert (parsed);
@@ -272,7 +272,7 @@ parsed_asn1_element (GcrParsed *parsed,
                return FALSE;
 
        parsed_attribute_bytes (parsed, type, value);
-       egg_bytes_unref (value);
+       g_bytes_unref (value);
        return TRUE;
 }
 
@@ -298,7 +298,7 @@ parsed_boolean_attribute (GcrParsed *parsed,
 static void
 parsing_block (GcrParsed *parsed,
                gint format,
-               EggBytes *data)
+               GBytes *data)
 {
        g_assert (parsed != NULL);
        g_assert (data != NULL);
@@ -306,7 +306,7 @@ parsing_block (GcrParsed *parsed,
        g_assert (parsed->data == NULL);
 
        parsed->format = format;
-       parsed->data = egg_bytes_ref (data);
+       parsed->data = g_bytes_ref (data);
 }
 
 static void
@@ -397,7 +397,7 @@ pop_parsed (GcrParser *self,
        gck_builder_clear (&parsed->builder);
        gck_attributes_unref (parsed->attrs);
        if (parsed->data)
-               egg_bytes_unref (parsed->data);
+               g_bytes_unref (parsed->data);
        g_free (parsed->label);
        g_free (parsed);
 }
@@ -472,7 +472,7 @@ parsed_fire (GcrParser *self,
 
 static gint
 parse_der_private_key_rsa (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        gint res = GCR_ERROR_UNRECOGNIZED;
        GNode *asn = NULL;
@@ -527,7 +527,7 @@ done:
 
 static gint
 parse_der_private_key_dsa (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        gint ret = GCR_ERROR_UNRECOGNIZED;
        GNode *asn = NULL;
@@ -565,8 +565,8 @@ done:
 
 static gint
 parse_der_private_key_dsa_parts (GcrParser *self,
-                                 EggBytes *keydata,
-                                 EggBytes *params)
+                                 GBytes *keydata,
+                                 GBytes *params)
 {
        gint ret = GCR_ERROR_UNRECOGNIZED;
        GNode *asn_params = NULL;
@@ -610,7 +610,7 @@ done:
 
 static gint
 parse_der_private_key (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        gint res;
 
@@ -628,8 +628,8 @@ parse_der_private_key (GcrParser *self,
 static gint
 handle_subject_public_key_rsa (GcrParser *self,
                                GcrParsed *parsed,
-                               EggBytes *key,
-                               EggBytes *params)
+                               GBytes *key,
+                               GBytes *params)
 {
        gint res = GCR_ERROR_FAILURE;
        GNode *asn = NULL;
@@ -655,8 +655,8 @@ done:
 static gint
 handle_subject_public_key_dsa (GcrParser *self,
                                GcrParsed *parsed,
-                               EggBytes *key,
-                               EggBytes *params)
+                               GBytes *key,
+                               GBytes *params)
 {
        gint res = GCR_ERROR_FAILURE;
        GNode *key_asn = NULL;
@@ -687,11 +687,11 @@ done:
 
 static gint
 parse_der_subject_public_key (GcrParser *self,
-                              EggBytes *data)
+                              GBytes *data)
 {
        GcrParsed *parsed;
-       EggBytes *params;
-       EggBytes *key;
+       GBytes *params;
+       GBytes *key;
        GNode *asn = NULL;
        GNode *node;
        GQuark oid;
@@ -723,8 +723,8 @@ parse_der_subject_public_key (GcrParser *self,
        else
                ret = GCR_ERROR_UNRECOGNIZED;
 
-       egg_bytes_unref (key);
-       egg_bytes_unref (params);
+       g_bytes_unref (key);
+       g_bytes_unref (params);
 
        if (ret == SUCCESS)
                parsed_fire (self, parsed);
@@ -741,13 +741,13 @@ parse_der_subject_public_key (GcrParser *self,
 
 static gint
 parse_der_pkcs8_plain (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        gint ret;
        CK_KEY_TYPE key_type;
        GQuark key_algo;
-       EggBytes *keydata = NULL;
-       EggBytes *params = NULL;
+       GBytes *keydata = NULL;
+       GBytes *params = NULL;
        GNode *asn = NULL;
        GcrParsed *parsed;
 
@@ -808,9 +808,9 @@ done:
        }
 
        if (keydata)
-               egg_bytes_unref (keydata);
+               g_bytes_unref (keydata);
        if (params)
-               egg_bytes_unref (params);
+               g_bytes_unref (params);
        egg_asn1x_destroy (asn);
        pop_parsed (self, parsed);
        return ret;
@@ -818,7 +818,7 @@ done:
 
 static gint
 parse_der_pkcs8_encrypted (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        PasswordState pstate = PASSWORD_STATE_INIT;
        GNode *asn = NULL;
@@ -827,8 +827,8 @@ parse_der_pkcs8_encrypted (GcrParser *self,
        gint ret, r;
        GQuark scheme;
        guchar *crypted = NULL;
-       EggBytes *params = NULL;
-       EggBytes *cbytes;
+       GBytes *params = NULL;
+       GBytes *cbytes;
        gsize n_crypted;
        const gchar *password;
        GcrParsed *parsed;
@@ -884,13 +884,13 @@ parse_der_pkcs8_encrypted (GcrParser *self,
                if (l > 0)
                        n_crypted = l;
 
-               cbytes = egg_bytes_new_with_free_func (crypted, n_crypted,
+               cbytes = g_bytes_new_with_free_func (crypted, n_crypted,
                                                       egg_secure_free, crypted);
                crypted = NULL;
 
                /* Try to parse the resulting key */
                r = parse_der_pkcs8_plain (self, cbytes);
-               egg_bytes_unref (cbytes);
+               g_bytes_unref (cbytes);
 
                if (r != GCR_ERROR_UNRECOGNIZED) {
                        ret = r;
@@ -902,7 +902,7 @@ parse_der_pkcs8_encrypted (GcrParser *self,
 
 done:
        if (params)
-               egg_bytes_unref (params);
+               g_bytes_unref (params);
        if (cih)
                gcry_cipher_close (cih);
        egg_asn1x_destroy (asn);
@@ -914,7 +914,7 @@ done:
 
 static gint
 parse_der_pkcs8 (GcrParser *self,
-                 EggBytes *data)
+                 GBytes *data)
 {
        gint ret;
 
@@ -931,7 +931,7 @@ parse_der_pkcs8 (GcrParser *self,
 
 static gint
 parse_der_certificate (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        gchar *name = NULL;
        GcrParsed *parsed;
@@ -977,12 +977,12 @@ parse_der_certificate (GcrParser *self,
 
 static gint
 handle_pkcs7_signed_data (GcrParser *self,
-                          EggBytes *data)
+                          GBytes *data)
 {
        GNode *asn = NULL;
        GNode *node;
        gint ret;
-       EggBytes *certificate;
+       GBytes *certificate;
        int i;
 
        ret = GCR_ERROR_UNRECOGNIZED;
@@ -1001,7 +1001,7 @@ handle_pkcs7_signed_data (GcrParser *self,
 
                certificate = egg_asn1x_get_element_raw (node);
                ret = parse_der_certificate (self, certificate);
-               egg_bytes_unref (certificate);
+               g_bytes_unref (certificate);
 
                if (ret != SUCCESS)
                        goto done;
@@ -1018,12 +1018,12 @@ done:
 
 static gint
 parse_der_pkcs7 (GcrParser *self,
-                 EggBytes *data)
+                 GBytes *data)
 {
        GNode *asn = NULL;
        GNode *node;
        gint ret;
-       EggBytes *content = NULL;
+       GBytes *content = NULL;
        GQuark oid;
        GcrParsed *parsed;
 
@@ -1058,7 +1058,7 @@ parse_der_pkcs7 (GcrParser *self,
 
 done:
        if (content)
-               egg_bytes_unref (content);
+               g_bytes_unref (content);
        egg_asn1x_destroy (asn);
        pop_parsed (self, parsed);
        return ret;
@@ -1071,7 +1071,7 @@ done:
 static GNode *
 decode_pkcs12_asn1_accepting_invalid_crap (const EggAsn1xDef *defs,
                                            const gchar *identifier,
-                                           EggBytes *data)
+                                           GBytes *data)
 {
        GNode *asn;
 
@@ -1101,14 +1101,14 @@ decode_pkcs12_asn1_accepting_invalid_crap (const EggAsn1xDef *defs,
 
 static gint
 handle_pkcs12_cert_bag (GcrParser *self,
-                        EggBytes *data)
+                        GBytes *data)
 {
        GNode *asn = NULL;
        GNode *asn_content = NULL;
        guchar *certificate = NULL;
-       EggBytes *element = NULL;
+       GBytes *element = NULL;
        gsize n_certificate;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint ret;
 
        ret = GCR_ERROR_UNRECOGNIZED;
@@ -1132,13 +1132,13 @@ handle_pkcs12_cert_bag (GcrParser *self,
        if (!certificate)
                goto done;
 
-       bytes = egg_bytes_new_take (certificate, n_certificate);
+       bytes = g_bytes_new_take (certificate, n_certificate);
        ret = parse_der_certificate (self, bytes);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
 done:
        if (element)
-               egg_bytes_unref (element);
+               g_bytes_unref (element);
        egg_asn1x_destroy (asn_content);
        egg_asn1x_destroy (asn);
        return ret;
@@ -1150,7 +1150,7 @@ parse_pkcs12_bag_friendly_name (GNode *asn)
        guint count, i;
        GQuark oid;
        GNode *node;
-       EggBytes *element;
+       GBytes *element;
        GNode *asn_str;
        gchar *result;
 
@@ -1166,7 +1166,7 @@ parse_pkcs12_bag_friendly_name (GNode *asn)
                                element = egg_asn1x_get_element_raw (node);
                                asn_str = egg_asn1x_create_and_decode (pkix_asn1_tab, "BMPString",
                                                                       element);
-                               egg_bytes_unref (element);
+                               g_bytes_unref (element);
                                if (asn_str) {
                                        result = egg_asn1x_get_bmpstring_as_utf8 (asn_str);
                                        egg_asn1x_destroy (asn_str);
@@ -1181,13 +1181,13 @@ parse_pkcs12_bag_friendly_name (GNode *asn)
 
 static gint
 handle_pkcs12_bag (GcrParser *self,
-                   EggBytes *data)
+                   GBytes *data)
 {
        GNode *asn = NULL;
        gint ret, r;
        guint count = 0;
        GQuark oid;
-       EggBytes *element = NULL;
+       GBytes *element = NULL;
        gchar *friendly;
        guint i;
        GcrParsed *parsed;
@@ -1245,7 +1245,7 @@ handle_pkcs12_bag (GcrParser *self,
                }
 
                if (element != NULL)
-                       egg_bytes_unref (element);
+                       g_bytes_unref (element);
 
                pop_parsed (self, parsed);
 
@@ -1266,17 +1266,17 @@ done:
 
 static gint
 handle_pkcs12_encrypted_bag (GcrParser *self,
-                             EggBytes *data)
+                             GBytes *data)
 {
        PasswordState pstate = PASSWORD_STATE_INIT;
        GNode *asn = NULL;
        gcry_cipher_hd_t cih = NULL;
        gcry_error_t gcry;
        guchar *crypted = NULL;
-       EggBytes *params = NULL;
+       GBytes *params = NULL;
        gsize n_crypted;
        const gchar *password;
-       EggBytes *cbytes;
+       GBytes *cbytes;
        GQuark scheme;
        gint ret, r;
        gint l;
@@ -1336,12 +1336,12 @@ handle_pkcs12_encrypted_bag (GcrParser *self,
                if (l > 0)
                        n_crypted = l;
 
-               cbytes = egg_bytes_new_with_free_func (crypted, n_crypted, egg_secure_free, crypted);
+               cbytes = g_bytes_new_with_free_func (crypted, n_crypted, egg_secure_free, crypted);
                crypted = NULL;
 
                /* Try to parse the resulting key */
                r = handle_pkcs12_bag (self, cbytes);
-               egg_bytes_unref (cbytes);
+               g_bytes_unref (cbytes);
 
                if (r != GCR_ERROR_UNRECOGNIZED) {
                        ret = r;
@@ -1353,7 +1353,7 @@ handle_pkcs12_encrypted_bag (GcrParser *self,
 
 done:
        if (params)
-               egg_bytes_unref (params);
+               g_bytes_unref (params);
        if (cih)
                gcry_cipher_close (cih);
        egg_asn1x_destroy (asn);
@@ -1363,13 +1363,13 @@ done:
 
 static gint
 handle_pkcs12_safe (GcrParser *self,
-                    EggBytes *data)
+                    GBytes *data)
 {
        GNode *asn = NULL;
        GNode *asn_content = NULL;
        gint ret, r;
-       EggBytes *bag = NULL;
-       EggBytes *content;
+       GBytes *bag = NULL;
+       GBytes *content;
        GQuark oid;
        guint i;
        GNode *node;
@@ -1418,7 +1418,7 @@ handle_pkcs12_safe (GcrParser *self,
                                goto done;
 
                        r = handle_pkcs12_bag (self, content);
-                       egg_bytes_unref (content);
+                       g_bytes_unref (content);
 
                /* Encrypted data first needs decryption */
                } else if (oid == GCR_OID_PKCS7_ENCRYPTED_DATA) {
@@ -1430,7 +1430,7 @@ handle_pkcs12_safe (GcrParser *self,
                        r = GCR_ERROR_UNRECOGNIZED;
                }
 
-               egg_bytes_unref (bag);
+               g_bytes_unref (bag);
                bag = NULL;
 
                if (r == GCR_ERROR_FAILURE ||
@@ -1445,7 +1445,7 @@ handle_pkcs12_safe (GcrParser *self,
 
 done:
        if (bag != NULL)
-               egg_bytes_unref (bag);
+               g_bytes_unref (bag);
        egg_asn1x_destroy (asn);
        egg_asn1x_destroy (asn_content);
        return ret;
@@ -1454,7 +1454,7 @@ done:
 static gint
 verify_pkcs12_safe (GcrParser *self,
                     GNode *asn,
-                    EggBytes *content)
+                    GBytes *content)
 {
        PasswordState pstate = PASSWORD_STATE_INIT;
        const gchar *password;
@@ -1465,7 +1465,7 @@ verify_pkcs12_safe (GcrParser *self,
        gsize n_digest;
        GQuark algorithm;
        GNode *mac_data;
-       EggBytes *params = NULL;
+       GBytes *params = NULL;
        int ret, r;
 
        ret = GCR_ERROR_FAILURE;
@@ -1513,7 +1513,7 @@ verify_pkcs12_safe (GcrParser *self,
                        r = GCR_ERROR_FAILURE;
 
                } else {
-                       gcry_md_write (mdh, egg_bytes_get_data (content), egg_bytes_get_size (content));
+                       gcry_md_write (mdh, g_bytes_get_data (content, NULL), g_bytes_get_size (content));
                        mac_digest = gcry_md_read (mdh, 0);
                        g_return_val_if_fail (mac_digest, GCR_ERROR_FAILURE);
                        r = memcmp (mac_digest, digest, n_digest) == 0 ? SUCCESS : GCR_ERROR_LOCKED;
@@ -1530,7 +1530,7 @@ verify_pkcs12_safe (GcrParser *self,
 
 done:
        if (params)
-               egg_bytes_unref (params);
+               g_bytes_unref (params);
        if (mdh)
                gcry_md_close (mdh);
        g_free (digest);
@@ -1540,13 +1540,13 @@ done:
 
 static gint
 parse_der_pkcs12 (GcrParser *self,
-                  EggBytes *data)
+                  GBytes *data)
 {
        GNode *asn = NULL;
        GNode *asn_content = NULL;
        gint ret;
-       EggBytes *element = NULL;
-       EggBytes *content = NULL;
+       GBytes *element = NULL;
+       GBytes *content = NULL;
        GQuark oid;
        GcrParsed *parsed;
 
@@ -1587,9 +1587,9 @@ parse_der_pkcs12 (GcrParser *self,
 
 done:
        if (element)
-               egg_bytes_unref (element);
+               g_bytes_unref (element);
        if (content)
-               egg_bytes_unref (content);
+               g_bytes_unref (content);
        egg_asn1x_destroy (asn_content);
        egg_asn1x_destroy (asn);
        pop_parsed (self, parsed);
@@ -1602,7 +1602,7 @@ done:
 
 static gint
 parse_der_pkcs10 (GcrParser *self,
-                  EggBytes *data)
+                  GBytes *data)
 {
        GNode *asn = NULL;
        GNode *node;
@@ -1642,7 +1642,7 @@ parse_der_pkcs10 (GcrParser *self,
 
 static gint
 parse_der_spkac (GcrParser *self,
-                 EggBytes *data)
+                 GBytes *data)
 {
        GNode *asn = NULL;
        GcrParsed *parsed;
@@ -1668,7 +1668,7 @@ parse_der_spkac (GcrParser *self,
 
 static gint
 parse_base64_spkac (GcrParser *self,
-                    EggBytes *dat)
+                    GBytes *dat)
 {
        const gchar *PREFIX = "SPKAC=";
        const gsize PREFIX_LEN = 6;
@@ -1677,12 +1677,11 @@ parse_base64_spkac (GcrParser *self,
        guchar *spkac;
        gsize n_spkac;
        const guchar *data;
-       EggBytes *bytes;
+       GBytes *bytes;
        gsize n_data;
        gint ret;
 
-       data = egg_bytes_get_data (dat);
-       n_data = egg_bytes_get_size (dat);
+       data = g_bytes_get_data (dat, &n_data);
 
        if (n_data > PREFIX_LEN && memcmp (PREFIX, data, PREFIX_LEN))
                return GCR_ERROR_UNRECOGNIZED;
@@ -1695,9 +1694,9 @@ parse_base64_spkac (GcrParser *self,
 
        spkac = g_base64_decode ((const gchar *)data, &n_spkac);
        if (spkac != NULL) {
-               bytes = egg_bytes_new_take (spkac, n_spkac);
+               bytes = g_bytes_new_take (spkac, n_spkac);
                ret = parse_der_spkac (self, bytes);
-               egg_bytes_unref (bytes);
+               g_bytes_unref (bytes);
        } else {
                ret = GCR_ERROR_FAILURE;
        }
@@ -1712,7 +1711,7 @@ parse_base64_spkac (GcrParser *self,
 
 static void
 on_openpgp_packet (GPtrArray *records,
-                   EggBytes *outer,
+                   GBytes *outer,
                    gpointer user_data)
 {
        GcrParser *self = GCR_PARSER (user_data);
@@ -1741,7 +1740,7 @@ on_openpgp_packet (GPtrArray *records,
 
 static gint
 parse_openpgp_packets (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        gint num_parsed;
 
@@ -1815,7 +1814,7 @@ static gint
 handle_plain_pem (GcrParser *self,
                   gint format_id,
                   gint want_format,
-                  EggBytes *data)
+                  GBytes *data)
 {
        ParserFormat *format;
 
@@ -1834,14 +1833,14 @@ handle_encrypted_pem (GcrParser *self,
                       gint format_id,
                       gint want_format,
                       GHashTable *headers,
-                      EggBytes *data)
+                      GBytes *data)
 {
        PasswordState pstate = PASSWORD_STATE_INIT;
        const gchar *password;
        guchar *decrypted;
        gsize n_decrypted;
        const gchar *val;
-       EggBytes *dbytes;
+       GBytes *dbytes;
        gint res;
        gint l;
 
@@ -1872,13 +1871,13 @@ handle_encrypted_pem (GcrParser *self,
                if (l > 0)
                        n_decrypted = l;
 
-               dbytes = egg_bytes_new_with_free_func (decrypted, n_decrypted,
+               dbytes = g_bytes_new_with_free_func (decrypted, n_decrypted,
                                                       egg_secure_free, decrypted);
                decrypted = NULL;
 
                /* Try to parse */
                res = handle_plain_pem (self, format_id, want_format, dbytes);
-               egg_bytes_unref (dbytes);
+               g_bytes_unref (dbytes);
 
                /* Unrecognized is a bad password */
                if (res != GCR_ERROR_UNRECOGNIZED)
@@ -1896,8 +1895,8 @@ typedef struct {
 
 static void
 handle_pem_data (GQuark type,
-                 EggBytes *data,
-                 EggBytes *outer,
+                 GBytes *data,
+                 GBytes *outer,
                  GHashTable *headers,
                  gpointer user_data)
 {
@@ -1949,12 +1948,12 @@ handle_pem_data (GQuark type,
 static gint
 handle_pem_format (GcrParser *self,
                    gint subformat,
-                   EggBytes *data)
+                   GBytes *data)
 {
        HandlePemArgs ctx = { self, GCR_ERROR_UNRECOGNIZED, subformat };
        guint found;
 
-       if (egg_bytes_get_size (data) == 0)
+       if (g_bytes_get_size (data) == 0)
                return GCR_ERROR_UNRECOGNIZED;
 
        found = egg_armor_parse (data, handle_pem_data, &ctx);
@@ -1968,70 +1967,70 @@ handle_pem_format (GcrParser *self,
 
 static gint
 parse_pem (GcrParser *self,
-           EggBytes *data)
+           GBytes *data)
 {
        return handle_pem_format (self, 0, data);
 }
 
 static gint
 parse_pem_private_key_rsa (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PRIVATE_KEY_RSA, data);
 }
 
 static gint
 parse_pem_private_key_dsa (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PRIVATE_KEY_DSA, data);
 }
 
 static gint
 parse_pem_certificate (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_CERTIFICATE_X509, data);
 }
 
 static gint
 parse_pem_pkcs8_plain (GcrParser *self,
-                       EggBytes *data)
+                       GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PKCS8_PLAIN, data);
 }
 
 static gint
 parse_pem_pkcs8_encrypted (GcrParser *self,
-                           EggBytes *data)
+                           GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PKCS8_ENCRYPTED, data);
 }
 
 static gint
 parse_pem_pkcs7 (GcrParser *self,
-                 EggBytes *data)
+                 GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PKCS7, data);
 }
 
 static gint
 parse_pem_pkcs10 (GcrParser *self,
-                  EggBytes *data)
+                  GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PKCS10, data);
 }
 
 static gint
 parse_pem_pkcs12 (GcrParser *self,
-                  EggBytes *data)
+                  GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_DER_PKCS12, data);
 }
 
 static gint
 parse_openpgp_armor (GcrParser *self,
-                     EggBytes *data)
+                     GBytes *data)
 {
        return handle_pem_format (self, GCR_FORMAT_OPENPGP_PACKET, data);
 }
@@ -2044,7 +2043,7 @@ static void
 on_openssh_public_key_parsed (GckAttributes *attrs,
                               const gchar *label,
                               const gchar *options,
-                              EggBytes *outer,
+                              GBytes *outer,
                               gpointer user_data)
 {
        GcrParser *self = GCR_PARSER (user_data);
@@ -2060,7 +2059,7 @@ on_openssh_public_key_parsed (GckAttributes *attrs,
 
 static gint
 parse_openssh_public (GcrParser *self,
-                      EggBytes *data)
+                      GBytes *data)
 {
        guint num_parsed;
 
@@ -2192,7 +2191,7 @@ compare_pointers (gconstpointer a, gconstpointer b)
 
 typedef struct _ForeachArgs {
        GcrParser *parser;
-       EggBytes *data;
+       GBytes *data;
        gint result;
 } ForeachArgs;
 
@@ -2458,7 +2457,7 @@ gcr_parser_parse_data (GcrParser *self,
 
        if (data && n_data) {
                /* TODO: Once GBytes is in the API, copy here */
-               args.data = egg_bytes_new_static (data, n_data);
+               args.data = g_bytes_new_static (data, n_data);
 
                /* Just the specific formats requested */
                if (self->pv->specific_formats) {
@@ -2473,7 +2472,7 @@ gcr_parser_parse_data (GcrParser *self,
                        }
                }
 
-               egg_bytes_unref (args.data);
+               g_bytes_unref (args.data);
        }
 
        switch (args.result) {
@@ -2650,7 +2649,7 @@ gcr_parsed_ref (GcrParsed *parsed)
        /* Find the block of data to copy */
        while (parsed != NULL) {
                if (parsed->data != NULL) {
-                       copy->data = egg_bytes_ref (parsed->data);
+                       copy->data = g_bytes_ref (parsed->data);
                        copy->sensitive = parsed->sensitive;
                        break;
                }
@@ -2679,7 +2678,7 @@ gcr_parsed_unref (gpointer parsed)
                        gck_attributes_unref (par->attrs);
                g_free (par->label);
                if (par->data)
-                       egg_bytes_unref (par->data);
+                       g_bytes_unref (par->data);
                g_free (par);
        }
 }
@@ -2842,10 +2841,8 @@ gcr_parsed_get_data (GcrParsed *parsed,
        g_return_val_if_fail (n_data != NULL, NULL);
 
        while (parsed != NULL) {
-               if (parsed->data != NULL) {
-                       *n_data = egg_bytes_get_size (parsed->data);
-                       return egg_bytes_get_data (parsed->data);
-               }
+               if (parsed->data != NULL)
+                       return g_bytes_get_data (parsed->data, n_data);
                parsed = parsed->next;
        }
 
index 5244039..f41b127 100644 (file)
@@ -527,9 +527,9 @@ rsa_subject_public_key_from_attributes (GckAttributes *attrs,
        const GckAttribute *exponent;
        GNode *key_asn;
        GNode *params_asn;
-       EggBytes *key;
-       EggBytes *params;
-       EggBytes *usg;
+       GBytes *key;
+       GBytes *params;
+       GBytes *usg;
 
        _gcr_oids_init ();
 
@@ -545,17 +545,17 @@ rsa_subject_public_key_from_attributes (GckAttributes *attrs,
        params_asn = egg_asn1x_create (pk_asn1_tab, "RSAParameters");
        g_return_val_if_fail (params_asn, FALSE);
 
-       usg = egg_bytes_new_with_free_func (modulus->value, modulus->length,
+       usg = g_bytes_new_with_free_func (modulus->value, modulus->length,
                                            gck_attributes_unref,
                                            gck_attributes_ref (attrs));
        egg_asn1x_set_integer_as_usg (egg_asn1x_node (key_asn, "modulus", NULL), usg);
-       egg_bytes_unref (usg);
+       g_bytes_unref (usg);
 
-       usg = egg_bytes_new_with_free_func (exponent->value, exponent->length,
+       usg = g_bytes_new_with_free_func (exponent->value, exponent->length,
                                            gck_attributes_unref,
                                            gck_attributes_ref (attrs));
        egg_asn1x_set_integer_as_usg (egg_asn1x_node (key_asn, "publicExponent", NULL), usg);
-       egg_bytes_unref (usg);
+       g_bytes_unref (usg);
 
        key = egg_asn1x_encode (key_asn, NULL);
        egg_asn1x_destroy (key_asn);
@@ -566,13 +566,13 @@ rsa_subject_public_key_from_attributes (GckAttributes *attrs,
        egg_asn1x_destroy (params_asn);
 
        egg_asn1x_set_bits_as_raw (egg_asn1x_node (info_asn, "subjectPublicKey", NULL),
-                                  key, egg_bytes_get_size (key) * 8);
+                                  key, g_bytes_get_size (key) * 8);
 
        egg_asn1x_set_oid_as_quark (egg_asn1x_node (info_asn, "algorithm", "algorithm", NULL), GCR_OID_PKIX1_RSA);
        egg_asn1x_set_element_raw (egg_asn1x_node (info_asn, "algorithm", "parameters", NULL), params);
 
-       egg_bytes_unref (key);
-       egg_bytes_unref (params);
+       g_bytes_unref (key);
+       g_bytes_unref (params);
        return TRUE;
 }
 
@@ -607,7 +607,7 @@ dsa_subject_public_key_from_private (GNode *key_asn,
 
        gcry = gcry_mpi_aprint (GCRYMPI_FMT_STD, &buffer, &n_buffer, my);
        g_return_val_if_fail (gcry == 0, FALSE);
-       egg_asn1x_take_integer_as_raw (key_asn, egg_bytes_new_with_free_func (buffer, n_buffer,
+       egg_asn1x_take_integer_as_raw (key_asn, g_bytes_new_with_free_func (buffer, n_buffer,
                                                                              gcry_free, buffer));
 
        gcry_mpi_release (mp);
@@ -626,8 +626,8 @@ dsa_subject_public_key_from_attributes (GckAttributes *attrs,
 {
        const GckAttribute *value, *g, *q, *p;
        GNode *key_asn, *params_asn;
-       EggBytes *key;
-       EggBytes *params;
+       GBytes *key;
+       GBytes *params;
 
        _gcr_oids_init ();
 
@@ -649,15 +649,15 @@ dsa_subject_public_key_from_attributes (GckAttributes *attrs,
        g_return_val_if_fail (params_asn, FALSE);
 
        egg_asn1x_take_integer_as_usg (egg_asn1x_node (params_asn, "p", NULL),
-                                      egg_bytes_new_with_free_func (p->value, p->length,
+                                      g_bytes_new_with_free_func (p->value, p->length,
                                                                     gck_attributes_unref,
                                                                     gck_attributes_ref (attrs)));
        egg_asn1x_take_integer_as_usg (egg_asn1x_node (params_asn, "q", NULL),
-                                      egg_bytes_new_with_free_func (q->value, q->length,
+                                      g_bytes_new_with_free_func (q->value, q->length,
                                                                     gck_attributes_unref,
                                                                     gck_attributes_ref (attrs)));
        egg_asn1x_take_integer_as_usg (egg_asn1x_node (params_asn, "g", NULL),
-                                      egg_bytes_new_with_free_func (g->value, g->length,
+                                      g_bytes_new_with_free_func (g->value, g->length,
                                                                     gck_attributes_unref,
                                                                     gck_attributes_ref (attrs)));
 
@@ -670,7 +670,7 @@ dsa_subject_public_key_from_attributes (GckAttributes *attrs,
 
        } else if (klass == CKO_PUBLIC_KEY) {
                egg_asn1x_take_integer_as_usg (key_asn,
-                                              egg_bytes_new_with_free_func (value->value, value->length,
+                                              g_bytes_new_with_free_func (value->value, value->length,
                                                                             gck_attributes_unref,
                                                                             gck_attributes_ref (attrs)));
        } else {
@@ -684,13 +684,13 @@ dsa_subject_public_key_from_attributes (GckAttributes *attrs,
        egg_asn1x_destroy (params_asn);
 
        egg_asn1x_set_bits_as_raw (egg_asn1x_node (info_asn, "subjectPublicKey", NULL),
-                                  key, egg_bytes_get_size (key) * 8);
+                                  key, g_bytes_get_size (key) * 8);
        egg_asn1x_set_element_raw (egg_asn1x_node (info_asn, "algorithm", "parameters", NULL), params);
 
        egg_asn1x_set_oid_as_quark (egg_asn1x_node (info_asn, "algorithm", "algorithm", NULL), GCR_OID_PKIX1_DSA);
 
-       egg_bytes_unref (key);
-       egg_bytes_unref (params);
+       g_bytes_unref (key);
+       g_bytes_unref (params);
        return TRUE;
 }
 
@@ -698,7 +698,7 @@ static GNode *
 cert_subject_public_key_from_attributes (GckAttributes *attributes)
 {
        const GckAttribute *attr;
-       EggBytes *bytes;
+       GBytes *bytes;
        GNode *cert;
        GNode *asn;
 
@@ -708,11 +708,11 @@ cert_subject_public_key_from_attributes (GckAttributes *attributes)
                return NULL;
        }
 
-       bytes = egg_bytes_new_with_free_func (attr->value, attr->length,
+       bytes = g_bytes_new_with_free_func (attr->value, attr->length,
                                              gck_attributes_unref,
                                              gck_attributes_ref (attributes));
        cert = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", bytes);
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 
        if (cert == NULL) {
                _gcr_debug ("couldn't parse certificate value");
@@ -776,10 +776,10 @@ _gcr_subject_public_key_for_attributes (GckAttributes *attributes)
 }
 
 static guint
-calculate_rsa_key_size (EggBytes *data)
+calculate_rsa_key_size (GBytes *data)
 {
        GNode *asn;
-       EggBytes *content;
+       GBytes *content;
        guint key_size;
 
        asn = egg_asn1x_create_and_decode (pk_asn1_tab, "RSAPublicKey", data);
@@ -792,17 +792,17 @@ calculate_rsa_key_size (EggBytes *data)
        egg_asn1x_destroy (asn);
 
        /* Removes the complement */
-       key_size = (egg_bytes_get_size (content) / 2) * 2 * 8;
+       key_size = (g_bytes_get_size (content) / 2) * 2 * 8;
 
-       egg_bytes_unref (content);
+       g_bytes_unref (content);
        return key_size;
 }
 
 static guint
-calculate_dsa_params_size (EggBytes *data)
+calculate_dsa_params_size (GBytes *data)
 {
        GNode *asn;
-       EggBytes *content;
+       GBytes *content;
        guint key_size;
 
        asn = egg_asn1x_create_and_decode (pk_asn1_tab, "DSAParameters", data);
@@ -815,16 +815,16 @@ calculate_dsa_params_size (EggBytes *data)
        egg_asn1x_destroy (asn);
 
        /* Removes the complement */
-       key_size = (egg_bytes_get_size (content) / 2) * 2 * 8;
+       key_size = (g_bytes_get_size (content) / 2) * 2 * 8;
 
-       egg_bytes_unref (content);
+       g_bytes_unref (content);
        return key_size;
 }
 
 guint
 _gcr_subject_public_key_calculate_size (GNode *subject_public_key)
 {
-       EggBytes *key;
+       GBytes *key;
        guint key_size = 0;
        guint n_bits;
        GQuark oid;
@@ -839,13 +839,13 @@ _gcr_subject_public_key_calculate_size (GNode *subject_public_key)
                key = egg_asn1x_get_bits_as_raw (egg_asn1x_node (subject_public_key, "subjectPublicKey", NULL), &n_bits);
                g_return_val_if_fail (key != NULL, 0);
                key_size = calculate_rsa_key_size (key);
-               egg_bytes_unref (key);
+               g_bytes_unref (key);
 
        /* The DSA key size is discovered by the prime in params */
        } else if (oid == GCR_OID_PKIX1_DSA) {
                key = egg_asn1x_get_element_raw (egg_asn1x_node (subject_public_key, "algorithm", "parameters", NULL));
                key_size = calculate_dsa_params_size (key);
-               egg_bytes_unref (key);
+               g_bytes_unref (key);
 
        } else {
                g_message ("unsupported key algorithm: %s", g_quark_to_string (oid));
index 46748f6..9763a62 100644 (file)
@@ -31,7 +31,7 @@
 
 static void
 on_packet_print_records (GPtrArray *records,
-                         EggBytes *packet,
+                         GBytes *packet,
                          gpointer user_data)
 {
        gchar *string;
@@ -45,7 +45,7 @@ on_packet_print_records (GPtrArray *records,
 }
 
 static gboolean
-parse_binary (EggBytes *contents)
+parse_binary (GBytes *contents)
 {
        guint packets;
 
@@ -59,8 +59,8 @@ parse_binary (EggBytes *contents)
 
 static void
 on_armor_parsed (GQuark type,
-                 EggBytes *data,
-                 EggBytes *outer,
+                 GBytes *data,
+                 GBytes *outer,
                  GHashTable *headers,
                  gpointer user_data)
 {
@@ -74,7 +74,7 @@ on_armor_parsed (GQuark type,
 }
 
 static gboolean
-parse_armor_or_binary (EggBytes *contents)
+parse_armor_or_binary (GBytes *contents)
 {
        gboolean result;
        guint parts;
@@ -91,7 +91,7 @@ main(int argc, char *argv[])
        GError *error = NULL;
        gchar *contents;
        gsize length;
-       EggBytes *bytes;
+       GBytes *bytes;
        int ret;
 
        g_set_prgname ("frob-openpgp");
@@ -107,13 +107,13 @@ main(int argc, char *argv[])
                return 1;
        }
 
-       bytes = egg_bytes_new_take (contents, length);
+       bytes = g_bytes_new_take (contents, length);
        ret = 0;
        if (!parse_armor_or_binary (bytes)) {
                g_printerr ("frob-openpgp: no openpgp data found in data");
                ret = 1;
        }
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
        return ret;
 }
index 7b4acf5..ba90f54 100644 (file)
 #include <errno.h>
 
 typedef struct {
-       EggBytes *cert_rsa;
-       EggBytes *key_rsa;
-       EggBytes *cert_dsa;
-       EggBytes *key_dsa;
+       GBytes *cert_rsa;
+       GBytes *key_rsa;
+       GBytes *cert_dsa;
+       GBytes *key_dsa;
 } Test;
 
 static void
@@ -54,28 +54,28 @@ setup (Test *test, gconstpointer unused)
 
        g_file_get_contents (SRCDIR "/files/client.crt", &contents, &length, &error);
        g_assert_no_error (error);
-       test->cert_rsa = egg_bytes_new_take (contents, length);
+       test->cert_rsa = g_bytes_new_take (contents, length);
 
        g_file_get_contents (SRCDIR "/files/client.key", &contents, &length, &error);
        g_assert_no_error (error);
-       test->key_rsa = egg_bytes_new_take (contents, length);
+       test->key_rsa = g_bytes_new_take (contents, length);
 
        g_file_get_contents (SRCDIR "/files/generic-dsa.crt", &contents, &length, &error);
        g_assert_no_error (error);
-       test->cert_dsa = egg_bytes_new_take (contents, length);
+       test->cert_dsa = g_bytes_new_take (contents, length);
 
        g_file_get_contents (SRCDIR "/files/generic-dsa.key", &contents, &length, &error);
        g_assert_no_error (error);
-       test->key_dsa = egg_bytes_new_take (contents, length);
+       test->key_dsa = g_bytes_new_take (contents, length);
 }
 
 static void
 teardown (Test *test, gconstpointer unused)
 {
-       egg_bytes_unref (test->cert_rsa);
-       egg_bytes_unref (test->key_rsa);
-       egg_bytes_unref (test->cert_dsa);
-       egg_bytes_unref (test->key_dsa);
+       g_bytes_unref (test->cert_rsa);
+       g_bytes_unref (test->key_rsa);
+       g_bytes_unref (test->cert_dsa);
+       g_bytes_unref (test->key_dsa);
 }
 
 static void
@@ -90,7 +90,7 @@ on_parser_parsed (GcrParser *parser,
 }
 
 static GckAttributes*
-parse_attributes_for_key (EggBytes *data)
+parse_attributes_for_key (GBytes *data)
 {
        GcrParser *parser;
        GckAttributes *attrs = NULL;
@@ -98,8 +98,8 @@ parse_attributes_for_key (EggBytes *data)
 
        parser = gcr_parser_new ();
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parser_parsed), &attrs);
-       gcr_parser_parse_data (parser, egg_bytes_get_data (data),
-                              egg_bytes_get_size (data), &error);
+       gcr_parser_parse_data (parser, g_bytes_get_data (data, NULL),
+                              g_bytes_get_size (data), &error);
        g_assert_no_error (error);
        g_object_unref (parser);
 
@@ -108,22 +108,22 @@ parse_attributes_for_key (EggBytes *data)
 }
 
 static GckAttributes *
-build_attributes_for_cert (EggBytes *data)
+build_attributes_for_cert (GBytes *data)
 {
        GckBuilder builder = GCK_BUILDER_INIT;
 
-       gck_builder_add_data (&builder, CKA_VALUE, egg_bytes_get_data (data),
-                             egg_bytes_get_size (data));
+       gck_builder_add_data (&builder, CKA_VALUE, g_bytes_get_data (data, NULL),
+                             g_bytes_get_size (data));
        gck_builder_add_ulong (&builder, CKA_CLASS, CKO_CERTIFICATE);
        gck_builder_add_ulong (&builder, CKA_CERTIFICATE_TYPE, CKC_X_509);
 
        return gck_attributes_ref_sink (gck_builder_end (&builder));
 }
 
-static EggBytes *
-parse_subject_public_key_info_for_cert (EggBytes *data)
+static GBytes *
+parse_subject_public_key_info_for_cert (GBytes *data)
 {
-       EggBytes *info;
+       GBytes *info;
        GNode *asn;
 
        asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data);
@@ -140,7 +140,7 @@ static void
 test_rsa (Test *test, gconstpointer unused)
 {
        GckAttributes *key, *cert;
-       EggBytes *info;
+       GBytes *info;
        guchar *fingerprint1, *fingerprint2, *fingerprint3;
        gsize n_fingerprint1, n_fingerprint2, n_fingerprint3;
 
@@ -148,8 +148,8 @@ test_rsa (Test *test, gconstpointer unused)
        info = parse_subject_public_key_info_for_cert (test->cert_rsa);
        cert = build_attributes_for_cert (test->cert_rsa);
 
-       fingerprint1 = gcr_fingerprint_from_subject_public_key_info (egg_bytes_get_data (info),
-                                                                    egg_bytes_get_size (info),
+       fingerprint1 = gcr_fingerprint_from_subject_public_key_info (g_bytes_get_data (info, NULL),
+                                                                    g_bytes_get_size (info),
                                                                     G_CHECKSUM_SHA1, &n_fingerprint1);
        fingerprint2 = gcr_fingerprint_from_attributes (key, G_CHECKSUM_SHA1, &n_fingerprint2);
        fingerprint3 = gcr_fingerprint_from_attributes (cert, G_CHECKSUM_SHA1, &n_fingerprint3);
@@ -161,7 +161,7 @@ test_rsa (Test *test, gconstpointer unused)
        g_free (fingerprint2);
        g_free (fingerprint3);
 
-       egg_bytes_unref (info);
+       g_bytes_unref (info);
        gck_attributes_unref (key);
        gck_attributes_unref (cert);
 }
@@ -170,7 +170,7 @@ static void
 test_dsa (Test *test, gconstpointer unused)
 {
        GckAttributes *key, *cert;
-       EggBytes *info;
+       GBytes *info;
        guchar *fingerprint1, *fingerprint2, *fingerprint3;
        gsize n_fingerprint1, n_fingerprint2, n_fingerprint3;
 
@@ -178,8 +178,8 @@ test_dsa (Test *test, gconstpointer unused)
        info = parse_subject_public_key_info_for_cert (test->cert_dsa);
        cert = build_attributes_for_cert (test->cert_dsa);
 
-       fingerprint1 = gcr_fingerprint_from_subject_public_key_info (egg_bytes_get_data (info),
-                                                                    egg_bytes_get_size (info),
+       fingerprint1 = gcr_fingerprint_from_subject_public_key_info (g_bytes_get_data (info, NULL),
+                                                                    g_bytes_get_size (info),
                                                                     G_CHECKSUM_SHA1, &n_fingerprint1);
        fingerprint2 = gcr_fingerprint_from_attributes (key, G_CHECKSUM_SHA1, &n_fingerprint2);
        fingerprint3 = gcr_fingerprint_from_attributes (cert, G_CHECKSUM_SHA1, &n_fingerprint3);
@@ -191,7 +191,7 @@ test_dsa (Test *test, gconstpointer unused)
        g_free (fingerprint2);
        g_free (fingerprint3);
 
-       egg_bytes_unref (info);
+       g_bytes_unref (info);
        gck_attributes_unref (key);
        gck_attributes_unref (cert);
 }
index f203898..0645a08 100644 (file)
@@ -240,7 +240,7 @@ compare_fixture_with_records (const gchar *fixture,
 
 static void
 on_openpgp_packet  (GPtrArray *records,
-                    EggBytes *outer,
+                    GBytes *outer,
                     gpointer user_data)
 {
        Test *test = user_data;
@@ -262,8 +262,8 @@ on_openpgp_packet  (GPtrArray *records,
 
 static void
 on_armor_parsed (GQuark type,
-                 EggBytes *data,
-                 EggBytes *outer,
+                 GBytes *data,
+                 GBytes *outer,
                  GHashTable *headers,
                  gpointer user_data)
 {
@@ -291,7 +291,7 @@ test_openpgp_armor (Test *test,
                     gconstpointer data)
 {
        GError *error = NULL;
-       EggBytes *bytes;
+       GBytes *bytes;
        gchar *armor;
        gsize length;
        guint parts;
@@ -299,11 +299,11 @@ test_openpgp_armor (Test *test,
        g_file_get_contents (test->fixture->filename, &armor, &length, &error);
        g_assert_no_error (error);
 
-       bytes = egg_bytes_new_take (armor, length);
+       bytes = g_bytes_new_take (armor, length);
        parts = egg_armor_parse (bytes, on_armor_parsed, test);
        g_assert_cmpuint (parts, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -311,7 +311,7 @@ test_openpgp_binary (Test *test,
                      gconstpointer data)
 {
        GError *error = NULL;
-       EggBytes *bytes;
+       GBytes *bytes;
        gchar *binary;
        gsize length;
        guint seen;
@@ -319,7 +319,7 @@ test_openpgp_binary (Test *test,
        g_file_get_contents (test->fixture->filename, &binary, &length, &error);
        g_assert_no_error (error);
 
-       bytes = egg_bytes_new_take (binary, length);
+       bytes = g_bytes_new_take (binary, length);
        seen = _gcr_openpgp_parse (bytes, test->fixture->flags, on_openpgp_packet, test);
        g_assert_cmpuint (seen, >, 0);
 
@@ -328,7 +328,7 @@ test_openpgp_binary (Test *test,
                g_assert_not_reached ();
        }
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 int
index 5c02c6b..376efe0 100644 (file)
@@ -91,7 +91,7 @@ static void
 on_openssh_pub_parse (GckAttributes *attrs,
                       const gchar *label,
                       const gchar *options,
-                      EggBytes *outer,
+                      GBytes *outer,
                       gpointer user_data)
 {
        Test *test = user_data;
@@ -112,16 +112,16 @@ test_parse_v1_rsa (Test *test,
                    gconstpointer unused)
 {
        const gchar *data = OPENSSH_PUBLIC_RSA1 EXTRA_LINES_WITHOUT_KEY;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint keys;
 
        test->expected_label = "rsa-key@example.com";
 
-       bytes = egg_bytes_new_static (data, strlen (data));
+       bytes = g_bytes_new_static (data, strlen (data));
        keys = _gcr_openssh_pub_parse (bytes, on_openssh_pub_parse, test);
        g_assert_cmpint (keys, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -129,16 +129,16 @@ test_parse_v2_rsa (Test *test,
                    gconstpointer unused)
 {
        const gchar *data = OPENSSH_PUBLIC_RSA2 EXTRA_LINES_WITHOUT_KEY;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint keys;
 
        test->expected_label = "rsa-key@example.com";
 
-       bytes = egg_bytes_new_static (data, strlen (data));
+       bytes = g_bytes_new_static (data, strlen (data));
        keys = _gcr_openssh_pub_parse (bytes, on_openssh_pub_parse, test);
        g_assert_cmpint (keys, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -146,16 +146,16 @@ test_parse_v2_dsa (Test *test,
                gconstpointer unused)
 {
        const gchar *data = OPENSSH_PUBLIC_DSA2 EXTRA_LINES_WITHOUT_KEY;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint keys;
 
        test->expected_label = "dsa-key@example.com";
 
-       bytes = egg_bytes_new_static (data, strlen (data));
+       bytes = g_bytes_new_static (data, strlen (data));
        keys = _gcr_openssh_pub_parse (bytes, on_openssh_pub_parse, test);
        g_assert_cmpint (keys, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -163,16 +163,16 @@ test_parse_v1_options (Test *test,
                        gconstpointer unused)
 {
        const gchar *data = "option1,option2=\"value 2\",option3 " OPENSSH_PUBLIC_RSA1;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint keys;
 
        test->expected_options = "option1,option2=\"value 2\",option3";
 
-       bytes = egg_bytes_new_static (data, strlen (data));
+       bytes = g_bytes_new_static (data, strlen (data));
        keys = _gcr_openssh_pub_parse (bytes, on_openssh_pub_parse, test);
        g_assert_cmpint (keys, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 static void
@@ -180,16 +180,16 @@ test_parse_v2_options (Test *test,
                        gconstpointer unused)
 {
        const gchar *data = "option1,option2=\"value 2\",option3 " OPENSSH_PUBLIC_RSA2;
-       EggBytes *bytes;
+       GBytes *bytes;
        gint keys;
 
        test->expected_options = "option1,option2=\"value 2\",option3";
 
-       bytes = egg_bytes_new_static (data, strlen (data));
+       bytes = g_bytes_new_static (data, strlen (data));
        keys = _gcr_openssh_pub_parse (bytes, on_openssh_pub_parse, test);
        g_assert_cmpint (keys, ==, 1);
 
-       egg_bytes_unref (bytes);
+       g_bytes_unref (bytes);
 }
 
 int
index 3c263f1..d1885ea 100644 (file)
@@ -53,8 +53,8 @@ setup (Test *test, gconstpointer unused)
        GList *modules = NULL;
        CK_FUNCTION_LIST_PTR f;
        GckModule *module;
-       EggBytes *subject;
-       EggBytes *bytes;
+       GBytes *subject;
+       GBytes *bytes;
        GNode *asn, *node;
        CK_RV rv;
 
@@ -82,7 +82,7 @@ setup (Test *test, gconstpointer unused)
        gcr_pkcs11_set_modules (modules);
        gck_list_unref_free (modules);
 
-       bytes = egg_bytes_new_static (test->cert_data, test->n_cert_data);
+       bytes = g_bytes_new_static (test->cert_data, test->n_cert_data);
        asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", bytes);
        g_assert (asn);
        node = egg_asn1x_node (asn, "tbsCertificate", "subject", NULL);
@@ -93,12 +93,12 @@ setup (Test *test, gconstpointer unused)
        gck_builder_add_ulong (&builder, CKA_CLASS, CKO_CERTIFICATE);
        gck_builder_add_ulong (&builder, CKA_CERTIFICATE_TYPE, CKC_X_509);
        gck_builder_add_data (&builder, CKA_SUBJECT,
-                             egg_bytes_get_data (subject),
-                             egg_bytes_get_size (subject));
+                             g_bytes_get_data (subject, NULL),
+                             g_bytes_get_size (subject));
        gck_mock_module_add_object (gck_builder_end (&builder));
 
-       egg_bytes_unref (bytes);
-       egg_bytes_unref (subject);
+       g_bytes_unref (bytes);
+       g_bytes_unref (subject);
        egg_asn1x_destroy (asn);
 }
 
index 0f2e301..594d3a4 100644 (file)
@@ -43,11 +43,11 @@ typedef struct {
 } TestFixture;
 
 typedef struct {
-       EggBytes *crt_data;
+       GBytes *crt_data;
        GckAttributes *crt_attrs;
-       EggBytes *key_data;
+       GBytes *key_data;
        GckAttributes *prv_attrs;
-       EggBytes *spk_data;
+       GBytes *spk_data;
        GckAttributes *pub_attrs;
 } TestAttributes;
 
@@ -63,7 +63,7 @@ on_parser_parsed (GcrParser *parser,
 }
 
 static GckAttributes *
-parse_attributes (EggBytes *data)
+parse_attributes (GBytes *data)
 {
        GcrParser *parser;
        GckAttributes *attrs = NULL;
@@ -71,8 +71,8 @@ parse_attributes (EggBytes *data)
 
        parser = gcr_parser_new ();
        g_signal_connect (parser, "parsed", G_CALLBACK (on_parser_parsed), &attrs);
-       gcr_parser_parse_data (parser, egg_bytes_get_data (data),
-                              egg_bytes_get_size (data), &error);
+       gcr_parser_parse_data (parser, g_bytes_get_data (data, NULL),
+                              g_bytes_get_size (data), &error);
        g_assert_no_error (error);
        g_object_unref (parser);
 
@@ -94,7 +94,7 @@ setup_attributes (TestAttributes *test,
        filename = g_strdup_printf (SRCDIR "/files/%s.crt", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
-       test->crt_data = egg_bytes_new_take (contents, length);
+       test->crt_data = g_bytes_new_take (contents, length);
        test->crt_attrs = parse_attributes (test->crt_data);
        g_assert (gck_attributes_find_ulong (test->crt_attrs, CKA_CLASS, &klass));
        gck_assert_cmpulong (klass, ==, CKO_CERTIFICATE);
@@ -103,7 +103,7 @@ setup_attributes (TestAttributes *test,
        filename = g_strdup_printf (SRCDIR "/files/%s.key", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
-       test->key_data = egg_bytes_new_take (contents, length);
+       test->key_data = g_bytes_new_take (contents, length);
        test->prv_attrs = parse_attributes (test->key_data);
        g_assert (gck_attributes_find_ulong (test->prv_attrs, CKA_CLASS, &klass));
        gck_assert_cmpulong (klass, ==, CKO_PRIVATE_KEY);
@@ -112,7 +112,7 @@ setup_attributes (TestAttributes *test,
        filename = g_strdup_printf (SRCDIR "/files/%s.spk", fixture->basename);
        g_file_get_contents (filename, &contents, &length, &error);
        g_assert_no_error (error);
-       test->spk_data = egg_bytes_new_take (contents, length);
+       test->spk_data = g_bytes_new_take (contents, length);
        test->pub_attrs = parse_attributes (test->spk_data);
        g_assert (gck_attributes_find_ulong (test->pub_attrs, CKA_CLASS, &klass));
        gck_assert_cmpulong (klass, ==, CKO_PUBLIC_KEY);
@@ -123,9 +123,9 @@ static void
 teardown_attributes (TestAttributes *test,
                      gconstpointer unused)
 {
-       egg_bytes_unref (test->crt_data);
-       egg_bytes_unref (test->key_data);
-       egg_bytes_unref (test->spk_data);
+       g_bytes_unref (test->crt_data);
+       g_bytes_unref (test->key_data);
+       g_bytes_unref (test->spk_data);
        gck_attributes_unref (test->crt_attrs);
        gck_attributes_unref (test->prv_attrs);
        gck_attributes_unref (test->pub_attrs);
@@ -136,16 +136,16 @@ perform_for_attributes (TestAttributes *test,
                         GckAttributes *attrs)
 {
        GNode *info;
-       EggBytes *data;
+       GBytes *data;
 
        info = _gcr_subject_public_key_for_attributes (attrs);
        g_assert (info != NULL);
 
        data = egg_asn1x_encode (info, NULL);
-       egg_assert_cmpbytes (data, ==, egg_bytes_get_data (test->spk_data),
-                                      egg_bytes_get_size (test->spk_data));
+       egg_assert_cmpbytes (data, ==, g_bytes_get_data (test->spk_data, NULL),
+                                      g_bytes_get_size (test->spk_data));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (info);
 
 }
@@ -183,7 +183,7 @@ perform_calculate_size (TestAttributes *test,
        g_assert (info != NULL);
 
        /* TODO: until encoding, we don't have readable attributes */
-       egg_bytes_unref (egg_asn1x_encode (info, NULL));
+       g_bytes_unref (egg_asn1x_encode (info, NULL));
 
        size = _gcr_subject_public_key_calculate_size (info);
        g_assert_cmpuint (size, ==, fixture->key_size);
@@ -317,7 +317,7 @@ perform_load (TestLoading *test,
               GckObject *object)
 {
        GError *error = NULL;
-       EggBytes *data;
+       GBytes *data;
        GNode *info;
 
        info = _gcr_subject_public_key_load (object, NULL, &error);
@@ -325,10 +325,10 @@ perform_load (TestLoading *test,
        g_assert (info != NULL);
 
        data = egg_asn1x_encode (info, NULL);
-       egg_assert_cmpbytes (data, ==, egg_bytes_get_data (test->at.spk_data),
-                                      egg_bytes_get_size (test->at.spk_data));
+       egg_assert_cmpbytes (data, ==, g_bytes_get_data (test->at.spk_data, NULL),
+                                      g_bytes_get_size (test->at.spk_data));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (info);
 }
 
@@ -372,7 +372,7 @@ perform_load_async (TestLoading *test,
 {
        GAsyncResult *result = NULL;
        GError *error = NULL;
-       EggBytes *data;
+       GBytes *data;
        GNode *info;
 
        _gcr_subject_public_key_load_async (object, NULL, on_async_result, &result);
@@ -386,10 +386,10 @@ perform_load_async (TestLoading *test,
        g_object_unref (result);
 
        data = egg_asn1x_encode (info, NULL);
-       egg_assert_cmpbytes (data, ==, egg_bytes_get_data (test->at.spk_data),
-                                      egg_bytes_get_size (test->at.spk_data));
+       egg_assert_cmpbytes (data, ==, g_bytes_get_data (test->at.spk_data, NULL),
+                                      g_bytes_get_size (test->at.spk_data));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (info);
 }
 
@@ -499,7 +499,7 @@ perform_load_already (TestLoading *test,
        const gulong INVALID = 0xFFF00FF; /* invalid handle, should not be used */
        GckObject *object;
        GError *error = NULL;
-       EggBytes *data;
+       GBytes *data;
        GNode *info;
 
        object = g_object_new (mock_object_get_type (),
@@ -514,10 +514,10 @@ perform_load_already (TestLoading *test,
        g_assert (info != NULL);
 
        data = egg_asn1x_encode (info, NULL);
-       egg_assert_cmpbytes (data, ==, egg_bytes_get_data (test->at.spk_data),
-                                      egg_bytes_get_size (test->at.spk_data));
+       egg_assert_cmpbytes (data, ==, g_bytes_get_data (test->at.spk_data, NULL),
+                                      g_bytes_get_size (test->at.spk_data));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (info);
        g_object_unref (object);
 }
@@ -552,7 +552,7 @@ perform_load_partial (TestLoading *test,
        GckAttributes *partial;
        GckObject *object;
        GError *error = NULL;
-       EggBytes *data;
+       GBytes *data;
        GNode *info;
        guint i;
 
@@ -573,10 +573,10 @@ perform_load_partial (TestLoading *test,
        g_assert (info != NULL);
 
        data = egg_asn1x_encode (info, NULL);
-       egg_assert_cmpbytes (data, ==, egg_bytes_get_data (test->at.spk_data),
-                                      egg_bytes_get_size (test->at.spk_data));
+       egg_assert_cmpbytes (data, ==, g_bytes_get_data (test->at.spk_data, NULL),
+                                      g_bytes_get_size (test->at.spk_data));
 
-       egg_bytes_unref (data);
+       g_bytes_unref (data);
        egg_asn1x_destroy (info);
        g_object_unref (object);
 }