static int _gnutls_x509_expand_extensions(ASN1_TYPE * rasn)
{
    int k, result, len;
    char name[128], name2[128], counter[MAX_INT_DIGITS];
    char name1[128];
    char extnID[128];

    k = 0;
    do {
	k++;

	_gnutls_str_cpy(name, sizeof(name), "tbsCertificate.extensions.?");
	_gnutls_int2str(k, counter);
	_gnutls_str_cat(name, sizeof(name), counter);

	_gnutls_str_cpy(name2, sizeof(name2), name);
	_gnutls_str_cat(name2, sizeof(name2), ".extnID");

	_gnutls_str_cpy(name1, sizeof(name1), name);
	_gnutls_str_cat(name1, sizeof(name1), ".extnValue");

	len = sizeof(extnID) - 1;

	result = asn1_expand_octet_string(_gnutls_get_pkix(),
					  rasn, name1, name2);

	if (result == ASN1_ELEMENT_NOT_FOUND)
	    break;
	else if (result != ASN1_SUCCESS) {
	    gnutls_assert();
	    return _gnutls_asn2err(result);
	}

    } while (1);

    if (result == ASN1_ELEMENT_NOT_FOUND)
	return 0;
    else
	return _gnutls_asn2err(result);
}
static int _gnutls_x509_expand_extensions(ASN1_TYPE * rasn)
{
    int k, result, len;
    char name[128], name2[128], counter[MAX_INT_DIGITS];
    char name1[128];
    char extnID[128];

    k = 0;
    do {
	k++;

	_gnutls_str_cpy(name, sizeof(name), "tbsCertificate.extensions.?");
	_gnutls_int2str(k, counter);
	_gnutls_str_cat(name, sizeof(name), counter);

	_gnutls_str_cpy(name2, sizeof(name2), name);
	_gnutls_str_cat(name2, sizeof(name2), ".extnID");

	_gnutls_str_cpy(name1, sizeof(name1), name);
	_gnutls_str_cat(name1, sizeof(name1), ".extnValue");

	len = sizeof(extnID) - 1;

	result = asn1_expand_octet_string(_gnutls_get_pkix(),
					  rasn, name1, name2);

	if (result == ASN1_ELEMENT_NOT_FOUND)
	    break;
	else if (result != ASN1_SUCCESS) {
	    gnutls_assert();
	    return _gnutls_asn2err(result);
	}

    } while (1);

    if (result == ASN1_ELEMENT_NOT_FOUND)
	return 0;
    else
	return _gnutls_asn2err(result);
}