diff options
author | Stef Walter <stefw@gnome.org> | 2012-07-16 11:26:18 +0200 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2012-07-16 11:30:34 +0200 |
commit | 9d5c86537af8940d26a573da82cafb69640438b2 (patch) | |
tree | 5eddf5d957848e151b0b1aec9d835926730a8433 | |
parent | d31a26df7ce8d9c084b9c66fe00458683dde9864 (diff) | |
download | gnome-keyring-9d5c86537af8940d26a573da82cafb69640438b2.tar.gz |
Convert from EggBytes to GBytes
* We were using EggBytes while GBytes was not yet in a stable
glib release
46 files changed, 724 insertions, 1303 deletions
diff --git a/configure.ac b/configure.ac index 04bd5999..7c0e68f3 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ GTK_DOC_CHECK(1.9) DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc" AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28.0) +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) diff --git a/egg/Makefile.am b/egg/Makefile.am index 2e8d133b..b43b4a65 100644 --- a/egg/Makefile.am +++ b/egg/Makefile.am @@ -36,7 +36,6 @@ libegg_la_SOURCES = \ egg-asn1-defs.c egg-asn1-defs.h \ egg-buffer.c egg-buffer.h \ egg-byte-array.c egg-byte-array.h \ - egg-bytes.c egg-bytes.h \ egg-cleanup.c egg-cleanup.h \ egg-dh.c egg-dh.h \ egg-dn.c egg-dn.h \ @@ -69,7 +68,6 @@ DISTCLEANFILES = \ libegg_asn1x_la_SOURCES = \ egg-asn1x.c egg-asn1x.h \ egg-asn1-defs.c egg-asn1-defs.h \ - egg-bytes.c egg-bytes.h \ $(BUILT_SOURCES) libegg_asn1x_la_CFLAGS = \ diff --git a/egg/egg-armor.c b/egg/egg-armor.c index 473e42ed..ec514cc2 100644 --- a/egg/egg-armor.c +++ b/egg/egg-armor.c @@ -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, + 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); diff --git a/egg/egg-armor.h b/egg/egg-armor.h index 586a0d22..e32d44d4 100644 --- a/egg/egg-armor.h +++ b/egg/egg-armor.h @@ -26,17 +26,15 @@ #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); diff --git a/egg/egg-asn1x.c b/egg/egg-asn1x.c index c940a547..2a3f276b 100644 --- a/egg/egg-asn1x.c +++ b/egg/egg-asn1x.c @@ -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,10 @@ 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 +1844,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 +1858,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 +1903,7 @@ egg_asn1x_encode (GNode *asn, return bytes; } - egg_bytes_unref (bytes); + g_bytes_unref (bytes); anode_encode_rollback (asn); return NULL; } @@ -2769,10 +2769,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 +2786,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 +2832,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 +2857,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 +2866,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 +2891,11 @@ 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, NULL); g_return_if_fail (p != NULL); sign = !!(p[0] & 0x80); - len = egg_bytes_get_size (value); + len = g_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,12 +3090,12 @@ 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); } gboolean egg_asn1x_set_string_as_bytes (GNode *node, - EggBytes *data) + GBytes *data) { gint type; @@ -3104,8 +3105,8 @@ egg_asn1x_set_string_as_bytes (GNode *node, type = anode_def_type (node); g_return_val_if_fail (type == EGG_ASN1X_OCTET_STRING || type == EGG_ASN1X_GENERALSTRING, FALSE); - anode_encode_tlv_and_enc (node, egg_bytes_get_size (data), anode_encoder_bytes, - egg_bytes_ref (data), egg_bytes_unref); + anode_encode_tlv_and_enc (node, g_bytes_get_size (data), anode_encoder_bytes, + g_bytes_ref (data), (GDestroyNotify)g_bytes_unref); return TRUE; } @@ -3166,10 +3167,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; @@ -3190,22 +3191,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; @@ -3295,7 +3297,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); @@ -4187,7 +4189,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; diff --git a/egg/egg-asn1x.h b/egg/egg-asn1x.h index 50cdfe5f..f4d4da9d 100644 --- a/egg/egg-asn1x.h +++ b/egg/egg-asn1x.h @@ -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,20 +155,20 @@ 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); gboolean egg_asn1x_set_string_as_bytes (GNode *node, - EggBytes *data); + GBytes *data); -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 index 8f58da2c..00000000 --- a/egg/egg-bytes.c +++ /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 index d25432fa..00000000 --- a/egg/egg-bytes.h +++ /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__ */ diff --git a/egg/egg-dn.c b/egg/egg-dn.c index 2ec5751c..e3b092ef 100644 --- a/egg/egg-dn.c +++ b/egg/egg-dn.c @@ -33,10 +33,10 @@ 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); } diff --git a/egg/egg-dn.h b/egg/egg-dn.h index 08251eca..a75e73dd 100644 --- a/egg/egg-dn.h +++ b/egg/egg-dn.h @@ -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, diff --git a/egg/egg-openssl.c b/egg/egg-openssl.c index 2433f076..5515be12 100644 --- a/egg/egg-openssl.c +++ b/egg/egg-openssl.c @@ -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); diff --git a/egg/egg-openssl.h b/egg/egg-openssl.h index 642d9062..6c94a7ba 100644 --- a/egg/egg-openssl.h +++ b/egg/egg-openssl.h @@ -26,20 +26,18 @@ #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); diff --git a/egg/egg-symkey.c b/egg/egg-symkey.c index 6af17513..8d4865c1 100644 --- a/egg/egg-symkey.c +++ b/egg/egg-symkey.c @@ -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) { diff --git a/egg/egg-symkey.h b/egg/egg-symkey.h index de9eb8b8..a7410ae4 100644 --- a/egg/egg-symkey.h +++ b/egg/egg-symkey.h @@ -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); diff --git a/egg/egg-testing.h b/egg/egg-testing.h index 393f4cb6..1ebf56b7 100644 --- a/egg/egg-testing.h +++ b/egg/egg-testing.h @@ -39,10 +39,10 @@ #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, diff --git a/egg/tests/test-asn1.c b/egg/tests/test-asn1.c index 7844c922..6a71b9e5 100644 --- a/egg/tests/test-asn1.c +++ b/egg/tests/test-asn1.c @@ -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), - 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); @@ -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); } diff --git a/egg/tests/test-asn1x.c b/egg/tests/test-asn1x.c index 720d62a9..4581756b 100644 --- a/egg/tests/test-asn1x.c +++ b/egg/tests/test-asn1x.c @@ -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 diff --git a/egg/tests/test-dn.c b/egg/tests/test-dn.c index 929cec2a..cf83dcb7 100644 --- a/egg/tests/test-dn.c +++ b/egg/tests/test-dn.c @@ -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 diff --git a/egg/tests/test-openssl.c b/egg/tests/test-openssl.c index 87596fd5..562f2000 100644 --- a/egg/tests/test-openssl.c +++ b/egg/tests/test-openssl.c @@ -36,12 +36,10 @@ #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); diff --git a/pkcs11/gkm/gkm-attributes.c b/pkcs11/gkm/gkm-attributes.c index 71f6af92..fb284886 100644 --- a/pkcs11/gkm/gkm-attributes.c +++ b/pkcs11/gkm/gkm-attributes.c @@ -248,9 +248,10 @@ gkm_attribute_set_data (CK_ATTRIBUTE_PTR attr, gconstpointer value, gsize n_valu CK_RV gkm_attribute_set_bytes (CK_ATTRIBUTE_PTR attr, - EggBytes *value) + GBytes *value) { - return gkm_attribute_set_data (attr, egg_bytes_get_data (value), egg_bytes_get_size (value)); + return gkm_attribute_set_data (attr, g_bytes_get_data (value, NULL), + g_bytes_get_size (value)); } CK_RV diff --git a/pkcs11/gkm/gkm-attributes.h b/pkcs11/gkm/gkm-attributes.h index 3c300af4..3f45a1b6 100644 --- a/pkcs11/gkm/gkm-attributes.h +++ b/pkcs11/gkm/gkm-attributes.h @@ -28,8 +28,6 @@ #include "pkcs11/pkcs11.h" -#include "egg/egg-bytes.h" - CK_RV gkm_attribute_get_bool (CK_ATTRIBUTE_PTR attr, gboolean *value); @@ -70,7 +68,7 @@ CK_RV gkm_attribute_set_data (CK_ATTRI gsize n_value); CK_RV gkm_attribute_set_bytes (CK_ATTRIBUTE_PTR attr, - EggBytes *value); + GBytes *value); CK_RV gkm_attribute_set_mpi (CK_ATTRIBUTE_PTR attr, gcry_mpi_t mpi); diff --git a/pkcs11/gkm/gkm-certificate.c b/pkcs11/gkm/gkm-certificate.c index 5efe036e..e2936f39 100644 --- a/pkcs11/gkm/gkm-certificate.c +++ b/pkcs11/gkm/gkm-certificate.c @@ -55,7 +55,7 @@ enum { struct _GkmCertificatePrivate { GkmCertificateKey *key; GNode *asn1; - EggBytes *der; + GBytes *der; gchar *label; }; @@ -123,7 +123,7 @@ factory_create_certificate (GkmSession *session, GkmTransaction *transaction, { CK_ATTRIBUTE_PTR attr; GkmCertificate *cert; - EggBytes *bytes; + GBytes *bytes; gboolean ret; g_return_val_if_fail (GKM_IS_TRANSACTION (transaction), NULL); @@ -142,9 +142,9 @@ factory_create_certificate (GkmSession *session, GkmTransaction *transaction, NULL); /* Load the certificate from the data specified */ - bytes = egg_bytes_new (attr->pValue, attr->ulValueLen); + bytes = g_bytes_new (attr->pValue, attr->ulValueLen); ret = gkm_serializable_load (GKM_SERIALIZABLE (cert), NULL, bytes); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); if(!ret) { gkm_transaction_fail (transaction, CKR_ATTRIBUTE_VALUE_INVALID); @@ -171,7 +171,7 @@ gkm_certificate_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATT { GkmCertificate *self = GKM_CERTIFICATE (base); CK_ULONG category; - EggBytes *cdata; + GBytes *cdata; guchar *data; gsize n_data; time_t when; @@ -205,8 +205,8 @@ gkm_certificate_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATT g_return_val_if_fail (n_data && n_data > 3, CKR_GENERAL_ERROR); data = g_new0 (guchar, n_data); gcry_md_hash_buffer (GCRY_MD_SHA1, data, - egg_bytes_get_data (self->pv->der), - egg_bytes_get_size (self->pv->der)); + g_bytes_get_data (self->pv->der, NULL), + g_bytes_get_size (self->pv->der)); rv = gkm_attribute_set_data (attr, data, 3); g_free (data); return rv; @@ -227,7 +227,7 @@ gkm_certificate_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATT cdata = egg_asn1x_get_element_raw (egg_asn1x_node (self->pv->asn1, "tbsCertificate", "subject", NULL)); g_return_val_if_fail (cdata, CKR_GENERAL_ERROR); rv = gkm_attribute_set_bytes (attr, cdata); - egg_bytes_unref (cdata); + g_bytes_unref (cdata); return rv; case CKA_ID: @@ -240,7 +240,7 @@ gkm_certificate_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATT cdata = egg_asn1x_get_element_raw (egg_asn1x_node (self->pv->asn1, "tbsCertificate", "issuer", NULL)); g_return_val_if_fail (cdata, CKR_GENERAL_ERROR); rv = gkm_attribute_set_bytes (attr, cdata); - egg_bytes_unref (cdata); + g_bytes_unref (cdata); return rv; case CKA_SERIAL_NUMBER: @@ -248,7 +248,7 @@ gkm_certificate_real_get_attribute (GkmObject *base, GkmSession *session, CK_ATT cdata = egg_asn1x_get_element_raw (egg_asn1x_node (self->pv->asn1, "tbsCertificate", "serialNumber", NULL)); g_return_val_if_fail (cdata, CKR_GENERAL_ERROR); rv = gkm_attribute_set_bytes (attr, cdata); - egg_bytes_unref (cdata); + g_bytes_unref (cdata); return rv; case CKA_VALUE: @@ -305,7 +305,7 @@ gkm_certificate_finalize (GObject *obj) g_assert (!self->pv->key); if (self->pv->der) - egg_bytes_unref (self->pv->der); + g_bytes_unref (self->pv->der); g_free (self->pv->label); egg_asn1x_destroy (self->pv->asn1); @@ -378,16 +378,16 @@ gkm_certificate_class_init (GkmCertificateClass *klass) static gboolean gkm_certificate_real_load (GkmSerializable *base, GkmSecret *login, - EggBytes *data) + GBytes *data) { GkmCertificate *self = GKM_CERTIFICATE (base); GNode *asn1 = NULL; GkmDataResult res; - EggBytes *keydata; + GBytes *keydata; gcry_sexp_t sexp; GkmSexp *wrapper; - if (egg_bytes_get_size (data) == 0) { + if (g_bytes_get_size (data) == 0) { gkm_debug ("cannot load empty certificate file"); return FALSE; } @@ -405,7 +405,7 @@ gkm_certificate_real_load (GkmSerializable *base, /* Now create us a nice public key with that identifier */ res = gkm_data_der_read_public_key_info (keydata, &sexp); - egg_bytes_unref (keydata); + g_bytes_unref (keydata); switch (res) { @@ -439,9 +439,9 @@ gkm_certificate_real_load (GkmSerializable *base, break; } - egg_bytes_ref (data); + g_bytes_ref (data); if (self->pv->der) - egg_bytes_unref (self->pv->der); + g_bytes_unref (self->pv->der); self->pv->der = data; egg_asn1x_destroy (self->pv->asn1); @@ -450,7 +450,7 @@ gkm_certificate_real_load (GkmSerializable *base, return TRUE; } -static EggBytes * +static GBytes * gkm_certificate_real_save (GkmSerializable *base, GkmSecret *login) { @@ -458,7 +458,7 @@ gkm_certificate_real_save (GkmSerializable *base, g_return_val_if_fail (GKM_IS_CERTIFICATE (self), FALSE); - return egg_bytes_ref (self->pv->der); + return g_bytes_ref (self->pv->der); } static void @@ -476,7 +476,7 @@ gkm_certificate_serializable (GkmSerializableIface *iface) gboolean gkm_certificate_calc_category (GkmCertificate *self, GkmSession *session, CK_ULONG* category) { - EggBytes *extension; + GBytes *extension; GkmManager *manager; GkmDataResult res; gboolean is_ca; @@ -522,7 +522,7 @@ gkm_certificate_get_public_key (GkmCertificate *self) return self->pv->key; } -EggBytes * +GBytes * gkm_certificate_get_extension (GkmCertificate *self, GQuark oid, gboolean *critical) { @@ -609,8 +609,8 @@ gkm_certificate_hash (GkmCertificate *self, int hash_algo, gsize *n_hash) g_return_val_if_fail (*n_hash > 0, NULL); hash = g_malloc0 (*n_hash); - gcry_md_hash_buffer (hash_algo, hash, egg_bytes_get_data (self->pv->der), - egg_bytes_get_size (self->pv->der)); + gcry_md_hash_buffer (hash_algo, hash, g_bytes_get_data (self->pv->der, NULL), + g_bytes_get_size (self->pv->der)); return hash; } @@ -622,8 +622,8 @@ gkm_certificate_der_data (GkmCertificate *self, gsize *n_data) g_return_val_if_fail (self->pv->der != NULL, NULL); g_return_val_if_fail (n_data, NULL); - *n_data = egg_bytes_get_size (self->pv->der); - return egg_bytes_get_data (self->pv->der); + *n_data = g_bytes_get_size (self->pv->der); + return g_bytes_get_data (self->pv->der, NULL); } GkmFactory* diff --git a/pkcs11/gkm/gkm-certificate.h b/pkcs11/gkm/gkm-certificate.h index 506a17fa..850f7fed 100644 --- a/pkcs11/gkm/gkm-certificate.h +++ b/pkcs11/gkm/gkm-certificate.h @@ -27,8 +27,6 @@ #include "gkm-object.h" #include "gkm-types.h" -#include "egg/egg-bytes.h" - #define GKM_FACTORY_CERTIFICATE (gkm_certificate_get_factory ()) #define GKM_TYPE_CERTIFICATE (gkm_certificate_get_type ()) @@ -60,7 +58,7 @@ gboolean gkm_certificate_calc_category (GkmCertificat GkmCertificateKey* gkm_certificate_get_public_key (GkmCertificate *self); -EggBytes * gkm_certificate_get_extension (GkmCertificate *self, +GBytes * gkm_certificate_get_extension (GkmCertificate *self, GQuark oid, gboolean *critical); diff --git a/pkcs11/gkm/gkm-data-asn1.c b/pkcs11/gkm/gkm-data-asn1.c index 57658622..49629c40 100644 --- a/pkcs11/gkm/gkm-data-asn1.c +++ b/pkcs11/gkm/gkm-data-asn1.c @@ -31,7 +31,7 @@ gboolean gkm_data_asn1_read_mpi (GNode *asn, gcry_mpi_t *mpi) { gcry_error_t gcry; - EggBytes *buf; + GBytes *buf; gsize sz; g_return_val_if_fail (asn, FALSE); @@ -42,8 +42,8 @@ gkm_data_asn1_read_mpi (GNode *asn, gcry_mpi_t *mpi) return FALSE; /* Automatically stores in secure memory if DER data is secure */ - sz = egg_bytes_get_size (buf); - gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, egg_bytes_get_data (buf), sz, &sz); + sz = g_bytes_get_size (buf); + gcry = gcry_mpi_scan (mpi, GCRYMPI_FMT_STD, g_bytes_get_data (buf, NULL), sz, &sz); if (gcry != 0) return FALSE; @@ -54,7 +54,7 @@ gboolean gkm_data_asn1_write_mpi (GNode *asn, gcry_mpi_t mpi) { gcry_error_t gcry; - EggBytes *bytes; + GBytes *bytes; gsize len; guchar *buf; @@ -71,9 +71,9 @@ gkm_data_asn1_write_mpi (GNode *asn, gcry_mpi_t mpi) gcry = gcry_mpi_print (GCRYMPI_FMT_STD, buf, len, &len, mpi); g_return_val_if_fail (gcry == 0, FALSE); - bytes = egg_bytes_new_with_free_func (buf, len, gcry_free, buf); + bytes = g_bytes_new_with_free_func (buf, len, gcry_free, buf); egg_asn1x_set_integer_as_raw (asn, bytes); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); return TRUE; } diff --git a/pkcs11/gkm/gkm-data-der.c b/pkcs11/gkm/gkm-data-der.c index 0dfc76d7..62114250 100644 --- a/pkcs11/gkm/gkm-data-der.c +++ b/pkcs11/gkm/gkm-data-der.c @@ -77,7 +77,7 @@ init_quarks (void) " (e %m)))" GkmDataResult -gkm_data_der_read_public_key_rsa (EggBytes *data, +gkm_data_der_read_public_key_rsa (GBytes *data, gcry_sexp_t *s_key) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; @@ -126,7 +126,7 @@ done: " (u %m)))" GkmDataResult -gkm_data_der_read_private_key_rsa (EggBytes *data, +gkm_data_der_read_private_key_rsa (GBytes *data, gcry_sexp_t *s_key) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; @@ -204,7 +204,7 @@ done: " (y %m)))" GkmDataResult -gkm_data_der_read_public_key_dsa (EggBytes *data, +gkm_data_der_read_public_key_dsa (GBytes *data, gcry_sexp_t *s_key) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; @@ -247,8 +247,8 @@ done: } GkmDataResult -gkm_data_der_read_public_key_dsa_parts (EggBytes *keydata, - EggBytes *params, +gkm_data_der_read_public_key_dsa_parts (GBytes *keydata, + GBytes *params, gcry_sexp_t *s_key) { gcry_mpi_t p, q, g, y; @@ -305,7 +305,7 @@ done: " (x %m)))" GkmDataResult -gkm_data_der_read_private_key_dsa (EggBytes *data, +gkm_data_der_read_private_key_dsa (GBytes *data, gcry_sexp_t *s_key) { gcry_mpi_t p, q, g, y, x; @@ -350,8 +350,8 @@ done: } GkmDataResult -gkm_data_der_read_private_key_dsa_parts (EggBytes *keydata, - EggBytes *params, +gkm_data_der_read_private_key_dsa_parts (GBytes *keydata, + GBytes *params, gcry_sexp_t *s_key) { gcry_mpi_t p, q, g, y, x; @@ -404,7 +404,7 @@ done: } GkmDataResult -gkm_data_der_read_public_key (EggBytes *data, gcry_sexp_t *s_key) +gkm_data_der_read_public_key (GBytes *data, gcry_sexp_t *s_key) { GkmDataResult res; @@ -416,14 +416,14 @@ gkm_data_der_read_public_key (EggBytes *data, gcry_sexp_t *s_key) } GkmDataResult -gkm_data_der_read_public_key_info (EggBytes *data, +gkm_data_der_read_public_key_info (GBytes *data, gcry_sexp_t* s_key) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; GQuark oid; GNode *asn = NULL; - EggBytes *params; - EggBytes *key = NULL; + GBytes *params; + GBytes *key = NULL; guint n_bits; init_quarks (); @@ -458,7 +458,7 @@ gkm_data_der_read_public_key_info (EggBytes *data, if (!params) goto done; ret = gkm_data_der_read_public_key_dsa_parts (key, params, s_key); - egg_bytes_unref (params); + g_bytes_unref (params); } else { g_message ("unsupported key algorithm in certificate: %s", g_quark_to_string (oid)); @@ -469,7 +469,7 @@ gkm_data_der_read_public_key_info (EggBytes *data, done: egg_asn1x_destroy (asn); if (key) - egg_bytes_unref (key); + g_bytes_unref (key); if (ret == GKM_DATA_FAILURE) g_message ("invalid subject public-key info"); @@ -478,7 +478,7 @@ done: } GkmDataResult -gkm_data_der_read_private_key (EggBytes *data, +gkm_data_der_read_private_key (GBytes *data, gcry_sexp_t *s_key) { GkmDataResult res; @@ -491,15 +491,15 @@ gkm_data_der_read_private_key (EggBytes *data, } GkmDataResult -gkm_data_der_read_private_pkcs8_plain (EggBytes *data, +gkm_data_der_read_private_pkcs8_plain (GBytes *data, gcry_sexp_t *s_key) { GNode *asn = NULL; GkmDataResult ret; int algorithm; GQuark key_algo; - EggBytes *keydata = NULL; - EggBytes *params = NULL; + GBytes *keydata = NULL; + GBytes *params = NULL; ret = GKM_DATA_UNRECOGNIZED; @@ -558,15 +558,15 @@ done: } if (params) - egg_bytes_unref (params); + g_bytes_unref (params); if (keydata) - egg_bytes_unref (keydata); + g_bytes_unref (keydata); egg_asn1x_destroy (asn); return ret; } GkmDataResult -gkm_data_der_read_private_pkcs8_crypted (EggBytes *data, +gkm_data_der_read_private_pkcs8_crypted (GBytes *data, const gchar *password, gsize n_password, gcry_sexp_t *s_key) @@ -577,8 +577,8 @@ gkm_data_der_read_private_pkcs8_crypted (EggBytes *data, GkmDataResult ret, r; GQuark scheme; guchar *crypted = NULL; - EggBytes *params; - EggBytes *bytes; + GBytes *params; + GBytes *bytes; gsize n_crypted; gint l; @@ -605,7 +605,7 @@ gkm_data_der_read_private_pkcs8_crypted (EggBytes *data, * Parse the encryption stuff into a cipher. */ r = egg_symkey_read_cipher (scheme, password, n_password, params, &cih); - egg_bytes_unref (params); + g_bytes_unref (params); if (r == GKM_DATA_UNRECOGNIZED) { ret = GKM_DATA_FAILURE; @@ -637,12 +637,12 @@ gkm_data_der_read_private_pkcs8_crypted (EggBytes *data, } n_crypted = l; - bytes = egg_bytes_new_with_free_func (crypted, n_crypted, egg_secure_free, crypted); + bytes = g_bytes_new_with_free_func (crypted, n_crypted, egg_secure_free, crypted); crypted = NULL; /* Try to parse the resulting key */ ret = gkm_data_der_read_private_pkcs8_plain (bytes, s_key); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); /* If unrecognized we assume bad password */ if (ret == GKM_DATA_UNRECOGNIZED) @@ -658,7 +658,7 @@ done: } GkmDataResult -gkm_data_der_read_private_pkcs8 (EggBytes *data, +gkm_data_der_read_private_pkcs8 (GBytes *data, const gchar *password, gsize n_password, gcry_sexp_t *s_key) @@ -672,12 +672,12 @@ gkm_data_der_read_private_pkcs8 (EggBytes *data, return res; } -EggBytes * +GBytes * gkm_data_der_write_public_key_rsa (gcry_sexp_t s_key) { GNode *asn = NULL; gcry_mpi_t n, e; - EggBytes *result = NULL; + GBytes *result = NULL; n = e = NULL; @@ -704,12 +704,12 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_private_key_rsa (gcry_sexp_t s_key) { GNode *asn = NULL; gcry_mpi_t n, e, d, p, q, u, e1, e2, tmp; - EggBytes *result = NULL; + GBytes *result = NULL; n = e = d = p = q = u = e1 = e2 = tmp = NULL; @@ -770,12 +770,12 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_public_key_dsa (gcry_sexp_t s_key) { GNode *asn = NULL; gcry_mpi_t p, q, g, y; - EggBytes *result = NULL; + GBytes *result = NULL; p = q = g = y = NULL; @@ -811,12 +811,12 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_private_key_dsa_part (gcry_sexp_t skey) { GNode *asn = NULL; gcry_mpi_t x; - EggBytes *result = NULL; + GBytes *result = NULL; x = NULL; @@ -840,12 +840,12 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_private_key_dsa_params (gcry_sexp_t skey) { GNode *asn = NULL; gcry_mpi_t p, q, g; - EggBytes *result = NULL; + GBytes *result = NULL; p = q = g = NULL; @@ -875,12 +875,12 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_private_key_dsa (gcry_sexp_t s_key) { GNode *asn = NULL; gcry_mpi_t p, q, g, y, x; - EggBytes *result = NULL; + GBytes *result = NULL; p = q = g = y = x = NULL; @@ -919,7 +919,7 @@ done: return result; } -EggBytes * +GBytes * gkm_data_der_write_public_key (gcry_sexp_t s_key) { gboolean is_priv; @@ -942,7 +942,7 @@ gkm_data_der_write_public_key (gcry_sexp_t s_key) } } -EggBytes * +GBytes * gkm_data_der_write_private_key (gcry_sexp_t s_key) { gboolean is_priv; @@ -974,7 +974,7 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, guchar salt[8]; gcry_error_t gcry; guchar *key, *iv; - EggBytes *portion; + GBytes *portion; gsize n_key; int iterations; @@ -1019,7 +1019,7 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, if (!egg_asn1x_set_element_raw (egg_asn1x_node (asn, "encryptionAlgorithm", "parameters", NULL), portion)) g_return_val_if_reached (NULL); - egg_bytes_unref (portion); + g_bytes_unref (portion); /* Now make a cipher that matches what we wrote out */ gcry = gcry_cipher_open (&cih, GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC, 0); @@ -1036,16 +1036,16 @@ prepare_and_encode_pkcs8_cipher (GNode *asn, const gchar *password, return cih; } -EggBytes * +GBytes * gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey) { GNode *asn = NULL; int algorithm; gboolean is_priv; GQuark oid; - EggBytes *params; - EggBytes *key; - EggBytes *data; + GBytes *params; + GBytes *key; + GBytes *data; init_quarks (); @@ -1092,14 +1092,14 @@ gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey) if (!egg_asn1x_set_element_raw (egg_asn1x_node (asn, "privateKeyAlgorithm", "parameters", NULL), params)) g_return_val_if_reached (NULL); - egg_bytes_unref (params); + g_bytes_unref (params); } /* Write out the key portion */ if (!egg_asn1x_set_string_as_bytes (egg_asn1x_node (asn, "privateKey", NULL), key)) g_return_val_if_reached (NULL); - egg_bytes_unref (key); + g_bytes_unref (key); data = egg_asn1x_encode (asn, egg_secure_realloc); if (data == NULL) @@ -1109,7 +1109,7 @@ gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey) return data; } -EggBytes * +GBytes * gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, const gchar *password, gsize n_password) @@ -1117,7 +1117,7 @@ gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, gcry_error_t gcry; gcry_cipher_hd_t cih; GNode *asn = NULL; - EggBytes *key, *data; + GBytes *key, *data; guchar *raw; gsize n_raw, n_key; gsize block = 0; @@ -1134,7 +1134,7 @@ gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, cih = prepare_and_encode_pkcs8_cipher (asn, password, n_password, &block); g_return_val_if_fail (cih, NULL); - n_key = egg_bytes_get_size (key); + n_key = g_bytes_get_size (key); /* Pad the block of data */ if(block > 1) { @@ -1142,29 +1142,29 @@ gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, if (n_pad == 0) n_pad = block; raw = egg_secure_alloc (n_key + n_pad); - memcpy (raw, egg_bytes_get_data (key), n_key); + memcpy (raw, g_bytes_get_data (key, NULL), n_key); memset (raw + n_key, (int)n_pad, n_pad); n_raw = n_key + n_pad; /* No padding, probably stream cipher */ } else { raw = egg_secure_alloc (n_key); - memcpy (raw, egg_bytes_get_data (key), n_key); + memcpy (raw, g_bytes_get_data (key, NULL), n_key); n_raw = n_key; } - egg_bytes_unref (key); + g_bytes_unref (key); gcry = gcry_cipher_encrypt (cih, raw, n_raw, NULL, 0); g_return_val_if_fail (gcry == 0, NULL); gcry_cipher_close (cih); - key = egg_bytes_new_with_free_func (raw, n_raw, egg_secure_free, raw); + key = g_bytes_new_with_free_func (raw, n_raw, egg_secure_free, raw); if (!egg_asn1x_set_string_as_bytes (egg_asn1x_node (asn, "encryptedData", NULL), key)) g_return_val_if_reached (NULL); - egg_bytes_unref (key); + g_bytes_unref (key); data = egg_asn1x_encode (asn, NULL); if (data == NULL) @@ -1179,7 +1179,7 @@ gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, */ GkmDataResult -gkm_data_der_read_certificate (EggBytes *data, +gkm_data_der_read_certificate (GBytes *data, GNode **asn1) { *asn1 = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data); @@ -1190,7 +1190,7 @@ gkm_data_der_read_certificate (EggBytes *data, } GkmDataResult -gkm_data_der_read_basic_constraints (EggBytes *data, +gkm_data_der_read_basic_constraints (GBytes *data, gboolean *is_ca, gint *path_len) { @@ -1234,7 +1234,7 @@ done: } GkmDataResult -gkm_data_der_read_key_usage (EggBytes *data, +gkm_data_der_read_key_usage (GBytes *data, gulong *key_usage) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; @@ -1258,7 +1258,7 @@ done: } GkmDataResult -gkm_data_der_read_enhanced_usage (EggBytes *data, +gkm_data_der_read_enhanced_usage (GBytes *data, GQuark **usage_oids) { GkmDataResult ret = GKM_DATA_UNRECOGNIZED; @@ -1293,10 +1293,10 @@ done: } -EggBytes * +GBytes * gkm_data_der_write_certificate (GNode *asn1) { - EggBytes *result; + GBytes *result; g_return_val_if_fail (asn1, NULL); diff --git a/pkcs11/gkm/gkm-data-der.h b/pkcs11/gkm/gkm-data-der.h index f98ec6bc..70157d42 100644 --- a/pkcs11/gkm/gkm-data-der.h +++ b/pkcs11/gkm/gkm-data-der.h @@ -30,50 +30,49 @@ #include "gkm-data-types.h" #include "egg/egg-asn1x.h" -#include "egg/egg-bytes.h" /* ----------------------------------------------------------------------------- * PRIVATE KEYS */ -GkmDataResult gkm_data_der_read_private_key_rsa (EggBytes *data, +GkmDataResult gkm_data_der_read_private_key_rsa (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_key_dsa (EggBytes *data, +GkmDataResult gkm_data_der_read_private_key_dsa (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_key_dsa_parts (EggBytes *keydata, - EggBytes *params, +GkmDataResult gkm_data_der_read_private_key_dsa_parts (GBytes *keydata, + GBytes *params, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_key (EggBytes *data, +GkmDataResult gkm_data_der_read_private_key (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_pkcs8 (EggBytes *data, +GkmDataResult gkm_data_der_read_private_pkcs8 (GBytes *data, const gchar *password, gsize n_password, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_pkcs8_plain (EggBytes *data, +GkmDataResult gkm_data_der_read_private_pkcs8_plain (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_private_pkcs8_crypted (EggBytes *data, +GkmDataResult gkm_data_der_read_private_pkcs8_crypted (GBytes *data, const gchar *password, gsize n_password, gcry_sexp_t *s_key); -EggBytes * gkm_data_der_write_private_key_rsa (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_private_key_rsa (gcry_sexp_t s_key); -EggBytes * gkm_data_der_write_private_key_dsa (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_private_key_dsa (gcry_sexp_t s_key); -EggBytes * gkm_data_der_write_private_key_dsa_part (gcry_sexp_t skey); +GBytes * gkm_data_der_write_private_key_dsa_part (gcry_sexp_t skey); -EggBytes * gkm_data_der_write_private_key_dsa_params (gcry_sexp_t skey); +GBytes * gkm_data_der_write_private_key_dsa_params (gcry_sexp_t skey); -EggBytes * gkm_data_der_write_private_key (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_private_key (gcry_sexp_t s_key); -EggBytes * gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey); +GBytes * gkm_data_der_write_private_pkcs8_plain (gcry_sexp_t skey); -EggBytes * gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, +GBytes * gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, const gchar *password, gsize n_password); @@ -81,46 +80,46 @@ EggBytes * gkm_data_der_write_private_pkcs8_crypted (gcry_sexp_t skey, * PUBLIC KEYS */ -GkmDataResult gkm_data_der_read_public_key_rsa (EggBytes *data, +GkmDataResult gkm_data_der_read_public_key_rsa (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_public_key_dsa (EggBytes *data, +GkmDataResult gkm_data_der_read_public_key_dsa (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_public_key_dsa_parts (EggBytes *keydata, - EggBytes *params, +GkmDataResult gkm_data_der_read_public_key_dsa_parts (GBytes *keydata, + GBytes *params, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_public_key (EggBytes *data, +GkmDataResult gkm_data_der_read_public_key (GBytes *data, gcry_sexp_t *s_key); -GkmDataResult gkm_data_der_read_public_key_info (EggBytes *data, +GkmDataResult gkm_data_der_read_public_key_info (GBytes *data, gcry_sexp_t *s_key); -EggBytes * gkm_data_der_write_public_key_rsa (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_public_key_rsa (gcry_sexp_t s_key); -EggBytes * gkm_data_der_write_public_key_dsa (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_public_key_dsa (gcry_sexp_t s_key); -EggBytes * gkm_data_der_write_public_key (gcry_sexp_t s_key); +GBytes * gkm_data_der_write_public_key (gcry_sexp_t s_key); /* ----------------------------------------------------------------------------- * CERTIFICATES */ -GkmDataResult gkm_data_der_read_certificate (EggBytes *data, +GkmDataResult gkm_data_der_read_certificate (GBytes *data, GNode **asn1); -GkmDataResult gkm_data_der_read_basic_constraints (EggBytes *data, +GkmDataResult gkm_data_der_read_basic_constraints (GBytes *data, gboolean *is_ca, gint *path_len); -GkmDataResult gkm_data_der_read_key_usage (EggBytes *data, +GkmDataResult gkm_data_der_read_key_usage (GBytes *data, gulong *key_usage); -GkmDataResult gkm_data_der_read_enhanced_usage (EggBytes *data, +GkmDataResult gkm_data_der_read_enhanced_usage (GBytes *data, GQuark **oids); -EggBytes * gkm_data_der_write_certificate (GNode *asn1); +GBytes * gkm_data_der_write_certificate (GNode *asn1); #endif /*GKRPKIXDER_H_*/ diff --git a/pkcs11/gkm/gkm-serializable.c b/pkcs11/gkm/gkm-serializable.c index 4fab9e51..49ddd032 100644 --- a/pkcs11/gkm/gkm-serializable.c +++ b/pkcs11/gkm/gkm-serializable.c @@ -63,7 +63,7 @@ gkm_serializable_get_type (void) } gboolean -gkm_serializable_load (GkmSerializable *self, GkmSecret *login, EggBytes *data) +gkm_serializable_load (GkmSerializable *self, GkmSecret *login, GBytes *data) { g_return_val_if_fail (GKM_IS_SERIALIZABLE (self), FALSE); g_return_val_if_fail (data != NULL, FALSE); @@ -71,7 +71,7 @@ gkm_serializable_load (GkmSerializable *self, GkmSecret *login, EggBytes *data) return GKM_SERIALIZABLE_GET_INTERFACE (self)->load (self, login, data); } -EggBytes * +GBytes * gkm_serializable_save (GkmSerializable *self, GkmSecret *login) { g_return_val_if_fail (GKM_IS_SERIALIZABLE (self), FALSE); diff --git a/pkcs11/gkm/gkm-serializable.h b/pkcs11/gkm/gkm-serializable.h index 8e773ec2..0b96dd99 100644 --- a/pkcs11/gkm/gkm-serializable.h +++ b/pkcs11/gkm/gkm-serializable.h @@ -26,8 +26,6 @@ #include "gkm-types.h" -#include "egg/egg-bytes.h" - G_BEGIN_DECLS #define GKM_TYPE_SERIALIZABLE (gkm_serializable_get_type()) @@ -45,9 +43,9 @@ struct _GkmSerializableIface { gboolean (*load) (GkmSerializable *self, GkmSecret *login, - EggBytes *data); + GBytes *data); - EggBytes * (*save) (GkmSerializable *self, + GBytes * (*save) (GkmSerializable *self, GkmSecret *login); }; @@ -55,9 +53,9 @@ GType gkm_serializable_get_type (void) gboolean gkm_serializable_load (GkmSerializable *self, GkmSecret *login, - EggBytes *data); + GBytes *data); -EggBytes * gkm_serializable_save (GkmSerializable *self, +GBytes * gkm_serializable_save (GkmSerializable *self, GkmSecret *login); G_END_DECLS diff --git a/pkcs11/gkm/tests/test-certificate.c b/pkcs11/gkm/tests/test-certificate.c index 19279268..a1f5fe53 100644 --- a/pkcs11/gkm/tests/test-certificate.c +++ b/pkcs11/gkm/tests/test-certificate.c @@ -40,7 +40,7 @@ typedef struct { GkmModule *module; GkmSession *session; - EggBytes *certificate_data; + GBytes *certificate_data; GkmCertificate *certificate; } Test; @@ -57,20 +57,20 @@ setup_basic (Test* test, if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &data, &length, NULL)) g_assert_not_reached (); - test->certificate_data = egg_bytes_new_take (data, length); + test->certificate_data = g_bytes_new_take (data, length); } static void teardown_basic (Test* test, gconstpointer unused) { - egg_bytes_unref (test->certificate_data); + g_bytes_unref (test->certificate_data); mock_module_leave_and_finalize (); } static GkmCertificate * create_certificate_object (GkmSession *session, - EggBytes *data) + GBytes *data) { GkmCertificate *certificate; @@ -169,8 +169,8 @@ test_attribute_value (Test* test, data = gkm_object_get_attribute_data (GKM_OBJECT (test->certificate), test->session, CKA_VALUE, &n_data); - raw = egg_bytes_get_data (test->certificate_data); - n_raw = egg_bytes_get_size (test->certificate_data); + raw = g_bytes_get_data (test->certificate_data, NULL); + n_raw = g_bytes_get_size (test->certificate_data); egg_assert_cmpmem (data, n_data, ==, raw, n_raw); g_free (data); } diff --git a/pkcs11/gkm/tests/test-data-asn1.c b/pkcs11/gkm/tests/test-data-asn1.c index e9d98d65..e3808877 100644 --- a/pkcs11/gkm/tests/test-data-asn1.c +++ b/pkcs11/gkm/tests/test-data-asn1.c @@ -46,17 +46,17 @@ typedef struct { static void setup (Test *test, gconstpointer unused) { - EggBytes *data; + GBytes *data; gchar *contents; gsize length; if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &contents, &length, NULL)) g_assert_not_reached (); - data = egg_bytes_new_take (contents, length); + data = g_bytes_new_take (contents, length); test->asn1_cert = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data); g_assert (test->asn1_cert); - egg_bytes_unref (data); + g_bytes_unref (data); } static void @@ -70,7 +70,7 @@ test_asn1_integers (Test *test, gconstpointer unused) { GNode *asn; gcry_mpi_t mpi, mpt; - EggBytes *data; + GBytes *data; gboolean ret; asn = egg_asn1x_create (test_asn1_tab, "TestIntegers"); @@ -99,7 +99,7 @@ test_asn1_integers (Test *test, gconstpointer unused) g_assert ("mpi returned is null" && mpt != NULL); g_assert ("mpi is wrong number" && gcry_mpi_cmp (mpi, mpt) == 0); - egg_bytes_unref (data); + g_bytes_unref (data); } int diff --git a/pkcs11/gkm/tests/test-data-der.c b/pkcs11/gkm/tests/test-data-der.c index dc751d30..0e74027c 100644 --- a/pkcs11/gkm/tests/test-data-der.c +++ b/pkcs11/gkm/tests/test-data-der.c @@ -95,14 +95,14 @@ compare_keys (gcry_sexp_t key, gcry_sexp_t sexp) static void test_der_public (gcry_sexp_t key) { - EggBytes *data; + GBytes *data; GkmDataResult ret; gcry_sexp_t sexp; /* Encode it */ data = gkm_data_der_write_public_key (key); g_assert ("couldn't encode public key" && data != NULL); - g_assert ("encoding is empty" && egg_bytes_get_size (data) > 0); + g_assert ("encoding is empty" && g_bytes_get_size (data) > 0); /* Now parse it */ ret = gkm_data_der_read_public_key (data, &sexp); @@ -112,28 +112,28 @@ test_der_public (gcry_sexp_t key) /* Now compare them */ g_assert ("key parsed differently" && compare_keys (key, sexp)); - egg_bytes_unref (data); + g_bytes_unref (data); } static void setup (Test *test, gconstpointer unused) { - EggBytes *data; + GBytes *data; if (!g_file_get_contents (SRCDIR "/files/test-certificate-1.der", &test->certificate_data, &test->n_certificate_data, NULL)) g_assert_not_reached (); - data = egg_bytes_new (test->certificate_data, test->n_certificate_data); + data = g_bytes_new (test->certificate_data, test->n_certificate_data); test->certificate = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data); g_assert (test->certificate != NULL); - egg_bytes_unref (data); + g_bytes_unref (data); if (!g_file_get_contents (SRCDIR "/files/test-certificate-2.der", &test->certificate2_data, &test->n_certificate2_data, NULL)) g_assert_not_reached (); - data = egg_bytes_new (test->certificate2_data, test->n_certificate2_data); + data = g_bytes_new (test->certificate2_data, test->n_certificate2_data); test->certificate2 = egg_asn1x_create_and_decode (pkix_asn1_tab, "Certificate", data); g_assert (test->certificate2 != NULL); - egg_bytes_unref (data); + g_bytes_unref (data); } static void @@ -172,14 +172,14 @@ test_der_dsa_public (Test *test, gconstpointer unused) static void test_der_private (gcry_sexp_t key) { - EggBytes *data; + GBytes *data; GkmDataResult ret; gcry_sexp_t sexp; /* Encode it */ data = gkm_data_der_write_private_key (key); g_assert ("couldn't encode private key" && data != NULL); - g_assert ("encoding is empty" && egg_bytes_get_size (data) > 0); + g_assert ("encoding is empty" && g_bytes_get_size (data) > 0); /* Now parse it */ ret = gkm_data_der_read_private_key (data, &sexp); @@ -189,7 +189,7 @@ test_der_private (gcry_sexp_t key) /* Now compare them */ g_assert ("key parsed differently" && compare_keys (key, sexp)); - egg_bytes_unref (data); + g_bytes_unref (data); } static void @@ -219,7 +219,7 @@ test_der_dsa_private (Test *test, gconstpointer unused) static void test_der_dsa_private_parts (Test *test, gconstpointer unused) { - EggBytes *params, *key; + GBytes *params, *key; gcry_sexp_t skey, pkey; gcry_error_t gcry; GkmDataResult result; @@ -241,8 +241,8 @@ test_der_dsa_private_parts (Test *test, gconstpointer unused) /* Now compare them */ g_assert ("key parsed differently" && compare_keys (skey, pkey)); - egg_bytes_unref (params); - egg_bytes_unref (key); + g_bytes_unref (params); + g_bytes_unref (key); } const gchar *certpub = "(public-key (rsa " \ @@ -252,7 +252,7 @@ const gchar *certpub = "(public-key (rsa " \ static void test_read_public_key_info (Test *test, gconstpointer unused) { - EggBytes *data; + GBytes *data; guchar hash[20]; GkmDataResult res; gcry_sexp_t sexp, match; @@ -275,7 +275,7 @@ test_read_public_key_info (Test *test, gconstpointer unused) gcry_sexp_release (sexp); gcry_sexp_release (match); - egg_bytes_unref (data); + g_bytes_unref (data); } static void @@ -283,38 +283,38 @@ test_read_certificate (Test *test, gconstpointer unused) { GNode *asn = NULL; GkmDataResult res; - EggBytes *data; + GBytes *data; - data = egg_bytes_new (test->certificate_data, test->n_certificate_data); + data = g_bytes_new (test->certificate_data, test->n_certificate_data); res = gkm_data_der_read_certificate (data, &asn); g_assert (res == GKM_DATA_SUCCESS); g_assert (asn != NULL); - egg_bytes_unref (data); + g_bytes_unref (data); egg_asn1x_destroy (asn); } static void test_write_certificate (Test *test, gconstpointer unused) { - EggBytes *data; + GBytes *data; data = gkm_data_der_write_certificate (test->certificate); - g_assert (egg_bytes_get_size (data) == test->n_certificate_data); - g_assert (memcmp (egg_bytes_get_data (data), test->certificate_data, egg_bytes_get_size (data)) == 0); - egg_bytes_unref (data); + g_assert (g_bytes_get_size (data) == test->n_certificate_data); + g_assert (memcmp (g_bytes_get_data (data, NULL), test->certificate_data, g_bytes_get_size (data)) == 0); + g_bytes_unref (data); } static void on_ca_certificate_public_key_info (GQuark type, - EggBytes *data, - EggBytes *outer, + GBytes *data, + GBytes *outer, GHashTable *headers, gpointer user_data) { GNode *asn1 = NULL; GkmDataResult res; - EggBytes *keydata; + GBytes *keydata; gcry_sexp_t sexp; g_assert (g_quark_try_string ("CERTIFICATE") == type); @@ -333,29 +333,29 @@ on_ca_certificate_public_key_info (GQuark type, if (res == GKM_DATA_SUCCESS) gcry_sexp_release (sexp); - egg_bytes_unref (keydata); + g_bytes_unref (keydata); } static void test_read_ca_certificates_public_key_info (Test *test, gconstpointer unused) { - EggBytes *bytes; + GBytes *bytes; gchar *data; gsize n_data; if (!g_file_get_contents (SRCDIR "/files/ca-certificates.crt", &data, &n_data, NULL)) g_assert_not_reached (); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); egg_armor_parse (bytes, on_ca_certificate_public_key_info, NULL); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); } -static EggBytes * +static GBytes * find_extension (GNode *asn, const gchar *oid) { - EggBytes *value; + GBytes *value; GNode *node = NULL; gchar *exoid; guint index; @@ -387,7 +387,7 @@ find_extension (GNode *asn, static void test_read_basic_constraints (Test *test, gconstpointer unused) { - EggBytes *extension; + GBytes *extension; gboolean is_ca; gint path_len; GkmDataResult res; @@ -400,13 +400,13 @@ test_read_basic_constraints (Test *test, gconstpointer unused) g_assert (is_ca == TRUE); g_assert (path_len == -1); - egg_bytes_unref (extension); + g_bytes_unref (extension); } static void test_read_key_usage (Test *test, gconstpointer unused) { - EggBytes *extension; + GBytes *extension; gulong key_usage; GkmDataResult res; @@ -417,13 +417,13 @@ test_read_key_usage (Test *test, gconstpointer unused) g_assert (res == GKM_DATA_SUCCESS); g_assert_cmpuint (key_usage, ==, 0x01); - egg_bytes_unref (extension); + g_bytes_unref (extension); } static void test_read_enhanced_usage (Test *test, gconstpointer unused) { - EggBytes *extension; + GBytes *extension; GQuark *usages; GkmDataResult res; @@ -433,14 +433,14 @@ test_read_enhanced_usage (Test *test, gconstpointer unused) res = gkm_data_der_read_enhanced_usage (extension, &usages); g_assert (res == GKM_DATA_SUCCESS); - egg_bytes_unref (extension); + g_bytes_unref (extension); g_free (usages); } static void test_read_all_pkcs8 (Test *test, gconstpointer unused) { - EggBytes *bytes; + GBytes *bytes; gcry_sexp_t sexp; GkmDataResult res; GDir *dir; @@ -465,10 +465,10 @@ test_read_all_pkcs8 (Test *test, gconstpointer unused) g_assert_not_reached (); g_free (path); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); res = gkm_data_der_read_private_pkcs8 (bytes, "booo", 4, &sexp); g_assert (res == GKM_DATA_SUCCESS); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); g_assert (gkm_sexp_parse_key (sexp, NULL, NULL, NULL)); gcry_sexp_release (sexp); @@ -482,18 +482,18 @@ test_read_pkcs8_bad_password (Test *test, gconstpointer unused) { gcry_sexp_t sexp; GkmDataResult res; - EggBytes *bytes; + GBytes *bytes; gchar *data; gsize n_data; if (!g_file_get_contents (SRCDIR "/files/der-key-encrypted-pkcs5.p8", &data, &n_data, NULL)) g_assert_not_reached (); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); res = gkm_data_der_read_private_pkcs8 (bytes, "wrong password", 4, &sexp); g_assert (res == GKM_DATA_LOCKED); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); } static void @@ -502,7 +502,7 @@ test_write_pkcs8_plain (Test *test, gconstpointer unused) gcry_sexp_t sexp, check; gcry_error_t gcry; GkmDataResult res; - EggBytes *data; + GBytes *data; /* RSA */ @@ -513,7 +513,7 @@ test_write_pkcs8_plain (Test *test, gconstpointer unused) g_assert (data != NULL); res = gkm_data_der_read_private_pkcs8_plain (data, &check); - egg_bytes_unref (data); + g_bytes_unref (data); g_assert (res == GKM_DATA_SUCCESS); g_assert (check != NULL); @@ -531,7 +531,7 @@ test_write_pkcs8_plain (Test *test, gconstpointer unused) g_assert (data != NULL); res = gkm_data_der_read_private_pkcs8_plain (data, &check); - egg_bytes_unref (data); + g_bytes_unref (data); g_assert (res == GKM_DATA_SUCCESS); g_assert (check != NULL); @@ -547,7 +547,7 @@ test_write_pkcs8_encrypted (Test *test, gconstpointer unused) gcry_sexp_t sexp, check; gcry_error_t gcry; GkmDataResult res; - EggBytes *data; + GBytes *data; /* RSA */ @@ -558,7 +558,7 @@ test_write_pkcs8_encrypted (Test *test, gconstpointer unused) g_assert (data != NULL); res = gkm_data_der_read_private_pkcs8_crypted (data, "testo", 5, &check); - egg_bytes_unref (data); + g_bytes_unref (data); g_assert (res == GKM_DATA_SUCCESS); g_assert (check != NULL); @@ -576,7 +576,7 @@ test_write_pkcs8_encrypted (Test *test, gconstpointer unused) g_assert (data != NULL); res = gkm_data_der_read_private_pkcs8_crypted (data, "testo", 5, &check); - egg_bytes_unref (data); + g_bytes_unref (data); g_assert (res == GKM_DATA_SUCCESS); g_assert (check != NULL); diff --git a/pkcs11/gnome2-store/gkm-gnome2-private-key.c b/pkcs11/gnome2-store/gkm-gnome2-private-key.c index cf0e4c82..b49cc6d3 100644 --- a/pkcs11/gnome2-store/gkm-gnome2-private-key.c +++ b/pkcs11/gnome2-store/gkm-gnome2-private-key.c @@ -46,7 +46,7 @@ enum { struct _GkmGnome2PrivateKey { GkmPrivateXsaKey parent; - EggBytes *private_bytes; + GBytes *private_bytes; GkmSexp *private_sexp; gboolean is_encrypted; GkmSecret *login; @@ -157,7 +157,7 @@ gkm_gnome2_private_key_finalize (GObject *obj) g_assert (self->login == NULL); if (self->private_bytes) - egg_bytes_unref (self->private_bytes); + g_bytes_unref (self->private_bytes); if (self->private_sexp) gkm_sexp_unref (self->private_sexp); @@ -208,7 +208,7 @@ gkm_gnome2_private_key_class_init (GkmGnome2PrivateKeyClass *klass) static gboolean gkm_gnome2_private_key_real_load (GkmSerializable *base, GkmSecret *login, - EggBytes *data) + GBytes *data) { GkmGnome2PrivateKey *self = GKM_GNOME2_PRIVATE_KEY (base); GkmDataResult res; @@ -217,7 +217,7 @@ gkm_gnome2_private_key_real_load (GkmSerializable *base, const gchar *password; gsize n_password; - if (egg_bytes_get_size (data) == 0) + if (g_bytes_get_size (data) == 0) return FALSE; res = gkm_data_der_read_private_pkcs8 (data, NULL, 0, &sexp); @@ -267,8 +267,8 @@ gkm_gnome2_private_key_real_load (GkmSerializable *base, /* Encrypted private key, keep login and data */ if (self->is_encrypted) { if (self->private_bytes) - egg_bytes_unref (self->private_bytes); - self->private_bytes = egg_bytes_ref (data); + g_bytes_unref (self->private_bytes); + self->private_bytes = g_bytes_ref (data); g_object_ref (login); if (self->login) @@ -293,14 +293,14 @@ gkm_gnome2_private_key_real_load (GkmSerializable *base, return TRUE; } -static EggBytes * +static GBytes * gkm_gnome2_private_key_real_save (GkmSerializable *base, GkmSecret *login) { GkmGnome2PrivateKey *self = GKM_GNOME2_PRIVATE_KEY (base); const gchar *password = NULL; gsize n_password; GkmSexp *sexp; - EggBytes *result; + GBytes *result; g_return_val_if_fail (GKM_IS_GNOME2_PRIVATE_KEY (self), FALSE); diff --git a/pkcs11/gnome2-store/gkm-gnome2-public-key.c b/pkcs11/gnome2-store/gkm-gnome2-public-key.c index e40d18b3..1b12e664 100644 --- a/pkcs11/gnome2-store/gkm-gnome2-public-key.c +++ b/pkcs11/gnome2-store/gkm-gnome2-public-key.c @@ -122,14 +122,14 @@ gkm_gnome2_public_key_class_init (GkmGnome2PublicKeyClass *klass) static gboolean gkm_gnome2_public_key_real_load (GkmSerializable *base, GkmSecret *login, - EggBytes *data) + GBytes *data) { GkmGnome2PublicKey *self = GKM_GNOME2_PUBLIC_KEY (base); GkmDataResult res; GkmSexp *wrapper; gcry_sexp_t sexp; - if (egg_bytes_get_size (data) == 0) + if (g_bytes_get_size (data) == 0) return FALSE; res = gkm_data_der_read_public_key (data, &sexp); @@ -157,7 +157,7 @@ gkm_gnome2_public_key_real_load (GkmSerializable *base, return TRUE; } -static EggBytes * +static GBytes * gkm_gnome2_public_key_real_save (GkmSerializable *base, GkmSecret *login) { GkmGnome2PublicKey *self = GKM_GNOME2_PUBLIC_KEY (base); diff --git a/pkcs11/gnome2-store/gkm-gnome2-storage.c b/pkcs11/gnome2-store/gkm-gnome2-storage.c index 50ca3293..acfe590c 100644 --- a/pkcs11/gnome2-store/gkm-gnome2-storage.c +++ b/pkcs11/gnome2-store/gkm-gnome2-storage.c @@ -97,15 +97,15 @@ name_for_subject (const guchar *subject, { GNode *asn; gchar *name; - EggBytes *bytes; + GBytes *bytes; g_assert (subject); g_assert (n_subject); - bytes = egg_bytes_new (subject, n_subject); + bytes = g_bytes_new (subject, n_subject); asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Name", bytes); g_return_val_if_fail (asn != NULL, NULL); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); name = egg_dn_read_part (egg_asn1x_node (asn, "rdnSequence", NULL), "CN"); egg_asn1x_destroy (asn); @@ -499,7 +499,7 @@ data_file_entry_added (GkmGnome2File *store, const gchar *identifier, GkmGnome2S { GError *error = NULL; GkmObject *object; - EggBytes *bytes; + GBytes *bytes; gboolean ret; guchar *data; gsize n_data; @@ -546,7 +546,7 @@ data_file_entry_added (GkmGnome2File *store, const gchar *identifier, GkmGnome2S g_return_if_fail (GKM_IS_SERIALIZABLE (object)); g_return_if_fail (GKM_SERIALIZABLE_GET_INTERFACE (object)->extension); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); /* And load the data into it */ if (gkm_serializable_load (GKM_SERIALIZABLE (object), self->login, bytes)) @@ -554,7 +554,7 @@ data_file_entry_added (GkmGnome2File *store, const gchar *identifier, GkmGnome2S else g_message ("failed to load file in user store: %s", identifier); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); g_object_unref (object); } @@ -595,7 +595,7 @@ relock_object (GkmGnome2Storage *self, GkmTransaction *transaction, const gchar { GError *error = NULL; GkmObject *object; - EggBytes *bytes; + GBytes *bytes; gpointer data; gsize n_data; GType type; @@ -641,18 +641,18 @@ relock_object (GkmGnome2Storage *self, GkmTransaction *transaction, const gchar return; } - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); /* Load it into our temporary object */ if (!gkm_serializable_load (GKM_SERIALIZABLE (object), old_login, bytes)) { g_message ("unrecognized or invalid user store file: %s", identifier); gkm_transaction_fail (transaction, CKR_FUNCTION_FAILED); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); g_object_unref (object); return; } - egg_bytes_unref (bytes); + g_bytes_unref (bytes); /* Read it out of our temporary object */ bytes = gkm_serializable_save (GKM_SERIALIZABLE (object), new_login); @@ -673,7 +673,7 @@ relock_object (GkmGnome2Storage *self, GkmTransaction *transaction, const gchar if (!gkm_transaction_get_failed (transaction)) store_object_hash (self, transaction, identifier, data, n_data); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); } typedef struct _RelockArgs { @@ -1069,7 +1069,7 @@ gkm_gnome2_storage_create (GkmGnome2Storage *self, GkmTransaction *transaction, gboolean is_private; GkmDataResult res; gchar *identifier; - EggBytes *data; + GBytes *data; gchar *path; g_return_if_fail (GKM_IS_GNOME2_STORAGE (self)); @@ -1145,14 +1145,14 @@ gkm_gnome2_storage_create (GkmGnome2Storage *self, GkmTransaction *transaction, path = g_build_filename (self->directory, identifier, NULL); gkm_transaction_write_file (transaction, path, - egg_bytes_get_data (data), - egg_bytes_get_size (data)); + g_bytes_get_data (data, NULL), + g_bytes_get_size (data)); /* Make sure we write in the object hash */ if (!gkm_transaction_get_failed (transaction)) store_object_hash (self, transaction, identifier, - egg_bytes_get_data (data), - egg_bytes_get_size (data)); + g_bytes_get_data (data, NULL), + g_bytes_get_size (data)); /* Now we decide to own the object */ if (!gkm_transaction_get_failed (transaction)) @@ -1160,7 +1160,7 @@ gkm_gnome2_storage_create (GkmGnome2Storage *self, GkmTransaction *transaction, g_free (identifier); g_free (path); - egg_bytes_unref (data); + g_bytes_unref (data); } void diff --git a/pkcs11/gnome2-store/tests/test-gnome2-private-key.c b/pkcs11/gnome2-store/tests/test-gnome2-private-key.c index 10580cf8..127e3b40 100644 --- a/pkcs11/gnome2-store/tests/test-gnome2-private-key.c +++ b/pkcs11/gnome2-store/tests/test-gnome2-private-key.c @@ -38,7 +38,6 @@ #include "gkm/gkm-session.h" #include "gkm/gkm-test.h" -#include "egg/egg-bytes.h" #include "egg/egg-testing.h" #include "pkcs11i.h" @@ -46,7 +45,7 @@ typedef struct { GkmModule *module; GkmSession *session; - EggBytes *key_data; + GBytes *key_data; GkmGnome2PrivateKey *key; } Test; @@ -63,14 +62,14 @@ setup_basic (Test* test, if (!g_file_get_contents (SRCDIR "/files/der-key-v2-des3.p8", &data, &length, NULL)) g_assert_not_reached (); - test->key_data = egg_bytes_new_take (data, length); + test->key_data = g_bytes_new_take (data, length); } static void teardown_basic (Test* test, gconstpointer unused) { - egg_bytes_unref (test->key_data); + g_bytes_unref (test->key_data); mock_gnome2_module_leave_and_finalize (); } @@ -132,14 +131,14 @@ test_save_private_key (Test *test, gconstpointer unused) { GkmSecret *login; - EggBytes *data; + GBytes *data; gcry_sexp_t sexp; /* Save unencrypted */ data = gkm_serializable_save (GKM_SERIALIZABLE (test->key), NULL); g_assert (data != NULL); g_assert (gkm_data_der_read_private_pkcs8_plain (data, &sexp) == GKM_DATA_SUCCESS); - egg_bytes_unref (data); + g_bytes_unref (data); gcry_sexp_release (sexp); /* Save encrypted */ @@ -147,7 +146,7 @@ test_save_private_key (Test *test, data = gkm_serializable_save (GKM_SERIALIZABLE (test->key), login); g_assert (data != NULL); g_assert (gkm_data_der_read_private_pkcs8_crypted (data, "booo", 4, &sexp) == GKM_DATA_SUCCESS); - egg_bytes_unref (data); + g_bytes_unref (data); gcry_sexp_release (sexp); g_object_unref (login); } diff --git a/pkcs11/gnome2-store/tests/test-gnome2-storage.c b/pkcs11/gnome2-store/tests/test-gnome2-storage.c index a18f904b..d3f315b9 100644 --- a/pkcs11/gnome2-store/tests/test-gnome2-storage.c +++ b/pkcs11/gnome2-store/tests/test-gnome2-storage.c @@ -72,7 +72,7 @@ setup_module (Test *test, CK_ATTRIBUTE url = { CKA_URL, NULL, 0 }; gchar *contents; gsize length; - EggBytes *bytes; + GBytes *bytes; GkmManager *manager; GError *error = NULL; GkmSession *session; @@ -105,10 +105,10 @@ setup_module (Test *test, g_file_get_contents (SRCDIR "/files/test-certificate.cer", &contents, &length, &error); g_assert_no_error (error); - bytes = egg_bytes_new_take (contents, length); + bytes = g_bytes_new_take (contents, length); if (!gkm_serializable_load (GKM_SERIALIZABLE (test->new_object), NULL, bytes)) g_assert_not_reached (); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); /* We happen to know this certificate will get named */ test->new_filename = g_build_filename (test->directory, "CA_Cert_Signing_Authority.cer", NULL); diff --git a/pkcs11/roots-store/gkm-roots-module.c b/pkcs11/roots-store/gkm-roots-module.c index 3ad45249..4a29bf8d 100644 --- a/pkcs11/roots-store/gkm-roots-module.c +++ b/pkcs11/roots-store/gkm-roots-module.c @@ -96,7 +96,7 @@ GKM_DEFINE_MODULE (gkm_roots_module, GKM_TYPE_ROOTS_MODULE); static GkmCertificate* add_certificate_for_data (GkmRootsModule *self, - EggBytes *data, + GBytes *data, const gchar *path) { GkmCertificate *cert; @@ -112,8 +112,8 @@ add_certificate_for_data (GkmRootsModule *self, /* Hash the certificate */ hash = g_compute_checksum_for_data (G_CHECKSUM_MD5, - egg_bytes_get_data (data), - egg_bytes_get_size (data)); + g_bytes_get_data (data, NULL), + g_bytes_get_size (data)); unique = g_strdup_printf ("%s:%s", path, hash); g_free (hash); @@ -144,8 +144,8 @@ add_certificate_for_data (GkmRootsModule *self, static void parsed_pem_block (GQuark type, - EggBytes *data, - EggBytes *outer, + GBytes *data, + GBytes *outer, GHashTable *headers, gpointer user_data) { @@ -187,7 +187,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmRootsModule *self) ParsePrivate ctx; GkmManager *manager; GkmCertificate *cert; - EggBytes *bytes; + GBytes *bytes; guchar *data; GList *objects, *l; GError *error = NULL; @@ -215,7 +215,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmRootsModule *self) g_hash_table_insert (ctx.checks, l->data, l->data); g_list_free (objects); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); /* Try and parse the PEM */ egg_armor_parse (bytes, parsed_pem_block, &ctx); @@ -230,7 +230,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmRootsModule *self) g_hash_table_foreach (ctx.checks, remove_each_certificate, self); g_hash_table_destroy (ctx.checks); - egg_bytes_unref (data); + g_bytes_unref (bytes); } static void diff --git a/pkcs11/roots-store/gkm-roots-trust.c b/pkcs11/roots-store/gkm-roots-trust.c index 3810cdb0..69993544 100644 --- a/pkcs11/roots-store/gkm-roots-trust.c +++ b/pkcs11/roots-store/gkm-roots-trust.c @@ -126,7 +126,7 @@ full_certificate (GkmRootsTrust *self, CK_ATTRIBUTE_PTR result) static GQuark* lookup_extended_usages (GkmRootsTrust *self) { - EggBytes *extension; + GBytes *extension; GQuark *usages = NULL; GkmDataResult res; @@ -145,7 +145,7 @@ lookup_extended_usages (GkmRootsTrust *self) usages = g_new0 (GQuark, 1); } - egg_bytes_unref (extension); + g_bytes_unref (extension); return usages; } diff --git a/pkcs11/ssh-store/gkm-ssh-openssh.c b/pkcs11/ssh-store/gkm-ssh-openssh.c index 831e5552..c3a59a8f 100644 --- a/pkcs11/ssh-store/gkm-ssh-openssh.c +++ b/pkcs11/ssh-store/gkm-ssh-openssh.c @@ -155,7 +155,7 @@ read_public (EggBuffer *req, gsize *offset, gcry_sexp_t *key, int *algo) } static GkmDataResult -load_encrypted_key (EggBytes *data, +load_encrypted_key (GBytes *data, const gchar *dekinfo, const gchar *password, gssize n_password, @@ -163,7 +163,7 @@ load_encrypted_key (EggBytes *data, { guchar *decrypted = NULL; gsize n_decrypted = 0; - EggBytes *bytes; + GBytes *bytes; GkmDataResult ret; gint length; @@ -178,11 +178,11 @@ load_encrypted_key (EggBytes *data, if (length > 0) n_decrypted = length; - bytes = egg_bytes_new_with_free_func (decrypted, n_decrypted, egg_secure_free, decrypted); + bytes = g_bytes_new_with_free_func (decrypted, n_decrypted, egg_secure_free, decrypted); /* Try to parse */ ret = gkm_data_der_read_private_key (bytes, skey); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); if (ret != GKM_DATA_UNRECOGNIZED) return ret; @@ -210,8 +210,8 @@ is_private_key_type (GQuark type) static void parsed_pem_block (GQuark type, - EggBytes *data, - EggBytes *outer, + GBytes *data, + GBytes *outer, GHashTable *headers, gpointer user_data) { @@ -241,8 +241,8 @@ parsed_pem_block (GQuark type, static void digest_pem_block (GQuark type, - EggBytes *data, - EggBytes *outer, + GBytes *data, + GBytes *outer, GHashTable *headers, gpointer user_data) { @@ -258,8 +258,8 @@ digest_pem_block (GQuark type, return; *result = g_compute_checksum_for_data (G_CHECKSUM_SHA1, - egg_bytes_get_data (data), - egg_bytes_get_size (data)); + g_bytes_get_data (data, NULL), + g_bytes_get_size (data)); } /* ------------------------------------------------------------------------------ @@ -373,7 +373,7 @@ gkm_ssh_openssh_parse_public_key (gconstpointer input, gsize n_data, } GkmDataResult -gkm_ssh_openssh_parse_private_key (EggBytes *data, +gkm_ssh_openssh_parse_private_key (GBytes *data, const gchar *password, gssize n_password, gcry_sexp_t *sexp) @@ -401,7 +401,7 @@ gkm_ssh_openssh_parse_private_key (EggBytes *data, } gchar * -gkm_ssh_openssh_digest_private_key (EggBytes *data) +gkm_ssh_openssh_digest_private_key (GBytes *data) { gchar *result = NULL; egg_armor_parse (data, digest_pem_block, &result); diff --git a/pkcs11/ssh-store/gkm-ssh-openssh.h b/pkcs11/ssh-store/gkm-ssh-openssh.h index 62cdd2e8..6e614d17 100644 --- a/pkcs11/ssh-store/gkm-ssh-openssh.h +++ b/pkcs11/ssh-store/gkm-ssh-openssh.h @@ -7,18 +7,16 @@ #include "gkm/gkm-data-types.h" -#include <egg/egg-bytes.h> - GkmDataResult gkm_ssh_openssh_parse_public_key (gconstpointer data, gsize n_data, gcry_sexp_t *sexp, gchar **comment); -GkmDataResult gkm_ssh_openssh_parse_private_key (EggBytes *data, +GkmDataResult gkm_ssh_openssh_parse_private_key (GBytes *data, const gchar *password, gssize n_password, gcry_sexp_t *sexp); -gchar* gkm_ssh_openssh_digest_private_key (EggBytes *data); +gchar* gkm_ssh_openssh_digest_private_key (GBytes *data); #endif /* GKM_SSHOPENSSH_H_ */ diff --git a/pkcs11/ssh-store/gkm-ssh-private-key.c b/pkcs11/ssh-store/gkm-ssh-private-key.c index ef2cd768..019bdcf9 100644 --- a/pkcs11/ssh-store/gkm-ssh-private-key.c +++ b/pkcs11/ssh-store/gkm-ssh-private-key.c @@ -48,7 +48,7 @@ struct _GkmSshPrivateKey { GkmPrivateXsaKey parent; GkmSshPublicKey *pubkey; - EggBytes *private_bytes; + GBytes *private_bytes; gchar *label; gboolean is_encrypted; @@ -102,7 +102,7 @@ static void realize_and_take_data (GkmSshPrivateKey *self, gcry_sexp_t sexp, gchar *comment, - EggBytes *private_data) + GBytes *private_data) { GkmSexp *wrapper; @@ -121,7 +121,7 @@ realize_and_take_data (GkmSshPrivateKey *self, /* Own the data */ if (self->private_bytes) - egg_bytes_unref (self->private_bytes); + g_bytes_unref (self->private_bytes); self->private_bytes = private_data; /* Try to parse the private data, and note if it's not actually encrypted */ @@ -237,7 +237,7 @@ gkm_ssh_private_key_finalize (GObject *obj) g_assert (self->pubkey == NULL); if (self->private_bytes) - egg_bytes_unref (self->private_bytes); + g_bytes_unref (self->private_bytes); g_free (self->label); G_OBJECT_CLASS (gkm_ssh_private_key_parent_class)->finalize (obj); @@ -353,7 +353,7 @@ gkm_ssh_private_key_parse (GkmSshPrivateKey *self, const gchar *public_path, if (comment == NULL) comment = g_path_get_basename (private_path); - realize_and_take_data (self, sexp, comment, egg_bytes_new_take (private_data, n_private_data)); + realize_and_take_data (self, sexp, comment, g_bytes_new_take (private_data, n_private_data)); return TRUE; } diff --git a/pkcs11/ssh-store/tests/test-ssh-openssh.c b/pkcs11/ssh-store/tests/test-ssh-openssh.c index 2cc81364..a2e58652 100644 --- a/pkcs11/ssh-store/tests/test-ssh-openssh.c +++ b/pkcs11/ssh-store/tests/test-ssh-openssh.c @@ -95,7 +95,7 @@ test_parse_private (void) gsize n_data; int algorithm; gboolean is_private; - EggBytes *bytes; + GBytes *bytes; guint i; GkmDataResult res; @@ -105,9 +105,9 @@ test_parse_private (void) if (!g_file_get_contents (PRIVATE_FILES[i], &data, &n_data, NULL)) g_assert_not_reached (); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); res = gkm_ssh_openssh_parse_private_key (bytes, "password", 8, &sexp); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); if (res != GKM_DATA_SUCCESS) { g_warning ("couldn't parse private key: %s", PRIVATE_FILES[i]); diff --git a/pkcs11/xdg-store/gkm-xdg-module.c b/pkcs11/xdg-store/gkm-xdg-module.c index 669a4bd8..5f2d3cd4 100644 --- a/pkcs11/xdg-store/gkm-xdg-module.c +++ b/pkcs11/xdg-store/gkm-xdg-module.c @@ -205,7 +205,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmXdgModule *self) GkmManager *manager; gboolean added = FALSE; GError *error = NULL; - EggBytes *bytes; + GBytes *bytes; GType type; guchar *data; gsize n_data; @@ -248,7 +248,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmXdgModule *self) return; } - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); /* And load the data into it */ if (gkm_serializable_load (GKM_SERIALIZABLE (object), NULL, bytes)) { @@ -264,7 +264,7 @@ file_load (GkmFileTracker *tracker, const gchar *path, GkmXdgModule *self) } } - egg_bytes_unref (bytes); + g_bytes_unref (bytes); g_object_unref (object); } @@ -285,16 +285,16 @@ static gchar* name_for_subject (gconstpointer data, gsize n_data) { - EggBytes *subject; + GBytes *subject; GNode *asn; gchar *name; g_assert (data != NULL); - subject = egg_bytes_new (data, n_data); + subject = g_bytes_new (data, n_data); asn = egg_asn1x_create_and_decode (pkix_asn1_tab, "Name", subject); g_return_val_if_fail (asn != NULL, NULL); - egg_bytes_unref (subject); + g_bytes_unref (subject); name = egg_dn_read_part (egg_asn1x_node (asn, "rdnSequence", NULL), "CN"); egg_asn1x_destroy (asn); @@ -441,7 +441,7 @@ gkm_xdg_module_real_store_token_object (GkmModule *module, GkmTransaction *trans { GkmXdgModule *self = GKM_XDG_MODULE (module); const gchar *filename; - EggBytes *bytes; + GBytes *bytes; GkmTrust *trust; /* Always serialize the trust object for each assertion */ @@ -470,9 +470,9 @@ gkm_xdg_module_real_store_token_object (GkmModule *module, GkmTransaction *trans g_return_if_fail (g_hash_table_lookup (self->objects_by_path, filename) == object); gkm_transaction_write_file (transaction, filename, - egg_bytes_get_data (bytes), - egg_bytes_get_size (bytes)); - egg_bytes_unref (bytes); + g_bytes_get_data (bytes, NULL), + g_bytes_get_size (bytes)); + g_bytes_unref (bytes); } static void diff --git a/pkcs11/xdg-store/gkm-xdg-trust.c b/pkcs11/xdg-store/gkm-xdg-trust.c index 9d225676..d885bbd7 100644 --- a/pkcs11/xdg-store/gkm-xdg-trust.c +++ b/pkcs11/xdg-store/gkm-xdg-trust.c @@ -49,7 +49,7 @@ extern const struct _EggAsn1xDef xdg_asn1_tab[]; struct _GkmXdgTrustPrivate { GHashTable *assertions; GNode *asn; - EggBytes *bytes; + GBytes *bytes; }; static void gkm_xdg_trust_serializable (GkmSerializableIface *iface); @@ -104,7 +104,7 @@ static CK_RV trust_get_der (GkmXdgTrust *self, const gchar *part, CK_ATTRIBUTE_PTR attr) { GNode *node; - EggBytes *element; + GBytes *element; CK_RV rv; g_assert (GKM_XDG_IS_TRUST (self)); @@ -121,7 +121,7 @@ trust_get_der (GkmXdgTrust *self, const gchar *part, CK_ATTRIBUTE_PTR attr) element = egg_asn1x_get_element_raw (node); rv = gkm_attribute_set_bytes (attr, element); - egg_bytes_unref (element); + g_bytes_unref (element); return rv; } @@ -130,7 +130,7 @@ static CK_RV trust_get_integer (GkmXdgTrust *self, const gchar *part, CK_ATTRIBUTE_PTR attr) { GNode *node; - EggBytes *integer; + GBytes *integer; CK_RV rv; g_assert (GKM_XDG_IS_TRUST (self)); @@ -149,7 +149,7 @@ trust_get_integer (GkmXdgTrust *self, const gchar *part, CK_ATTRIBUTE_PTR attr) g_return_val_if_fail (integer, CKR_GENERAL_ERROR); rv = gkm_attribute_set_bytes (attr, integer); - egg_bytes_unref (integer); + g_bytes_unref (integer); return rv; } @@ -158,7 +158,7 @@ static CK_RV trust_get_hash (GkmXdgTrust *self, GChecksumType ctype, CK_ATTRIBUTE_PTR attr) { GNode *cert; - EggBytes *element; + GBytes *element; CK_RV rv; cert = egg_asn1x_node (self->pv->asn, "reference", "certComplete", NULL); @@ -175,10 +175,10 @@ trust_get_hash (GkmXdgTrust *self, GChecksumType ctype, CK_ATTRIBUTE_PTR attr) g_return_val_if_fail (element != NULL, CKR_GENERAL_ERROR); rv = gkm_attribute_set_checksum (attr, ctype, - egg_bytes_get_data (element), - egg_bytes_get_size (element)); + g_bytes_get_data (element, NULL), + g_bytes_get_size (element)); - egg_bytes_unref (element); + g_bytes_unref (element); return rv; } @@ -186,7 +186,7 @@ static CK_RV trust_get_complete (GkmXdgTrust *self, CK_ATTRIBUTE_PTR attr) { GNode *cert; - EggBytes *element; + GBytes *element; CK_RV rv; cert = egg_asn1x_node (self->pv->asn, "reference", "certComplete", NULL); @@ -203,7 +203,7 @@ trust_get_complete (GkmXdgTrust *self, CK_ATTRIBUTE_PTR attr) g_return_val_if_fail (element != NULL, CKR_GENERAL_ERROR); rv = gkm_attribute_set_bytes (attr, element); - egg_bytes_unref (element); + g_bytes_unref (element); return rv; } @@ -214,7 +214,7 @@ validate_der (CK_ATTRIBUTE_PTR attr, const gchar *asn_type) { GNode *asn; gboolean valid = TRUE; - EggBytes *data; + GBytes *data; if (!attr->pValue || attr->ulValueLen == (CK_ULONG)-1) return FALSE; @@ -222,9 +222,9 @@ validate_der (CK_ATTRIBUTE_PTR attr, const gchar *asn_type) asn = egg_asn1x_create (pkix_asn1_tab, asn_type); g_return_val_if_fail (asn, FALSE); - data = egg_bytes_new_static (attr->pValue, attr->ulValueLen); + data = g_bytes_new_static (attr->pValue, attr->ulValueLen); valid = egg_asn1x_decode (asn, data); - egg_bytes_unref (data); + g_bytes_unref (data); if (!valid) g_message ("failed to parse certificate passed to trust assertion: %s", @@ -286,8 +286,8 @@ check_and_unref_assertion (gpointer data) static GHashTable* create_assertions (void) { - return g_hash_table_new_full (egg_bytes_hash, egg_bytes_equal, - (GDestroyNotify)egg_bytes_unref, + return g_hash_table_new_full (g_bytes_hash, g_bytes_equal, + (GDestroyNotify)g_bytes_unref, check_and_unref_assertion); } @@ -335,7 +335,7 @@ create_assertion (GkmXdgTrust *self, GNode *asn) return assertion; } -static EggBytes * +static GBytes * create_assertion_key (const gchar *purpose, const gchar *peer) { @@ -353,26 +353,26 @@ create_assertion_key (const gchar *purpose, } len = string->len; - return egg_bytes_new_take (g_string_free (string, FALSE), len); + return g_bytes_new_take (g_string_free (string, FALSE), len); } -static EggBytes * +static GBytes * lookup_assertion_key (GkmAssertion *assertion) { return g_object_get_qdata (G_OBJECT (assertion), QDATA_ASSERTION_KEY); } -static EggBytes * +static GBytes * lookup_or_create_assertion_key (GkmAssertion *assertion) { - EggBytes *key; + GBytes *key; key = lookup_assertion_key (assertion); if (key == NULL) { key = create_assertion_key (gkm_assertion_get_purpose (assertion), gkm_assertion_get_peer (assertion)); g_object_set_qdata_full (G_OBJECT (assertion), QDATA_ASSERTION_KEY, - egg_bytes_ref (key), (GDestroyNotify)egg_bytes_unref); + g_bytes_ref (key), (GDestroyNotify)g_bytes_unref); } return key; @@ -395,12 +395,12 @@ static void add_assertion_to_trust (GkmXdgTrust *self, GkmAssertion *assertion, GkmTransaction *transaction) { - EggBytes *key; + GBytes *key; key = lookup_or_create_assertion_key (assertion); g_assert (key != NULL); - g_hash_table_insert (self->pv->assertions, egg_bytes_ref (key), g_object_ref (assertion)); + g_hash_table_insert (self->pv->assertions, g_bytes_ref (key), g_object_ref (assertion)); gkm_object_expose (GKM_OBJECT (assertion), gkm_object_is_exposed (GKM_OBJECT (self))); if (transaction != NULL) @@ -426,7 +426,7 @@ static void remove_assertion_from_trust (GkmXdgTrust *self, GkmAssertion *assertion, GkmTransaction *transaction) { - EggBytes *key; + GBytes *key; key = lookup_assertion_key (assertion); g_assert (key != NULL); @@ -448,7 +448,7 @@ load_assertions (GkmXdgTrust *self, GNode *asn) { GHashTable *assertions; GkmAssertion *assertion; - EggBytes *key; + GBytes *key; GNode *node; guint count, i; @@ -480,7 +480,7 @@ load_assertions (GkmXdgTrust *self, GNode *asn) } add_assertion_to_trust (self, assertion, NULL); - egg_bytes_unref (key); + g_bytes_unref (key); g_object_unref (assertion); } @@ -543,7 +543,7 @@ create_trust_for_reference (GkmModule *module, GkmManager *manager, { GkmXdgTrust *trust; GNode *asn, *ref, *node; - EggBytes *bytes; + GBytes *bytes; asn = egg_asn1x_create (xdg_asn1_tab, "trust-1"); g_return_val_if_fail (asn, NULL); @@ -552,13 +552,13 @@ create_trust_for_reference (GkmModule *module, GkmManager *manager, node = egg_asn1x_node (ref, "certReference", NULL); egg_asn1x_set_choice (ref, node); - bytes = egg_bytes_new (serial->pValue, serial->ulValueLen); + bytes = g_bytes_new (serial->pValue, serial->ulValueLen); egg_asn1x_set_integer_as_raw (egg_asn1x_node (node, "serialNumber", NULL), bytes); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); - bytes = egg_bytes_new (issuer->pValue, issuer->ulValueLen); + bytes = g_bytes_new (issuer->pValue, issuer->ulValueLen); egg_asn1x_set_element_raw (egg_asn1x_node (node, "issuer", NULL), bytes); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); trust = g_object_new (GKM_XDG_TYPE_TRUST, "module", module, "manager", manager, NULL); trust->pv->asn = asn; @@ -579,7 +579,7 @@ create_trust_for_complete (GkmModule *module, GkmManager *manager, { GkmXdgTrust *trust; GNode *asn, *ref, *node; - EggBytes *bytes; + GBytes *bytes; asn = egg_asn1x_create (xdg_asn1_tab, "trust-1"); g_return_val_if_fail (asn, NULL); @@ -588,9 +588,9 @@ create_trust_for_complete (GkmModule *module, GkmManager *manager, node = egg_asn1x_node (ref, "certComplete", NULL); egg_asn1x_set_choice (ref, node); - bytes = egg_bytes_new (cert->pValue, cert->ulValueLen); + bytes = g_bytes_new (cert->pValue, cert->ulValueLen); egg_asn1x_set_element_raw (node, bytes); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); trust = g_object_new (GKM_XDG_TYPE_TRUST, "module", module, "manager", manager, NULL); trust->pv->asn = asn; @@ -666,12 +666,12 @@ gkm_xdg_trust_get_level (GkmTrust *base, const gchar *purpose) { GkmXdgTrust *self = GKM_XDG_TRUST (base); GkmAssertion *assertion; - EggBytes *key; + GBytes *key; gulong type; key = create_assertion_key (purpose, NULL); assertion = g_hash_table_lookup (self->pv->assertions, key); - egg_bytes_unref (key); + g_bytes_unref (key); if (!assertion) return GKM_TRUST_UNKNOWN; @@ -731,12 +731,12 @@ gkm_xdg_trust_class_init (GkmXdgTrustClass *klass) static gboolean gkm_xdg_trust_real_load (GkmSerializable *base, GkmSecret *login, - EggBytes *data) + GBytes *data) { GkmXdgTrust *self = GKM_XDG_TRUST (base); GNode *asn = NULL; - if (egg_bytes_get_size (data) == 0) + if (g_bytes_get_size (data) == 0) return FALSE; asn = egg_asn1x_create (xdg_asn1_tab, "trust-1"); @@ -756,19 +756,19 @@ gkm_xdg_trust_real_load (GkmSerializable *base, /* Take ownership of this new data */ if (self->pv->bytes) - egg_bytes_unref (self->pv->bytes); - self->pv->bytes = egg_bytes_ref (data); + g_bytes_unref (self->pv->bytes); + self->pv->bytes = g_bytes_ref (data); egg_asn1x_destroy (self->pv->asn); self->pv->asn = asn; return TRUE; } -static EggBytes * +static GBytes * gkm_xdg_trust_real_save (GkmSerializable *base, GkmSecret *login) { GkmXdgTrust *self = GKM_XDG_TRUST (base); - EggBytes *bytes; + GBytes *bytes; g_return_val_if_fail (GKM_XDG_IS_TRUST (self), FALSE); g_return_val_if_fail (self->pv->asn, FALSE); @@ -783,10 +783,10 @@ gkm_xdg_trust_real_save (GkmSerializable *base, GkmSecret *login) } if (self->pv->bytes) - egg_bytes_unref (self->pv->bytes); + g_bytes_unref (self->pv->bytes); self->pv->bytes = bytes; - return egg_bytes_ref (bytes); + return g_bytes_ref (bytes); } static void @@ -861,7 +861,7 @@ gkm_xdg_trust_replace_assertion (GkmXdgTrust *self, GkmAssertion *assertion, GkmTransaction *transaction) { GkmAssertion *previous; - EggBytes *key; + GBytes *key; g_return_if_fail (GKM_XDG_IS_TRUST (self)); g_return_if_fail (GKM_IS_ASSERTION (assertion)); @@ -876,14 +876,14 @@ gkm_xdg_trust_replace_assertion (GkmXdgTrust *self, GkmAssertion *assertion, remove_assertion_from_trust (self, previous, transaction); add_assertion_to_trust (self, assertion, transaction); - egg_bytes_unref (key); + g_bytes_unref (key); } void gkm_xdg_trust_remove_assertion (GkmXdgTrust *self, GkmAssertion *assertion, GkmTransaction *transaction) { - EggBytes *key; + GBytes *key; g_return_if_fail (GKM_XDG_IS_TRUST (self)); g_return_if_fail (GKM_IS_ASSERTION (assertion)); diff --git a/pkcs11/xdg-store/tests/dump-trust-file.c b/pkcs11/xdg-store/tests/dump-trust-file.c index a118d784..32eb4db7 100644 --- a/pkcs11/xdg-store/tests/dump-trust-file.c +++ b/pkcs11/xdg-store/tests/dump-trust-file.c @@ -48,9 +48,9 @@ static void dump_certificate_reference (GNode *asn) { gchar *issuer, *serial; - EggBytes *data; + GBytes *data; GNode *name; - EggBytes *element; + GBytes *element; /* Parse the name out */ name = egg_asn1x_create (pkix_asn1_tab, "Name"); @@ -59,14 +59,14 @@ dump_certificate_reference (GNode *asn) g_return_if_fail (element); if (!egg_asn1x_decode (name, element)) barf_and_die ("couldn't parse certificate", egg_asn1x_message (name)); - egg_bytes_unref (element); + g_bytes_unref (element); issuer = egg_dn_read (name); g_return_if_fail (issuer); data = egg_asn1x_get_integer_as_raw (egg_asn1x_node (asn, "serial", NULL)); g_return_if_fail (data != NULL); - serial = egg_hex_encode (egg_bytes_get_data (data), egg_bytes_get_size (data)); + serial = egg_hex_encode (g_bytes_get_data (data, NULL), g_bytes_get_size (data)); g_print ("Reference\n"); g_print (" issuer: %s\n", issuer); @@ -83,8 +83,8 @@ dump_certificate_complete (GNode *asn) { GNode *cert; gchar *issuer, *serial, *subject; - EggBytes *element; - EggBytes *data; + GBytes *element; + GBytes *data; /* Parse the certificate out */ cert = egg_asn1x_create (pkix_asn1_tab, "Certificate"); @@ -94,7 +94,7 @@ dump_certificate_complete (GNode *asn) g_return_if_fail (element); if (!egg_asn1x_decode (cert, element)) barf_and_die ("couldn't parse certificate", egg_asn1x_message (cert)); - egg_bytes_unref (element); + g_bytes_unref (element); issuer = egg_dn_read (egg_asn1x_node (asn, "issuer", NULL)); g_return_if_fail (issuer); @@ -104,8 +104,8 @@ dump_certificate_complete (GNode *asn) data = egg_asn1x_get_integer_as_raw (egg_asn1x_node (asn, "serial", NULL)); g_return_if_fail (data != NULL); - serial = egg_hex_encode (egg_bytes_get_data (data), egg_bytes_get_size (data)); - egg_bytes_unref (data); + serial = egg_hex_encode (g_bytes_get_data (data, NULL), g_bytes_get_size (data)); + g_bytes_unref (data); g_print ("Complete\n"); g_print (" issuer: %s\n", issuer); @@ -154,7 +154,7 @@ main(int argc, char* argv[]) gchar *contents; gsize n_contents; GNode *asn, *node; - EggBytes *bytes; + GBytes *bytes; gint i, count; if (argc != 2) { @@ -168,10 +168,10 @@ main(int argc, char* argv[]) asn = egg_asn1x_create (xdg_asn1_tab, "trust-1"); g_return_val_if_fail (asn, 1); - bytes = egg_bytes_new_take (contents, n_contents); + bytes = g_bytes_new_take (contents, n_contents); if (!egg_asn1x_decode (asn, bytes)) barf_and_die ("couldn't parse file", egg_asn1x_message (asn)); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); /* Print out the certificate we refer to first */ node = egg_asn1x_node (asn, "reference", "certReference", NULL); diff --git a/pkcs11/xdg-store/tests/frob-trust-file.c b/pkcs11/xdg-store/tests/frob-trust-file.c index e1412d25..a6d226a5 100644 --- a/pkcs11/xdg-store/tests/frob-trust-file.c +++ b/pkcs11/xdg-store/tests/frob-trust-file.c @@ -47,7 +47,7 @@ create_trust_file_for_certificate (const gchar *filename, const gchar *certifica { GError *err = NULL; GNode *asn, *cert, *choice, *ref; - EggBytes *bytes, *result; + GBytes *bytes, *result; gchar *data; gsize n_data; @@ -58,7 +58,7 @@ create_trust_file_for_certificate (const gchar *filename, const gchar *certifica cert = egg_asn1x_create (pkix_asn1_tab, "Certificate"); g_return_if_fail (cert); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); if (!egg_asn1x_decode (cert, bytes)) barf_and_die ("couldn't parse der certificate file", egg_asn1x_message (cert)); @@ -71,7 +71,7 @@ create_trust_file_for_certificate (const gchar *filename, const gchar *certifica if (!egg_asn1x_set_choice (ref, choice) || !egg_asn1x_set_element_raw (choice, bytes)) g_return_if_reached (); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); result = egg_asn1x_encode (asn, NULL); if (result == NULL) @@ -80,11 +80,11 @@ create_trust_file_for_certificate (const gchar *filename, const gchar *certifica egg_asn1x_destroy (asn); egg_asn1x_destroy (cert); - if (!g_file_set_contents (filename, egg_bytes_get_data (result), - egg_bytes_get_size (result), &err)) + if (!g_file_set_contents (filename, g_bytes_get_data (result, NULL), + g_bytes_get_size (result), &err)) barf_and_die ("couldn't write trust file", egg_error_message (err)); - egg_bytes_unref (result); + g_bytes_unref (result); } static void @@ -94,11 +94,11 @@ create_trust_file_for_issuer_and_serial (const gchar *filename, const gchar *cer GNode *asn, *cert, *choice, *ref; GNode *issuer, *serial; gchar *data; - EggBytes *result; - EggBytes *value; - EggBytes *element; + GBytes *result; + GBytes *value; + GBytes *element; gsize n_data; - EggBytes *bytes; + GBytes *bytes; if (!g_file_get_contents (certificate, &data, &n_data, &err)) barf_and_die ("couldn't read certificate file", egg_error_message (err)); @@ -107,10 +107,10 @@ create_trust_file_for_issuer_and_serial (const gchar *filename, const gchar *cer cert = egg_asn1x_create (pkix_asn1_tab, "Certificate"); g_return_if_fail (cert); - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); if (!egg_asn1x_decode (cert, bytes)) barf_and_die ("couldn't parse der certificate file", egg_asn1x_message (cert)); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); /* Dig out the issuer and serial */ issuer = egg_asn1x_node (cert, "tbsCertificate", "issuer", NULL); @@ -131,11 +131,11 @@ create_trust_file_for_issuer_and_serial (const gchar *filename, const gchar *cer element = egg_asn1x_get_element_raw (issuer); if (!egg_asn1x_set_element_raw (egg_asn1x_node (choice, "issuer", NULL), element)) g_return_if_reached (); - egg_bytes_unref (element); + g_bytes_unref (element); value = egg_asn1x_get_integer_as_raw (serial); egg_asn1x_set_integer_as_raw (egg_asn1x_node (choice, "serialNumber", NULL), value); - egg_bytes_unref (value); + g_bytes_unref (value); result = egg_asn1x_encode (asn, NULL); if (result == NULL) @@ -145,11 +145,11 @@ create_trust_file_for_issuer_and_serial (const gchar *filename, const gchar *cer egg_asn1x_destroy (cert); egg_asn1x_destroy (asn); - if (!g_file_set_contents (filename, egg_bytes_get_data (result), - egg_bytes_get_size (result), &err)) + if (!g_file_set_contents (filename, g_bytes_get_data (result, NULL), + g_bytes_get_size (result), &err)) barf_and_die ("couldn't write trust file", egg_error_message (err)); - egg_bytes_unref (result); + g_bytes_unref (result); } static void @@ -157,10 +157,10 @@ add_trust_purpose_to_file (const gchar *filename, const gchar *purpose) { GError *err = NULL; gchar *data; - EggBytes *result; + GBytes *result; gsize n_data; GNode *asn, *assertion; - EggBytes *bytes; + GBytes *bytes; if (!g_file_get_contents (filename, &data, &n_data, &err)) barf_and_die ("couldn't read trust file", egg_error_message (err)); @@ -170,10 +170,10 @@ add_trust_purpose_to_file (const gchar *filename, const gchar *purpose) g_return_if_fail (asn); /* And parse it */ - bytes = egg_bytes_new_take (data, n_data); + bytes = g_bytes_new_take (data, n_data); if (!egg_asn1x_decode (asn, bytes)) barf_and_die ("couldn't parse trust file", egg_asn1x_message (asn)); - egg_bytes_unref (bytes); + g_bytes_unref (bytes); assertion = egg_asn1x_append (egg_asn1x_node (asn, "assertions", NULL)); g_return_if_fail (assertion); @@ -189,8 +189,8 @@ add_trust_purpose_to_file (const gchar *filename, const gchar *purpose) g_free (data); egg_asn1x_destroy (asn); - if (!g_file_set_contents (filename, egg_bytes_get_data (result), - egg_bytes_get_size (result), &err)) + if (!g_file_set_contents (filename, g_bytes_get_data (result, NULL), + g_bytes_get_size (result), &err)) barf_and_die ("couldn't write trust file", egg_error_message (err)); g_free (result); |