}
static void
+test_boolean_decode_bad (void)
+{
+ const gchar BOOLEAN_INVALID_LENGTH[] = "\x01\x02\x00\x00";
+ const gchar BOOLEAN_BAD_VALUE[] = "\x01\x01\x05";
+
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBoolean");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (BOOLEAN_INVALID_LENGTH, XL (BOOLEAN_INVALID_LENGTH));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "invalid length boolean") != NULL);
+ g_bytes_unref (bytes);
+
+ bytes = g_bytes_new_static (BOOLEAN_BAD_VALUE, XL (BOOLEAN_BAD_VALUE));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "boolean must be true or false") != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_boolean_default (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ const gchar BOOLEAN[] = "\x30\x00";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBooleanDefault");
+ /* This is equal to the default value, and shouldn't be included */
+ egg_asn1x_set_boolean (egg_asn1x_node (asn, "boolean", NULL), TRUE);
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ egg_asn1x_assert (bytes != NULL, asn);
+ egg_assert_cmpbytes (bytes, ==, BOOLEAN, XL (BOOLEAN));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_null (void)
{
GNode *asn;
}
static void
+test_integer_zero_length (void)
+{
+ const gchar INTEGER_EMPTY[] = "\x02\x00";
+
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (INTEGER_EMPTY, XL (INTEGER_EMPTY));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "zero length integer") != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_unsigned (void)
{
GNode *asn;
}
static void
+test_unsigned_not_set (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn);
+
+ bytes = egg_asn1x_get_integer_as_usg (asn);
+ g_assert (bytes == NULL);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_unsigned_default (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ const gchar INTEGERS[] = "\x30\x06\x02\x01\x01\x02\x01\x02";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestIntegers");
+ egg_asn1x_set_integer_as_ulong (egg_asn1x_node (asn, "uint1", NULL), 1);
+ egg_asn1x_set_integer_as_ulong (egg_asn1x_node (asn, "uint2", NULL), 2);
+ /* This is equal to the default value, and shouldn't be included */
+ egg_asn1x_set_integer_as_ulong (egg_asn1x_node (asn, "uint3", NULL), 8888);
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ egg_assert_cmpbytes (bytes, ==, INTEGERS, XL (INTEGERS));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_unsigned_constant (void)
+{
+ gulong value;
+ GNode *asn;
+
+ /* const gchar SEQ[] = "\x30\x00"; */
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestConstant");
+ if (!egg_asn1x_get_integer_as_ulong (egg_asn1x_node (asn, "version", NULL), &value))
+ g_assert_not_reached ();
+ g_assert_cmpint (value, ==, 3);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_unsigned_zero (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\x02\x01\x00";
+
+ /* No bits set in 0 but should still be 1 byte */
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ egg_asn1x_set_integer_as_ulong (asn, 0);
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ egg_asn1x_assert (bytes != NULL, asn);
+ egg_assert_cmpbytes (bytes, ==, DER, XL (DER));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_integer_raw (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("\x01\x02\x03", 3);
+ egg_asn1x_set_integer_as_raw (asn, bytes);
+ g_bytes_unref (bytes);
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ egg_assert_cmpbytes (bytes, ==, "\x02\x03\x01\x02\x03", 5);
+ g_bytes_unref (bytes);
+
+ bytes = egg_asn1x_get_integer_as_raw (asn);
+ egg_assert_cmpbytes (bytes, ==, "\x01\x02\x03", 3);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_integer_raw_not_twos_complement (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("\x81\x02\x03", 3);
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
+ egg_asn1x_set_integer_as_raw (asn, bytes); /* UNREACHABLE: */
+ exit(0); /* UNREACHABLE: for code coverage */
+ }
+
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*not two's complement*");
+
+ g_bytes_unref (bytes);
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_octet_string (void)
{
GNode *asn;
}
static void
+test_octet_string_set_bad_utf8 (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestOctetString");
+ g_assert (asn);
+
+ if (egg_asn1x_set_string_as_utf8 (asn, "\xFF\xFA", NULL))
+ g_assert_not_reached ();
+
+ /* Shouldn't succeed */
+ if (egg_asn1x_get_string_as_utf8 (asn, NULL))
+ g_assert_not_reached ();
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_octet_string_bmp_as_utf8 (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ gchar *data;
+
+ const gchar SFUER[] = "\x04\x06""\x00\x46\x00\xfc\x00\x72";
+
+ bytes = g_bytes_new_static (SFUER, XL (SFUER));
+ asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_assert (asn != NULL);
+ g_bytes_unref (bytes);
+
+ data = egg_asn1x_get_bmpstring_as_utf8 (asn);
+ g_assert_cmpstr (data, ==, "F\303\274r");
+
+ g_free (data);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_octet_string_get_as_bytes (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ bytes = g_bytes_new_static (SFARNSWORTH, XL (SFARNSWORTH));
+ asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_assert (asn != NULL);
+ g_bytes_unref (bytes);
+
+ bytes = egg_asn1x_get_string_as_bytes (asn);
+ g_assert (bytes != NULL);
+ egg_assert_cmpbytes (bytes, ==, "farnsworth", 10);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_octet_string_set_as_bytes (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestOctetString");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("farnsworth", 10);
+ egg_asn1x_set_string_as_bytes (asn, bytes);
+ g_bytes_unref (bytes);
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ g_assert (bytes != NULL);
+ egg_assert_cmpbytes (bytes, ==, SFARNSWORTH, XL (SFARNSWORTH));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_octet_string_structured (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ guchar *string;
+ gsize n_string = 0;
+
+ const gchar STRUCTURED[] = "\x24\x0c"
+ "\x04\x04""blah"
+ "\x04\x04""blah";
+
+ bytes = g_bytes_new_static (STRUCTURED, XL (STRUCTURED));
+ asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_bytes_unref (bytes);
+
+ string = egg_asn1x_get_string_as_raw (asn, NULL, &n_string);
+ g_assert_cmpstr ((gchar *)string, ==, "blahblah");
+ g_assert_cmpint (n_string, ==, 8);
+ g_free (string);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_octet_string_structured_bad (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ guchar *string;
+ gsize n_string = 0;
+
+ const gchar STRUCTURED[] = "\x24\x0c"
+ "\x24\x04\x04\02""bl"
+ "\x04\x04""blah";
+
+ bytes = g_bytes_new_static (STRUCTURED, XL (STRUCTURED));
+ asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_bytes_unref (bytes);
+
+ string = egg_asn1x_get_string_as_raw (asn, NULL, &n_string);
+ g_assert (string == NULL);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_generalized_time (void)
{
GBytes *bytes;
}
static void
+test_time_get_missing (void)
+{
+ GDate date;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestGeneralized");
+ if (egg_asn1x_get_time_as_date (asn, &date))
+ g_assert_not_reached ();
+ g_assert (egg_asn1x_get_time_as_long (asn) == -1);
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_implicit_encode (void)
{
GBytes *bytes;
}
static void
+test_explicit_no_context_specific (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\x45\x0A\x04\x08""explicit";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestExplicit");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "missing context specific tag"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_explicit_no_context_child (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\xA5\x00";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestExplicit");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "missing context specific child"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_explicit_extra_context_child (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\xA5\x14"
+ "\x04\x08""explicit"
+ "\x04\x08""explicit";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestExplicit");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "multiple context specific children"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_explicit_encode (void)
{
GBytes *bytes;
GNode *asn;
gchar *value;
- asn = egg_asn1x_create (test_asn1_tab, "TestUniversal");
+ asn = egg_asn1x_create (test_asn1_tab, "TestUniversal");
+ g_assert (asn);
+
+ /* Should work */
+ bytes = g_bytes_new_static (SUNIVERSAL, XL (SUNIVERSAL));
+ if (!egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_bytes_unref (bytes);
+
+ value = egg_asn1x_get_string_as_utf8 (asn, NULL);
+ g_assert_cmpstr (value, ==, "universal");
+ g_free (value);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_universal_encode (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestUniversal");
+ g_assert (asn);
+
+ if (!egg_asn1x_set_string_as_utf8 (asn, g_strdup ("universal"), g_free))
+ g_assert_not_reached ();
+
+ bytes = egg_asn1x_encode (asn, NULL);
+ egg_assert_cmpbytes (bytes, ==, SUNIVERSAL, XL (SUNIVERSAL));
+
+ egg_asn1x_destroy (asn);
+ g_bytes_unref (bytes);
+}
+
+static void
+test_bit_string_decode (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ GBytes *bits;
+ guint n_bits;
+ const guchar *data;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
+ g_assert (asn);
+
+ g_assert_cmpint (EGG_ASN1X_BIT_STRING, ==, egg_asn1x_type (asn));
+
+ /* Should work */
+ bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
+ if (!egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ 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 = g_bytes_get_data (bits, NULL);
+ g_assert_cmpint (data[0], ==, 0x6e);
+ g_assert_cmpint (data[1], ==, 0x5d);
+ g_assert_cmpint (data[2], ==, 0xc0);
+
+ g_bytes_unref (bits);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_bit_string_decode_bad (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
+ g_assert (asn);
+
+ /* Should not work */
+ bytes = g_bytes_new_static (BITS_BAD, XL (BITS_BAD));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_bit_string_decode_ulong (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ gulong bits;
+ guint n_bits;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
g_assert (asn);
/* Should work */
- bytes = g_bytes_new_static (SUNIVERSAL, XL (SUNIVERSAL));
+ bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
if (!egg_asn1x_decode (asn, bytes))
g_assert_not_reached ();
g_bytes_unref (bytes);
- value = egg_asn1x_get_string_as_utf8 (asn, NULL);
- g_assert_cmpstr (value, ==, "universal");
- g_free (value);
+ if (!egg_asn1x_get_bits_as_ulong (asn, &bits, &n_bits))
+ g_assert_not_reached ();
+
+ g_assert_cmpuint (n_bits, ==, 18);
+ g_assert_cmphex (bits, ==, 0x1b977);
egg_asn1x_destroy (asn);
}
static void
-test_universal_encode (void)
+test_bit_string_ulong_too_long (void)
{
GBytes *bytes;
GNode *asn;
+ gulong bits;
+ guint n_bits;
- asn = egg_asn1x_create (test_asn1_tab, "TestUniversal");
+ const gchar BITS_TEST[] = "\x03\x20\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
g_assert (asn);
- if (!egg_asn1x_set_string_as_utf8 (asn, g_strdup ("universal"), g_free))
+ /* Should work */
+
+ bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
+ if (!egg_asn1x_decode (asn, bytes))
g_assert_not_reached ();
+ g_bytes_unref (bytes);
- bytes = egg_asn1x_encode (asn, NULL);
- egg_assert_cmpbytes (bytes, ==, SUNIVERSAL, XL (SUNIVERSAL));
+ if (egg_asn1x_get_bits_as_ulong (asn, &bits, &n_bits))
+ g_assert_not_reached ();
egg_asn1x_destroy (asn);
- g_bytes_unref (bytes);
}
static void
-test_bit_string_decode (void)
+test_bit_string_get_not_set (void)
{
- GBytes *bytes;
GNode *asn;
- GBytes *bits;
+ gulong bits;
guint n_bits;
- const guchar *data;
asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
- g_assert (asn);
- g_assert_cmpint (EGG_ASN1X_BIT_STRING, ==, egg_asn1x_type (asn));
-
- /* Should work */
- bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
- if (!egg_asn1x_decode (asn, bytes))
+ if (egg_asn1x_get_bits_as_ulong (asn, &bits, &n_bits))
g_assert_not_reached ();
- 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 = g_bytes_get_data (bits, NULL);
- g_assert_cmpint (data[0], ==, 0x6e);
- g_assert_cmpint (data[1], ==, 0x5d);
- g_assert_cmpint (data[2], ==, 0xc0);
+ g_assert (egg_asn1x_get_bits_as_raw (asn, &n_bits) == NULL);
- g_bytes_unref (bits);
egg_asn1x_destroy (asn);
}
static void
-test_bit_string_decode_bad (void)
+test_bit_string_invalid_length (void)
{
GBytes *bytes;
GNode *asn;
+ const gchar DER[] = "\x03\x00";
+
asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
g_assert (asn);
- /* Should not work */
- bytes = g_bytes_new_static (BITS_BAD, XL (BITS_BAD));
+ /* Should work */
+
+ bytes = g_bytes_new_static (DER, XL (DER));
if (egg_asn1x_decode (asn, bytes))
g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "invalid length bit string"));
g_bytes_unref (bytes);
egg_asn1x_destroy (asn);
}
static void
-test_bit_string_decode_ulong (void)
+test_bit_string_invalid_empty (void)
{
GBytes *bytes;
GNode *asn;
- gulong bits;
- guint n_bits;
+
+ const gchar DER[] = "\x03\x01\x09";
asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
g_assert (asn);
/* Should work */
- bytes = g_bytes_new_static (BITS_TEST, XL (BITS_TEST));
- if (!egg_asn1x_decode (asn, bytes))
- g_assert_not_reached ();
- g_bytes_unref (bytes);
- if (!egg_asn1x_get_bits_as_ulong (asn, &bits, &n_bits))
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
g_assert_not_reached ();
-
- g_assert_cmpuint (n_bits, ==, 18);
- g_assert_cmphex (bits, ==, 0x1b977);
+ g_assert (strstr (egg_asn1x_message (asn), "invalid number of empty bits"));
+ g_bytes_unref (bytes);
egg_asn1x_destroy (asn);
}
GNode *asn;
guchar bits[] = { 0x5d, 0x6e, 0x83 };
GBytes *check;
+ GBytes *bytes;
const guchar *ch;
guint n_bits = 17;
guint n_check;
asn = egg_asn1x_create (test_asn1_tab, "TestBitString");
g_assert (asn);
- egg_asn1x_take_bits_as_raw (asn, g_bytes_new (bits, 3), n_bits);
+ bytes = g_bytes_new (bits, 3);
+ egg_asn1x_set_bits_as_raw (asn, bytes, n_bits);
+ g_bytes_unref (bytes);
data = egg_asn1x_encode (asn, NULL);
g_assert (data);
}
static void
-test_any_set_raw (void)
+test_any_raw (void)
{
GBytes *bytes;
GNode *asn, *node;
egg_assert_cmpbytes (data, ==, SEQ_ENCODING, XL (SEQ_ENCODING));
check = egg_asn1x_get_element_raw (node);
- g_assert (check);
+ g_assert (check != NULL);
+ egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
+ g_bytes_unref (check);
+ check = egg_asn1x_get_any_raw (node, NULL);
+ g_assert (check != NULL);
egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
+ g_bytes_unref (check);
g_bytes_unref (data);
- g_bytes_unref (check);
egg_asn1x_destroy (asn);
g_assert (is_freed);
}
static void
-test_any_set_raw_explicit (void)
+test_any_raw_explicit (void)
{
GBytes *bytes;
GNode *asn, *node;
}
static void
+test_any_raw_invalid (void)
+{
+ GBytes *bytes;
+ GNode *asn, *node;
+
+ const gchar TRUNCATED[] = "\x04\x0A""farns";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestAnySeq");
+ g_assert (asn != NULL);
+
+ node = egg_asn1x_node (asn, "contents", NULL);
+ g_assert (node != NULL);
+
+ bytes = g_bytes_new_static (TRUNCATED, XL (TRUNCATED));
+ if (egg_asn1x_set_any_raw (node, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (node), "content is not encoded properly") != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_any_raw_not_set (void)
+{
+ GBytes *check;
+ GNode *asn, *node;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestAnySeq");
+ g_assert (asn != NULL);
+
+ node = egg_asn1x_node (asn, "contents", NULL);
+ g_assert (node != NULL);
+
+ check = egg_asn1x_get_any_raw (node, NULL);
+ g_assert (check == NULL);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_any_into (void)
+{
+ GBytes *bytes;
+ GNode *asn, *node;
+ GNode *part;
+ GBytes *data;
+ GBytes *check;
+
+ /* ENCODED SEQUENCE ANY with OCTET STRING */
+ const gchar SEQ_ENCODING[] = "\x30\x0C\x04\x0A""farnsworth";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestAnySeq");
+ g_assert (asn != NULL);
+
+ is_freed = FALSE;
+ node = egg_asn1x_node (asn, "contents", NULL);
+ g_assert (node);
+
+ bytes = g_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH),
+ test_is_freed, NULL);
+ part = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_assert (part != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_set_any_from (node, part);
+ egg_asn1x_destroy (part);
+
+ data = egg_asn1x_encode (asn, NULL);
+ g_assert (data != NULL);
+ egg_assert_cmpbytes (data, ==, SEQ_ENCODING, XL (SEQ_ENCODING));
+
+ part = egg_asn1x_create (test_asn1_tab, "TestOctetString");
+ if (!egg_asn1x_get_any_into (node, part))
+ g_assert_not_reached ();
+
+ check = egg_asn1x_encode (part, NULL);
+ egg_asn1x_destroy (part);
+ g_assert (check != NULL);
+ egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
+ g_bytes_unref (check);
+
+ g_bytes_unref (data);
+ egg_asn1x_destroy (asn);
+ g_assert (is_freed);
+}
+
+static void
+test_any_into_explicit (void)
+{
+ GBytes *bytes;
+ GNode *asn, *node;
+ GNode *part;
+ GBytes *data;
+ GBytes *check;
+
+ /* ENCODED SEQUENCE [89] ANY with OCTET STRING */
+ const gchar SEQ_ENCODING[] = "\x30\x0F\xBF\x59\x0C\x04\x0A""farnsworth";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestAnyExp");
+ g_assert (asn != NULL);
+
+ is_freed = FALSE;
+ node = egg_asn1x_node (asn, "contents", NULL);
+ g_assert (node);
+
+ bytes = g_bytes_new_with_free_func (SFARNSWORTH, XL (SFARNSWORTH),
+ test_is_freed, NULL);
+ part = egg_asn1x_create_and_decode (test_asn1_tab, "TestOctetString", bytes);
+ g_assert (part != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_set_any_from (node, part);
+ egg_asn1x_destroy (part);
+
+ data = egg_asn1x_encode (asn, NULL);
+ g_assert (data != NULL);
+ egg_assert_cmpbytes (data, ==, SEQ_ENCODING, XL (SEQ_ENCODING));
+
+ part = egg_asn1x_create (test_asn1_tab, "TestOctetString");
+ if (!egg_asn1x_get_any_into (node, part))
+ g_assert_not_reached ();
+
+ check = egg_asn1x_encode (part, NULL);
+ egg_asn1x_destroy (part);
+ g_assert (check != NULL);
+ egg_assert_cmpbytes (check, ==, SFARNSWORTH, XL (SFARNSWORTH));
+ g_bytes_unref (check);
+
+ g_bytes_unref (data);
+ egg_asn1x_destroy (asn);
+ g_assert (is_freed);
+}
+
+static void
+test_any_into_explicit_not_set (void)
+{
+ GNode *asn, *node;
+ GNode *part;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestAnyExp");
+ g_assert (asn != NULL);
+
+ node = egg_asn1x_node (asn, "contents", NULL);
+ g_assert (node);
+
+ part = egg_asn1x_create (test_asn1_tab, "TestOctetString");
+ if (egg_asn1x_get_any_into (node, part))
+ g_assert_not_reached ();
+
+ egg_asn1x_destroy (part);
+ egg_asn1x_destroy (asn);
+}
+
+static void
test_choice_not_chosen (void)
{
GBytes *bytes;
}
static void
-test_any_choice_set_raw_long_tag (void)
+test_any_choice_set_raw_long_tag (void)
+{
+ const gchar ENCODING[] = "\xBF\x1F\x0C\x04\x0A""farnsworth";
+ perform_asn1_any_choice_set_raw ("choiceLongTag", ENCODING, XL (ENCODING));
+}
+
+static void
+test_seq_of_any (void)
+{
+ GNode *asn;
+ GNode *integer;
+ GBytes *bytes;
+ gboolean ret;
+ gulong value;
+
+ const gchar DER[] = "\x30\x06"
+ "\x02\x01\x88"
+ "\x02\x01\x33";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOfAny");
+ g_assert (asn != NULL);
+
+ egg_asn1x_append (asn);
+ egg_asn1x_append (asn);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ ret = egg_asn1x_decode (asn, bytes);
+ egg_asn1x_assert (ret == TRUE, asn);
+ g_bytes_unref (bytes);
+
+ integer = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (integer != NULL);
+
+ ret = egg_asn1x_get_any_into (egg_asn1x_node (asn, 1, NULL), integer);
+ egg_asn1x_assert (ret == TRUE, integer);
+ if (!egg_asn1x_get_integer_as_ulong (integer, &value))
+ g_assert_not_reached ();
+ g_assert_cmpint (value, ==, 0x88);
+
+ ret = egg_asn1x_get_any_into (egg_asn1x_node (asn, 2, NULL), integer);
+ egg_asn1x_assert (ret == TRUE, integer);
+ if (!egg_asn1x_get_integer_as_ulong (integer, &value))
+ g_assert_not_reached ();
+ g_assert_cmpint (value, ==, 0x33);
+
+ egg_asn1x_destroy (integer);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_seq_of_invalid (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ const gchar DER[] = "\x30\x05"
+ "\x04\x00"
+ "\x02\x01\x88";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOf");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_seq_of_different (void)
+{
+ GNode *asn;
+ GBytes *bytes;
+
+ const gchar DER[] = "\x30\x05"
+ "\x02\x01\x88"
+ "\x04\x00";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOf");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_set_order (void)
{
- const gchar ENCODING[] = "\xBF\x1F\x0C\x04\x0A""farnsworth";
- perform_asn1_any_choice_set_raw ("choiceLongTag", ENCODING, XL (ENCODING));
+ GNode *asn;
+ GBytes *bytes;
+
+ const gchar DER[] = "\x31\x0f"
+ "\xA2\x03\x02\x01\x99"
+ "\xA1\x03\x02\x01\x88"
+ "\xA3\x03\x02\x01\x88";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSet");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "content must be in ascending order"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
}
static void
egg_asn1x_destroy (asn);
}
+static void
+test_enumerated_decode_bad (void)
+{
+ const gchar ENUM_NEGATIVE[] = "\x0A\x01\x85";
+
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestEnumerated");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (ENUM_NEGATIVE, XL (ENUM_NEGATIVE));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "enumerated must be positive") != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_enumerated_not_in_list (void)
+{
+ const gchar ENUM_OTHER[] = "\x0A\x01\x08";
+ const gchar ENUM_LARGE[] = "\x0A\x20\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f";
+
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestEnumerated");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (ENUM_OTHER, XL (ENUM_OTHER));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "not part of list") != NULL);
+ g_bytes_unref (bytes);
+
+ bytes = g_bytes_new_static (ENUM_LARGE, XL (ENUM_LARGE));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "not part of list") != NULL);
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_enumerated_not_set (void)
+{
+ GNode *asn;
+ GQuark value;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestEnumerated");
+ g_assert (asn != NULL);
+
+ value = egg_asn1x_get_enumerated (asn);
+ g_assert (value == 0);
+
+ egg_asn1x_destroy (asn);
+}
+
+
typedef struct {
GNode *asn1;
guchar *data;
}
static void
-test_oid (Test* test, gconstpointer unused)
+test_oid (void)
{
GBytes *buffer;
GNode *asn = NULL;
egg_asn1x_destroy (asn);
}
+static void
+test_oid_set_invalid (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestOid");
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ if (egg_asn1x_set_oid_as_string (egg_asn1x_node (asn, "oid", NULL), "abcd"))
+ g_assert_not_reached ();
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_oid_decode_bad (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ /* Has invalid leading integer in oid value */
+ const gchar INVALID_OID[] = "\x30\x07\x06\x05\x2b\x80\x83\x82\x1a";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestOid");
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ bytes = g_bytes_new_static (INVALID_OID, XL (INVALID_OID));
+ ret = egg_asn1x_decode (asn, bytes);
+ g_assert (ret == FALSE);
+ g_assert (strstr (egg_asn1x_message (asn), "object id encoding is invalid") != NULL);
+
+ g_bytes_unref (bytes);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_oid_get_no_value (void)
+{
+ GNode *asn;
+ gchar *oid;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestOid");
+ g_assert ("asn test structure is null" && asn != NULL);
+
+ oid = egg_asn1x_get_oid_as_string (egg_asn1x_node (asn, "oid", NULL));
+ g_assert (oid == NULL);
+
+ egg_asn1x_destroy (asn);
+}
+
typedef struct _TimeTestData {
gchar *value;
time_t ref;
egg_asn1x_destroy (asn);
}
+static void
+test_create_and_decode_invalid (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ bytes = g_bytes_new_static ("", 0);
+ asn = egg_asn1x_create_and_decode (test_asn1_tab, "TestData", bytes);
+ g_assert (asn == NULL);
+ g_bytes_unref (bytes);
+}
+
+static void
+test_decode_extra (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOf");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("\x30\x00\x11", 3);
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "extra unexpected trailing data"));
+ g_bytes_unref (bytes);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_decode_nested_short (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOfAny");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("\x30\x02\xA5\x08", 4);
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "content is not encoded properly"));
+ g_bytes_unref (bytes);
+
+ bytes = g_bytes_new_static ("\x30\x04\x30\x02\xA5\x08", 6);
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "content is not encoded properly"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_decode_indefinite_primitive (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static ("\x04\x80\x04\x01\x55\x00\x00", 7);
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "indefinite length on non-structured type"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_decode_invalid_long_length (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\x04\xA0"
+ "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+ "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01";
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "content is not encoded properly"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_decode_truncated_at_tag (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+
+ const gchar DER[] = "\x04";
+ asn = egg_asn1x_create (test_asn1_tab, "TestInteger");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ if (egg_asn1x_decode (asn, bytes))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "content is not encoded properly"));
+ g_bytes_unref (bytes);
+
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_decode_long_tag (void)
+{
+ GBytes *bytes;
+ GNode *asn;
+ gboolean ret;
+
+ const gchar DER[] = "\xbf\x89\x52\x03\x04\x01\x33";
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestTagLong");
+ g_assert (asn != NULL);
+
+ bytes = g_bytes_new_static (DER, XL (DER));
+ ret = egg_asn1x_decode (asn, bytes);
+ egg_asn1x_assert (ret == TRUE, asn);
+
+ g_bytes_unref (bytes);
+ egg_asn1x_destroy (asn);
+
+}
+
+static void
+test_create_quark (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create_quark (test_asn1_tab, g_quark_from_static_string ("1.5.13"));
+ g_assert (asn != NULL);
+ g_assert_cmpstr (egg_asn1x_name (asn), ==, "TestIntegers");
+}
+
+static void
+test_validate_default (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBooleanSeq");
+ /* We leave first boolean field empty */
+ egg_asn1x_set_boolean (egg_asn1x_node (asn, "boolean2", NULL), TRUE);
+ if (!egg_asn1x_validate (asn, TRUE))
+ g_assert_not_reached ();
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_validate_missing (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBooleanSeq");
+ /* No fields set */
+ if (egg_asn1x_validate (asn, TRUE))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "missing value") != NULL);
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_validate_seq_of_child_invalid (void)
+{
+ GNode *asn;
+ GNode *child;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOfSeq");
+ child = egg_asn1x_append (asn);
+ egg_asn1x_set_integer_as_ulong (egg_asn1x_node (child, "uint1", NULL), 5);
+ /* We didn't set uint2 or uint3 so the child is invalid */
+ if (egg_asn1x_validate (asn, TRUE))
+ g_assert_not_reached ();
+ g_assert (strstr (egg_asn1x_message (asn), "missing value") != NULL);
+ egg_asn1x_destroy (asn);
+
+}
+
+static void
+test_validate_optional_seq (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestSeqOptional");
+ if (!egg_asn1x_validate (asn, TRUE))
+ g_assert_not_reached ();
+ egg_asn1x_destroy (asn);
+}
+
+static void
+test_element_get_not_set (void)
+{
+ GNode *asn;
+
+ asn = egg_asn1x_create (test_asn1_tab, "TestBooleanSeq");
+ g_assert (egg_asn1x_get_element_raw (asn) == NULL);
+ egg_asn1x_destroy (asn);
+}
+
int
main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
+ g_test_add_func ("/asn1/decode/extra", test_decode_extra);
+ g_test_add_func ("/asn1/decode/nested-short", test_decode_nested_short);
+ g_test_add_func ("/asn1/decode/indefinite-primitive", test_decode_indefinite_primitive);
+ g_test_add_func ("/asn1/decode/invalid-long-length", test_decode_invalid_long_length);
+ g_test_add_func ("/asn1/decode/truncated-at-tag", test_decode_truncated_at_tag);
+ g_test_add_func ("/asn1/decode/decode-long-tag", test_decode_long_tag);
g_test_add_func ("/asn1/boolean", test_boolean);
+ g_test_add_func ("/asn1/boolean-bad", test_boolean_decode_bad);
+ g_test_add_func ("/asn1/boolean-default", test_boolean_default);
g_test_add_func ("/asn1/null", test_null);
g_test_add_func ("/asn1/integer", test_integer);
+ g_test_add_func ("/asn1/integer-zero-length", test_integer_zero_length);
+ g_test_add_func ("/asn1/integer/raw", test_integer_raw);
+ g_test_add_func ("/asn1/integer/raw-not-twos-complement", test_integer_raw_not_twos_complement);
g_test_add_func ("/asn1/unsigned", test_unsigned);
+ g_test_add_func ("/asn1/unsigned/not-set", test_unsigned_not_set);
+ g_test_add_func ("/asn1/unsigned/default", test_unsigned_default);
+ g_test_add_func ("/asn1/unsigned/constant", test_unsigned_constant);
+ g_test_add_func ("/asn1/unsigned/zero", test_unsigned_zero);
g_test_add_func ("/asn1/octet_string", test_octet_string);
+ g_test_add_func ("/asn1/octet-string/set-bad-utf8", test_octet_string_set_bad_utf8);
+ g_test_add_func ("/asn1/octet-string/bmp-as-utf8", test_octet_string_bmp_as_utf8);
+ g_test_add_func ("/asn1/octet-string/get-as-bytes", test_octet_string_get_as_bytes);
+ g_test_add_func ("/asn1/octet-string/set-as-bytes", test_octet_string_set_as_bytes);
+ g_test_add_func ("/asn1/octet-string/structured", test_octet_string_structured);
+ g_test_add_func ("/asn1/octet-string/structured-bad", test_octet_string_structured_bad);
g_test_add_func ("/asn1/generalized_time", test_generalized_time);
+ g_test_add_func ("/asn1/time-get-missing", test_time_get_missing);
g_test_add_func ("/asn1/implicit/decode", test_implicit_decode);
g_test_add_func ("/asn1/implicit/encode", test_implicit_encode);
g_test_add_func ("/asn1/explicit/decode", test_explicit_decode);
g_test_add_func ("/asn1/explicit/encode", test_explicit_encode);
+ g_test_add_func ("/asn1/explicit/no-context-specific", test_explicit_no_context_specific);
+ g_test_add_func ("/asn1/explicit/no-context-child", test_explicit_no_context_child);
+ g_test_add_func ("/asn1/explicit/extra-context-child", test_explicit_extra_context_child);
g_test_add_func ("/asn1/universal/decode", test_universal_decode);
g_test_add_func ("/asn1/universal/encode", test_universal_encode);
g_test_add_func ("/asn1/bit_string_decode", test_bit_string_decode);
g_test_add_func ("/asn1/bit_string_encode_decode", test_bit_string_encode_decode);
g_test_add_func ("/asn1/bit_string_encode_decode_ulong", test_bit_string_encode_decode_ulong);
g_test_add_func ("/asn1/bit_string_encode_decode_zero", test_bit_string_encode_decode_zero);
+ g_test_add_func ("/asn1/bit-string/ulong-too-long", test_bit_string_ulong_too_long);
+ g_test_add_func ("/asn1/bit-string/get-not-set", test_bit_string_get_not_set);
+ g_test_add_func ("/asn1/bit-string/invalid-length", test_bit_string_invalid_length);
+ g_test_add_func ("/asn1/bit-string/invalid-empty", test_bit_string_invalid_empty);
+ g_test_add_func ("/asn1/oid", test_oid);
+ g_test_add_func ("/asn1/oid/set-invalid", test_oid_set_invalid);
+ g_test_add_func ("/asn1/oid/get-no-value", test_oid_get_no_value);
+ g_test_add_func ("/asn1/oid/decode-bad", test_oid_decode_bad);
g_test_add_func ("/asn1/have", test_have);
- g_test_add_func ("/asn1/any_set_raw", test_any_set_raw);
- g_test_add_func ("/asn1/any_set_raw_explicit", test_any_set_raw_explicit);
+ g_test_add_func ("/asn1/any-raw", test_any_raw);
+ g_test_add_func ("/asn1/any-raw/explicit", test_any_raw_explicit);
+ g_test_add_func ("/asn1/any-raw/invalid", test_any_raw_invalid);
+ g_test_add_func ("/asn1/any-raw/not-set", test_any_raw_not_set);
+ g_test_add_func ("/asn1/any-into", test_any_into);
+ g_test_add_func ("/asn1/any-into/explicit", test_any_into_explicit);
+ g_test_add_func ("/asn1/any-into/explicit-not-set", test_any_into_explicit_not_set);
g_test_add_func ("/asn1/choice_not_chosen", test_choice_not_chosen);
g_test_add_func ("/asn1/any_choice_set_raw_short_tag", test_any_choice_set_raw_short_tag);
g_test_add_func ("/asn1/any_choice_set_raw_long_tag", test_any_choice_set_raw_long_tag);
+ g_test_add_func ("/asn1/seq-of-any", test_seq_of_any);\
+ g_test_add_func ("/asn1/seq-of-invalid", test_seq_of_invalid);
+ g_test_add_func ("/asn1/seq-of-different", test_seq_of_different);
+ g_test_add_func ("/asn1/set-order", test_set_order);
g_test_add_func ("/asn1/append", test_append);
g_test_add_func ("/asn1/append_and_clear", test_append_and_clear);
g_test_add_func ("/asn1/setof", test_setof);
g_test_add_func ("/asn1/setof_empty", test_setof_empty);
g_test_add_func ("/asn1/enumerated", test_enumerated);
+ g_test_add_func ("/asn1/enumerated-bad", test_enumerated_decode_bad);
+ g_test_add_func ("/asn1/enumerated-not-in-list", test_enumerated_not_in_list);
+ g_test_add_func ("/asn1/enumerated-not-set", test_enumerated_not_set);
g_test_add_func ("/asn1/nested-fails-with-extra", test_nested_fails_with_extra);
g_test_add_func ("/asn1/nested-unexpected", test_nested_unexpected);
+ g_test_add_func ("/asn1/create-and-decode-invalid", test_create_and_decode_invalid);
+ g_test_add_func ("/asn1/create-quark", test_create_quark);
+ g_test_add_func ("/asn1/validate-default", test_validate_default);
+ g_test_add_func ("/asn1/validate-missing", test_validate_missing);
+ g_test_add_func ("/asn1/validate-seq-of-child-invalid", test_validate_seq_of_child_invalid);
+ g_test_add_func ("/asn1/validate-optional-seq", test_validate_optional_seq);
+ g_test_add_func ("/asn1/get-element/not-set", test_element_get_not_set);
g_test_add ("/asn1/node_name", Test, NULL, setup, test_node_name, teardown);
g_test_add ("/asn1/asn1_integers", Test, NULL, setup, test_asn1_integers, teardown);
g_test_add ("/asn1/boolean_seq", Test, NULL, setup, test_boolean_seq, teardown);
g_test_add ("/asn1/write_value", Test, NULL, setup, test_write_value, teardown);
g_test_add ("/asn1/element_length_content", Test, NULL, setup, test_element_length_content, teardown);
g_test_add ("/asn1/read_element", Test, NULL, setup, test_read_element, teardown);
- g_test_add ("/asn1/oid", Test, NULL, setup, test_oid, teardown);
g_test_add ("/asn1/general_time", Test, NULL, setup, test_general_time, teardown);
g_test_add ("/asn1/utc_time", Test, NULL, setup, test_utc_time, teardown);
g_test_add ("/asn1/read_time", Test, NULL, setup, test_read_time, teardown);