list_init:
  235|      1|int list_init(list_t *simclist_restrict l) {
  236|      1|    if (l == NULL) {
  ------------------
  |  Branch (236:9): [True: 0, False: 1]
  ------------------
  237|      0|        return -1;
  238|      0|    }
  239|       |
  240|      1|    memset(l, 0, sizeof *l);
  241|       |
  242|      1|    seed_random();
  243|       |
  244|      1|    l->numels = 0;
  245|       |
  246|       |    /* head/tail sentinels and mid pointer */
  247|      1|    l->head_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  248|      1|    l->tail_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  249|      1|    if (l->tail_sentinel == NULL || l->head_sentinel == NULL) {
  ------------------
  |  Branch (249:9): [True: 0, False: 1]
  |  Branch (249:37): [True: 0, False: 1]
  ------------------
  250|      0|        return -1;
  251|      0|    }
  252|      1|    l->head_sentinel->next = l->tail_sentinel;
  253|      1|    l->tail_sentinel->prev = l->head_sentinel;
  254|      1|    l->head_sentinel->prev = l->tail_sentinel->next = l->mid = NULL;
  255|      1|    l->head_sentinel->data = l->tail_sentinel->data = NULL;
  256|       |
  257|       |    /* iteration attributes */
  258|      1|    l->iter_active = 0;
  259|      1|    l->iter_pos = 0;
  260|      1|    l->iter_curentry = NULL;
  261|       |
  262|       |    /* free-list attributes */
  263|      1|    l->spareelsnum = 0;
  264|      1|    l->spareels = (struct list_entry_s **)malloc(SIMCLIST_MAX_SPARE_ELEMS * sizeof(struct list_entry_s *));
  ------------------
  |  |  115|      1|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  265|      1|    if (l->spareels == NULL) {
  ------------------
  |  Branch (265:9): [True: 0, False: 1]
  ------------------
  266|      0|        return -1;
  267|      0|    }
  268|       |
  269|       |#ifdef SIMCLIST_WITH_THREADS
  270|       |    l->threadcount = 0;
  271|       |#endif
  272|       |
  273|      1|    if (0 != list_attributes_setdefaults(l)) {
  ------------------
  |  Branch (273:9): [True: 0, False: 1]
  ------------------
  274|      0|        return -1;
  275|      0|    }
  276|       |
  277|      1|    assert(list_repOk(l));
  278|      1|    assert(list_attrOk(l));
  279|       |
  280|      1|    return 0;
  281|      1|}
list_attributes_seeker:
  325|      1|int list_attributes_seeker(list_t *simclist_restrict l, element_seeker seeker_fun) {
  326|      1|    if (l == NULL) return -1;
  ------------------
  |  Branch (326:9): [True: 0, False: 1]
  ------------------
  327|       |
  328|      1|    l->attrs.seeker = seeker_fun;
  329|      1|    assert(list_attrOk(l));
  330|       |
  331|      1|    return 0;
  332|      1|}
simclist.c:list_attributes_setdefaults:
  295|      1|int list_attributes_setdefaults(list_t *simclist_restrict l) {
  296|      1|    l->attrs.comparator = NULL;
  297|      1|    l->attrs.seeker = NULL;
  298|       |
  299|       |    /* also free() element data when removing and element from the list */
  300|      1|    l->attrs.meter = NULL;
  301|      1|    l->attrs.copy_data = 0;
  302|       |
  303|      1|    l->attrs.hasher = NULL;
  304|       |
  305|       |    /* serializer/unserializer */
  306|      1|    l->attrs.serializer = NULL;
  307|      1|    l->attrs.unserializer = NULL;
  308|       |
  309|      1|    assert(list_attrOk(l));
  310|       |
  311|      1|    return 0;
  312|      1|}

sc_asn1_read_tag:
   64|    972|{
   65|    972|	const u8 *p = *buf;
   66|    972|	size_t left = buflen, len;
   67|    972|	unsigned int cla, tag, i;
   68|       |
   69|    972|	*buf = NULL;
   70|       |
   71|    972|	if (left == 0 || !p || buflen == 0)
  ------------------
  |  Branch (71:6): [True: 33, False: 939]
  |  Branch (71:19): [True: 0, False: 939]
  |  Branch (71:25): [True: 0, False: 939]
  ------------------
   72|     33|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     33|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   73|    939|	if (*p == 0xff || *p == 0) {
  ------------------
  |  Branch (73:6): [True: 2, False: 937]
  |  Branch (73:20): [True: 7, False: 930]
  ------------------
   74|       |		/* end of data reached */
   75|      9|		*taglen = 0;
   76|      9|		*tag_out = SC_ASN1_TAG_EOC;
  ------------------
  |  |  194|      9|#define SC_ASN1_TAG_EOC			0
  ------------------
   77|      9|		return SC_SUCCESS;
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
   78|      9|	}
   79|       |
   80|       |	/* parse tag byte(s)
   81|       |	 * Resulted tag is presented by integer that has not to be
   82|       |	 * confused with the 'tag number' part of ASN.1 tag.
   83|       |	 */
   84|    930|	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  184|    930|#define SC_ASN1_TAG_CLASS		0xC0
  ------------------
              	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  190|    930|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
   85|    930|	tag = *p & SC_ASN1_TAG_PRIMITIVE;
  ------------------
  |  |  191|    930|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
   86|    930|	if (left < 1)
  ------------------
  |  Branch (86:6): [True: 0, False: 930]
  ------------------
   87|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   88|    930|	p++;
   89|    930|	left--;
   90|    930|	if (tag == SC_ASN1_TAG_PRIMITIVE) {
  ------------------
  |  |  191|    930|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
  |  Branch (90:6): [True: 70, False: 860]
  ------------------
   91|       |		/* high tag number */
   92|     70|		size_t n = SC_ASN1_TAGNUM_SIZE - 1;
  ------------------
  |  |  145|     70|#define SC_ASN1_TAGNUM_SIZE		3
  ------------------
   93|       |		/* search the last tag octet */
   94|    121|		do {
   95|    121|			if (left == 0 || n == 0)
  ------------------
  |  Branch (95:8): [True: 3, False: 118]
  |  Branch (95:21): [True: 7, False: 111]
  ------------------
   96|       |				/* either an invalid tag or it doesn't fit in
   97|       |				 * unsigned int */
   98|     10|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     10|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   99|    111|			tag <<= 8;
  100|    111|			tag |= *p;
  101|    111|			p++;
  102|    111|			left--;
  103|    111|			n--;
  104|    111|		} while (tag & 0x80);
  ------------------
  |  Branch (104:12): [True: 51, False: 60]
  ------------------
  105|     70|	}
  106|       |
  107|       |	/* parse length byte(s) */
  108|    920|	if (left == 0)
  ------------------
  |  Branch (108:6): [True: 5, False: 915]
  ------------------
  109|      5|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      5|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  110|    915|	len = *p;
  111|    915|	p++;
  112|    915|	left--;
  113|    915|	if (len & 0x80) {
  ------------------
  |  Branch (113:6): [True: 434, False: 481]
  ------------------
  114|    434|		len &= 0x7f;
  115|    434|		unsigned int a = 0;
  116|    434|		if (len > sizeof a || len > left)
  ------------------
  |  Branch (116:7): [True: 27, False: 407]
  |  Branch (116:25): [True: 5, False: 402]
  ------------------
  117|     32|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     32|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  118|  1.31k|		for (i = 0; i < len; i++) {
  ------------------
  |  Branch (118:15): [True: 908, False: 402]
  ------------------
  119|    908|			a <<= 8;
  120|    908|			a |= *p;
  121|    908|			p++;
  122|    908|			left--;
  123|    908|		}
  124|    402|		len = a;
  125|    402|	}
  126|       |
  127|    883|	*cla_out = cla;
  128|    883|	*tag_out = tag;
  129|    883|	*taglen = len;
  130|    883|	*buf = p;
  131|       |
  132|    883|	if (len > left)
  ------------------
  |  Branch (132:6): [True: 133, False: 750]
  ------------------
  133|    133|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|    133|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  134|       |
  135|    750|	return SC_SUCCESS;
  ------------------
  |  |   28|    750|#define SC_SUCCESS				0
  ------------------
  136|    883|}
sc_format_asn1_entry:
  140|  3.22k|{
  141|  3.22k|	entry->parm = parm;
  142|  3.22k|	entry->arg  = arg;
  143|  3.22k|	if (set_present)
  ------------------
  |  Branch (143:6): [True: 1.61k, False: 1.61k]
  ------------------
  144|  1.61k|		entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  1.61k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  145|  3.22k|}
sc_copy_asn1_entry:
  149|  2.15k|{
  150|  5.38k|	while (src->name != NULL) {
  ------------------
  |  Branch (150:9): [True: 3.22k, False: 2.15k]
  ------------------
  151|  3.22k|		*dest = *src;
  152|  3.22k|		dest++;
  153|  3.22k|		src++;
  154|  3.22k|	}
  155|       |	dest->name = NULL;
  156|  2.15k|}
sc_asn1_skip_tag:
  524|    972|{
  525|    972|	const u8 *p = *buf;
  526|    972|	size_t len = *buflen, taglen;
  527|    972|	unsigned int cla = 0, tag;
  528|       |
  529|    972|	if (sc_asn1_read_tag((const u8 **) &p, len, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|  1.94k|#define SC_SUCCESS				0
  ------------------
  |  Branch (529:6): [True: 213, False: 759]
  ------------------
  530|    759|			|| p == NULL)
  ------------------
  |  Branch (530:7): [True: 9, False: 750]
  ------------------
  531|    222|		return NULL;
  532|    750|	switch (cla & 0xC0) {
  ------------------
  |  Branch (532:10): [True: 750, False: 0]
  ------------------
  533|    701|	case SC_ASN1_TAG_UNIVERSAL:
  ------------------
  |  |  185|    701|#define SC_ASN1_TAG_UNIVERSAL		0x00
  ------------------
  |  Branch (533:2): [True: 701, False: 49]
  ------------------
  534|    701|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  136|    701|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  137|    701|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (534:7): [True: 0, False: 701]
  ------------------
  535|      0|			return NULL;
  536|    701|		break;
  537|    701|	case SC_ASN1_TAG_APPLICATION:
  ------------------
  |  |  186|     18|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
  |  Branch (537:2): [True: 18, False: 732]
  ------------------
  538|     18|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  136|     18|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  138|     18|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (538:7): [True: 18, False: 0]
  ------------------
  539|     18|			return NULL;
  540|      0|		break;
  541|     13|	case SC_ASN1_TAG_CONTEXT:
  ------------------
  |  |  187|     13|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
  |  Branch (541:2): [True: 13, False: 737]
  ------------------
  542|     13|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  136|     13|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  139|     13|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (542:7): [True: 13, False: 0]
  ------------------
  543|     13|			return NULL;
  544|      0|		break;
  545|     18|	case SC_ASN1_TAG_PRIVATE:
  ------------------
  |  |  188|     18|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
  |  Branch (545:2): [True: 18, False: 732]
  ------------------
  546|     18|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  136|     18|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  140|     18|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (546:7): [True: 18, False: 0]
  ------------------
  547|     18|			return NULL;
  548|      0|		break;
  549|    750|	}
  550|    701|	if (cla & SC_ASN1_TAG_CONSTRUCTED) {
  ------------------
  |  |  190|    701|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (550:6): [True: 308, False: 393]
  ------------------
  551|    308|		if ((tag_in & SC_ASN1_CONS) == 0)
  ------------------
  |  |  141|    308|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (551:7): [True: 4, False: 304]
  ------------------
  552|      4|			return NULL;
  553|    308|	} else
  554|    393|		if (tag_in & SC_ASN1_CONS)
  ------------------
  |  |  141|    393|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (554:7): [True: 9, False: 384]
  ------------------
  555|      9|			return NULL;
  556|    688|	if ((tag_in & SC_ASN1_TAG_MASK) != tag)
  ------------------
  |  |  144|    688|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
  |  Branch (556:6): [True: 51, False: 637]
  ------------------
  557|     51|		return NULL;
  558|    637|	len -= (p - *buf);	/* header size */
  559|    637|	if (taglen > len) {
  ------------------
  |  Branch (559:6): [True: 0, False: 637]
  ------------------
  560|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  561|      0|			 "too long ASN.1 object (size %"SC_FORMAT_LEN_SIZE_T"u while only %"SC_FORMAT_LEN_SIZE_T"u available)\n",
  562|      0|			 taglen, len);
  563|      0|		return NULL;
  564|      0|	}
  565|    637|	*buflen -= (p - *buf) + taglen;
  566|    637|	*buf = p + taglen;	/* point to next tag */
  567|    637|	*taglen_out = taglen;
  568|    637|	return p;
  569|    637|}
sc_asn1_decode:
 1816|    538|{
 1817|    538|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 0, 0);
 1818|    538|}
sc_asn1_encode:
 2088|    538|{
 2089|    538|	return asn1_encode(ctx, asn1, ptr, size, 0);
 2090|    538|}
sc_asn1_sig_value_rs_to_sequence:
 2162|    538|{
 2163|    538|	struct sc_asn1_entry asn1_sig_value[C_ASN1_SIG_VALUE_SIZE];
 2164|    538|	struct sc_asn1_entry asn1_sig_value_coefficients[C_ASN1_SIG_VALUE_COEFFICIENTS_SIZE];
 2165|    538|	unsigned char *r = in, *s = in + inlen/2;
 2166|    538|	size_t r_len = inlen/2, s_len = inlen/2;
 2167|    538|	int rv;
 2168|       |
 2169|    538|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    538|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    538|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    538|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    538|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 538]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2170|       |
 2171|       |	/* R/S are filled up with zeroes, we do not want that in sequence format */
 2172|    868|	while(r_len > 1 && *r == 0x00) {
  ------------------
  |  Branch (2172:8): [True: 808, False: 60]
  |  Branch (2172:21): [True: 330, False: 478]
  ------------------
 2173|    330|		r++;
 2174|    330|		r_len--;
 2175|    330|	}
 2176|  1.84M|	while(s_len > 1 && *s == 0x00) {
  ------------------
  |  Branch (2176:8): [True: 1.84M, False: 69]
  |  Branch (2176:21): [True: 1.84M, False: 469]
  ------------------
 2177|  1.84M|		s++;
 2178|  1.84M|		s_len--;
 2179|  1.84M|	}
 2180|       |
 2181|    538|	sc_copy_asn1_entry(c_asn1_sig_value, asn1_sig_value);
 2182|    538|	sc_format_asn1_entry(asn1_sig_value + 0, asn1_sig_value_coefficients, NULL, 1);
 2183|       |
 2184|    538|	sc_copy_asn1_entry(c_asn1_sig_value_coefficients, asn1_sig_value_coefficients);
 2185|    538|	sc_format_asn1_entry(asn1_sig_value_coefficients + 0, r, &r_len, 1);
 2186|    538|	sc_format_asn1_entry(asn1_sig_value_coefficients + 1, s, &s_len, 1);
 2187|       |
 2188|    538|	rv = sc_asn1_encode(ctx, asn1_sig_value, buf, buflen);
 2189|    538|	LOG_TEST_RET(ctx, rv, "ASN.1 encoding ECDSA-SIg-Value failed");
  ------------------
  |  |  174|    538|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    538|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    538|	int _ret = (r); \
  |  |  |  |  168|    538|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 537]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|    538|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 537]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2190|       |
 2191|    537|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    537|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    537|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    537|	int _ret = r; \
  |  |  |  |  155|    537|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 537, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    537|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 537]
  |  |  |  |  ------------------
  |  |  |  |  157|    537|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    537|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    537|	return _ret; \
  |  |  |  |  163|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2192|    537|}
sc_asn1_sig_value_sequence_to_rs:
 2198|    538|{
 2199|    538|	struct sc_asn1_entry asn1_sig_value[C_ASN1_SIG_VALUE_SIZE];
 2200|    538|	struct sc_asn1_entry asn1_sig_value_coefficients[C_ASN1_SIG_VALUE_COEFFICIENTS_SIZE];
 2201|    538|	unsigned char *r = NULL, *s = NULL;
 2202|    538|	size_t r_len = 0, s_len = 0, halflen = buflen/2;
 2203|    538|	int rv;
 2204|       |
 2205|    538|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    538|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    538|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    538|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    538|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 538]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2206|    538|	if (!buf || !buflen)
  ------------------
  |  Branch (2206:6): [True: 0, False: 538]
  |  Branch (2206:14): [True: 0, False: 538]
  ------------------
 2207|    538|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2208|       |
 2209|    538|	sc_copy_asn1_entry(c_asn1_sig_value, asn1_sig_value);
 2210|    538|	sc_format_asn1_entry(asn1_sig_value + 0, asn1_sig_value_coefficients, NULL, 0);
 2211|       |
 2212|    538|	sc_copy_asn1_entry(c_asn1_sig_value_coefficients, asn1_sig_value_coefficients);
 2213|    538|	sc_format_asn1_entry(asn1_sig_value_coefficients + 0, &r, &r_len, 0);
 2214|    538|	sc_format_asn1_entry(asn1_sig_value_coefficients + 1, &s, &s_len, 0);
 2215|       |
 2216|    538|	rv = sc_asn1_decode(ctx, asn1_sig_value, in, inlen, NULL, NULL);
 2217|    538|	LOG_TEST_GOTO_ERR(ctx, rv, "ASN.1 decoding ECDSA-Sig-Value failed");
  ------------------
  |  |  184|    538|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    538|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    538|	int _ret = (r); \
  |  |  |  |  178|    538|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 376, False: 162]
  |  |  |  |  ------------------
  |  |  |  |  179|    376|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    376|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    376|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    376|		goto err; \
  |  |  |  |  182|    376|	} \
  |  |  |  |  183|    538|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 162]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2218|       |
 2219|    162|	if (halflen < r_len || halflen < s_len)   {
  ------------------
  |  Branch (2219:6): [True: 0, False: 162]
  |  Branch (2219:25): [True: 0, False: 162]
  ------------------
 2220|      0|		rv = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 2221|      0|		goto err;
 2222|      0|	}
 2223|       |
 2224|    162|	memset(buf, 0, buflen);
 2225|    162|	if (r_len > 0)
  ------------------
  |  Branch (2225:6): [True: 74, False: 88]
  ------------------
 2226|     74|		memcpy(buf + (halflen - r_len), r, r_len);
 2227|    162|	if (s_len > 0)
  ------------------
  |  Branch (2227:6): [True: 85, False: 77]
  ------------------
 2228|     85|		memcpy(buf + (buflen - s_len), s, s_len);
 2229|       |
 2230|    162|	sc_log(ctx, "r(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen,
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2231|    162|	       sc_dump_hex(buf, halflen));
 2232|    162|	sc_log(ctx, "s(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen,
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2233|    162|	       sc_dump_hex(buf + halflen, halflen));
 2234|       |
 2235|    162|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    162|#define SC_SUCCESS				0
  ------------------
 2236|    538|err:
 2237|    538|	free(r);
 2238|    538|	free(s);
 2239|       |
 2240|    538|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    538|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    538|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    538|	int _ret = r; \
  |  |  |  |  155|    538|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 538, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    538|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    376|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 376, False: 162]
  |  |  |  |  ------------------
  |  |  |  |  157|    538|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    538|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    538|	return _ret; \
  |  |  |  |  163|    538|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2241|    538|}
asn1.c:asn1_write_element:
 1056|  1.61k|{
 1057|  1.61k|	unsigned char t;
 1058|  1.61k|	unsigned char *buf, *p;
 1059|  1.61k|	int c = 0;
 1060|  1.61k|	unsigned short_tag;
 1061|  1.61k|	unsigned char tag_char[3] = {0, 0, 0};
 1062|  1.61k|	size_t tag_len, ii;
 1063|       |
 1064|  1.61k|	short_tag = tag & SC_ASN1_TAG_MASK;
  ------------------
  |  |  144|  1.61k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
 1065|  3.22k|	for (tag_len = 0; short_tag >> (8 * tag_len); tag_len++)
  ------------------
  |  Branch (1065:20): [True: 1.61k, False: 1.61k]
  ------------------
 1066|  1.61k|		tag_char[tag_len] = (short_tag >> (8 * tag_len)) & 0xFF;
 1067|  1.61k|	if (!tag_len)
  ------------------
  |  Branch (1067:6): [True: 0, False: 1.61k]
  ------------------
 1068|      0|		tag_len = 1;
 1069|       |
 1070|  1.61k|	if (tag_len > 1)   {
  ------------------
  |  Branch (1070:6): [True: 0, False: 1.61k]
  ------------------
 1071|      0|		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  191|      0|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
              		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  222|      0|#define SC_ASN1_TAG_ESCAPE_MARKER	31
  ------------------
  |  Branch (1071:7): [True: 0, False: 0]
  ------------------
 1072|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "First byte of the long tag is not 'escape marker'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1073|       |
 1074|      0|		for (ii = 1; ii < tag_len - 1; ii++)
  ------------------
  |  Branch (1074:16): [True: 0, False: 0]
  ------------------
 1075|      0|			if (!(tag_char[ii] & 0x80))
  ------------------
  |  Branch (1075:8): [True: 0, False: 0]
  ------------------
 1076|      0|				SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit expected to be 'one'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1077|       |
 1078|      0|		if (tag_char[0] & 0x80)
  ------------------
  |  Branch (1078:7): [True: 0, False: 0]
  ------------------
 1079|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit of the last byte expected to be 'zero'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1080|      0|	}
 1081|       |
 1082|  1.61k|	t = tag_char[tag_len - 1] & 0x1F;
 1083|       |
 1084|  1.61k|	switch (tag & SC_ASN1_CLASS_MASK) {
  ------------------
  |  |  136|  1.61k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
  |  Branch (1084:10): [True: 1.61k, False: 0]
  ------------------
 1085|  1.61k|	case SC_ASN1_UNI:
  ------------------
  |  |  137|  1.61k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (1085:2): [True: 1.61k, False: 0]
  ------------------
 1086|  1.61k|		break;
 1087|      0|	case SC_ASN1_APP:
  ------------------
  |  |  138|      0|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (1087:2): [True: 0, False: 1.61k]
  ------------------
 1088|      0|		t |= SC_ASN1_TAG_APPLICATION;
  ------------------
  |  |  186|      0|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
 1089|      0|		break;
 1090|      0|	case SC_ASN1_CTX:
  ------------------
  |  |  139|      0|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (1090:2): [True: 0, False: 1.61k]
  ------------------
 1091|      0|		t |= SC_ASN1_TAG_CONTEXT;
  ------------------
  |  |  187|      0|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
 1092|      0|		break;
 1093|      0|	case SC_ASN1_PRV:
  ------------------
  |  |  140|      0|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (1093:2): [True: 0, False: 1.61k]
  ------------------
 1094|      0|		t |= SC_ASN1_TAG_PRIVATE;
  ------------------
  |  |  188|      0|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
 1095|      0|		break;
 1096|  1.61k|	}
 1097|  1.61k|	if (tag & SC_ASN1_CONS)
  ------------------
  |  |  141|  1.61k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (1097:6): [True: 537, False: 1.07k]
  ------------------
 1098|    537|		t |= SC_ASN1_TAG_CONSTRUCTED;
  ------------------
  |  |  190|    537|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
 1099|  1.61k|	if (datalen > 127) {
  ------------------
  |  Branch (1099:6): [True: 832, False: 779]
  ------------------
 1100|    832|		c = 1;
 1101|  1.85k|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1101:10): [True: 1.01k, False: 832]
  ------------------
 1102|  1.01k|			c++;
 1103|    832|	}
 1104|       |
 1105|  1.61k|	*outlen = tag_len + 1 + c + datalen;
 1106|  1.61k|	buf = malloc(*outlen);
 1107|  1.61k|	if (buf == NULL)
  ------------------
  |  Branch (1107:6): [True: 0, False: 1.61k]
  ------------------
 1108|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1109|       |
 1110|  1.61k|	*out = p = buf;
 1111|  1.61k|	*p++ = t;
 1112|  1.61k|	for (ii=1;ii<tag_len;ii++)
  ------------------
  |  Branch (1112:12): [True: 0, False: 1.61k]
  ------------------
 1113|      0|		*p++ = tag_char[tag_len - ii - 1];
 1114|       |
 1115|  1.61k|	if (c) {
  ------------------
  |  Branch (1115:6): [True: 832, False: 779]
  ------------------
 1116|    832|		*p++ = 0x80 | c;
 1117|  2.68k|		while (c--)
  ------------------
  |  Branch (1117:10): [True: 1.85k, False: 832]
  ------------------
 1118|  1.85k|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1119|    832|	}
 1120|    779|	else   {
 1121|    779|		*p++ = datalen & 0x7F;
 1122|    779|	}
 1123|  1.61k|	if (datalen && data) {
  ------------------
  |  Branch (1123:6): [True: 1.61k, False: 0]
  |  Branch (1123:17): [True: 1.61k, False: 0]
  ------------------
 1124|  1.61k|		memcpy(p, data, datalen);
 1125|  1.61k|	}
 1126|       |
 1127|  1.61k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.61k|#define SC_SUCCESS				0
  ------------------
 1128|  1.61k|}
asn1.c:asn1_decode:
 1724|    800|{
 1725|    800|	int r, idx = 0;
 1726|    800|	const u8 *p = in, *obj;
 1727|    800|	struct sc_asn1_entry *entry = asn1;
 1728|    800|	size_t left = len, objlen;
 1729|       |
 1730|    800|	sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  1.60k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (70:115): [True: 0, False: 800]
  |  |  ------------------
  ------------------
 1731|    800|		 "%*.*s""called, left=%"SC_FORMAT_LEN_SIZE_T"u, depth %d%s\n",
 1732|    800|		 depth, depth, "", left, depth, choice ? ", choice" : "");
 1733|       |
 1734|    800|	if (!p)
  ------------------
  |  Branch (1734:6): [True: 0, False: 800]
  ------------------
 1735|      0|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      0|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1736|    800|	if (left < 2) {
  ------------------
  |  Branch (1736:6): [True: 6, False: 794]
  ------------------
 1737|      6|		while (asn1->name && (asn1->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|      6|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1737:10): [True: 6, False: 0]
  |  Branch (1737:24): [True: 0, False: 6]
  ------------------
 1738|      0|			asn1++;
 1739|       |		/* If all elements were optional, there's nothing
 1740|       |		 * to complain about */
 1741|      6|		if (asn1->name == NULL)
  ------------------
  |  Branch (1741:7): [True: 0, False: 6]
  ------------------
 1742|      0|			return 0;
 1743|      6|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "End of ASN.1 stream, "
  ------------------
  |  |   70|      6|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1744|      6|			      "non-optional field \"%s\" not found\n",
 1745|      6|			      asn1->name);
 1746|      6|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      6|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1747|      6|	}
 1748|    794|	if (p[0] == 0 || p[0] == 0xFF || len == 0)
  ------------------
  |  Branch (1748:6): [True: 19, False: 775]
  |  Branch (1748:19): [True: 16, False: 759]
  |  Branch (1748:35): [True: 0, False: 759]
  ------------------
 1749|     35|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|     35|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
 1750|       |
 1751|  1.29k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1751:16): [True: 972, False: 324]
  ------------------
 1752|    972|		entry = &asn1[idx];
 1753|       |
 1754|    972|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Looking for '%s', tag 0x%x%s%s\n",
  ------------------
  |  |   70|    972|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1755|    972|			entry->name, entry->tag, choice? ", CHOICE" : "",
  |  |  |  | 1756|    972|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  148|    972|#define SC_ASN1_OPTIONAL		0x00000002
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|    972|			entry->name, entry->tag, choice? ", CHOICE" : "",
 1756|    972|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
 1757|       |
 1758|       |		/* Special case CHOICE has no tag */
 1759|    972|		if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|    972|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1759:7): [True: 0, False: 972]
  ------------------
 1760|      0|			r = asn1_decode(ctx,
 1761|      0|				(struct sc_asn1_entry *) entry->parm,
 1762|      0|				p, left, &p, &left, 1, depth + 1);
 1763|       |			/* When the inner call fails it returns before writing
 1764|       |			 * back to *newp and *len_left, so the caller's p/left are
 1765|       |			 * unchanged.  Swallowing the error for an optional
 1766|       |			 * CHOICE is therefore safe: the next field will be
 1767|       |			 * attempted at the same position. */
 1768|      0|			if (r >= 0 || (entry->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|      0|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1768:8): [True: 0, False: 0]
  |  Branch (1768:18): [True: 0, False: 0]
  ------------------
 1769|      0|				r = 0;
 1770|      0|			goto decode_ok;
 1771|      0|		}
 1772|       |
 1773|    972|		obj = sc_asn1_skip_tag(ctx, &p, &left, entry->tag, &objlen);
 1774|    972|		if (obj == NULL) {
  ------------------
  |  Branch (1774:7): [True: 335, False: 637]
  ------------------
 1775|    335|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "'%s' not present\n", entry->name);
  ------------------
  |  |   70|    335|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1776|    335|			if (choice)
  ------------------
  |  Branch (1776:8): [True: 0, False: 335]
  ------------------
 1777|      0|				continue;
 1778|    335|			if (entry->flags & SC_ASN1_OPTIONAL)
  ------------------
  |  |  148|    335|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1778:8): [True: 0, False: 335]
  ------------------
 1779|      0|				continue;
 1780|    335|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "mandatory ASN.1 object '%s' not found\n", entry->name);
  ------------------
  |  |   70|    335|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1781|    335|			if (left) {
  ------------------
  |  Branch (1781:8): [True: 302, False: 33]
  ------------------
 1782|    302|				u8 line[128], *linep = line;
 1783|    302|				size_t i;
 1784|       |
 1785|    302|				line[0] = 0;
 1786|  2.52k|				for (i = 0; i < 10 && i < left; i++) {
  ------------------
  |  Branch (1786:17): [True: 2.34k, False: 178]
  |  Branch (1786:27): [True: 2.22k, False: 124]
  ------------------
 1787|  2.22k|					sprintf((char *) linep, "%02X ", p[i]);
 1788|  2.22k|					linep += 3;
 1789|  2.22k|				}
 1790|    302|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "next tag: %s\n", line);
  ------------------
  |  |   70|    302|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1791|    302|			}
 1792|    335|			sc_free_entry(asn1);
 1793|    335|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|    335|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    335|	int _ret = r; \
  |  |  155|    335|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 335, False: 0]
  |  |  ------------------
  |  |  156|    335|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    335|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 335, False: 0]
  |  |  ------------------
  |  |  157|    335|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    335|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    335|	return _ret; \
  |  |  163|    335|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1794|    335|		}
 1795|    637|		r = asn1_decode_entry(ctx, entry, obj, objlen, depth);
 1796|       |
 1797|    637|decode_ok:
 1798|    637|		if (r)
  ------------------
  |  Branch (1798:7): [True: 100, False: 537]
  ------------------
 1799|    100|			return r;
 1800|    537|		if (choice)
  ------------------
  |  Branch (1800:7): [True: 0, False: 537]
  ------------------
 1801|      0|			break;
 1802|    537| 	}
 1803|    324| 	if (choice && asn1[idx].name == NULL) /* No match */
  ------------------
  |  Branch (1803:7): [True: 0, False: 324]
  |  Branch (1803:17): [True: 0, False: 0]
  ------------------
 1804|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1805|    324| 	if (newp != NULL)
  ------------------
  |  Branch (1805:7): [True: 0, False: 324]
  ------------------
 1806|      0|		*newp = p;
 1807|    324| 	if (len_left != NULL)
  ------------------
  |  Branch (1807:7): [True: 0, False: 324]
  ------------------
 1808|      0|		*len_left = left;
 1809|    324|	if (choice)
  ------------------
  |  Branch (1809:6): [True: 0, False: 324]
  ------------------
 1810|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, idx);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1811|    324|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, 0);
  ------------------
  |  |  153|    324|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    324|	int _ret = r; \
  |  |  155|    324|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 324, False: 0]
  |  |  ------------------
  |  |  156|    324|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 324]
  |  |  ------------------
  |  |  157|    324|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    324|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    324|	return _ret; \
  |  |  163|    324|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1812|    324|}
asn1.c:sc_free_entry:
 1689|    589|static void sc_free_entry(struct sc_asn1_entry *asn1) {
 1690|    589|	int idx = 0;
 1691|    589|	struct sc_asn1_entry *entry = asn1;
 1692|       |
 1693|    589|	if (!asn1)
  ------------------
  |  Branch (1693:6): [True: 0, False: 589]
  ------------------
 1694|      0|		return;
 1695|       |
 1696|  1.51k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1696:16): [True: 924, False: 589]
  ------------------
 1697|    924|		entry = &asn1[idx];
 1698|    924|		switch (entry->type) {
 1699|      0|		case SC_ASN1_CHOICE:
  ------------------
  |  |  170|      0|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1699:3): [True: 0, False: 924]
  ------------------
 1700|    254|		case SC_ASN1_STRUCT:
  ------------------
  |  |  169|    254|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1700:3): [True: 254, False: 670]
  ------------------
 1701|    254|			sc_free_entry((struct sc_asn1_entry *) entry->parm);
 1702|    254|			break;
 1703|    670|		case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|    670|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1703:3): [True: 670, False: 254]
  ------------------
 1704|    670|		case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|    670|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1704:3): [True: 0, False: 924]
  ------------------
 1705|    670|		case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|    670|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1705:3): [True: 0, False: 924]
  ------------------
 1706|    670|		case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|    670|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1706:3): [True: 0, False: 924]
  ------------------
 1707|    670|		case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|    670|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1707:3): [True: 0, False: 924]
  ------------------
 1708|    670|		case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|    670|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1708:3): [True: 0, False: 924]
  ------------------
 1709|    670|			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  149|    670|#define SC_ASN1_ALLOC			0x00000004
  ------------------
              			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    670|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1709:8): [True: 670, False: 0]
  |  Branch (1709:42): [True: 51, False: 619]
  ------------------
 1710|     51|				u8 **buf = (u8 **)entry->parm;
 1711|     51|				free(*buf);
 1712|     51|				*buf = NULL;
 1713|     51|			}
 1714|    670|			break;
 1715|      0|		default:
  ------------------
  |  Branch (1715:3): [True: 0, False: 924]
  ------------------
 1716|      0|			break;
 1717|    924|		}
 1718|    924|	}
 1719|    589|}
asn1.c:asn1_decode_entry:
 1491|    637|{
 1492|    637|	void *parm = entry->parm;
 1493|    637|	int (*callback_func)(sc_context_t *nctx, void *arg, const u8 *nobj,
 1494|    637|			     size_t nobjlen, int ndepth);
 1495|    637|	size_t *len = (size_t *) entry->arg;
 1496|    637|	int r = 0;
 1497|       |
 1498|    637|	callback_func = parm;
 1499|       |
 1500|    637|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s', raw data:%s%s\n",
  ------------------
  |  |   70|  2.54k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (70:115): [True: 265, False: 372]
  |  |  |  Branch (70:115): [True: 265, False: 372]
  |  |  ------------------
  ------------------
 1501|    637|		depth, depth, "", entry->name,
 1502|    637|		sc_dump_hex(obj, objlen > 16  ? 16 : objlen),
 1503|    637|		objlen > 16 ? "..." : "");
 1504|       |
 1505|    637|	switch (entry->type) {
 1506|    262|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|    262|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1506:2): [True: 262, False: 375]
  ------------------
 1507|    262|		if (parm != NULL)
  ------------------
  |  Branch (1507:7): [True: 262, False: 0]
  ------------------
 1508|    262|			r = asn1_decode(ctx, (struct sc_asn1_entry *) parm, obj,
 1509|    262|				       objlen, NULL, NULL, 0, depth + 1);
 1510|    262|		break;
 1511|      0|	case SC_ASN1_NULL:
  ------------------
  |  |  158|      0|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1511:2): [True: 0, False: 637]
  ------------------
 1512|      0|		break;
 1513|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1513:2): [True: 0, False: 637]
  ------------------
 1514|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1514:7): [True: 0, False: 0]
  ------------------
 1515|      0|			if (objlen != 1) {
  ------------------
  |  Branch (1515:8): [True: 0, False: 0]
  ------------------
 1516|      0|				sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1517|      0|					 "invalid ASN.1 object length: %"SC_FORMAT_LEN_SIZE_T"u\n",
 1518|      0|					 objlen);
 1519|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1520|      0|			} else
 1521|      0|				*((int *) parm) = obj[0] ? 1 : 0;
  ------------------
  |  Branch (1521:23): [True: 0, False: 0]
  ------------------
 1522|      0|		}
 1523|      0|		break;
 1524|      0|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|      0|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1524:2): [True: 0, False: 637]
  ------------------
 1525|      0|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|      0|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1525:2): [True: 0, False: 637]
  ------------------
 1526|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1526:7): [True: 0, False: 0]
  ------------------
 1527|      0|			r = sc_asn1_decode_integer(obj, objlen, (int *) entry->parm, 0);
 1528|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1528:8): [True: 0, False: 0]
  ------------------
 1529|      0|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s' returned %d\n",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1530|      0|						depth, depth, "", entry->name, *((int *)entry->parm));
 1531|      0|			}
 1532|      0|		}
 1533|      0|		break;
 1534|      0|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|      0|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1534:2): [True: 0, False: 637]
  ------------------
 1535|      0|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1535:2): [True: 0, False: 637]
  ------------------
 1536|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1536:7): [True: 0, False: 0]
  ------------------
 1537|      0|			int invert = entry->type == SC_ASN1_BIT_STRING ? 1 : 0;
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1537:17): [True: 0, False: 0]
  ------------------
 1538|      0|			if (len == NULL)
  ------------------
  |  Branch (1538:8): [True: 0, False: 0]
  ------------------
 1539|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1540|      0|			if (objlen < 1) {
  ------------------
  |  Branch (1540:8): [True: 0, False: 0]
  ------------------
 1541|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1542|      0|				break;
 1543|      0|			}
 1544|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1544:8): [True: 0, False: 0]
  ------------------
 1545|      0|				u8 **buf = (u8 **) parm;
 1546|      0|				if (objlen > 1) {
  ------------------
  |  Branch (1546:9): [True: 0, False: 0]
  ------------------
 1547|      0|					*buf = malloc(objlen-1);
 1548|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1548:10): [True: 0, False: 0]
  ------------------
 1549|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1550|      0|						break;
 1551|      0|					}
 1552|      0|				}
 1553|      0|				*len = objlen-1;
 1554|      0|				parm = *buf;
 1555|      0|			}
 1556|      0|			r = decode_bit_string(obj, objlen, (u8 *) parm, *len, invert, 0);
 1557|      0|			if (r >= 0) {
  ------------------
  |  Branch (1557:8): [True: 0, False: 0]
  ------------------
 1558|      0|				*len = r;
 1559|      0|				r = 0;
 1560|      0|			}
 1561|      0|		}
 1562|      0|		break;
 1563|      0|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|      0|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1563:2): [True: 0, False: 637]
  ------------------
 1564|      0|		if (parm != NULL)
  ------------------
  |  Branch (1564:7): [True: 0, False: 0]
  ------------------
 1565|      0|			r = decode_bit_field(obj, objlen, (u8 *) parm, *len, 0);
 1566|      0|		break;
 1567|    375|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|    375|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1567:2): [True: 375, False: 262]
  ------------------
 1568|    375|		if (parm != NULL) {
  ------------------
  |  Branch (1568:7): [True: 375, False: 0]
  ------------------
 1569|    375|			size_t c;
 1570|    375|			if (len == NULL)
  ------------------
  |  Branch (1570:8): [True: 0, False: 375]
  ------------------
 1571|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1572|       |
 1573|       |			/* Strip off padding zero */
 1574|    375|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|    375|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1574:8): [True: 375, False: 0]
  ------------------
 1575|    375|					&& objlen > 1 && obj[0] == 0x00) {
  ------------------
  |  Branch (1575:9): [True: 189, False: 186]
  |  Branch (1575:23): [True: 53, False: 136]
  ------------------
 1576|     53|				objlen--;
 1577|     53|				obj++;
 1578|     53|			}
 1579|       |
 1580|       |			/* Allocate buffer if needed */
 1581|    375|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|    375|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1581:8): [True: 375, False: 0]
  ------------------
 1582|    375|				u8 **buf = (u8 **) parm;
 1583|    375|				if (objlen > 0) {
  ------------------
  |  Branch (1583:9): [True: 200, False: 175]
  ------------------
 1584|    200|					*buf = malloc(objlen);
 1585|    200|					if (*buf == NULL) {
  ------------------
  |  Branch (1585:10): [True: 0, False: 200]
  ------------------
 1586|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1587|      0|						break;
 1588|      0|					}
 1589|    200|				}
 1590|    375|				c = *len = objlen;
 1591|    375|				parm = *buf;
 1592|    375|			} else
 1593|      0|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1593:9): [True: 0, False: 0]
  ------------------
 1594|       |
 1595|    375|			memcpy(parm, obj, c);
 1596|    375|			*len = c;
 1597|    375|		}
 1598|    375|		break;
 1599|    375|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|      0|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1599:2): [True: 0, False: 637]
  ------------------
 1600|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1600:7): [True: 0, False: 0]
  ------------------
 1601|      0|			size_t c;
 1602|      0|			if (len == NULL)
  ------------------
  |  Branch (1602:8): [True: 0, False: 0]
  ------------------
 1603|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1604|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1604:8): [True: 0, False: 0]
  ------------------
 1605|      0|				u8 **buf = (u8 **) parm;
 1606|      0|				if (objlen > 0) {
  ------------------
  |  Branch (1606:9): [True: 0, False: 0]
  ------------------
 1607|      0|					*buf = malloc(objlen);
 1608|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1608:10): [True: 0, False: 0]
  ------------------
 1609|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1610|      0|						break;
 1611|      0|					}
 1612|      0|				}
 1613|      0|				c = *len = objlen;
 1614|      0|				parm = *buf;
 1615|      0|			} else
 1616|      0|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1616:9): [True: 0, False: 0]
  ------------------
 1617|       |
 1618|      0|			memcpy(parm, obj, c);
 1619|      0|			*len = c;
 1620|      0|		}
 1621|      0|		break;
 1622|      0|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|      0|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1622:2): [True: 0, False: 637]
  ------------------
 1623|      0|		if (parm != NULL)
  ------------------
  |  Branch (1623:7): [True: 0, False: 0]
  ------------------
 1624|      0|			r = sc_asn1_decode_object_id(obj, objlen, (struct sc_object_id *) parm);
 1625|      0|		break;
 1626|      0|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      0|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1626:2): [True: 0, False: 637]
  ------------------
 1627|      0|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|      0|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1627:2): [True: 0, False: 637]
  ------------------
 1628|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1628:7): [True: 0, False: 0]
  ------------------
 1629|      0|			if (len == NULL)
  ------------------
  |  Branch (1629:8): [True: 0, False: 0]
  ------------------
 1630|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1631|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1631:8): [True: 0, False: 0]
  ------------------
 1632|      0|				u8 **buf = (u8 **) parm;
 1633|      0|				*buf = malloc(objlen+1);
 1634|      0|				if (*buf == NULL) {
  ------------------
  |  Branch (1634:9): [True: 0, False: 0]
  ------------------
 1635|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1636|      0|					break;
 1637|      0|				}
 1638|      0|				*len = objlen+1;
 1639|      0|				parm = *buf;
 1640|      0|			}
 1641|      0|			r = sc_asn1_decode_utf8string(obj, objlen, (u8 *) parm, len);
 1642|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1642:8): [True: 0, False: 0]
  ------------------
 1643|      0|				*len -= 1;
 1644|      0|			}
 1645|      0|		}
 1646|      0|		break;
 1647|      0|	case SC_ASN1_PATH:
  ------------------
  |  |  174|      0|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1647:2): [True: 0, False: 637]
  ------------------
 1648|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1648:7): [True: 0, False: 0]
  ------------------
 1649|      0|			r = asn1_decode_path(ctx, obj, objlen, (sc_path_t *) parm, depth);
 1650|      0|		break;
 1651|      0|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|      0|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1651:2): [True: 0, False: 637]
  ------------------
 1652|      0|		if (entry->parm != NULL) {
  ------------------
  |  Branch (1652:7): [True: 0, False: 0]
  ------------------
 1653|      0|			struct sc_pkcs15_id *id = (struct sc_pkcs15_id *) parm;
 1654|      0|			size_t c = objlen > sizeof(id->value) ? sizeof(id->value) : objlen;
  ------------------
  |  Branch (1654:15): [True: 0, False: 0]
  ------------------
 1655|       |
 1656|      0|			memcpy(id->value, obj, c);
 1657|      0|			id->len = c;
 1658|      0|		}
 1659|      0|		break;
 1660|      0|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|      0|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1660:2): [True: 0, False: 637]
  ------------------
 1661|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1661:7): [True: 0, False: 0]
  ------------------
 1662|      0|			r = asn1_decode_p15_object(ctx, obj, objlen, (struct sc_asn1_pkcs15_object *) parm, depth);
 1663|      0|		break;
 1664|      0|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|      0|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1664:2): [True: 0, False: 637]
  ------------------
 1665|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1665:7): [True: 0, False: 0]
  ------------------
 1666|      0|			r = sc_asn1_decode_algorithm_id(ctx, obj, objlen, (struct sc_algorithm_id *) parm, depth);
 1667|      0|		break;
 1668|      0|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|      0|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1668:2): [True: 0, False: 637]
  ------------------
 1669|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1669:7): [True: 0, False: 0]
  ------------------
 1670|      0|			r = asn1_decode_se_info(ctx, obj, objlen, (sc_pkcs15_sec_env_info_t ***)entry->parm, len, depth);
 1671|      0|		break;
 1672|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1672:2): [True: 0, False: 637]
  ------------------
 1673|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1673:7): [True: 0, False: 0]
  ------------------
 1674|      0|			r = callback_func(ctx, entry->arg, obj, objlen, depth);
 1675|      0|		break;
 1676|      0|	default:
  ------------------
  |  Branch (1676:2): [True: 0, False: 637]
  ------------------
 1677|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1678|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1679|    637|	}
 1680|    637|	if (r) {
  ------------------
  |  Branch (1680:6): [True: 100, False: 537]
  ------------------
 1681|    100|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|    100|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1682|    100|		      sc_strerror(r));
 1683|    100|		return r;
 1684|    100|	}
 1685|    537|	entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|    537|#define SC_ASN1_PRESENT			0x00000001
  ------------------
 1686|    537|	return 0;
 1687|    637|}
asn1.c:asn1_encode:
 2045|  1.07k|{
 2046|  1.07k|	int r, idx = 0;
 2047|  1.07k|	u8 *obj = NULL, *buf = NULL, *tmp;
 2048|  1.07k|	size_t total = 0, objsize;
 2049|       |
 2050|  1.07k|	if (asn1 == NULL) {
  ------------------
  |  Branch (2050:6): [True: 0, False: 1.07k]
  ------------------
 2051|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2052|      0|	}
 2053|       |
 2054|  2.68k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (2054:16): [True: 1.61k, False: 1.07k]
  ------------------
 2055|  1.61k|		r = asn1_encode_entry(ctx, &asn1[idx], &obj, &objsize, depth);
 2056|  1.61k|		if (r) {
  ------------------
  |  Branch (2056:7): [True: 2, False: 1.61k]
  ------------------
 2057|      2|			if (obj)
  ------------------
  |  Branch (2057:8): [True: 0, False: 2]
  ------------------
 2058|      0|				free(obj);
 2059|      2|			if (buf)
  ------------------
  |  Branch (2059:8): [True: 0, False: 2]
  ------------------
 2060|      0|				free(buf);
 2061|      2|			return r;
 2062|      2|		}
 2063|       |		/* in case of an empty (optional) element continue with
 2064|       |		 * the next asn1 element */
 2065|  1.61k|		if (!objsize)
  ------------------
  |  Branch (2065:7): [True: 0, False: 1.61k]
  ------------------
 2066|      0|			continue;
 2067|  1.61k|		tmp = (u8 *) realloc(buf, total + objsize);
 2068|  1.61k|		if (!tmp) {
  ------------------
  |  Branch (2068:7): [True: 0, False: 1.61k]
  ------------------
 2069|      0|			if (obj)
  ------------------
  |  Branch (2069:8): [True: 0, False: 0]
  ------------------
 2070|      0|				free(obj);
 2071|      0|			if (buf)
  ------------------
  |  Branch (2071:8): [True: 0, False: 0]
  ------------------
 2072|      0|				free(buf);
 2073|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2074|      0|		}
 2075|  1.61k|		buf = tmp;
 2076|  1.61k|		memcpy(buf + total, obj, objsize);
 2077|  1.61k|		free(obj);
 2078|  1.61k|		obj = NULL;
 2079|  1.61k|		total += objsize;
 2080|  1.61k|	}
 2081|  1.07k|	*ptr = buf;
 2082|  1.07k|	*size = total;
 2083|  1.07k|	return 0;
 2084|  1.07k|}
asn1.c:asn1_encode_entry:
 1828|  1.61k|{
 1829|  1.61k|	void *parm = entry->parm;
 1830|  1.61k|	int (*callback_func)(sc_context_t *nctx, void *arg, u8 **nobj,
 1831|  1.61k|			     size_t *nobjlen, int ndepth);
 1832|  1.61k|	const size_t *len = (const size_t *) entry->arg;
 1833|  1.61k|	int r = 0;
 1834|  1.61k|	u8 * buf = NULL;
 1835|  1.61k|	size_t buflen = 0;
 1836|       |
 1837|  1.61k|	callback_func = parm;
 1838|       |
 1839|  1.61k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sencoding '%s'%s\n",
  ------------------
  |  |   70|  1.61k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1840|  1.61k|	       	depth, depth, "", entry->name,
  |  |  |  | 1841|  1.61k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  1.61k|#define SC_ASN1_PRESENT			0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1840|  1.61k|	       	depth, depth, "", entry->name,
 1841|  1.61k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
 1842|  1.61k|	if (!(entry->flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  1.61k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1842:6): [True: 0, False: 1.61k]
  ------------------
 1843|      0|		goto no_object;
 1844|  1.61k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  3.22k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (70:115): [True: 1.07k, False: 538]
  |  |  ------------------
  ------------------
 1845|  1.61k|		 "%*.*stype=%d, tag=0x%02x, parm=%p, len=%"SC_FORMAT_LEN_SIZE_T"u\n",
 1846|  1.61k|		 depth, depth, "", entry->type, entry->tag, parm,
 1847|  1.61k|		 len ? *len : 0);
 1848|       |
 1849|  1.61k|	if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  1.61k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1849:6): [True: 0, False: 1.61k]
  ------------------
 1850|      0|		const struct sc_asn1_entry *list, *choice = NULL;
 1851|       |
 1852|      0|		list = (const struct sc_asn1_entry *) parm;
 1853|      0|		while (list->name != NULL) {
  ------------------
  |  Branch (1853:10): [True: 0, False: 0]
  ------------------
 1854|      0|			if (list->flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1854:8): [True: 0, False: 0]
  ------------------
 1855|      0|				if (choice) {
  ------------------
  |  Branch (1855:9): [True: 0, False: 0]
  ------------------
 1856|      0|					sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1857|      0|						"ASN.1 problem: more than "
 1858|      0|						"one CHOICE when encoding %s: "
 1859|      0|						"%s and %s both present\n",
 1860|      0|						entry->name,
 1861|      0|						choice->name,
 1862|      0|						list->name);
 1863|      0|					return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1864|      0|				}
 1865|      0|				choice = list;
 1866|      0|			}
 1867|      0|			list++;
 1868|      0|		}
 1869|      0|		if (choice == NULL)
  ------------------
  |  Branch (1869:7): [True: 0, False: 0]
  ------------------
 1870|      0|			goto no_object;
 1871|      0|		return asn1_encode_entry(ctx, choice, obj, objlen, depth + 1);
 1872|      0|	}
 1873|       |
 1874|  1.61k|	if (entry->type != SC_ASN1_NULL && parm == NULL) {
  ------------------
  |  |  158|  3.22k|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1874:6): [True: 1.61k, False: 0]
  |  Branch (1874:37): [True: 0, False: 1.61k]
  ------------------
 1875|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "unexpected parm == NULL\n");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1876|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1877|      0|	}
 1878|       |
 1879|  1.61k|	switch (entry->type) {
 1880|    538|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|    538|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1880:2): [True: 538, False: 1.07k]
  ------------------
 1881|    538|		r = asn1_encode(ctx, (const struct sc_asn1_entry *) parm, &buf,
 1882|    538|				&buflen, depth + 1);
 1883|    538|		break;
 1884|      0|	case SC_ASN1_NULL:
  ------------------
  |  |  158|      0|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1884:2): [True: 0, False: 1.61k]
  ------------------
 1885|      0|		buf = NULL;
 1886|      0|		buflen = 0;
 1887|      0|		break;
 1888|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1888:2): [True: 0, False: 1.61k]
  ------------------
 1889|      0|		buf = malloc(1);
 1890|      0|		if (buf == NULL) {
  ------------------
  |  Branch (1890:7): [True: 0, False: 0]
  ------------------
 1891|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1892|      0|			break;
 1893|      0|		}
 1894|      0|		buf[0] = *((int *) parm) ? 0xFF : 0;
  ------------------
  |  Branch (1894:12): [True: 0, False: 0]
  ------------------
 1895|      0|		buflen = 1;
 1896|      0|		break;
 1897|      0|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|      0|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1897:2): [True: 0, False: 1.61k]
  ------------------
 1898|      0|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|      0|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1898:2): [True: 0, False: 1.61k]
  ------------------
 1899|      0|		r = asn1_encode_integer(*((int *) entry->parm), &buf, &buflen);
 1900|      0|		break;
 1901|      0|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|      0|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1901:2): [True: 0, False: 1.61k]
  ------------------
 1902|      0|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1902:2): [True: 0, False: 1.61k]
  ------------------
 1903|      0|		if (len != NULL) {
  ------------------
  |  Branch (1903:7): [True: 0, False: 0]
  ------------------
 1904|      0|			if (entry->type == SC_ASN1_BIT_STRING)
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1904:8): [True: 0, False: 0]
  ------------------
 1905|      0|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 1);
 1906|      0|			else
 1907|      0|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 0);
 1908|      0|		} else {
 1909|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1910|      0|		}
 1911|      0|		break;
 1912|      0|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|      0|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1912:2): [True: 0, False: 1.61k]
  ------------------
 1913|      0|		if (len != NULL) {
  ------------------
  |  Branch (1913:7): [True: 0, False: 0]
  ------------------
 1914|      0|			r = encode_bit_field((const u8 *) parm, *len, &buf, &buflen);
 1915|      0|		} else {
 1916|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1917|      0|		}
 1918|      0|		break;
 1919|      0|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      0|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1919:2): [True: 0, False: 1.61k]
  ------------------
 1920|  1.07k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  1.07k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1920:2): [True: 1.07k, False: 538]
  ------------------
 1921|  1.07k|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  1.07k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1921:2): [True: 0, False: 1.61k]
  ------------------
 1922|  1.07k|		if (len != NULL) {
  ------------------
  |  Branch (1922:7): [True: 1.07k, False: 0]
  ------------------
 1923|  1.07k|			buf = malloc(*len + 1);
 1924|  1.07k|			if (buf == NULL) {
  ------------------
  |  Branch (1924:8): [True: 0, False: 1.07k]
  ------------------
 1925|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1926|      0|				break;
 1927|      0|			}
 1928|  1.07k|			buflen = 0;
 1929|       |			/* If the integer is supposed to be unsigned, insert
 1930|       |			 * a padding byte if the MSB is one */
 1931|  1.07k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  1.07k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1931:8): [True: 1.07k, False: 0]
  ------------------
 1932|  1.07k|					&& (((u8 *) parm)[0] & 0x80)) {
  ------------------
  |  Branch (1932:9): [True: 353, False: 722]
  ------------------
 1933|    353|				buf[buflen++] = 0x00;
 1934|    353|			}
 1935|  1.07k|			memcpy(buf + buflen, parm, *len);
 1936|  1.07k|			buflen += *len;
 1937|  1.07k|		} else {
 1938|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1939|      0|		}
 1940|  1.07k|		break;
 1941|  1.07k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|      0|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1941:2): [True: 0, False: 1.61k]
  ------------------
 1942|      0|		if (len != NULL) {
  ------------------
  |  Branch (1942:7): [True: 0, False: 0]
  ------------------
 1943|      0|			buf = malloc(*len);
 1944|      0|			if (buf == NULL) {
  ------------------
  |  Branch (1944:8): [True: 0, False: 0]
  ------------------
 1945|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1946|      0|				break;
 1947|      0|			}
 1948|      0|			memcpy(buf, parm, *len);
 1949|      0|			buflen = *len;
 1950|      0|		} else {
 1951|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1952|      0|		}
 1953|      0|		break;
 1954|      0|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|      0|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1954:2): [True: 0, False: 1.61k]
  ------------------
 1955|      0|		r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm);
 1956|      0|		break;
 1957|      0|	case SC_ASN1_PATH:
  ------------------
  |  |  174|      0|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1957:2): [True: 0, False: 1.61k]
  ------------------
 1958|      0|		r = asn1_encode_path(ctx, (const sc_path_t *) parm, &buf, &buflen, depth, entry->flags);
 1959|      0|		break;
 1960|      0|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|      0|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1960:2): [True: 0, False: 1.61k]
  ------------------
 1961|      0|		{
 1962|      0|			const struct sc_pkcs15_id *id = (const struct sc_pkcs15_id *) parm;
 1963|       |
 1964|      0|			buf = malloc(id->len);
 1965|      0|			if (buf == NULL) {
  ------------------
  |  Branch (1965:8): [True: 0, False: 0]
  ------------------
 1966|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1967|      0|				break;
 1968|      0|			}
 1969|      0|			memcpy(buf, id->value, id->len);
 1970|      0|			buflen = id->len;
 1971|      0|		}
 1972|      0|		break;
 1973|      0|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|      0|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1973:2): [True: 0, False: 1.61k]
  ------------------
 1974|      0|		r = asn1_encode_p15_object(ctx, (const struct sc_asn1_pkcs15_object *) parm, &buf, &buflen, depth);
 1975|      0|		break;
 1976|      0|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|      0|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1976:2): [True: 0, False: 1.61k]
  ------------------
 1977|      0|		r = sc_asn1_encode_algorithm_id(ctx, &buf, &buflen, (const struct sc_algorithm_id *) parm, depth);
 1978|      0|		break;
 1979|      0|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|      0|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1979:2): [True: 0, False: 1.61k]
  ------------------
 1980|      0|		if (!len)
  ------------------
  |  Branch (1980:7): [True: 0, False: 0]
  ------------------
 1981|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1982|      0|		r = asn1_encode_se_info(ctx, (struct sc_pkcs15_sec_env_info **)parm, *len, &buf, &buflen, depth);
 1983|      0|		break;
 1984|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1984:2): [True: 0, False: 1.61k]
  ------------------
 1985|      0|		r = callback_func(ctx, entry->arg, &buf, &buflen, depth);
 1986|      0|		break;
 1987|      0|	default:
  ------------------
  |  Branch (1987:2): [True: 0, False: 1.61k]
  ------------------
 1988|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1989|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1990|  1.61k|	}
 1991|  1.61k|	if (r) {
  ------------------
  |  Branch (1991:6): [True: 1, False: 1.61k]
  ------------------
 1992|      1|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "encoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|      1|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1993|      1|		      sc_strerror(r));
 1994|      1|		if (buf)
  ------------------
  |  Branch (1994:7): [True: 0, False: 1]
  ------------------
 1995|      0|			free(buf);
 1996|      1|		return r;
 1997|      1|	}
 1998|       |
 1999|       |	/* Treatment of OPTIONAL elements:
 2000|       |	 *  -	if the encoding has 0 length, and the element is OPTIONAL,
 2001|       |	 *	we don't write anything (unless it's an ASN1 NULL and the
 2002|       |	 *      SC_ASN1_PRESENT flag is set).
 2003|       |	 *  -	if the encoding has 0 length, but the element is non-OPTIONAL,
 2004|       |	 *	constructed, we write a empty element (e.g. a SEQUENCE of
 2005|       |	 *      length 0). In case of an ASN1 NULL just write the tag and
 2006|       |	 *      length (i.e. 0x05,0x00).
 2007|       |	 *  -	any other empty objects are considered bogus
 2008|       |	 */
 2009|  1.61k|no_object:
 2010|  1.61k|	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  148|  1.61k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
              	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2010:6): [True: 1, False: 1.61k]
  |  Branch (2010:17): [True: 0, False: 1]
  |  Branch (2010:52): [True: 0, False: 0]
  ------------------
 2011|       |		/* This happens when we try to encode e.g. the
 2012|       |		 * subClassAttributes, which may be empty */
 2013|      0|		*obj = NULL;
 2014|      0|		*objlen = 0;
 2015|      0|		r = 0;
 2016|  1.61k|	} else if (!buflen && (entry->flags & SC_ASN1_EMPTY_ALLOWED)) {
  ------------------
  |  |  151|      1|#define SC_ASN1_EMPTY_ALLOWED           0x00000010
  ------------------
  |  Branch (2016:13): [True: 1, False: 1.61k]
  |  Branch (2016:24): [True: 0, False: 1]
  ------------------
 2017|      0|		*obj = NULL;
 2018|      0|		*objlen = 0;
 2019|      0|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2020|      0|		if (r)
  ------------------
  |  Branch (2020:7): [True: 0, False: 0]
  ------------------
 2021|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n", sc_strerror(r));
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2022|  1.61k|	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  158|  1.61k|#define SC_ASN1_NULL                    5
  ------------------
              	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  141|      1|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (2022:13): [True: 1.61k, False: 1]
  |  Branch (2022:23): [True: 0, False: 1]
  |  Branch (2022:54): [True: 0, False: 1]
  ------------------
 2023|  1.61k|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2024|  1.61k|		if (r)
  ------------------
  |  Branch (2024:7): [True: 0, False: 1.61k]
  ------------------
 2025|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2026|  1.61k|					sc_strerror(r));
 2027|  1.61k|	} else if (!(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2027:13): [True: 0, False: 1]
  ------------------
 2028|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode non-optional ASN.1 object: not given by caller\n");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2029|      0|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2030|      1|	} else {
 2031|      1|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode empty non-optional ASN.1 object\n");
  ------------------
  |  |   70|      1|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2032|      1|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2033|      1|	}
 2034|  1.61k|	if (buf)
  ------------------
  |  Branch (2034:6): [True: 1.61k, False: 0]
  ------------------
 2035|  1.61k|		free(buf);
 2036|  1.61k|	if (r >= 0)
  ------------------
  |  Branch (2036:6): [True: 1.61k, False: 1]
  ------------------
 2037|  1.61k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  1.61k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2038|  1.61k|			 "%*.*slength of encoded item=%"SC_FORMAT_LEN_SIZE_T"u\n",
 2039|  1.61k|			 depth, depth, "", *objlen);
 2040|  1.61k|	return r;
 2041|  1.61k|}

sc_get_asepcos_driver:
 1090|      1|{
 1091|      1|	return sc_get_driver();
 1092|      1|}
card-asepcos.c:sc_get_driver:
 1068|      1|{
 1069|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1069:6): [True: 1, False: 0]
  ------------------
 1070|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1071|      1|	asepcos_ops = *iso_ops;
 1072|      1|	asepcos_ops.match_card        = asepcos_match_card;
 1073|      1|	asepcos_ops.init              = asepcos_init;
 1074|      1|	asepcos_ops.select_file       = asepcos_select_file;
 1075|      1|	asepcos_ops.set_security_env  = asepcos_set_security_env;
 1076|      1|	asepcos_ops.decipher          = asepcos_decipher;
 1077|      1|	asepcos_ops.compute_signature = asepcos_compute_signature;
 1078|      1|	asepcos_ops.create_file       = asepcos_create_file;
 1079|      1|	asepcos_ops.delete_file       = asepcos_delete_file;
 1080|      1|	asepcos_ops.list_files        = asepcos_list_files;
 1081|      1|	asepcos_ops.card_ctl          = asepcos_card_ctl;
 1082|      1|	asepcos_ops.pin_cmd           = asepcos_pin_cmd;
 1083|      1|	asepcos_ops.logout            = asepcos_logout;
 1084|      1|	asepcos_ops.card_reader_lock_obtained = asepcos_card_reader_lock_obtained;
 1085|       |
 1086|      1|	return &asepcos_drv;
 1087|      1|}

sc_get_atrust_acos_driver:
  814|      1|{
  815|      1|	return sc_get_driver();
  816|      1|}
card-atrust-acos.c:sc_get_driver:
  789|      1|{
  790|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  791|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (791:6): [True: 1, False: 0]
  ------------------
  792|      1|		iso_ops = iso_drv->ops;
  793|       |
  794|      1|	atrust_acos_ops = *iso_drv->ops;
  795|      1|	atrust_acos_ops.match_card = atrust_acos_match_card;
  796|      1|	atrust_acos_ops.init   = atrust_acos_init;
  797|      1|	atrust_acos_ops.finish = atrust_acos_finish;
  798|      1|	atrust_acos_ops.select_file = atrust_acos_select_file;
  799|      1|	atrust_acos_ops.check_sw    = atrust_acos_check_sw;
  800|      1|	atrust_acos_ops.create_file = NULL;
  801|      1|	atrust_acos_ops.delete_file = NULL;
  802|      1|	atrust_acos_ops.set_security_env  = atrust_acos_set_security_env;
  803|      1|	atrust_acos_ops.compute_signature = atrust_acos_compute_signature;
  804|      1|	atrust_acos_ops.decipher    = atrust_acos_decipher;
  805|      1|	atrust_acos_ops.card_ctl    = atrust_acos_card_ctl;
  806|      1|	atrust_acos_ops.logout      = atrust_acos_logout;
  807|       |
  808|      1|	return &atrust_acos_drv;
  809|      1|}

sc_get_authentic_driver:
 2178|      1|{
 2179|      1|	return sc_get_driver();
 2180|      1|}
card-authentic.c:sc_get_driver:
 2143|      1|{
 2144|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2145|       |
 2146|      1|	if (!iso_ops)
  ------------------
  |  Branch (2146:6): [True: 1, False: 0]
  ------------------
 2147|      1|		iso_ops = iso_drv->ops;
 2148|       |
 2149|      1|	authentic_ops = *iso_ops;
 2150|       |
 2151|      1|	authentic_ops.match_card = authentic_match_card;
 2152|      1|	authentic_ops.init = authentic_init;
 2153|      1|	authentic_ops.finish = authentic_finish;
 2154|      1|	authentic_ops.read_binary = authentic_read_binary;
 2155|      1|	authentic_ops.write_binary = authentic_write_binary;
 2156|      1|	authentic_ops.update_binary = authentic_update_binary;
 2157|      1|	authentic_ops.erase_binary = authentic_erase_binary;
 2158|       |	/* authentic_ops.resize_file = authentic_resize_file; */
 2159|      1|	authentic_ops.select_file = authentic_select_file;
 2160|       |	/* get_response: Untested */
 2161|      1|	authentic_ops.get_challenge = authentic_get_challenge;
 2162|      1|	authentic_ops.set_security_env = authentic_set_security_env;
 2163|       |	/* decipher: Untested */
 2164|      1|	authentic_ops.decipher = authentic_decipher;
 2165|       |	/* authentic_ops.compute_signature = authentic_compute_signature; */
 2166|      1|	authentic_ops.create_file = authentic_create_file;
 2167|      1|	authentic_ops.delete_file = authentic_delete_file;
 2168|      1|	authentic_ops.card_ctl = authentic_card_ctl;
 2169|      1|	authentic_ops.process_fci = authentic_process_fci;
 2170|      1|	authentic_ops.pin_cmd = authentic_pin_cmd;
 2171|      1|	authentic_ops.card_reader_lock_obtained = authentic_card_reader_lock_obtained;
 2172|       |
 2173|      1|	return &authentic_drv;
 2174|      1|}

sc_get_belpic_driver:
  447|      1|{
  448|      1|	return sc_get_driver();
  449|      1|}
card-belpic.c:sc_get_driver:
  424|      1|{
  425|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (425:6): [True: 1, False: 0]
  ------------------
  426|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  427|       |
  428|      1|	belpic_ops.match_card = belpic_match_card;
  429|      1|	belpic_ops.init = belpic_init;
  430|       |
  431|      1|	belpic_ops.update_binary = iso_ops->update_binary;
  432|      1|	belpic_ops.select_file = belpic_select_file;
  433|      1|	belpic_ops.read_binary = belpic_read_binary;
  434|      1|	belpic_ops.pin_cmd = belpic_pin_cmd;
  435|      1|	belpic_ops.set_security_env = belpic_set_security_env;
  436|       |
  437|      1|	belpic_ops.compute_signature = iso_ops->compute_signature;
  438|      1|	belpic_ops.get_challenge = iso_ops->get_challenge;
  439|      1|	belpic_ops.get_response = iso_ops->get_response;
  440|      1|	belpic_ops.check_sw = iso_ops->check_sw;
  441|       |
  442|      1|	return &belpic_drv;
  443|      1|}

sc_get_cac_driver:
 1944|      2|{
 1945|      2|	return sc_get_driver();
 1946|      2|}
card-cac.c:sc_get_driver:
 1918|      2|{
 1919|      2|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1920|       |
 1921|      2|	cac_ops = *iso_drv->ops;
 1922|      2|	cac_ops.match_card = cac_match_card;
 1923|      2|	cac_ops.init = cac_init;
 1924|      2|	cac_ops.finish = cac_finish;
 1925|       |
 1926|      2|	cac_ops.select_file =  cac_select_file; /* need to record object type */
 1927|      2|	cac_ops.get_challenge = cac_get_challenge;
 1928|      2|	cac_ops.read_binary = cac_read_binary;
 1929|       |	/* CAC driver is read only */
 1930|      2|	cac_ops.write_binary = NULL;
 1931|      2|	cac_ops.set_security_env = cac_set_security_env;
 1932|      2|	cac_ops.restore_security_env = cac_restore_security_env;
 1933|      2|	cac_ops.compute_signature = cac_compute_signature;
 1934|      2|	cac_ops.decipher =  cac_decipher;
 1935|      2|	cac_ops.card_ctl = cac_card_ctl;
 1936|      2|	cac_ops.pin_cmd = cac_pin_cmd;
 1937|      2|	cac_ops.logout = cac_logout;
 1938|       |
 1939|      2|	return &cac_drv;
 1940|      2|}

sc_get_cac1_driver:
  557|      1|{
  558|      1|	return sc_get_driver();
  559|      1|}
card-cac1.c:sc_get_driver:
  539|      1|{
  540|       |	/* Inherit most of the things from the CAC driver */
  541|      1|	struct sc_card_driver *cac_drv = sc_get_cac_driver();
  542|       |
  543|      1|	cac_ops = *cac_drv->ops;
  544|      1|	cac_ops.match_card = cac_match_card;
  545|      1|	cac_ops.init = cac_init;
  546|      1|	cac_ops.finish = cac_finish;
  547|       |
  548|      1|	cac_ops.select_file =  cac_select_file; /* need to record object type */
  549|      1|	cac_ops.read_binary = cac_read_binary;
  550|      1|	cac_ops.logout = cac_logout;
  551|       |
  552|      1|	return &cac1_drv;
  553|      1|}

sc_get_cardos_driver:
 1571|      1|{
 1572|      1|	return sc_get_driver();
 1573|      1|}
card-cardos.c:sc_get_driver:
 1546|      1|{
 1547|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1547:6): [True: 1, False: 0]
  ------------------
 1548|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1549|      1|	cardos_ops = *iso_ops;
 1550|      1|	cardos_ops.match_card = cardos_match_card;
 1551|      1|	cardos_ops.init = cardos_init;
 1552|      1|	cardos_ops.finish = cardos_finish;
 1553|      1|	cardos_ops.select_file = cardos_select_file;
 1554|      1|	cardos_ops.create_file = cardos_create_file;
 1555|      1|	cardos_ops.set_security_env = cardos_set_security_env;
 1556|      1|	cardos_ops.restore_security_env = cardos_restore_security_env;
 1557|      1|	cardos_ops.compute_signature = cardos_compute_signature;
 1558|      1|	cardos_ops.decipher = cardos_decipher;
 1559|       |
 1560|      1|	cardos_ops.list_files = cardos_list_files;
 1561|      1|	cardos_ops.check_sw = cardos_check_sw;
 1562|      1|	cardos_ops.card_ctl = cardos_card_ctl;
 1563|      1|	cardos_ops.pin_cmd = cardos_pin_cmd;
 1564|      1|	cardos_ops.logout  = cardos_logout;
 1565|       |
 1566|      1|	return &cardos_drv;
 1567|      1|}

sc_get_coolkey_driver:
 2479|      1|{
 2480|      1|	return sc_get_driver();
 2481|      1|}
card-coolkey.c:sc_get_driver:
 2452|      1|{
 2453|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2454|       |
 2455|      1|	coolkey_ops = *iso_drv->ops;
 2456|      1|	coolkey_ops.match_card = coolkey_match_card;
 2457|      1|	coolkey_ops.init = coolkey_init;
 2458|      1|	coolkey_ops.finish = coolkey_finish;
 2459|       |
 2460|      1|	coolkey_ops.select_file =  coolkey_select_file; /* need to record object type */
 2461|      1|	coolkey_ops.get_challenge = coolkey_get_challenge;
 2462|      1|	coolkey_ops.read_binary = coolkey_read_binary;
 2463|      1|	coolkey_ops.write_binary = coolkey_write_binary;
 2464|      1|	coolkey_ops.set_security_env = coolkey_set_security_env;
 2465|      1|	coolkey_ops.restore_security_env = coolkey_restore_security_env;
 2466|      1|	coolkey_ops.compute_signature = coolkey_compute_crypt;
 2467|      1|	coolkey_ops.decipher =  coolkey_compute_crypt;
 2468|      1|	coolkey_ops.card_ctl = coolkey_card_ctl;
 2469|      1|	coolkey_ops.check_sw = coolkey_check_sw;
 2470|      1|	coolkey_ops.pin_cmd = coolkey_pin_cmd;
 2471|      1|	coolkey_ops.logout = coolkey_logout;
 2472|      1|	coolkey_ops.card_reader_lock_obtained = coolkey_card_reader_lock_obtained;
 2473|       |
 2474|      1|	return &coolkey_drv;
 2475|      1|}

sc_get_default_driver:
   67|      1|{
   68|      1|	return sc_get_driver();
   69|      1|}
card-default.c:sc_get_driver:
   56|      1|{
   57|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
   58|       |
   59|      1|	default_ops = *iso_drv->ops;
   60|      1|	default_ops.match_card = default_match_card;
   61|      1|	default_ops.init = default_init;
   62|       |
   63|      1|	return &default_drv;
   64|      1|}

sc_get_dnie_driver:
 2305|      1|{
 2306|      1|	return get_dnie_driver();
 2307|      1|}
card-dnie.c:get_dnie_driver:
 2242|      1|{
 2243|      1|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 2244|       |
 2245|       |	/* memcpy() from standard iso7816 declared operations */
 2246|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2246:6): [True: 1, False: 0]
  ------------------
 2247|      1|		iso_ops = iso_drv->ops;
 2248|      1|	dnie_ops = *iso_drv->ops;
 2249|       |
 2250|       |	/* fill card specific function pointers */
 2251|       |	/* NULL means that function is not supported neither by DNIe nor iso7816.c */
 2252|       |	/* if pointer is omitted, default ISO7816 function will be used */
 2253|       |
 2254|       |	/* initialization */
 2255|      1|	dnie_ops.match_card	= dnie_match_card;
 2256|      1|	dnie_ops.init		= dnie_init;
 2257|      1|	dnie_ops.finish		= dnie_finish;
 2258|       |
 2259|       |	/* iso7816-4 functions */
 2260|      1|	dnie_ops.read_binary	= dnie_read_binary;
 2261|      1|	dnie_ops.write_binary	= NULL;
 2262|      1|	dnie_ops.update_binary	= NULL;
 2263|      1|	dnie_ops.erase_binary	= NULL;
 2264|      1|	dnie_ops.read_record	= NULL;
 2265|      1|	dnie_ops.write_record	= NULL;
 2266|      1|	dnie_ops.append_record	= NULL;
 2267|      1|	dnie_ops.update_record	= NULL;
 2268|      1|	dnie_ops.select_file	= dnie_select_file;
 2269|      1|	dnie_ops.get_challenge	= dnie_get_challenge;
 2270|       |
 2271|       |	/* iso7816-8 functions */
 2272|      1|	dnie_ops.verify		= NULL;
 2273|      1|	dnie_ops.logout		= dnie_logout;
 2274|       |	/* dnie_ops.restore_security_env */
 2275|      1|	dnie_ops.set_security_env = dnie_set_security_env;
 2276|      1|	dnie_ops.decipher	= dnie_decipher;
 2277|      1|	dnie_ops.compute_signature = dnie_compute_signature;
 2278|      1|	dnie_ops.change_reference_data = NULL;
 2279|      1|	dnie_ops.reset_retry_counter = NULL;
 2280|       |
 2281|       |	/* iso7816-9 functions */
 2282|      1|	dnie_ops.create_file	= NULL;
 2283|      1|	dnie_ops.delete_file	= NULL;
 2284|      1|	dnie_ops.list_files	= dnie_list_files;
 2285|      1|	dnie_ops.check_sw	= dnie_check_sw;
 2286|      1|	dnie_ops.card_ctl	= dnie_card_ctl;
 2287|      1|	dnie_ops.process_fci	= dnie_process_fci;
 2288|       |	/* dnie_ops.construct_fci */
 2289|      1|	dnie_ops.pin_cmd	= dnie_pin_cmd;
 2290|      1|	dnie_ops.get_data	= NULL;
 2291|      1|	dnie_ops.put_data	= NULL;
 2292|      1|	dnie_ops.delete_record	= NULL;
 2293|       |
 2294|      1|	return &dnie_driver;
 2295|      1|}

sc_get_dtrust_driver:
 1057|      1|{
 1058|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1058:6): [True: 1, False: 0]
  ------------------
 1059|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1060|       |
 1061|      1|	dtrust_ops = *iso_ops;
 1062|      1|	dtrust_ops.match_card = dtrust_match_card;
 1063|      1|	dtrust_ops.init = dtrust_init;
 1064|      1|	dtrust_ops.finish = dtrust_finish;
 1065|      1|	dtrust_ops.pin_cmd = dtrust_pin_cmd;
 1066|      1|	dtrust_ops.set_security_env = dtrust_set_security_env;
 1067|      1|	dtrust_ops.compute_signature = dtrust_compute_signature;
 1068|      1|	dtrust_ops.decipher = dtrust_decipher;
 1069|      1|	dtrust_ops.logout = dtrust_logout;
 1070|       |
 1071|      1|	return &dtrust_drv;
 1072|      1|}

sc_get_edo_driver:
  306|      1|struct sc_card_driver* sc_get_edo_driver(void) {
  307|      1|	edo_ops = *sc_get_iso7816_driver()->ops;
  308|      1|	edo_ops.match_card = edo_match_card;
  309|      1|	edo_ops.init = edo_init;
  310|      1|	edo_ops.select_file = edo_select_file;
  311|      1|	edo_ops.set_security_env = edo_set_security_env;
  312|      1|	edo_ops.compute_signature = edo_compute_signature;
  313|      1|	edo_ops.logout = edo_logout;
  314|       |
  315|      1|	return &edo_drv;
  316|      1|}

sc_get_entersafe_driver:
 1580|      1|{
 1581|      1|	return sc_get_driver();
 1582|      1|}
card-entersafe.c:sc_get_driver:
 1554|      1|{
 1555|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1556|       |
 1557|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1557:6): [True: 1, False: 0]
  ------------------
 1558|      1|		iso_ops = iso_drv->ops;
 1559|       |
 1560|      1|	entersafe_ops = *iso_drv->ops;
 1561|      1|	entersafe_ops.match_card = entersafe_match_card;
 1562|      1|	entersafe_ops.init = entersafe_init;
 1563|      1|	entersafe_ops.read_binary = entersafe_read_binary;
 1564|      1|	entersafe_ops.write_binary = NULL;
 1565|      1|	entersafe_ops.update_binary = entersafe_update_binary;
 1566|      1|	entersafe_ops.select_file = entersafe_select_file;
 1567|      1|	entersafe_ops.restore_security_env = entersafe_restore_security_env;
 1568|      1|	entersafe_ops.set_security_env = entersafe_set_security_env;
 1569|      1|	entersafe_ops.decipher = entersafe_decipher;
 1570|      1|	entersafe_ops.compute_signature = entersafe_compute_signature;
 1571|      1|	entersafe_ops.create_file = entersafe_create_file;
 1572|       |	entersafe_ops.delete_file = NULL;
 1573|      1|	entersafe_ops.pin_cmd = entersafe_pin_cmd;
 1574|      1|	entersafe_ops.card_ctl = entersafe_card_ctl_2048;
 1575|      1|	entersafe_ops.process_fci = entersafe_process_fci;
 1576|      1|	return &entersafe_drv;
 1577|      1|}

sc_get_eoi_driver:
  566|      1|{
  567|      1|	eoi_ops = *sc_get_iso7816_driver()->ops;
  568|       |
  569|      1|	eoi_ops.match_card = eoi_match_card;
  570|      1|	eoi_ops.init = eoi_init;
  571|      1|	eoi_ops.finish = eoi_finish;
  572|      1|	eoi_ops.select_file = eoi_select_file;
  573|      1|	eoi_ops.logout = eoi_logout;
  574|      1|	eoi_ops.pin_cmd = eoi_pin_cmd;
  575|      1|	eoi_ops.card_ctl = eoi_card_ctl;
  576|      1|	eoi_ops.set_security_env = eoi_set_security_env;
  577|      1|	eoi_ops.compute_signature = eoi_compute_signature;
  578|       |
  579|      1|	return &eoi_drv;
  580|      1|}

sc_get_epass2003_driver:
 3295|      1|{
 3296|      1|	return sc_get_driver();
 3297|      1|}
card-epass2003.c:sc_get_driver:
 3262|      1|{
 3263|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3264|       |
 3265|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (3265:6): [True: 1, False: 0]
  ------------------
 3266|      1|		iso_ops = iso_drv->ops;
 3267|       |
 3268|      1|	epass2003_ops = *iso_ops;
 3269|       |
 3270|      1|	epass2003_ops.match_card = epass2003_match_card;
 3271|      1|	epass2003_ops.init = epass2003_init;
 3272|      1|	epass2003_ops.finish = epass2003_finish;
 3273|      1|	epass2003_ops.write_binary = NULL;
 3274|      1|	epass2003_ops.write_record = NULL;
 3275|      1|	epass2003_ops.select_file = epass2003_select_file;
 3276|       |	epass2003_ops.get_response = NULL;
 3277|      1|	epass2003_ops.restore_security_env = epass2003_restore_security_env;
 3278|      1|	epass2003_ops.set_security_env = epass2003_set_security_env;
 3279|      1|	epass2003_ops.decipher = epass2003_decipher;
 3280|      1|	epass2003_ops.compute_signature = epass2003_decipher;
 3281|      1|	epass2003_ops.create_file = epass2003_create_file;
 3282|      1|	epass2003_ops.delete_file = epass2003_delete_file;
 3283|      1|	epass2003_ops.list_files = epass2003_list_files;
 3284|      1|	epass2003_ops.card_ctl = epass2003_card_ctl;
 3285|      1|	epass2003_ops.process_fci = epass2003_process_fci;
 3286|      1|	epass2003_ops.construct_fci = epass2003_construct_fci;
 3287|      1|	epass2003_ops.pin_cmd = epass2003_pin_cmd;
 3288|      1|	epass2003_ops.check_sw = epass2003_check_sw;
 3289|      1|	epass2003_ops.get_challenge = epass2003_get_challenge;
 3290|      1|	epass2003_ops.logout = epass2003_logout;
 3291|      1|	return &epass2003_drv;
 3292|      1|}

sc_get_esteid2018_driver:
  303|      1|struct sc_card_driver *sc_get_esteid2018_driver(void) {
  304|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  305|       |
  306|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (306:6): [True: 1, False: 0]
  ------------------
  307|      1|		iso_ops = iso_drv->ops;
  308|       |
  309|      1|	esteid_ops = *iso_drv->ops;
  310|      1|	esteid_ops.match_card = esteid_match_card;
  311|      1|	esteid_ops.init = esteid_init;
  312|      1|	esteid_ops.finish = esteid_finish;
  313|       |
  314|      1|	esteid_ops.select_file = esteid_select_file;
  315|       |
  316|      1|	esteid_ops.set_security_env = esteid_set_security_env;
  317|      1|	esteid_ops.compute_signature = esteid_compute_signature;
  318|      1|	esteid_ops.pin_cmd = esteid_pin_cmd;
  319|      1|	esteid_ops.logout = esteid_logout;
  320|       |
  321|      1|	return &esteid2018_driver;
  322|      1|}

sc_get_esteid2025_driver:
  220|      1|{
  221|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  222|       |
  223|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (223:6): [True: 1, False: 0]
  ------------------
  224|      1|		iso_ops = iso_drv->ops;
  225|       |
  226|      1|	esteid_ops = *iso_drv->ops;
  227|      1|	esteid_ops.match_card = esteid_match_card;
  228|      1|	esteid_ops.init = esteid_init;
  229|       |
  230|      1|	esteid_ops.select_file = esteid_select_file;
  231|       |
  232|      1|	esteid_ops.set_security_env = esteid_set_security_env;
  233|      1|	esteid_ops.compute_signature = esteid_compute_signature;
  234|      1|	esteid_ops.pin_cmd = esteid_pin_cmd;
  235|      1|	esteid_ops.logout = esteid_logout;
  236|       |
  237|      1|	return &esteid2025_driver;
  238|      1|}

sc_get_cryptoflex_driver:
 1218|      1|{
 1219|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1219:6): [True: 0, False: 1]
  ------------------
 1220|      0|		iso_ops = sc_get_iso7816_driver()->ops;
 1221|       |
 1222|      1|	cryptoflex_ops = *iso_ops;
 1223|      1|	cryptoflex_ops.match_card = cryptoflex_match_card;
 1224|      1|	cryptoflex_ops.init = flex_init;
 1225|      1|	cryptoflex_ops.finish = flex_finish;
 1226|      1|	cryptoflex_ops.process_fci = cryptoflex_process_file_attrs;
 1227|      1|	cryptoflex_ops.construct_fci = cryptoflex_construct_file_attrs;
 1228|      1|	cryptoflex_ops.select_file = flex_select_file;
 1229|      1|	cryptoflex_ops.list_files = cryptoflex_list_files;
 1230|      1|	cryptoflex_ops.delete_file = flex_delete_file;
 1231|      1|	cryptoflex_ops.create_file = flex_create_file;
 1232|      1|	cryptoflex_ops.card_ctl = flex_card_ctl;
 1233|      1|	cryptoflex_ops.set_security_env = flex_set_security_env;
 1234|      1|	cryptoflex_ops.restore_security_env = flex_restore_security_env;
 1235|      1|	cryptoflex_ops.compute_signature = cryptoflex_compute_signature;
 1236|      1|	cryptoflex_ops.decipher = flex_decipher;
 1237|      1|	cryptoflex_ops.pin_cmd = flex_pin_cmd;
 1238|      1|	cryptoflex_ops.logout = flex_logout;
 1239|      1|	return &cryptoflex_drv;
 1240|      1|}
sc_get_cyberflex_driver:
 1243|      1|{
 1244|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1244:6): [True: 1, False: 0]
  ------------------
 1245|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1246|       |
 1247|      1|	cyberflex_ops = *iso_ops;
 1248|      1|	cyberflex_ops.match_card = cyberflex_match_card;
 1249|      1|	cyberflex_ops.init = flex_init;
 1250|      1|	cyberflex_ops.finish = flex_finish;
 1251|      1|	cyberflex_ops.process_fci = cyberflex_process_file_attrs;
 1252|      1|	cyberflex_ops.construct_fci = cyberflex_construct_file_attrs;
 1253|      1|	cyberflex_ops.select_file = flex_select_file;
 1254|      1|	cyberflex_ops.list_files = cyberflex_list_files;
 1255|      1|	cyberflex_ops.delete_file = flex_delete_file;
 1256|      1|	cyberflex_ops.create_file = flex_create_file;
 1257|      1|	cyberflex_ops.card_ctl = flex_card_ctl;
 1258|      1|	cyberflex_ops.set_security_env = flex_set_security_env;
 1259|      1|	cyberflex_ops.restore_security_env = flex_restore_security_env;
 1260|      1|	cyberflex_ops.compute_signature = cyberflex_compute_signature;
 1261|      1|	cyberflex_ops.decipher = flex_decipher;
 1262|      1|	cyberflex_ops.pin_cmd = flex_pin_cmd;
 1263|      1|	cyberflex_ops.logout = flex_logout;
 1264|      1|	return &cyberflex_drv;
 1265|      1|}

sc_get_gemsafeV1_driver:
  593|      1|{
  594|      1|	return sc_get_driver();
  595|      1|}
card-gemsafeV1.c:sc_get_driver:
  568|      1|{
  569|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  570|      1|	if (!iso_ops)
  ------------------
  |  Branch (570:6): [True: 1, False: 0]
  ------------------
  571|      1|		iso_ops = iso_drv->ops;
  572|       |	/* use the standard iso operations as default */
  573|      1|	gemsafe_ops = *iso_drv->ops;
  574|       |	/* gemsafe specific functions */
  575|      1|	gemsafe_ops.match_card	= gemsafe_match_card;
  576|      1|	gemsafe_ops.init	= gemsafe_init;
  577|      1|	gemsafe_ops.finish	= gemsafe_finish;
  578|      1|	gemsafe_ops.select_file	= gemsafe_select_file;
  579|      1|	gemsafe_ops.restore_security_env = gemsafe_restore_security_env;
  580|      1|	gemsafe_ops.set_security_env     = gemsafe_set_security_env;
  581|      1|	gemsafe_ops.decipher             = gemsafe_decipher;
  582|      1|	gemsafe_ops.compute_signature    = gemsafe_compute_signature;
  583|      1|	gemsafe_ops.get_challenge 		 = gemsafe_get_challenge;
  584|      1|	gemsafe_ops.process_fci	= gemsafe_process_fci;
  585|      1|	gemsafe_ops.pin_cmd		 = iso_ops->pin_cmd;
  586|      1|	gemsafe_ops.card_reader_lock_obtained = gemsafe_card_reader_lock_obtained;
  587|      1|	gemsafe_ops.logout = gemsafe_logout;
  588|       |
  589|      1|	return &gemsafe_drv;
  590|      1|}

sc_get_gids_driver:
 2196|      1|{
 2197|      1|	return sc_get_driver();
 2198|      1|}
card-gids.c:sc_get_driver:
 2151|      1|{
 2152|       |
 2153|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2153:6): [True: 1, False: 0]
  ------------------
 2154|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2155|       |
 2156|      1|	gids_ops.match_card = gids_match_card;
 2157|      1|	gids_ops.init = gids_init;
 2158|      1|	gids_ops.finish = gids_finish;
 2159|      1|	gids_ops.read_binary = gids_read_binary;
 2160|      1|	gids_ops.write_binary = NULL;
 2161|      1|	gids_ops.update_binary = NULL;
 2162|      1|	gids_ops.erase_binary = NULL;
 2163|      1|	gids_ops.read_record = NULL;
 2164|      1|	gids_ops.write_record = NULL;
 2165|      1|	gids_ops.append_record = NULL;
 2166|      1|	gids_ops.update_record = NULL;
 2167|      1|	gids_ops.select_file = gids_select_file;
 2168|      1|	gids_ops.get_response = iso_ops->get_response;
 2169|      1|	gids_ops.get_challenge = NULL;
 2170|      1|	gids_ops.verify = NULL; // see pin_cmd
 2171|      1|	gids_ops.logout = gids_logout;
 2172|      1|	gids_ops.restore_security_env = NULL;
 2173|      1|	gids_ops.set_security_env = gids_set_security_env;
 2174|      1|	gids_ops.decipher = gids_decipher;
 2175|      1|	gids_ops.compute_signature = iso_ops->compute_signature;
 2176|      1|	gids_ops.change_reference_data = NULL; // see pin_cmd
 2177|      1|	gids_ops.reset_retry_counter = NULL; // see pin_cmd
 2178|      1|	gids_ops.create_file = iso_ops->create_file;
 2179|      1|	gids_ops.delete_file = NULL;
 2180|      1|	gids_ops.list_files = NULL;
 2181|      1|	gids_ops.check_sw = iso_ops->check_sw;
 2182|      1|	gids_ops.card_ctl = gids_card_ctl;
 2183|      1|	gids_ops.process_fci = iso_ops->process_fci;
 2184|      1|	gids_ops.construct_fci = iso_ops->construct_fci;
 2185|      1|	gids_ops.pin_cmd = gids_pin_cmd;
 2186|      1|	gids_ops.get_data = NULL;
 2187|      1|	gids_ops.put_data = NULL;
 2188|      1|	gids_ops.delete_record = NULL;
 2189|      1|	gids_ops.read_public_key = gids_read_public_key;
 2190|      1|	gids_ops.card_reader_lock_obtained = gids_card_reader_lock_obtained;
 2191|       |
 2192|      1|	return &gids_drv;
 2193|      1|}

sc_get_iasecc_driver:
 3688|      1|{
 3689|      1|	return sc_get_driver();
 3690|      1|}
card-iasecc.c:sc_get_driver:
 3641|      1|{
 3642|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3643|       |
 3644|      1|	if (!iso_ops)
  ------------------
  |  Branch (3644:6): [True: 1, False: 0]
  ------------------
 3645|      1|		iso_ops = iso_drv->ops;
 3646|       |
 3647|      1|	iasecc_ops = *iso_ops;
 3648|       |
 3649|      1|	iasecc_ops.match_card = iasecc_match_card;
 3650|      1|	iasecc_ops.init = iasecc_init;
 3651|      1|	iasecc_ops.finish = iasecc_finish;
 3652|      1|	iasecc_ops.read_binary = iasecc_read_binary;
 3653|       |	/*	write_binary: ISO7816 implementation works	*/
 3654|       |	/*	update_binary: ISO7816 implementation works	*/
 3655|      1|	iasecc_ops.erase_binary = iasecc_erase_binary;
 3656|       |	/*	resize_binary	*/
 3657|       |	/* 	read_record: Untested	*/
 3658|       |	/*	write_record: Untested	*/
 3659|       |	/*	append_record: Untested	*/
 3660|       |	/*	update_record: Untested	*/
 3661|      1|	iasecc_ops.select_file = iasecc_select_file;
 3662|       |	/*	get_response: Untested	*/
 3663|      1|	iasecc_ops.get_challenge = iasecc_get_challenge;
 3664|      1|	iasecc_ops.logout = iasecc_logout;
 3665|       |	/*	restore_security_env	*/
 3666|      1|	iasecc_ops.set_security_env = iasecc_set_security_env;
 3667|      1|	iasecc_ops.decipher = iasecc_decipher;
 3668|      1|	iasecc_ops.compute_signature = iasecc_compute_signature;
 3669|      1|	iasecc_ops.create_file = iasecc_create_file;
 3670|      1|	iasecc_ops.delete_file = iasecc_delete_file;
 3671|       |	/*	list_files	*/
 3672|      1|	iasecc_ops.check_sw = iasecc_check_sw;
 3673|      1|	iasecc_ops.card_ctl = iasecc_card_ctl;
 3674|      1|	iasecc_ops.process_fci = iasecc_process_fci;
 3675|       |	/*	construct_fci: Not needed	*/
 3676|      1|	iasecc_ops.pin_cmd = iasecc_pin_cmd;
 3677|       |	/*	get_data: Not implemented	*/
 3678|       |	/*	put_data: Not implemented	*/
 3679|       |	/*	delete_record: Not implemented	*/
 3680|       |
 3681|      1|	iasecc_ops.read_public_key = iasecc_read_public_key;
 3682|       |
 3683|      1|	return &iasecc_drv;
 3684|      1|}

sc_get_idprime_driver:
 1279|      1|{
 1280|      1|	return sc_get_driver();
 1281|      1|}
card-idprime.c:sc_get_driver:
 1256|      1|{
 1257|      1|	if (iso_ops == NULL) {
  ------------------
  |  Branch (1257:6): [True: 1, False: 0]
  ------------------
 1258|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1259|      1|	}
 1260|       |
 1261|      1|	idprime_ops = *iso_ops;
 1262|      1|	idprime_ops.match_card = idprime_match_card;
 1263|      1|	idprime_ops.init = idprime_init;
 1264|      1|	idprime_ops.finish = idprime_finish;
 1265|       |
 1266|      1|	idprime_ops.read_binary = idprime_read_binary;
 1267|      1|	idprime_ops.select_file = idprime_select_file;
 1268|      1|	idprime_ops.card_ctl = idprime_card_ctl;
 1269|      1|	idprime_ops.set_security_env = idprime_set_security_env;
 1270|      1|	idprime_ops.compute_signature = idprime_compute_signature;
 1271|      1|	idprime_ops.decipher = idprime_decipher;
 1272|       |
 1273|      1|	idprime_ops.get_challenge = idprime_get_challenge;
 1274|       |
 1275|      1|	return &idprime_drv;
 1276|      1|}

sc_get_isoApplet_driver:
 1295|      1|{
 1296|      1|	return sc_get_driver();
 1297|      1|}
card-isoApplet.c:sc_get_driver:
 1259|      1|{
 1260|      1|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 1261|       |
 1262|      1|	if(iso_ops == NULL)
  ------------------
  |  Branch (1262:5): [True: 1, False: 0]
  ------------------
 1263|      1|	{
 1264|      1|		iso_ops = iso_drv->ops;
 1265|      1|	}
 1266|       |
 1267|      1|	isoApplet_ops = *iso_drv->ops;
 1268|       |
 1269|      1|	isoApplet_ops.match_card = isoApplet_match_card;
 1270|      1|	isoApplet_ops.init = isoApplet_init;
 1271|      1|	isoApplet_ops.finish = isoApplet_finish;
 1272|       |
 1273|      1|	isoApplet_ops.card_ctl = isoApplet_card_ctl;
 1274|       |
 1275|      1|	isoApplet_ops.create_file = isoApplet_create_file;
 1276|      1|	isoApplet_ops.process_fci = isoApplet_process_fci;
 1277|      1|	isoApplet_ops.set_security_env = isoApplet_set_security_env;
 1278|      1|	isoApplet_ops.compute_signature = isoApplet_compute_signature;
 1279|      1|	isoApplet_ops.get_challenge = isoApplet_get_challenge;
 1280|      1|	isoApplet_ops.card_reader_lock_obtained = isoApplet_card_reader_lock_obtained;
 1281|      1|	isoApplet_ops.logout = isoApplet_logout;
 1282|       |
 1283|       |	/* unsupported functions */
 1284|      1|	isoApplet_ops.write_binary = NULL;
 1285|      1|	isoApplet_ops.read_record = NULL;
 1286|      1|	isoApplet_ops.write_record = NULL;
 1287|      1|	isoApplet_ops.append_record = NULL;
 1288|      1|	isoApplet_ops.update_record = NULL;
 1289|      1|	isoApplet_ops.restore_security_env = NULL;
 1290|       |
 1291|      1|	return &isoApplet_drv;
 1292|      1|}

sc_get_itacns_driver:
  524|      1|{
  525|      1|	return sc_get_driver();
  526|      1|}
card-itacns.c:sc_get_driver:
  505|      1|{
  506|      1|	if (!default_ops)
  ------------------
  |  Branch (506:6): [True: 1, False: 0]
  ------------------
  507|      1|		default_ops = sc_get_iso7816_driver()->ops;
  508|      1|	itacns_ops = *default_ops;
  509|      1|	itacns_ops.match_card = itacns_match_card;
  510|      1|	itacns_ops.init = itacns_init;
  511|      1|	itacns_ops.finish = itacns_finish;
  512|      1|	itacns_ops.set_security_env = itacns_set_security_env;
  513|      1|	itacns_ops.restore_security_env = itacns_restore_security_env;
  514|      1|	itacns_ops.pin_cmd = itacns_pin_cmd;
  515|      1|	itacns_ops.read_binary = itacns_read_binary;
  516|      1|	itacns_ops.list_files = itacns_list_files;
  517|      1|	itacns_ops.select_file = itacns_select_file;
  518|      1|	itacns_ops.card_ctl = itacns_card_ctl;
  519|      1|	itacns_ops.get_challenge = itacns_get_challenge;
  520|      1|	return &itacns_drv;
  521|      1|}

sc_get_jpki_driver:
  395|      1|{
  396|      1|	return sc_get_driver();
  397|      1|}
card-jpki.c:sc_get_driver:
  376|      1|{
  377|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  378|       |
  379|      1|	jpki_ops = *iso_drv->ops;
  380|      1|	jpki_ops.match_card = jpki_match_card;
  381|      1|	jpki_ops.init = jpki_init;
  382|      1|	jpki_ops.finish = jpki_finish;
  383|      1|	jpki_ops.select_file = jpki_select_file;
  384|      1|	jpki_ops.pin_cmd = jpki_pin_cmd;
  385|      1|	jpki_ops.set_security_env = jpki_set_security_env;
  386|      1|	jpki_ops.compute_signature = jpki_compute_signature;
  387|      1|	jpki_ops.card_reader_lock_obtained = jpki_card_reader_lock_obtained;
  388|      1|	jpki_ops.logout = jpki_logout;
  389|       |
  390|      1|	return &jpki_drv;
  391|      1|}

sc_get_lteid_driver:
  563|      1|{
  564|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  565|       |
  566|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (566:6): [True: 1, False: 0]
  ------------------
  567|      1|		iso_ops = iso_drv->ops;
  568|       |
  569|      1|	lteid_ops = *iso_ops;
  570|      1|	lteid_ops.init = lteid_init;
  571|      1|	lteid_ops.finish = lteid_finish;
  572|      1|	lteid_ops.set_security_env = lteid_set_security_env;
  573|      1|	lteid_ops.compute_signature = lteid_compute_signature;
  574|      1|	lteid_ops.pin_cmd = lteid_pin_cmd;
  575|      1|	lteid_ops.logout = lteid_logout;
  576|      1|	lteid_ops.process_fci = lteid_process_fci;
  577|       |
  578|      1|	return &lteid_drv;
  579|      1|}

sc_get_masktech_driver:
  377|      1|{
  378|      1|	return sc_get_driver();
  379|      1|}
card-masktech.c:sc_get_driver:
  358|      1|{
  359|       |
  360|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (360:6): [True: 1, False: 0]
  ------------------
  361|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  362|       |
  363|      1|	masktech_ops = *iso_ops;
  364|       |
  365|      1|	masktech_ops.match_card = masktech_match_card;
  366|      1|	masktech_ops.init = masktech_init;
  367|      1|	masktech_ops.finish = masktech_finish;
  368|      1|	masktech_ops.set_security_env = masktech_set_security_env;
  369|      1|	masktech_ops.compute_signature = masktech_compute_signature;
  370|      1|	masktech_ops.decipher = masktech_decipher;
  371|      1|	masktech_ops.pin_cmd = masktech_pin_cmd;
  372|      1|	masktech_ops.card_ctl = masktech_card_ctl;
  373|      1|	return &masktech_drv;
  374|      1|}

sc_get_mcrd_driver:
 1069|      1|{
 1070|      1|	return sc_get_driver();
 1071|      1|}
card-mcrd.c:sc_get_driver:
 1050|      1|{
 1051|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1052|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1052:6): [True: 1, False: 0]
  ------------------
 1053|      1|		iso_ops = iso_drv->ops;
 1054|       |
 1055|      1|	mcrd_ops = *iso_drv->ops;
 1056|      1|	mcrd_ops.match_card = mcrd_match_card;
 1057|      1|	mcrd_ops.init = mcrd_init;
 1058|      1|	mcrd_ops.finish = mcrd_finish;
 1059|      1|	mcrd_ops.select_file = mcrd_select_file;
 1060|      1|	mcrd_ops.set_security_env = mcrd_set_security_env;
 1061|      1|	mcrd_ops.compute_signature = mcrd_compute_signature;
 1062|      1|	mcrd_ops.pin_cmd = mcrd_pin_cmd;
 1063|      1|	mcrd_ops.logout = mcrd_logout;
 1064|       |
 1065|      1|	return &mcrd_drv;
 1066|      1|}

sc_get_muscle_driver:
  904|      1|{
  905|      1|	return sc_get_driver();
  906|      1|}
card-muscle.c:sc_get_driver:
  872|      1|{
  873|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  874|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (874:6): [True: 1, False: 0]
  ------------------
  875|      1|		iso_ops = iso_drv->ops;
  876|       |
  877|      1|	muscle_ops = *iso_drv->ops;
  878|      1|	muscle_ops.check_sw = muscle_check_sw;
  879|      1|	muscle_ops.pin_cmd = muscle_pin_cmd;
  880|      1|	muscle_ops.match_card = muscle_match_card;
  881|      1|	muscle_ops.init = muscle_init;
  882|      1|	muscle_ops.finish = muscle_finish;
  883|       |
  884|      1|	muscle_ops.get_challenge = muscle_get_challenge;
  885|       |
  886|      1|	muscle_ops.set_security_env = muscle_set_security_env;
  887|      1|	muscle_ops.restore_security_env = muscle_restore_security_env;
  888|      1|	muscle_ops.compute_signature = muscle_compute_signature;
  889|      1|	muscle_ops.decipher = muscle_decipher;
  890|      1|	muscle_ops.card_ctl = muscle_card_ctl;
  891|      1|	muscle_ops.read_binary = muscle_read_binary;
  892|      1|	muscle_ops.update_binary = muscle_update_binary;
  893|      1|	muscle_ops.create_file = muscle_create_file;
  894|      1|	muscle_ops.select_file = muscle_select_file;
  895|      1|	muscle_ops.delete_file = muscle_delete_file;
  896|      1|	muscle_ops.list_files = muscle_list_files;
  897|      1|	muscle_ops.card_reader_lock_obtained = muscle_card_reader_lock_obtained;
  898|      1|	muscle_ops.logout = muscle_logout;
  899|       |
  900|      1|	return &muscle_drv;
  901|      1|}

sc_get_myeid_driver:
 2146|      1|{
 2147|      1|	return sc_get_driver();
 2148|      1|}
card-myeid.c:sc_get_driver:
 2111|      1|{
 2112|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2113|       |
 2114|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2114:6): [True: 1, False: 0]
  ------------------
 2115|      1|		iso_ops = iso_drv->ops;
 2116|       |
 2117|      1|	myeid_ops			= *iso_drv->ops;
 2118|      1|	myeid_ops.match_card		= myeid_match_card;
 2119|      1|	myeid_ops.init			= myeid_init;
 2120|      1|	myeid_ops.finish		= myeid_finish;
 2121|       |	/* no record oriented file services */
 2122|      1|	myeid_ops.read_record		= NULL;
 2123|      1|	myeid_ops.write_record		= NULL;
 2124|      1|	myeid_ops.append_record		= NULL;
 2125|       |	myeid_ops.update_record		= NULL;
 2126|      1|	myeid_ops.select_file		= myeid_select_file;
 2127|      1|	myeid_ops.get_response		= iso_ops->get_response;
 2128|      1|	myeid_ops.logout		= myeid_logout;
 2129|      1|	myeid_ops.create_file		= myeid_create_file;
 2130|      1|	myeid_ops.delete_file		= myeid_delete_file;
 2131|      1|	myeid_ops.list_files		= myeid_list_files;
 2132|      1|	myeid_ops.set_security_env	= myeid_set_security_env;
 2133|      1|	myeid_ops.compute_signature	= myeid_compute_signature;
 2134|      1|	myeid_ops.decipher		= myeid_decipher;
 2135|      1|	myeid_ops.process_fci		= myeid_process_fci;
 2136|      1|	myeid_ops.card_ctl		= myeid_card_ctl;
 2137|      1|	myeid_ops.pin_cmd		= myeid_pin_cmd;
 2138|      1|	myeid_ops.wrap			= myeid_wrap_key;
 2139|      1|	myeid_ops.unwrap		= myeid_unwrap_key;
 2140|      1|	myeid_ops.encrypt_sym		= myeid_encrypt_sym;
 2141|      1|	myeid_ops.decrypt_sym		= myeid_decrypt_sym;
 2142|      1|	return &myeid_drv;
 2143|      1|}

sc_get_npa_driver:
  815|      1|{
  816|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  817|       |
  818|      1|	npa_ops = *iso_drv->ops;
  819|      1|	npa_ops.match_card = npa_match_card;
  820|      1|	npa_ops.init = npa_init;
  821|      1|	npa_ops.finish = npa_finish;
  822|      1|	npa_ops.set_security_env = npa_set_security_env;
  823|      1|	npa_ops.pin_cmd = npa_pin_cmd;
  824|      1|	npa_ops.logout = npa_logout;
  825|       |
  826|      1|	return &npa_drv;
  827|      1|}

sc_get_nqApplet_driver:
  471|      1|{
  472|      1|	sc_card_driver_t *iso_driver = sc_get_iso7816_driver();
  473|       |
  474|      1|	if (iso_operations == NULL) {
  ------------------
  |  Branch (474:6): [True: 1, False: 0]
  ------------------
  475|      1|		iso_operations = iso_driver->ops;
  476|      1|	}
  477|       |
  478|      1|	nqapplet_operations = *iso_driver->ops;
  479|       |
  480|       |	/* supported operations */
  481|      1|	nqapplet_operations.match_card = nqapplet_match_card;
  482|      1|	nqapplet_operations.init = nqapplet_init;
  483|      1|	nqapplet_operations.finish = nqapplet_finish;
  484|      1|	nqapplet_operations.get_response = nqapplet_get_response;
  485|      1|	nqapplet_operations.get_challenge = nqapplet_get_challenge;
  486|      1|	nqapplet_operations.logout = nqapplet_logout;
  487|      1|	nqapplet_operations.set_security_env = nqapplet_set_security_env;
  488|      1|	nqapplet_operations.decipher = nqapplet_decipher;
  489|      1|	nqapplet_operations.compute_signature = nqapplet_compute_signature;
  490|      1|	nqapplet_operations.check_sw = nqapplet_check_sw;
  491|      1|	nqapplet_operations.get_data = nqapplet_get_data;
  492|      1|	nqapplet_operations.select_file = nqapplet_select_file;
  493|      1|	nqapplet_operations.card_ctl = nqapplet_card_ctl;
  494|      1|	nqapplet_operations.pin_cmd = nqapplet_pin_cmd;
  495|       |
  496|       |	/* unsupported operations */
  497|      1|	nqapplet_operations.read_binary = NULL;
  498|      1|	nqapplet_operations.write_binary = NULL;
  499|      1|	nqapplet_operations.update_binary = NULL;
  500|      1|	nqapplet_operations.erase_binary = NULL;
  501|      1|	nqapplet_operations.read_record = NULL;
  502|      1|	nqapplet_operations.write_record = NULL;
  503|      1|	nqapplet_operations.append_record = NULL;
  504|      1|	nqapplet_operations.update_record = NULL;
  505|       |
  506|      1|	nqapplet_operations.verify = NULL;
  507|      1|	nqapplet_operations.restore_security_env = NULL;
  508|      1|	nqapplet_operations.change_reference_data = NULL;
  509|      1|	nqapplet_operations.reset_retry_counter = NULL;
  510|      1|	nqapplet_operations.create_file = NULL;
  511|      1|	nqapplet_operations.delete_file = NULL;
  512|      1|	nqapplet_operations.list_files = NULL;
  513|      1|	nqapplet_operations.process_fci = NULL;
  514|      1|	nqapplet_operations.construct_fci = NULL;
  515|      1|	nqapplet_operations.put_data = NULL;
  516|      1|	nqapplet_operations.delete_record = NULL;
  517|      1|	nqapplet_operations.read_public_key = NULL;
  518|       |
  519|       |	/* let iso driver handle these operations
  520|       |	nqapplet_operations.card_reader_lock_obtained;
  521|       |	nqapplet_operations.wrap;
  522|       |	nqapplet_operations.unwrap;
  523|       |	*/
  524|       |
  525|      1|	return &nqapplet_driver;
  526|      1|}

sc_get_oberthur_driver:
 2335|      1|{
 2336|      1|	return sc_get_driver();
 2337|      1|}
card-oberthur.c:sc_get_driver:
 2304|      1|{
 2305|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2305:6): [True: 1, False: 0]
  ------------------
 2306|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2307|       |
 2308|      1|	auth_ops = *iso_ops;
 2309|      1|	auth_ops.match_card = auth_match_card;
 2310|      1|	auth_ops.init = auth_init;
 2311|      1|	auth_ops.finish = auth_finish;
 2312|      1|	auth_ops.select_file = auth_select_file;
 2313|      1|	auth_ops.list_files = auth_list_files;
 2314|      1|	auth_ops.delete_file = auth_delete_file;
 2315|      1|	auth_ops.create_file = auth_create_file;
 2316|      1|	auth_ops.read_binary = auth_read_binary;
 2317|      1|	auth_ops.update_binary = auth_update_binary;
 2318|      1|	auth_ops.read_record = auth_read_record;
 2319|      1|	auth_ops.delete_record = auth_delete_record;
 2320|      1|	auth_ops.card_ctl = auth_card_ctl;
 2321|      1|	auth_ops.set_security_env = auth_set_security_env;
 2322|      1|	auth_ops.restore_security_env = auth_restore_security_env;
 2323|      1|	auth_ops.compute_signature = auth_compute_signature;
 2324|      1|	auth_ops.decipher = auth_decipher;
 2325|      1|	auth_ops.process_fci = auth_process_fci;
 2326|      1|	auth_ops.pin_cmd = auth_pin_cmd;
 2327|      1|	auth_ops.logout = auth_logout;
 2328|      1|	auth_ops.check_sw = auth_check_sw;
 2329|      1|	return &auth_drv;
 2330|      1|}

sc_get_openpgp_driver:
 4213|      1|{
 4214|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 4215|       |
 4216|      1|	iso_ops = iso_drv->ops;
 4217|       |
 4218|      1|	pgp_ops = *iso_ops;
 4219|      1|	pgp_ops.match_card	= pgp_match_card;
 4220|      1|	pgp_ops.init		= pgp_init;
 4221|      1|	pgp_ops.finish		= pgp_finish;
 4222|      1|	pgp_ops.select_file	= pgp_select_file;
 4223|      1|	pgp_ops.list_files	= pgp_list_files;
 4224|      1|	pgp_ops.get_challenge	= pgp_get_challenge;
 4225|      1|	pgp_ops.read_binary	= pgp_read_binary;
 4226|      1|	pgp_ops.write_binary	= NULL;
 4227|      1|	pgp_ops.pin_cmd		= pgp_pin_cmd;
 4228|      1|	pgp_ops.logout		= pgp_logout;
 4229|      1|	pgp_ops.get_data	= pgp_get_data;
 4230|      1|	pgp_ops.put_data	= pgp_put_data;
 4231|      1|	pgp_ops.set_security_env= pgp_set_security_env;
 4232|      1|	pgp_ops.compute_signature= pgp_compute_signature;
 4233|      1|	pgp_ops.decipher	= pgp_decipher;
 4234|      1|	pgp_ops.card_ctl	= pgp_card_ctl;
 4235|      1|	pgp_ops.delete_file	= pgp_delete_file;
 4236|      1|	pgp_ops.update_binary	= pgp_update_binary;
 4237|      1|	pgp_ops.card_reader_lock_obtained = pgp_card_reader_lock_obtained;
 4238|       |
 4239|      1|	return &pgp_drv;
 4240|      1|}

sc_get_piv_driver:
 6473|      1|{
 6474|      1|	return sc_get_driver();
 6475|      1|}
card-piv.c:sc_get_driver:
 6446|      1|{
 6447|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6448|       |
 6449|      1|	piv_ops = *iso_drv->ops;
 6450|      1|	piv_ops.match_card = piv_match_card;
 6451|      1|	piv_ops.init = piv_init;
 6452|      1|	piv_ops.finish = piv_finish;
 6453|       |
 6454|      1|	piv_ops.select_file = piv_select_file; /* must use get/put, could emulate? */
 6455|      1|	piv_ops.get_challenge = piv_get_challenge;
 6456|      1|	piv_ops.logout = piv_logout;
 6457|      1|	piv_ops.read_binary = piv_read_binary;
 6458|      1|	piv_ops.write_binary = piv_write_binary;
 6459|      1|	piv_ops.set_security_env = piv_set_security_env;
 6460|      1|	piv_ops.restore_security_env = piv_restore_security_env;
 6461|      1|	piv_ops.compute_signature = piv_compute_signature;
 6462|      1|	piv_ops.decipher = piv_decipher;
 6463|      1|	piv_ops.check_sw = piv_check_sw;
 6464|      1|	piv_ops.card_ctl = piv_card_ctl;
 6465|      1|	piv_ops.pin_cmd = piv_pin_cmd;
 6466|      1|	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 6467|       |
 6468|      1|	return &piv_drv;
 6469|      1|}

sc_get_rtecp_driver:
  869|      1|{
  870|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (870:6): [True: 1, False: 0]
  ------------------
  871|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  872|      1|	rtecp_ops = *iso_ops;
  873|       |
  874|      1|	rtecp_ops.match_card = rtecp_match_card;
  875|      1|	rtecp_ops.init = rtecp_init;
  876|       |	/* read_binary */
  877|      1|	rtecp_ops.write_binary = NULL;
  878|       |	/* update_binary */
  879|      1|	rtecp_ops.read_record = NULL;
  880|      1|	rtecp_ops.write_record = NULL;
  881|      1|	rtecp_ops.append_record = NULL;
  882|      1|	rtecp_ops.update_record = NULL;
  883|      1|	rtecp_ops.select_file = rtecp_select_file;
  884|       |	/* get_response */
  885|       |	/* get_challenge */
  886|      1|	rtecp_ops.verify = rtecp_verify;
  887|      1|	rtecp_ops.logout = rtecp_logout;
  888|       |	/* restore_security_env */
  889|      1|	rtecp_ops.set_security_env = rtecp_set_security_env;
  890|      1|	rtecp_ops.decipher = rtecp_decipher;
  891|      1|	rtecp_ops.compute_signature = rtecp_compute_signature;
  892|      1|	rtecp_ops.change_reference_data = rtecp_change_reference_data;
  893|      1|	rtecp_ops.reset_retry_counter = rtecp_reset_retry_counter;
  894|      1|	rtecp_ops.create_file = rtecp_create_file;
  895|       |	/* delete_file */
  896|      1|	rtecp_ops.list_files = rtecp_list_files;
  897|       |	/* check_sw */
  898|      1|	rtecp_ops.card_ctl = rtecp_card_ctl;
  899|       |	/* process_fci */
  900|      1|	rtecp_ops.construct_fci = rtecp_construct_fci;
  901|       |	rtecp_ops.pin_cmd = NULL;
  902|      1|	return &rtecp_drv;
  903|      1|}

sc_get_rutoken_driver:
 1326|      1|{
 1327|      1|	return get_rutoken_driver();
 1328|      1|}
card-rutoken.c:get_rutoken_driver:
 1287|      1|{
 1288|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1288:6): [True: 1, False: 0]
  ------------------
 1289|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1290|      1|	rutoken_ops = *iso_ops;
 1291|       |
 1292|      1|	rutoken_ops.match_card = rutoken_match_card;
 1293|      1|	rutoken_ops.init = rutoken_init;
 1294|      1|	rutoken_ops.finish = rutoken_finish;
 1295|       |	/* read_binary */
 1296|      1|	rutoken_ops.write_binary = NULL;
 1297|       |	/* update_binary */
 1298|      1|	rutoken_ops.read_record = NULL;
 1299|      1|	rutoken_ops.write_record = NULL;
 1300|      1|	rutoken_ops.append_record = NULL;
 1301|      1|	rutoken_ops.update_record = NULL;
 1302|      1|	rutoken_ops.select_file = rutoken_select_file;
 1303|      1|	rutoken_ops.get_response = NULL;
 1304|      1|	rutoken_ops.get_challenge = rutoken_get_challenge;
 1305|      1|	rutoken_ops.verify = rutoken_verify;
 1306|      1|	rutoken_ops.logout = rutoken_logout;
 1307|      1|	rutoken_ops.restore_security_env = rutoken_restore_security_env;
 1308|      1|	rutoken_ops.set_security_env = rutoken_set_security_env;
 1309|      1|	rutoken_ops.decipher = NULL;
 1310|      1|	rutoken_ops.compute_signature = rutoken_compute_signature;
 1311|      1|	rutoken_ops.change_reference_data = rutoken_change_reference_data;
 1312|      1|	rutoken_ops.reset_retry_counter = rutoken_reset_retry_counter;
 1313|      1|	rutoken_ops.create_file = rutoken_create_file;
 1314|      1|	rutoken_ops.delete_file = rutoken_delete_file;
 1315|      1|	rutoken_ops.list_files = rutoken_list_files;
 1316|      1|	rutoken_ops.check_sw = rutoken_check_sw;
 1317|      1|	rutoken_ops.card_ctl = rutoken_card_ctl;
 1318|      1|	rutoken_ops.process_fci = rutoken_process_fci;
 1319|      1|	rutoken_ops.construct_fci = rutoken_construct_fci;
 1320|      1|	rutoken_ops.pin_cmd = NULL;
 1321|       |
 1322|      1|	return &rutoken_drv;
 1323|      1|}

sc_get_sc_hsm_driver:
 1980|      1|{
 1981|      1|	return sc_get_driver();
 1982|      1|}
card-sc-hsm.c:sc_get_driver:
 1944|      1|{
 1945|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1946|       |
 1947|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1947:6): [True: 1, False: 0]
  ------------------
 1948|      1|		iso_ops = iso_drv->ops;
 1949|       |
 1950|      1|	sc_hsm_ops                   = *iso_drv->ops;
 1951|      1|	sc_hsm_ops.match_card        = sc_hsm_match_card;
 1952|      1|	sc_hsm_ops.select_file       = sc_hsm_select_file;
 1953|      1|	sc_hsm_ops.get_challenge     = sc_hsm_get_challenge;
 1954|      1|	sc_hsm_ops.read_binary       = sc_hsm_read_binary;
 1955|      1|	sc_hsm_ops.update_binary     = sc_hsm_update_binary;
 1956|      1|	sc_hsm_ops.list_files        = sc_hsm_list_files;
 1957|      1|	sc_hsm_ops.create_file       = sc_hsm_create_file;
 1958|      1|	sc_hsm_ops.delete_file       = sc_hsm_delete_file;
 1959|      1|	sc_hsm_ops.set_security_env  = sc_hsm_set_security_env;
 1960|      1|	sc_hsm_ops.compute_signature = sc_hsm_compute_signature;
 1961|      1|	sc_hsm_ops.decipher          = sc_hsm_decipher;
 1962|      1|	sc_hsm_ops.init              = sc_hsm_init;
 1963|      1|	sc_hsm_ops.finish            = sc_hsm_finish;
 1964|      1|	sc_hsm_ops.card_ctl          = sc_hsm_card_ctl;
 1965|      1|	sc_hsm_ops.pin_cmd           = sc_hsm_pin_cmd;
 1966|      1|	sc_hsm_ops.logout            = sc_hsm_logout;
 1967|       |
 1968|       |	/* no record oriented file services */
 1969|      1|	sc_hsm_ops.read_record       = NULL;
 1970|      1|	sc_hsm_ops.write_record      = NULL;
 1971|      1|	sc_hsm_ops.append_record     = NULL;
 1972|      1|	sc_hsm_ops.update_record     = NULL;
 1973|       |
 1974|      1|	return &sc_hsm_drv;
 1975|      1|}

sc_get_setcos_driver:
 1130|      1|{
 1131|      1|	return sc_get_driver();
 1132|      1|}
card-setcos.c:sc_get_driver:
 1110|      1|{
 1111|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1112|       |
 1113|      1|	setcos_ops = *iso_drv->ops;
 1114|      1|	setcos_ops.match_card = setcos_match_card;
 1115|      1|	setcos_ops.init = setcos_init;
 1116|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1116:6): [True: 1, False: 0]
  ------------------
 1117|      1|		iso_ops = iso_drv->ops;
 1118|      1|	setcos_ops.create_file = setcos_create_file;
 1119|      1|	setcos_ops.set_security_env = setcos_set_security_env;
 1120|      1|	setcos_ops.select_file = setcos_select_file;
 1121|      1|	setcos_ops.list_files = setcos_list_files;
 1122|      1|	setcos_ops.process_fci = setcos_process_fci;
 1123|      1|	setcos_ops.construct_fci = setcos_construct_fci;
 1124|      1|	setcos_ops.card_ctl = setcos_card_ctl;
 1125|       |
 1126|      1|	return &setcos_drv;
 1127|      1|}

sc_get_skeid_driver:
  179|      1|{
  180|      1|	if (iso_ops == NULL) iso_ops = sc_get_iso7816_driver()->ops;
  ------------------
  |  Branch (180:6): [True: 1, False: 0]
  ------------------
  181|      1|	skeid_ops = *iso_ops;
  182|      1|	skeid_ops.match_card = skeid_match_card;
  183|      1|	skeid_ops.init = skeid_init;
  184|      1|	skeid_ops.set_security_env = skeid_set_security_env;
  185|      1|	skeid_ops.logout = skeid_logout;
  186|      1|	return &skeid_drv;
  187|      1|}

sc_get_srbeid_driver:
  301|      1|{
  302|       |	/* Save ISO ops for delegation, then override what we handle. */
  303|      1|	iso_ops = sc_get_iso7816_driver()->ops;
  304|      1|	srbeid_ops = *iso_ops;
  305|      1|	srbeid_ops.match_card = srbeid_match_card;
  306|      1|	srbeid_ops.init = srbeid_init;
  307|      1|	srbeid_ops.select_file = srbeid_select_file;
  308|      1|	srbeid_ops.set_security_env = srbeid_set_security_env;
  309|      1|	srbeid_ops.compute_signature = srbeid_compute_signature;
  310|      1|	srbeid_ops.decipher = srbeid_decipher;
  311|       |
  312|      1|	return &srbeid_drv;
  313|      1|}

sc_get_starcos_driver:
 2119|      1|{
 2120|      1|	return sc_get_driver();
 2121|      1|}
card-starcos.c:sc_get_driver:
 2094|      1|{
 2095|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2096|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2096:6): [True: 1, False: 0]
  ------------------
 2097|      1|		iso_ops = iso_drv->ops;
 2098|       |
 2099|      1|	starcos_ops = *iso_drv->ops;
 2100|      1|	starcos_ops.match_card = starcos_match_card;
 2101|      1|	starcos_ops.init   = starcos_init;
 2102|      1|	starcos_ops.finish = starcos_finish;
 2103|      1|	starcos_ops.select_file = starcos_select_file;
 2104|      1|	starcos_ops.get_challenge = starcos_get_challenge;
 2105|      1|	starcos_ops.check_sw    = starcos_check_sw;
 2106|      1|	starcos_ops.create_file = starcos_create_file;
 2107|      1|	starcos_ops.delete_file = NULL;
 2108|      1|	starcos_ops.set_security_env  = starcos_set_security_env;
 2109|      1|	starcos_ops.compute_signature = starcos_compute_signature;
 2110|      1|	starcos_ops.decipher = starcos_decipher;
 2111|      1|	starcos_ops.card_ctl    = starcos_card_ctl;
 2112|      1|	starcos_ops.logout      = starcos_logout;
 2113|      1|	starcos_ops.pin_cmd     = starcos_pin_cmd;
 2114|       |
 2115|      1|	return &starcos_drv;
 2116|      1|}

sc_get_tcos_driver:
  739|      1|{
  740|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  741|       |
  742|      1|	if (iso_ops == NULL) iso_ops = iso_drv->ops;
  ------------------
  |  Branch (742:6): [True: 1, False: 0]
  ------------------
  743|      1|	tcos_ops = *iso_drv->ops;
  744|       |
  745|      1|	tcos_ops.match_card           = tcos_match_card;
  746|      1|	tcos_ops.init                 = tcos_init;
  747|      1|	tcos_ops.finish               = tcos_finish;
  748|      1|	tcos_ops.create_file          = tcos_create_file;
  749|      1|	tcos_ops.set_security_env     = tcos_set_security_env;
  750|      1|	tcos_ops.select_file          = tcos_select_file;
  751|      1|	tcos_ops.list_files           = tcos_list_files;
  752|      1|	tcos_ops.delete_file          = tcos_delete_file;
  753|      1|	tcos_ops.compute_signature    = tcos_compute_signature;
  754|      1|	tcos_ops.decipher             = tcos_decipher;
  755|      1|	tcos_ops.restore_security_env = tcos_restore_security_env;
  756|      1|	tcos_ops.card_ctl             = tcos_card_ctl;
  757|       |
  758|      1|	return &tcos_drv;
  759|      1|}

sc_get_conf_block:
 1453|      1|{
 1454|      1|	int i;
 1455|      1|	scconf_block *conf_block = NULL;
 1456|       |
 1457|      2|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (1457:14): [True: 1, False: 1]
  ------------------
 1458|      1|		scconf_block **blocks;
 1459|       |
 1460|      1|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], name1, name2);
 1461|      1|		if (blocks != NULL) {
  ------------------
  |  Branch (1461:7): [True: 1, False: 0]
  ------------------
 1462|      1|			conf_block = blocks[0];
 1463|      1|			free(blocks);
 1464|      1|		}
 1465|      1|		if (conf_block != NULL && priority)
  ------------------
  |  Branch (1465:7): [True: 0, False: 1]
  |  Branch (1465:29): [True: 0, False: 0]
  ------------------
 1466|      0|			break;
 1467|      1|	}
 1468|      1|	return conf_block;
 1469|      1|}

sc_ctx_detect_readers:
  781|      1|{
  782|      1|	int r = 0;
  783|      1|	const struct sc_reader_driver *drv = ctx->reader_driver;
  784|       |
  785|      1|	sc_mutex_lock(ctx, ctx->mutex);
  786|       |
  787|      1|	if (drv->ops->detect_readers != NULL)
  ------------------
  |  Branch (787:6): [True: 0, False: 1]
  ------------------
  788|      0|		r = drv->ops->detect_readers(ctx);
  789|       |
  790|      1|	sc_mutex_unlock(ctx, ctx->mutex);
  791|       |
  792|      1|	return r;
  793|      1|}
sc_establish_context:
  816|      1|{
  817|      1|	sc_context_param_t ctx_param;
  818|       |
  819|      1|	memset(&ctx_param, 0, sizeof(sc_context_param_t));
  820|      1|	ctx_param.ver      = 0;
  821|      1|	ctx_param.app_name = app_name;
  822|      1|	return sc_context_create(ctx_out, &ctx_param);
  823|      1|}
sc_context_create:
  945|      1|{
  946|      1|	sc_context_t		*ctx;
  947|      1|	struct _sc_ctx_options	opts;
  948|      1|	int			r;
  949|      1|	char			*driver;
  950|       |
  951|      1|	if (ctx_out == NULL || parm == NULL)
  ------------------
  |  Branch (951:6): [True: 0, False: 1]
  |  Branch (951:25): [True: 0, False: 1]
  ------------------
  952|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  953|       |
  954|      1|	ctx = calloc(1, sizeof(sc_context_t));
  955|      1|	if (ctx == NULL)
  ------------------
  |  Branch (955:6): [True: 0, False: 1]
  ------------------
  956|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  957|      1|	memset(&opts, 0, sizeof(opts));
  958|       |
  959|       |	/* set the application name if set in the parameter options */
  960|      1|	if (parm->app_name != NULL)
  ------------------
  |  Branch (960:6): [True: 1, False: 0]
  ------------------
  961|      1|		ctx->app_name = strdup(parm->app_name);
  962|      0|	else
  963|      0|		ctx->app_name = strdup("default");
  964|      1|	if (ctx->app_name == NULL) {
  ------------------
  |  Branch (964:6): [True: 0, False: 1]
  ------------------
  965|      0|		sc_release_context(ctx);
  966|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  967|      0|	}
  968|       |
  969|      1|	ctx->exe_path = get_exe_path();
  970|      1|	if (ctx->exe_path == NULL) {
  ------------------
  |  Branch (970:6): [True: 0, False: 1]
  ------------------
  971|      0|		sc_release_context(ctx);
  972|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  973|      0|	}
  974|       |
  975|      1|	ctx->flags = parm->flags;
  976|      1|	set_defaults(ctx, &opts);
  977|       |
  978|      1|	if (0 != list_init(&ctx->readers)) {
  ------------------
  |  Branch (978:6): [True: 0, False: 1]
  ------------------
  979|      0|		del_drvs(&opts);
  980|      0|		sc_release_context(ctx);
  981|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  982|      0|	}
  983|      1|	list_attributes_seeker(&ctx->readers, reader_list_seeker);
  984|       |	/* set thread context and create mutex object (if specified) */
  985|      1|	if (parm->thread_ctx != NULL)
  ------------------
  |  Branch (985:6): [True: 0, False: 1]
  ------------------
  986|      0|		ctx->thread_ctx = parm->thread_ctx;
  987|      1|	r = sc_mutex_create(ctx, &ctx->mutex);
  988|      1|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (988:6): [True: 0, False: 1]
  ------------------
  989|      0|		del_drvs(&opts);
  990|      0|		sc_release_context(ctx);
  991|      0|		return r;
  992|      0|	}
  993|       |
  994|       |#if defined(ENABLE_OPENSSL) && defined(OPENSSL_SECURE_MALLOC_SIZE) && !defined(LIBRESSL_VERSION_NUMBER)
  995|       |	if (!CRYPTO_secure_malloc_initialized()) {
  996|       |		CRYPTO_secure_malloc_init(OPENSSL_SECURE_MALLOC_SIZE, OPENSSL_SECURE_MALLOC_SIZE/8);
  997|       |	}
  998|       |#endif
  999|       |
 1000|      1|	process_config_file(ctx, &opts);
 1001|       |
 1002|       |	/* overwrite with caller's parameters if explicitly given */
 1003|      1|	if (parm->debug) {
  ------------------
  |  Branch (1003:6): [True: 0, False: 1]
  ------------------
 1004|      0|		ctx->debug = parm->debug;
 1005|      0|	}
 1006|      1|	if (parm->debug_file) {
  ------------------
  |  Branch (1006:6): [True: 0, False: 1]
  ------------------
 1007|      0|		if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (1007:7): [True: 0, False: 0]
  |  Branch (1007:27): [True: 0, False: 0]
  |  Branch (1007:56): [True: 0, False: 0]
  ------------------
 1008|      0|			fclose(ctx->debug_file);
 1009|      0|		ctx->debug_file = parm->debug_file;
 1010|      0|	}
 1011|       |
 1012|      1|	sc_log(ctx, "==================================="); /* first thing in the log */
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1013|      1|	sc_log(ctx, "OpenSC version: %s", sc_get_version());
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1014|      1|	sc_log(ctx, "Configured for %s (%s)", ctx->app_name, ctx->exe_path);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1015|       |
 1016|       |#ifdef USE_OPENSSL3_LIBCTX
 1017|       |	r = sc_openssl3_init(ctx);
 1018|       |	if (r != SC_SUCCESS) {
 1019|       |		del_drvs(&opts);
 1020|       |		sc_release_context(ctx);
 1021|       |		return r;
 1022|       |	}
 1023|       |#endif
 1024|       |
 1025|       |#ifdef ENABLE_PCSC
 1026|       |	ctx->reader_driver = sc_get_pcsc_driver();
 1027|       |#elif defined(ENABLE_CRYPTOTOKENKIT)
 1028|       |	ctx->reader_driver = sc_get_cryptotokenkit_driver();
 1029|       |#elif defined(ENABLE_CTAPI)
 1030|       |	ctx->reader_driver = sc_get_ctapi_driver();
 1031|       |#elif defined(ENABLE_OPENCT)
 1032|       |	ctx->reader_driver = sc_get_openct_driver();
 1033|       |#endif
 1034|       |
 1035|      1|	r = ctx->reader_driver->ops->init(ctx);
 1036|      1|	if (r != SC_SUCCESS)   {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (1036:6): [True: 0, False: 1]
  ------------------
 1037|      0|		del_drvs(&opts);
 1038|      0|		sc_release_context(ctx);
 1039|      0|		return r;
 1040|      0|	}
 1041|       |
 1042|      1|	driver = getenv("OPENSC_DRIVER");
 1043|      1|	if (driver) {
  ------------------
  |  Branch (1043:6): [True: 0, False: 1]
  ------------------
 1044|      0|		scconf_list *list = NULL;
 1045|      0|		scconf_list_add(&list, driver);
 1046|      0|		set_drivers(&opts, list);
 1047|      0|		scconf_list_destroy(list);
 1048|      0|	}
 1049|       |
 1050|      1|	load_card_drivers(ctx, &opts);
 1051|      1|	load_card_atrs(ctx);
 1052|       |
 1053|      1|	del_drvs(&opts);
 1054|      1|	sc_ctx_detect_readers(ctx);
 1055|      1|	*ctx_out = ctx;
 1056|       |
 1057|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1058|      1|}
ctx.c:load_card_atrs:
  629|      1|{
  630|      1|	struct sc_card_driver *driver;
  631|      1|	scconf_block **blocks;
  632|      1|	int i, j, k;
  633|       |
  634|      2|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (634:14): [True: 1, False: 1]
  ------------------
  635|      1|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], "card_atr", NULL);
  636|      1|		if (!blocks)
  ------------------
  |  Branch (636:7): [True: 0, False: 1]
  ------------------
  637|      0|			continue;
  638|      1|		for (j = 0; blocks[j] != NULL; j++) {
  ------------------
  |  Branch (638:15): [True: 0, False: 1]
  ------------------
  639|      0|			scconf_block *b = blocks[j];
  640|      0|			char *atr = b->name->data;
  641|      0|			const scconf_list *list;
  642|      0|			struct sc_atr_table t;
  643|      0|			const char *dname;
  644|       |
  645|      0|			driver = NULL;
  646|       |
  647|      0|			if (strlen(atr) < 4)
  ------------------
  |  Branch (647:8): [True: 0, False: 0]
  ------------------
  648|      0|				continue;
  649|       |
  650|       |			/* The interesting part. If there's no card
  651|       |			 * driver assigned for the ATR, add it to
  652|       |			 * the default driver. This will reduce the
  653|       |			 * amount of code required to process things
  654|       |			 * related to card_atr blocks in situations,
  655|       |			 * where the code is not exactly related to
  656|       |			 * card driver settings, but for example
  657|       |			 * forcing a protocol at the reader driver.
  658|       |			 */
  659|      0|			dname = scconf_get_str(b, "driver", "default");
  660|       |
  661|       |			/* Find the card driver structure according to dname */
  662|      0|			for (k = 0; ctx->card_drivers[k] != NULL; k++) {
  ------------------
  |  Branch (662:16): [True: 0, False: 0]
  ------------------
  663|      0|				driver = ctx->card_drivers[k];
  664|      0|				if (!strcmp(dname, driver->short_name))
  ------------------
  |  Branch (664:9): [True: 0, False: 0]
  ------------------
  665|      0|					break;
  666|      0|				driver = NULL;
  667|      0|			}
  668|       |
  669|      0|			if (!driver)
  ------------------
  |  Branch (669:8): [True: 0, False: 0]
  ------------------
  670|      0|				continue;
  671|       |
  672|      0|			memset(&t, 0, sizeof(struct sc_atr_table));
  673|      0|			t.atr = atr;
  674|      0|			t.atrmask = (char *) scconf_get_str(b, "atrmask", NULL);
  675|      0|			t.name = (char *) scconf_get_str(b, "name", NULL);
  676|      0|			t.type = scconf_get_int(b, "type", SC_CARD_TYPE_UNKNOWN);
  677|      0|			list = scconf_find_list(b, "flags");
  678|      0|			while (list != NULL) {
  ------------------
  |  Branch (678:11): [True: 0, False: 0]
  ------------------
  679|      0|				unsigned int flags = 0;
  680|       |
  681|      0|				if (!list->data) {
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  ------------------
  682|      0|					list = list->next;
  683|      0|					continue;
  684|      0|				}
  685|       |
  686|      0|				if (!strcmp(list->data, "rng"))
  ------------------
  |  Branch (686:9): [True: 0, False: 0]
  ------------------
  687|      0|					flags = SC_CARD_FLAG_RNG;
  ------------------
  |  |  543|      0|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  688|      0|				else if (!strcmp(list->data, "keep_alive"))
  ------------------
  |  Branch (688:14): [True: 0, False: 0]
  ------------------
  689|      0|					flags = SC_CARD_FLAG_KEEP_ALIVE;
  ------------------
  |  |  544|      0|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  690|      0|				else if (sscanf(list->data, "%x", &flags) != 1)
  ------------------
  |  Branch (690:14): [True: 0, False: 0]
  ------------------
  691|      0|					flags = 0;
  692|       |
  693|      0|				t.flags |= flags;
  694|      0|				list = list->next;
  695|      0|			}
  696|      0|			t.card_atr = b;
  697|      0|			_sc_add_atr(ctx, driver, &t);
  698|      0|		}
  699|      1|		free(blocks);
  700|      1|	}
  701|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  702|      1|}
ctx.c:get_exe_path:
  910|      1|{
  911|       |	/* Find the executable's path which runs this code.
  912|       |	 * See https://github.com/gpakosz/whereami/ for
  913|       |	 * potentially more platforms */
  914|      1|	char exe_path[PATH_MAX] = "unknown executable path";
  915|      1|	int path_found = 0;
  916|       |
  917|       |#if   defined(_WIN32)
  918|       |	if (0 < GetModuleFileNameA(NULL, exe_path, sizeof exe_path))
  919|       |		path_found = 1;
  920|       |#elif defined(__APPLE__)
  921|       |	if (0 < proc_pidpath(getpid(), exe_path, sizeof exe_path))
  922|       |		path_found = 1;
  923|       |#elif defined(__linux__) || defined(__CYGWIN__)
  924|      1|	if (NULL != realpath("/proc/self/exe", exe_path))
  ------------------
  |  Branch (924:6): [True: 1, False: 0]
  ------------------
  925|      1|		path_found = 1;
  926|      1|#endif
  927|       |
  928|       |#if defined(HAVE_GETPROGNAME)
  929|       |	if (!path_found) {
  930|       |		/* getprogname is unreliable and typically only returns the basename.
  931|       |		 * However, this should be enough for our purposes */
  932|       |		const char *prog = getprogname();
  933|       |		if (prog)
  934|       |			strlcpy(exe_path, prog, sizeof exe_path);
  935|       |	}
  936|       |#else
  937|       |	/* avoid warning "set but not used" */
  938|      1|	(void) path_found;
  939|      1|#endif
  940|       |
  941|      1|	return strdup(exe_path);
  942|      1|}
ctx.c:set_defaults:
  321|      1|{
  322|      1|	ctx->debug = 0;
  323|      1|	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (323:6): [True: 0, False: 1]
  |  Branch (323:26): [True: 0, False: 0]
  |  Branch (323:55): [True: 0, False: 0]
  ------------------
  324|      0|		fclose(ctx->debug_file);
  325|      1|	ctx->debug_file = stderr;
  326|      1|	ctx->flags = 0;
  327|       |	ctx->forced_driver = NULL;
  328|      1|	add_internal_drvs(opts);
  329|      1|}
ctx.c:add_internal_drvs:
  295|      2|{
  296|      2|	const struct _sc_driver_entry *lst;
  297|      2|	int i;
  298|       |
  299|      2|	lst = internal_card_drivers;
  300|      2|	i = 0;
  301|     80|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (301:9): [True: 78, False: 2]
  ------------------
  302|     78|		add_drv(opts, lst[i].name);
  303|     78|		i++;
  304|     78|	}
  305|      2|}
ctx.c:add_drv:
  277|     83|{
  278|     83|	struct _sc_driver_entry *lst;
  279|     83|	int *cp, max, i;
  280|       |
  281|     83|	lst = opts->cdrv;
  282|     83|	cp = &opts->ccount;
  283|     83|	max = SC_MAX_CARD_DRIVERS;
  ------------------
  |  |   31|     83|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  284|     83|	if (*cp == max) /* No space for more drivers... */
  ------------------
  |  Branch (284:6): [True: 0, False: 83]
  ------------------
  285|      0|		return;
  286|  1.77k|	for (i = 0; i < *cp; i++)
  ------------------
  |  Branch (286:14): [True: 1.68k, False: 83]
  ------------------
  287|  1.68k|		if (strcmp(name, lst[i].name) == 0)
  ------------------
  |  Branch (287:7): [True: 0, False: 1.68k]
  ------------------
  288|      0|			return;
  289|     83|	lst[*cp].name = strdup(name);
  290|       |
  291|     83|	*cp = *cp + 1;
  292|     83|}
ctx.c:del_drvs:
  263|      2|{
  264|      2|	struct _sc_driver_entry *lst;
  265|      2|	int *cp, i;
  266|       |
  267|      2|	lst = opts->cdrv;
  268|      2|	cp = &opts->ccount;
  269|       |
  270|     85|	for (i = 0; i < *cp; i++) {
  ------------------
  |  Branch (270:14): [True: 83, False: 2]
  ------------------
  271|     83|		free((void *)lst[i].name);
  272|     83|	}
  273|      2|	*cp = 0;
  274|      2|}
ctx.c:process_config_file:
  705|      1|{
  706|      1|	int i, r, count = 0;
  707|      1|	scconf_block **blocks;
  708|      1|	const char *conf_path = NULL;
  709|      1|	const char *debug = NULL;
  710|       |#ifdef _WIN32
  711|       |	char temp_path[PATH_MAX];
  712|       |	size_t temp_len;
  713|       |#endif
  714|       |
  715|       |	/* Takes effect even when no config around */
  716|      1|	debug = getenv("OPENSC_DEBUG");
  717|      1|	if (debug)
  ------------------
  |  Branch (717:6): [True: 0, False: 1]
  ------------------
  718|      0|		ctx->debug = atoi(debug);
  719|       |
  720|      1|	memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks));
  721|       |#ifdef _WIN32
  722|       |	temp_len = PATH_MAX-1;
  723|       |	r = sc_ctx_win32_get_config_value("OPENSC_CONF", "ConfigFile", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
  724|       |			temp_path, &temp_len);
  725|       |	if (r)   {
  726|       |		sc_log(ctx, "process_config_file doesn't find opensc config file. Please set the registry key.");
  727|       |		return;
  728|       |	}
  729|       |	temp_path[temp_len] = '\0';
  730|       |	conf_path = temp_path;
  731|       |#else
  732|      1|	conf_path = getenv("OPENSC_CONF");
  733|      1|	if (!conf_path)
  ------------------
  |  Branch (733:6): [True: 1, False: 0]
  ------------------
  734|      1|		conf_path = OPENSC_CONF_PATH;
  735|      1|#endif
  736|      1|	ctx->conf = scconf_new(conf_path);
  737|      1|	if (ctx->conf == NULL)
  ------------------
  |  Branch (737:6): [True: 0, False: 1]
  ------------------
  738|      0|		return;
  739|      1|	r = scconf_parse(ctx->conf);
  740|      1|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  741|      1|#ifdef OPENSC_CONFIG_STRING
  742|       |	/* Parse the string if config file didn't exist */
  743|      1|	if (r < 0)
  ------------------
  |  Branch (743:6): [True: 1, False: 0]
  ------------------
  744|      1|		r = scconf_parse_string(ctx->conf, OPENSC_CONFIG_STRING);
  ------------------
  |  |  740|      1|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  ------------------
  745|      1|#endif
  746|      1|	if (r < 1) {
  ------------------
  |  Branch (746:6): [True: 0, False: 1]
  ------------------
  747|       |		/* A negative return value means the config file isn't
  748|       |		 * there, which is not an error. Nevertheless log this
  749|       |		 * fact. */
  750|      0|		if (r < 0)
  ------------------
  |  Branch (750:7): [True: 0, False: 0]
  ------------------
  751|      0|			sc_log(ctx, "scconf_parse failed: %s", ctx->conf->errmsg);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  752|      0|		else
  753|      0|			sc_log(ctx, "scconf_parse failed: %s", ctx->conf->errmsg);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  754|      0|		scconf_free(ctx->conf);
  755|      0|		ctx->conf = NULL;
  756|      0|		return;
  757|      0|	}
  758|       |	/* needs to be after the log file is known */
  759|      1|	sc_log(ctx, "Used configuration file '%s'", conf_path);
  ------------------
  |  |   71|      1|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  760|      1|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->exe_path);
  761|      1|	if (blocks && blocks[0])
  ------------------
  |  Branch (761:6): [True: 1, False: 0]
  |  Branch (761:16): [True: 0, False: 1]
  ------------------
  762|      0|		ctx->conf_blocks[count++] = blocks[0];
  763|      1|	free(blocks);
  764|      1|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->app_name);
  765|      1|	if (blocks && blocks[0])
  ------------------
  |  Branch (765:6): [True: 1, False: 0]
  |  Branch (765:16): [True: 0, False: 1]
  ------------------
  766|      0|		ctx->conf_blocks[count++] = blocks[0];
  767|      1|	free(blocks);
  768|      1|	if (strcmp(ctx->app_name, "default") != 0) {
  ------------------
  |  Branch (768:6): [True: 1, False: 0]
  ------------------
  769|      1|		blocks = scconf_find_blocks(ctx->conf, NULL, "app", "default");
  770|      1|		if (blocks && blocks[0])
  ------------------
  |  Branch (770:7): [True: 1, False: 0]
  |  Branch (770:17): [True: 1, False: 0]
  ------------------
  771|      1|			ctx->conf_blocks[count] = blocks[0];
  772|      1|		free(blocks);
  773|      1|	}
  774|       |	/* Above we add 3 blocks at most, but conf_blocks has 4 elements,
  775|       |	 * so at least one is NULL */
  776|      2|	for (i = 0; ctx->conf_blocks[i]; i++)
  ------------------
  |  Branch (776:14): [True: 1, False: 1]
  ------------------
  777|      1|		load_parameters(ctx, ctx->conf_blocks[i], opts);
  778|      1|}
ctx.c:load_parameters:
  384|      1|{
  385|      1|	int err = 0;
  386|      1|	const scconf_list *list;
  387|      1|	const char *val;
  388|      1|	int debug;
  389|      1|	const char *disable_hw_pkcs1_padding;
  390|       |#ifdef _WIN32
  391|       |	char expanded_val[PATH_MAX];
  392|       |	DWORD expanded_len;
  393|       |#endif
  394|       |
  395|      1|	debug = scconf_get_int(block, "debug", ctx->debug);
  396|      1|	if (debug > ctx->debug)
  ------------------
  |  Branch (396:6): [True: 0, False: 1]
  ------------------
  397|      0|		ctx->debug = debug;
  398|       |
  399|      1|	val = scconf_get_str(block, "debug_file", NULL);
  400|      1|	if (val)   {
  ------------------
  |  Branch (400:6): [True: 0, False: 1]
  ------------------
  401|       |#ifdef _WIN32
  402|       |		expanded_len = PATH_MAX;
  403|       |		expanded_len = ExpandEnvironmentStringsA(val, expanded_val, expanded_len);
  404|       |		if (0 < expanded_len && expanded_len < sizeof expanded_val)
  405|       |			val = expanded_val;
  406|       |#endif
  407|      0|		sc_ctx_log_to_file(ctx, val);
  408|      0|	}
  409|      1|	else if (ctx->debug)   {
  ------------------
  |  Branch (409:11): [True: 0, False: 1]
  ------------------
  410|      0|		sc_ctx_log_to_file(ctx, NULL);
  411|      0|	}
  412|       |
  413|      1|	if (scconf_get_bool (block, "disable_popups",
  ------------------
  |  Branch (413:6): [True: 0, False: 1]
  ------------------
  414|      1|				ctx->flags & SC_CTX_FLAG_DISABLE_POPUPS))
  ------------------
  |  |  869|      1|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  415|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_POPUPS;
  ------------------
  |  |  869|      0|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  416|       |
  417|      1|	if (scconf_get_bool (block, "disable_colors",
  ------------------
  |  Branch (417:6): [True: 0, False: 1]
  ------------------
  418|      1|				ctx->flags & SC_CTX_FLAG_DISABLE_COLORS))
  ------------------
  |  |  870|      1|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  419|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_COLORS;
  ------------------
  |  |  870|      0|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  420|       |
  421|      1|	if (scconf_get_bool (block, "enable_default_driver",
  ------------------
  |  Branch (421:6): [True: 0, False: 1]
  ------------------
  422|      1|				ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER))
  ------------------
  |  |  868|      1|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  423|      0|		ctx->flags |= SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER;
  ------------------
  |  |  868|      0|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  424|       |
  425|      1|	list = scconf_find_list(block, "card_drivers");
  426|      1|	set_drivers(opts, list);
  427|       |
  428|       |	/* Disable PKCS#1 v1.5 type 2 (for decryption) depadding on card by default */
  429|      1|	disable_hw_pkcs1_padding = "decipher";
  430|      1|	ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  431|      1|	disable_hw_pkcs1_padding = scconf_get_str(block, "disable_hw_pkcs1_padding", disable_hw_pkcs1_padding);
  432|      1|	if (0 == strcmp(disable_hw_pkcs1_padding, "no")) {
  ------------------
  |  Branch (432:6): [True: 0, False: 1]
  ------------------
  433|      0|		ctx->disable_hw_pkcs1_padding = 0;
  434|      1|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "sign")) {
  ------------------
  |  Branch (434:13): [True: 0, False: 1]
  ------------------
  435|      0|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01;
  ------------------
  |  |  118|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  436|      1|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "decipher")) {
  ------------------
  |  Branch (436:13): [True: 1, False: 0]
  ------------------
  437|      1|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  438|      1|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "both")) {
  ------------------
  |  Branch (438:13): [True: 0, False: 0]
  ------------------
  439|      0|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  118|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  440|      0|	}
  441|       |
  442|       |#ifdef USE_OPENSSL3_LIBCTX
  443|       |	val = scconf_get_str(block, "openssl_config", NULL);
  444|       |	if (val != NULL) {
  445|       |		ctx->openssl_config = strdup(val);
  446|       |	}
  447|       |#endif
  448|       |
  449|      1|	return err;
  450|      1|}
ctx.c:set_drivers:
  367|      1|{
  368|      1|	const char *s_internal = "internal", *s_old = "old";
  369|      1|	if (list != NULL)
  ------------------
  |  Branch (369:6): [True: 1, False: 0]
  ------------------
  370|      1|		del_drvs(opts);
  371|      3|	while (list != NULL) {
  ------------------
  |  Branch (371:9): [True: 2, False: 1]
  ------------------
  372|      2|		if (strcmp(list->data, s_internal) == 0)
  ------------------
  |  Branch (372:7): [True: 1, False: 1]
  ------------------
  373|      1|			add_internal_drvs(opts);
  374|      1|		else if (strcmp(list->data, s_old) == 0)
  ------------------
  |  Branch (374:12): [True: 1, False: 0]
  ------------------
  375|      1|			add_old_drvs(opts);
  376|      0|		else
  377|      0|			add_drv(opts, list->data);
  378|      2|		list = list->next;
  379|      2|	}
  380|      1|}
ctx.c:add_old_drvs:
  308|      1|{
  309|      1|	const struct _sc_driver_entry *lst;
  310|      1|	int i;
  311|       |
  312|      1|	lst = old_card_drivers;
  313|      1|	i = 0;
  314|      6|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (314:9): [True: 5, False: 1]
  ------------------
  315|      5|		add_drv(opts, lst[i].name);
  316|      5|		i++;
  317|      5|	}
  318|      1|}
ctx.c:load_card_drivers:
  563|      1|{
  564|      1|	const struct _sc_driver_entry *ent;
  565|      1|	int drv_count;
  566|      1|	int i;
  567|       |
  568|      1|	for (drv_count = 0; ctx->card_drivers[drv_count] != NULL; drv_count++)
  ------------------
  |  Branch (568:22): [True: 0, False: 1]
  ------------------
  569|      0|		;
  570|       |
  571|     45|	for (i = 0; i < opts->ccount; i++) {
  ------------------
  |  Branch (571:14): [True: 44, False: 1]
  ------------------
  572|     44|		struct sc_card_driver *(*func)(void) = NULL;
  573|     44|		struct sc_card_driver *(**tfunc)(void) = &func;
  574|     44|		void *dll = NULL;
  575|     44|		int  j;
  576|       |
  577|     44|		if (drv_count >= SC_MAX_CARD_DRIVERS - 1)   {
  ------------------
  |  |   31|     44|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  |  Branch (577:7): [True: 0, False: 44]
  ------------------
  578|      0|			sc_log(ctx, "Not more then %i card drivers allowed.", SC_MAX_CARD_DRIVERS);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  578|      0|			sc_log(ctx, "Not more then %i card drivers allowed.", SC_MAX_CARD_DRIVERS);
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|      0|#define SC_MAX_CARD_DRIVERS		48
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|      0|			break;
  580|      0|		}
  581|       |
  582|     44|		ent = &opts->cdrv[i];
  583|    980|		for (j = 0; internal_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (583:15): [True: 975, False: 5]
  ------------------
  584|    975|			if (strcmp(ent->name, internal_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (584:8): [True: 39, False: 936]
  ------------------
  585|     39|				func = (struct sc_card_driver *(*)(void)) internal_card_drivers[j].func;
  586|     39|				break;
  587|     39|			}
  588|    975|		}
  589|     44|		if (func == NULL) {
  ------------------
  |  Branch (589:7): [True: 5, False: 39]
  ------------------
  590|     15|			for (j = 0; old_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (590:16): [True: 15, False: 0]
  ------------------
  591|     15|				if (strcmp(ent->name, old_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (591:9): [True: 5, False: 10]
  ------------------
  592|      5|					func = (struct sc_card_driver *(*)(void)) old_card_drivers[j].func;
  593|      5|					break;
  594|      5|				}
  595|     15|			}
  596|      5|		}
  597|       |		/* if not initialized assume external module */
  598|     44|		if (func == NULL)
  ------------------
  |  Branch (598:7): [True: 0, False: 44]
  ------------------
  599|      0|			*(void **)(tfunc) = load_dynamic_driver(ctx, &dll, ent->name);
  600|       |		/* if still null, assume driver not found */
  601|     44|		if (func == NULL) {
  ------------------
  |  Branch (601:7): [True: 0, False: 44]
  ------------------
  602|      0|			sc_log(ctx, "Unable to load '%s'.", ent->name);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  603|      0|			if (dll)
  ------------------
  |  Branch (603:8): [True: 0, False: 0]
  ------------------
  604|      0|				sc_dlclose(dll);
  605|      0|			continue;
  606|      0|		}
  607|       |
  608|     44|		ctx->card_drivers[drv_count] = func();
  609|     44|		if (ctx->card_drivers[drv_count] == NULL) {
  ------------------
  |  Branch (609:7): [True: 0, False: 44]
  ------------------
  610|      0|			sc_log(ctx, "Driver '%s' not available.", ent->name);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  611|      0|			continue;
  612|      0|		}
  613|       |
  614|     44|		ctx->card_drivers[drv_count]->dll = dll;
  615|     44|		ctx->card_drivers[drv_count]->atr_map = NULL;
  616|     44|		ctx->card_drivers[drv_count]->natrs = 0;
  617|       |
  618|     44|		load_card_driver_options(ctx, ctx->card_drivers[drv_count]);
  619|       |
  620|       |		/* Ensure that the list is always terminated by NULL */
  621|     44|		ctx->card_drivers[drv_count + 1] = NULL;
  622|       |
  623|     44|		drv_count++;
  624|     44|	}
  625|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  626|      1|}
ctx.c:load_card_driver_options:
  542|     44|{
  543|     44|	scconf_block **blocks, *blk;
  544|     44|	int i;
  545|       |
  546|     88|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (546:14): [True: 44, False: 44]
  ------------------
  547|     44|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  548|     44|				"card_driver", driver->short_name);
  549|     44|		if (!blocks)
  ------------------
  |  Branch (549:7): [True: 0, False: 44]
  ------------------
  550|      0|			continue;
  551|     44|		blk = blocks[0];
  552|     44|		free(blocks);
  553|       |
  554|     44|		if (blk == NULL)
  ------------------
  |  Branch (554:7): [True: 44, False: 0]
  ------------------
  555|     44|			continue;
  556|       |
  557|       |		/* no options at the moment */
  558|     44|	}
  559|     44|	return SC_SUCCESS;
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  560|     44|}

sc_strerror:
   32|  2.21k|{
   33|  2.21k|	unsigned int error_index = 0;
   34|  2.21k|	const char *rdr_errors[] = {
   35|  2.21k|		"Generic reader error",
   36|  2.21k|		"No readers found",
   37|  2.21k|		"UNUSED",
   38|  2.21k|		"UNUSED",
   39|  2.21k|		"Card not present",
   40|  2.21k|		"Card removed",
   41|  2.21k|		"Card reset",
   42|  2.21k|		"Transmit failed",
   43|  2.21k|		"Timed out while waiting for user input",
   44|  2.21k|		"Input operation cancelled by user",
   45|  2.21k|		"The two PINs did not match",
   46|  2.21k|		"Message too long (keypad)",
   47|  2.21k|		"Timeout while waiting for event from card reader",
   48|  2.21k|		"Unresponsive card (correctly inserted?)",
   49|  2.21k|		"Reader detached",
   50|  2.21k|		"Reader reattached",
   51|  2.21k|		"Reader in use by another application"
   52|  2.21k|	};
   53|  2.21k|	const unsigned int rdr_base = -SC_ERROR_READER;
  ------------------
  |  |   31|  2.21k|#define SC_ERROR_READER				-1100
  ------------------
   54|       |
   55|  2.21k|	const char *card_errors[] = {
   56|  2.21k|		"Card command failed",
   57|  2.21k|		"File not found",
   58|  2.21k|		"Record not found",
   59|  2.21k|		"Unsupported CLA byte in APDU",
   60|  2.21k|		"Unsupported INS byte in APDU",
   61|  2.21k|		"Incorrect parameters in APDU",
   62|  2.21k|		"Wrong length",
   63|  2.21k|		"Card memory failure",
   64|  2.21k|		"Card does not support the requested operation",
   65|  2.21k|		"Not allowed",
   66|  2.21k|		"Card is invalid or cannot be handled",
   67|  2.21k|		"Security status not satisfied",
   68|  2.21k|		"Authentication method blocked",
   69|  2.21k|		"Unknown data received from card",
   70|  2.21k|		"PIN code or key incorrect",
   71|  2.21k|		"File already exists",
   72|  2.21k|		"Data object not found",
   73|  2.21k|		"Not enough memory on card",
   74|  2.21k|		"Part of returned data may be corrupted",
   75|  2.21k|		"End of file/record reached before reading Le bytes",
   76|  2.21k|		"Reference data not usable"
   77|  2.21k|	};
   78|  2.21k|	const unsigned int card_base = -SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  2.21k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
   79|       |
   80|  2.21k|	const char *arg_errors[] = {
   81|  2.21k|		"Invalid arguments",
   82|  2.21k|		"UNUSED",
   83|  2.21k|		"UNUSED",
   84|  2.21k|		"Buffer too small",
   85|  2.21k|		"Invalid PIN length",
   86|  2.21k|		"Invalid data",
   87|  2.21k|	};
   88|  2.21k|	const unsigned int arg_base = -SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  2.21k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   89|       |
   90|  2.21k|	const char *int_errors[] = {
   91|  2.21k|		"Internal error",
   92|  2.21k|		"Invalid ASN.1 object",
   93|  2.21k|		"Required ASN.1 object not found",
   94|  2.21k|		"Premature end of ASN.1 stream",
   95|  2.21k|		"Out of memory",
   96|  2.21k|		"Too many objects",
   97|  2.21k|		"Object not valid",
   98|  2.21k|		"Requested object not found",
   99|  2.21k|		"Not supported",
  100|  2.21k|		"Passphrase required",
  101|  2.21k|		"Inconsistent configuration",
  102|  2.21k|		"Decryption failed",
  103|  2.21k|		"Wrong padding",
  104|  2.21k|		"Unsupported card",
  105|  2.21k|		"Unable to load external module",
  106|  2.21k|		"EF offset too large",
  107|  2.21k|		"Not implemented",
  108|  2.21k|		"Invalid Simple TLV object",
  109|  2.21k|		"Premature end of Simple TLV stream",
  110|  2.21k|	};
  111|  2.21k|	const unsigned int int_base = -SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  2.21k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  112|       |
  113|  2.21k|	const char *p15i_errors[] = {
  114|  2.21k|		"Generic PKCS#15 initialization error",
  115|  2.21k|		"Syntax error",
  116|  2.21k|		"Inconsistent or incomplete PKCS#15 profile",
  117|  2.21k|		"Key length/algorithm not supported by card",
  118|  2.21k|		"No default (transport) key available",
  119|  2.21k|		"Non unique object ID",
  120|  2.21k|		"Unable to load key and certificate(s) from file",
  121|  2.21k|		"UNUSED",
  122|  2.21k|		"File template not found",
  123|  2.21k|		"Invalid PIN reference",
  124|  2.21k|		"File too small",
  125|  2.21k|	};
  126|  2.21k|	const unsigned int p15i_base = -SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|  2.21k|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
  127|       |
  128|  2.21k|	const char *sm_errors[] = {
  129|  2.21k|		"Generic Secure Messaging error",
  130|  2.21k|		"Data enciphering error",
  131|  2.21k|		"Invalid secure messaging level",
  132|  2.21k|		"No session keys",
  133|  2.21k|		"Invalid session keys",
  134|  2.21k|		"Secure Messaging not initialized",
  135|  2.21k|		"Cannot authenticate card",
  136|  2.21k|		"Random generation error",
  137|  2.21k|		"Secure messaging keyset not found",
  138|  2.21k|		"IFD data missing",
  139|  2.21k|		"SM not applied",
  140|  2.21k|		"SM session already active",
  141|  2.21k|		"Invalid checksum"
  142|  2.21k|	};
  143|  2.21k|	const unsigned int sm_base = -SC_ERROR_SM;
  ------------------
  |  |  115|  2.21k|#define SC_ERROR_SM				-1600
  ------------------
  144|       |
  145|  2.21k|	const char *misc_errors[] = {
  146|  2.21k|		"Unknown error",
  147|  2.21k|		"PKCS#15 compatible smart card not found",
  148|  2.21k|	};
  149|  2.21k|	const unsigned int misc_base = -SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|  2.21k|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  150|       |
  151|  2.21k|	const char *no_errors = "Success";
  152|  2.21k|	const char **errors = NULL;
  153|  2.21k|	unsigned int count = 0, err_base = 0;
  154|       |
  155|  2.21k|	if (!error)
  ------------------
  |  Branch (155:6): [True: 1.02k, False: 1.18k]
  ------------------
  156|  1.02k|		return no_errors;
  157|  1.18k|	error_index = error < 0 ? (unsigned)(-(long long int)error) : (unsigned)error;
  ------------------
  |  Branch (157:16): [True: 1.18k, False: 0]
  ------------------
  158|       |
  159|  1.18k|	if (error_index >= misc_base) {
  ------------------
  |  Branch (159:6): [True: 0, False: 1.18k]
  ------------------
  160|      0|		errors = misc_errors;
  161|      0|		count = DIM(misc_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  162|      0|		err_base = misc_base;
  163|  1.18k|	} else if (error_index >= sm_base) {
  ------------------
  |  Branch (163:13): [True: 0, False: 1.18k]
  ------------------
  164|      0|		errors = sm_errors;
  165|      0|		count = DIM(sm_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  166|      0|		err_base = sm_base;
  167|  1.18k|	} else if (error_index >= p15i_base) {
  ------------------
  |  Branch (167:13): [True: 0, False: 1.18k]
  ------------------
  168|      0|		errors = p15i_errors;
  169|      0|		count = DIM(p15i_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  170|      0|		err_base = p15i_base;
  171|  1.18k|	} else if (error_index >= int_base) {
  ------------------
  |  Branch (171:13): [True: 1.18k, False: 0]
  ------------------
  172|  1.18k|		errors = int_errors;
  173|  1.18k|		count = DIM(int_errors);
  ------------------
  |  |   29|  1.18k|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  174|  1.18k|		err_base = int_base;
  175|  1.18k|	} else if (error_index >= arg_base) {
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  ------------------
  176|      0|		errors = arg_errors;
  177|      0|		count = DIM(arg_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  178|      0|		err_base = arg_base;
  179|      0|	} else if (error_index >= card_base) {
  ------------------
  |  Branch (179:13): [True: 0, False: 0]
  ------------------
  180|      0|		errors = card_errors;
  181|      0|		count = DIM(card_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  182|      0|		err_base = card_base;
  183|      0|	} else if (error_index >= rdr_base) {
  ------------------
  |  Branch (183:13): [True: 0, False: 0]
  ------------------
  184|      0|		errors = rdr_errors;
  185|      0|		count = DIM(rdr_errors);
  ------------------
  |  |   29|      0|#define DIM(v)		(sizeof(v)/(sizeof((v)[0])))
  ------------------
  186|      0|		err_base = rdr_base;
  187|      0|	}
  188|  1.18k|	error_index -= err_base;
  189|  1.18k|	if (error_index >= count)
  ------------------
  |  Branch (189:6): [True: 0, False: 1.18k]
  ------------------
  190|      0|		return misc_errors[0];
  191|  1.18k|	return errors[error_index];
  192|  1.18k|}

sc_get_iso7816_driver:
 1497|     43|{
 1498|     43|	return &iso_driver;
 1499|     43|}

sc_do_log:
   58|  9.73k|{
   59|  9.73k|	va_list ap;
   60|       |
   61|  9.73k|	va_start(ap, format);
   62|  9.73k|	sc_do_log_va(ctx, level, file, line, func, 0, format, ap);
   63|       |	va_end(ap);
   64|  9.73k|}
sc_do_log_color:
   67|  2.11k|{
   68|  2.11k|	va_list ap;
   69|       |
   70|  2.11k|	va_start(ap, format);
   71|  2.11k|	sc_do_log_va(ctx, level, file, line, func, color, format, ap);
   72|       |	va_end(ap);
   73|  2.11k|}
sc_dump_hex:
  405|    961|{
  406|    961|	static char dump_buf[0x1000];
  407|    961|	size_t ii, size = sizeof(dump_buf) - 0x10;
  408|    961|	size_t offs = 0;
  409|       |
  410|    961|	memset(dump_buf, 0, sizeof(dump_buf));
  411|    961|	if (in == NULL)
  ------------------
  |  Branch (411:6): [True: 0, False: 961]
  ------------------
  412|      0|		return dump_buf;
  413|       |
  414|   360k|	for (ii=0; ii<count; ii++) {
  ------------------
  |  Branch (414:13): [True: 359k, False: 805]
  ------------------
  415|   359k|		if (ii && !(ii%16))   {
  ------------------
  |  Branch (415:7): [True: 358k, False: 784]
  |  Branch (415:13): [True: 21.9k, False: 336k]
  ------------------
  416|  21.9k|			if (!(ii%48))
  ------------------
  |  Branch (416:8): [True: 7.27k, False: 14.6k]
  ------------------
  417|  7.27k|				snprintf(dump_buf + offs, size - offs, "\n");
  418|  14.6k|			else
  419|  14.6k|				snprintf(dump_buf + offs, size - offs, " ");
  420|  21.9k|			offs = strlen(dump_buf);
  421|  21.9k|		}
  422|       |
  423|   359k|		snprintf(dump_buf + offs, size - offs, "%02X", *(in + ii));
  424|   359k|		offs += 2;
  425|       |
  426|   359k|		if (offs > size)
  ------------------
  |  Branch (426:7): [True: 156, False: 359k]
  ------------------
  427|    156|			break;
  428|   359k|	}
  429|       |
  430|    961|	if (ii<count)
  ------------------
  |  Branch (430:6): [True: 156, False: 805]
  ------------------
  431|    156|		snprintf(dump_buf + offs, sizeof(dump_buf) - offs, "....\n");
  432|       |
  433|    961|	return dump_buf;
  434|    961|}
log.c:sc_do_log_va:
  124|  11.8k|{
  125|       |#ifdef _WIN32
  126|       |	SYSTEMTIME st;
  127|       |#else
  128|  11.8k|	struct tm *tm;
  129|  11.8k|	struct timeval tv;
  130|  11.8k|	char time_string[40];
  131|  11.8k|#endif
  132|       |
  133|  11.8k|	if (!ctx || ctx->debug < level)
  ------------------
  |  Branch (133:6): [True: 0, False: 11.8k]
  |  Branch (133:14): [True: 11.8k, False: 0]
  ------------------
  134|  11.8k|		return;
  135|       |
  136|       |#ifdef _WIN32
  137|       |	/* In Windows, file handles can not be shared between DLL-s, each DLL has a
  138|       |	 * separate file handle table. Make sure we always have a valid file
  139|       |	 * descriptor. */
  140|       |	if (sc_ctx_log_to_file(ctx, ctx->debug_filename) < 0)
  141|       |		return;
  142|       |#endif
  143|      0|	if (ctx->debug_file == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 0]
  ------------------
  144|      0|		return;
  145|       |
  146|       |#ifdef _WIN32
  147|       |	GetLocalTime(&st);
  148|       |	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  149|       |			ctx, ctx->debug_file,
  150|       |			"P:%lu; T:%lu",
  151|       |			(unsigned long)GetCurrentProcessId(),
  152|       |			(unsigned long)GetCurrentThreadId());
  153|       |	sc_color_fprintf(SC_COLOR_FG_GREEN,
  154|       |			ctx, ctx->debug_file,
  155|       |			" %i-%02i-%02i %02i:%02i:%02i.%03i",
  156|       |			st.wYear, st.wMonth, st.wDay,
  157|       |			st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
  158|       |#else
  159|      0|	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  ------------------
  |  |   45|      0|#define SC_COLOR_FG_GREEN		0x0002
  ------------------
              	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  ------------------
  |  |   56|      0|#define SC_COLOR_BOLD			0x8080
  ------------------
  160|      0|			ctx, ctx->debug_file,
  161|      0|			"P:%lu; T:0x%lu",
  162|      0|			(unsigned long)getpid(),
  163|      0|			(unsigned long)pthread_self());
  164|      0|	gettimeofday (&tv, NULL);
  165|      0|	tm = localtime (&tv.tv_sec);
  166|      0|	strftime (time_string, sizeof(time_string), "%H:%M:%S", tm);
  167|      0|	sc_color_fprintf(SC_COLOR_FG_GREEN,
  ------------------
  |  |   45|      0|#define SC_COLOR_FG_GREEN		0x0002
  ------------------
  168|      0|			ctx, ctx->debug_file,
  169|      0|			" %s.%03ld",
  170|      0|			time_string,
  171|      0|			(long)tv.tv_usec / 1000);
  172|      0|#endif
  173|       |
  174|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  175|      0|			ctx, ctx->debug_file,
  176|      0|			" [");
  177|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW|SC_COLOR_BOLD,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
              	sc_color_fprintf(SC_COLOR_FG_YELLOW|SC_COLOR_BOLD,
  ------------------
  |  |   56|      0|#define SC_COLOR_BOLD			0x8080
  ------------------
  178|      0|			ctx, ctx->debug_file,
  179|      0|			"%s",
  180|      0|			ctx->app_name);
  181|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  182|      0|			ctx, ctx->debug_file,
  183|      0|			"] ");
  184|       |
  185|      0|	if (file != NULL) {
  ------------------
  |  Branch (185:6): [True: 0, False: 0]
  ------------------
  186|      0|		sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  187|      0|				ctx, ctx->debug_file,
  188|      0|				"%s:%d:%s: ",
  189|      0|				file, line, func ? func : "");
  ------------------
  |  Branch (189:17): [True: 0, False: 0]
  ------------------
  190|      0|	}
  191|       |
  192|      0|	sc_color_fprintf_va(color, ctx, ctx->debug_file, format, args);
  193|      0|	if (strlen(format) == 0 || format[strlen(format) - 1] != '\n')
  ------------------
  |  Branch (193:6): [True: 0, False: 0]
  |  Branch (193:29): [True: 0, False: 0]
  ------------------
  194|      0|		sc_color_fprintf(color, ctx, ctx->debug_file, "\n");
  195|      0|	fflush(ctx->debug_file);
  196|       |
  197|       |#ifdef _WIN32
  198|       |	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  199|       |		fclose(ctx->debug_file);
  200|       |	ctx->debug_file = NULL;
  201|       |#endif
  202|      0|}

sc_get_ctapi_driver:
  558|      1|{
  559|      1|	ctapi_ops.init = ctapi_init;
  560|      1|	ctapi_ops.finish = ctapi_finish;
  561|      1|	ctapi_ops.detect_readers = NULL;
  562|      1|	ctapi_ops.transmit = ctapi_transmit;
  563|      1|	ctapi_ops.detect_card_presence = ctapi_detect_card_presence;
  564|      1|	ctapi_ops.lock = ctapi_lock;
  565|      1|	ctapi_ops.unlock = ctapi_unlock;
  566|      1|	ctapi_ops.release = ctapi_release;
  567|      1|	ctapi_ops.connect = ctapi_connect;
  568|      1|	ctapi_ops.disconnect = ctapi_disconnect;
  569|      1|	ctapi_ops.perform_verify = ctbcs_pin_cmd;
  570|      1|	ctapi_ops.perform_pace = NULL;
  571|      1|	ctapi_ops.use_reader = NULL;
  572|       |
  573|      1|	return &ctapi_drv;
  574|      1|}
reader-ctapi.c:ctapi_init:
  515|      1|{
  516|      1|	int i;
  517|      1|	struct ctapi_global_private_data *gpriv;
  518|      1|	scconf_block **blocks = NULL, *conf_block = NULL;
  519|       |
  520|      1|	gpriv = calloc(1, sizeof(struct ctapi_global_private_data));
  521|      1|	if (gpriv == NULL)
  ------------------
  |  Branch (521:6): [True: 0, False: 1]
  ------------------
  522|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  523|      1|	ctx->reader_drv_data = gpriv;
  524|       |
  525|      1|	conf_block = sc_get_conf_block(ctx, "reader_driver", "ctapi", 1);
  526|      1|	if (conf_block)   {
  ------------------
  |  Branch (526:6): [True: 0, False: 1]
  ------------------
  527|      0|		blocks = scconf_find_blocks(ctx->conf, conf_block, "module", NULL);
  528|      0|		for (i = 0; blocks != NULL && blocks[i] != NULL; i++)
  ------------------
  |  Branch (528:15): [True: 0, False: 0]
  |  Branch (528:33): [True: 0, False: 0]
  ------------------
  529|      0|			ctapi_load_module(ctx, gpriv, blocks[i]);
  530|      0|		free(blocks);
  531|      0|	}
  532|       |
  533|      1|	return 0;
  534|      1|}

sc_get_version:
   59|      1|{
   60|      1|    return sc_version;
   61|      1|}
sc_mutex_create:
 1082|      1|{
 1083|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1083:6): [True: 0, False: 1]
  ------------------
 1084|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1085|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)
  ------------------
  |  Branch (1085:6): [True: 0, False: 1]
  |  Branch (1085:33): [True: 0, False: 0]
  ------------------
 1086|      0|		return ctx->thread_ctx->create_mutex(mutex);
 1087|      1|	else
 1088|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1089|      1|}
sc_mutex_lock:
 1092|      1|{
 1093|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1093:6): [True: 0, False: 1]
  ------------------
 1094|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1095|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->lock_mutex != NULL)
  ------------------
  |  Branch (1095:6): [True: 0, False: 1]
  |  Branch (1095:33): [True: 0, False: 0]
  ------------------
 1096|      0|		return ctx->thread_ctx->lock_mutex(mutex);
 1097|      1|	else
 1098|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1099|      1|}
sc_mutex_unlock:
 1102|      1|{
 1103|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1103:6): [True: 0, False: 1]
  ------------------
 1104|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1105|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->unlock_mutex != NULL)
  ------------------
  |  Branch (1105:6): [True: 0, False: 1]
  |  Branch (1105:33): [True: 0, False: 0]
  ------------------
 1106|      0|		return ctx->thread_ctx->unlock_mutex(mutex);
 1107|      1|	else
 1108|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1109|      1|}

scconf_parse_token:
  251|     10|{
  252|     10|	scconf_item *item;
  253|     10|	size_t len;
  254|       |
  255|     10|	if (parser->error) {
  ------------------
  |  Branch (255:6): [True: 0, False: 10]
  ------------------
  256|       |		/* fatal error */
  257|      0|		return;
  258|      0|	}
  259|     10|	switch (token_type) {
  ------------------
  |  Branch (259:10): [True: 10, False: 0]
  ------------------
  260|      0|	case TOKEN_TYPE_NEWLINE:
  ------------------
  |  |   32|      0|#define TOKEN_TYPE_NEWLINE	1
  ------------------
  |  Branch (260:2): [True: 0, False: 10]
  ------------------
  261|      0|		parser->line++;
  262|      0|		if (parser->last_token_type != TOKEN_TYPE_NEWLINE) {
  ------------------
  |  |   32|      0|#define TOKEN_TYPE_NEWLINE	1
  ------------------
  |  Branch (262:7): [True: 0, False: 0]
  ------------------
  263|      0|			break;
  264|      0|		}
  265|       |		/* fall through - treat empty lines as comments */
  266|      0|	case TOKEN_TYPE_COMMENT:
  ------------------
  |  |   31|      0|#define TOKEN_TYPE_COMMENT	0
  ------------------
  |  Branch (266:2): [True: 0, False: 10]
  ------------------
  267|      0|		item = scconf_item_add_internal(parser, SCCONF_ITEM_TYPE_COMMENT);
  ------------------
  |  |   42|      0|#define SCCONF_ITEM_TYPE_COMMENT	0	/* key = NULL, comment */
  ------------------
  268|      0|		if (!item) {
  ------------------
  |  Branch (268:7): [True: 0, False: 0]
  ------------------
  269|      0|			return;
  270|      0|		}
  271|      0|		item->value.comment = token ? strdup(token) : NULL;
  ------------------
  |  Branch (271:25): [True: 0, False: 0]
  ------------------
  272|      0|		break;
  273|      5|	case TOKEN_TYPE_STRING:
  ------------------
  |  |   33|      5|#define TOKEN_TYPE_STRING	2
  ------------------
  |  Branch (273:2): [True: 5, False: 5]
  ------------------
  274|      5|		{
  275|      5|			char *stoken = NULL;
  276|       |
  277|      5|			if ((parser->state & (STATE_VALUE | STATE_SET)) ==
  ------------------
  |  |   37|      5|#define STATE_VALUE	0x02
  ------------------
              			if ((parser->state & (STATE_VALUE | STATE_SET)) ==
  ------------------
  |  |   38|      5|#define STATE_SET	0x10
  ------------------
  |  Branch (277:8): [True: 0, False: 5]
  ------------------
  278|      5|			    (STATE_VALUE | STATE_SET)) {
  ------------------
  |  |   37|      5|#define STATE_VALUE	0x02
  ------------------
              			    (STATE_VALUE | STATE_SET)) {
  ------------------
  |  |   38|      5|#define STATE_SET	0x10
  ------------------
  279|      0|				scconf_parse_warning_expect(parser, ";");
  280|      0|				scconf_parse_reset_state(parser);
  281|      0|			}
  282|      5|			if (token && *token == '"') {
  ------------------
  |  Branch (282:8): [True: 5, False: 0]
  |  Branch (282:17): [True: 0, False: 5]
  ------------------
  283|       |				/* quoted string, remove them */
  284|      0|				token++;
  285|      0|				len = strlen(token);
  286|      0|				if (len < 1 || token[len - 1] != '"') {
  ------------------
  |  Branch (286:9): [True: 0, False: 0]
  |  Branch (286:20): [True: 0, False: 0]
  ------------------
  287|      0|					scconf_parse_warning_expect(parser, "\"");
  288|      0|				} else {
  289|       |					/* stoken */
  290|      0|					stoken = strdup(token);
  291|      0|					if (stoken) {
  ------------------
  |  Branch (291:10): [True: 0, False: 0]
  ------------------
  292|      0|						stoken[len - 1] = '\0';
  293|      0|					}
  294|      0|				}
  295|      0|			}
  296|      5|			if (!stoken) {
  ------------------
  |  Branch (296:8): [True: 5, False: 0]
  ------------------
  297|      5|				stoken = token ? strdup(token) : NULL;
  ------------------
  |  Branch (297:14): [True: 5, False: 0]
  ------------------
  298|      5|			}
  299|      5|			if (parser->state == 0) {
  ------------------
  |  Branch (299:8): [True: 2, False: 3]
  ------------------
  300|       |				/* key */
  301|      2|				parser->key = stoken ? strdup(stoken) : NULL;
  ------------------
  |  Branch (301:19): [True: 2, False: 0]
  ------------------
  302|      2|				parser->state = STATE_NAME;
  ------------------
  |  |   36|      2|#define STATE_NAME	0x01
  ------------------
  303|      3|			} else if (parser->state == STATE_NAME) {
  ------------------
  |  |   36|      3|#define STATE_NAME	0x01
  ------------------
  |  Branch (303:15): [True: 1, False: 2]
  ------------------
  304|       |				/* name */
  305|      1|				parser->state |= STATE_SET;
  ------------------
  |  |   38|      1|#define STATE_SET	0x10
  ------------------
  306|      1|				scconf_list_add(&parser->name, stoken);
  307|      2|			} else if (parser->state == STATE_VALUE && parser->current_item->type == SCCONF_ITEM_TYPE_VALUE) {
  ------------------
  |  |   37|      4|#define STATE_VALUE	0x02
  ------------------
              			} else if (parser->state == STATE_VALUE && parser->current_item->type == SCCONF_ITEM_TYPE_VALUE) {
  ------------------
  |  |   44|      2|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (307:15): [True: 2, False: 0]
  |  Branch (307:47): [True: 2, False: 0]
  ------------------
  308|       |				/* value */
  309|      2|				parser->state |= STATE_SET;
  ------------------
  |  |   38|      2|#define STATE_SET	0x10
  ------------------
  310|      2|				scconf_list_add(&parser->current_item->value.list,
  311|      2|						      stoken);
  312|      2|			} else {
  313|       |				/* error */
  314|      0|				scconf_parse_error_not_expect(parser, stoken);
  315|      0|			}
  316|      5|			if (stoken) {
  ------------------
  |  Branch (316:8): [True: 5, False: 0]
  ------------------
  317|      5|				free(stoken);
  318|      5|			}
  319|      5|			stoken = NULL;
  320|      5|		}
  321|      5|		break;
  322|      5|	case TOKEN_TYPE_PUNCT:
  ------------------
  |  |   34|      5|#define TOKEN_TYPE_PUNCT	3
  ------------------
  |  Branch (322:2): [True: 5, False: 5]
  ------------------
  323|      5|		switch (*token) {
  324|      1|		case '{':
  ------------------
  |  Branch (324:3): [True: 1, False: 4]
  ------------------
  325|      1|			if ((parser->state & STATE_NAME) == 0) {
  ------------------
  |  |   36|      1|#define STATE_NAME	0x01
  ------------------
  |  Branch (325:8): [True: 0, False: 1]
  ------------------
  326|      0|				scconf_parse_error_not_expect(parser, "{");
  327|      0|				break;
  328|      0|			}
  329|      1|			parser->nested_blocks++;
  330|      1|			scconf_block_add_internal(parser);
  331|      1|			scconf_parse_reset_state(parser);
  332|      1|			break;
  333|      1|		case '}':
  ------------------
  |  Branch (333:3): [True: 1, False: 4]
  ------------------
  334|      1|			parser->nested_blocks--;
  335|      1|			if (parser->state != 0) {
  ------------------
  |  Branch (335:8): [True: 0, False: 1]
  ------------------
  336|      0|				if ((parser->state & STATE_VALUE) == 0 ||
  ------------------
  |  |   37|      0|#define STATE_VALUE	0x02
  ------------------
  |  Branch (336:9): [True: 0, False: 0]
  ------------------
  337|      0|				    (parser->state & STATE_SET) == 0) {
  ------------------
  |  |   38|      0|#define STATE_SET	0x10
  ------------------
  |  Branch (337:9): [True: 0, False: 0]
  ------------------
  338|      0|					scconf_parse_error_not_expect(parser,
  339|      0|								      "}");
  340|      0|					break;
  341|      0|				}
  342|       |				/* foo = bar } */
  343|      0|				scconf_parse_warning_expect(parser, ";");
  344|      0|				scconf_parse_reset_state(parser);
  345|      0|			}
  346|      1|			if (!parser->block->parent) {
  ------------------
  |  Branch (346:8): [True: 0, False: 1]
  ------------------
  347|       |				/* too many '}' */
  348|      0|				scconf_parse_error(parser,
  349|      0|						   "missing matching '{'");
  350|      0|				break;
  351|      0|			}
  352|      1|			scconf_parse_parent(parser);
  353|      1|			break;
  354|      1|		case ',':
  ------------------
  |  Branch (354:3): [True: 1, False: 4]
  ------------------
  355|      1|			if ((parser->state & (STATE_NAME | STATE_VALUE)) == 0) {
  ------------------
  |  |   36|      1|#define STATE_NAME	0x01
  ------------------
              			if ((parser->state & (STATE_NAME | STATE_VALUE)) == 0) {
  ------------------
  |  |   37|      1|#define STATE_VALUE	0x02
  ------------------
  |  Branch (355:8): [True: 0, False: 1]
  ------------------
  356|      0|				scconf_parse_error_not_expect(parser, ",");
  357|      0|			}
  358|      1|			parser->state &= ~STATE_SET;
  ------------------
  |  |   38|      1|#define STATE_SET	0x10
  ------------------
  359|      1|			break;
  360|      1|		case '=':
  ------------------
  |  Branch (360:3): [True: 1, False: 4]
  ------------------
  361|      1|			if ((parser->state & STATE_NAME) == 0) {
  ------------------
  |  |   36|      1|#define STATE_NAME	0x01
  ------------------
  |  Branch (361:8): [True: 0, False: 1]
  ------------------
  362|      0|				scconf_parse_error_not_expect(parser, "=");
  363|      0|				break;
  364|      0|			}
  365|      1|			scconf_item_add_internal(parser, SCCONF_ITEM_TYPE_VALUE);
  ------------------
  |  |   44|      1|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  366|      1|			parser->state = STATE_VALUE;
  ------------------
  |  |   37|      1|#define STATE_VALUE	0x02
  ------------------
  367|      1|			break;
  368|      1|		case ';':
  ------------------
  |  Branch (368:3): [True: 1, False: 4]
  ------------------
  369|      1|			scconf_parse_reset_state(parser);
  370|      1|			break;
  371|      0|		default:
  ------------------
  |  Branch (371:3): [True: 0, False: 5]
  ------------------
  372|      0|			snprintf(parser->emesg, sizeof(parser->emesg),
  373|      0|				"Line %d: bad token ignoring\n",
  374|      0|				parser->line);
  375|      5|		}
  376|      5|		break;
  377|     10|	}
  378|       |
  379|     10|	parser->last_token_type = token_type;
  380|     10|}
scconf_parse:
  383|      1|{
  384|      1|	static char buffer[256];
  385|      1|	scconf_parser p;
  386|      1|	int r = 1;
  387|       |
  388|      1|	memset(&p, 0, sizeof(p));
  389|      1|	p.config = config;
  390|      1|	p.block = config->root;
  391|      1|	p.line = 1;
  392|      1|	p.nested_blocks = 0;
  393|       |
  394|      1|	if (!scconf_lex_parse(&p, config->filename)) {
  ------------------
  |  Branch (394:6): [True: 1, False: 0]
  ------------------
  395|      1|		snprintf(buffer, sizeof(buffer),
  396|      1|				"Unable to open \"%s\": %s",
  397|      1|				config->filename, strerror(errno));
  398|      1|		r = -1;
  399|      1|	} else if (p.error) {
  ------------------
  |  Branch (399:13): [True: 0, False: 0]
  ------------------
  400|      0|		strlcpy(buffer, p.emesg, sizeof(buffer));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  401|      0|		r = 0;
  402|      0|	} else {
  403|      0|		r = 1;
  404|      0|	}
  405|       |
  406|      1|	if (r <= 0)
  ------------------
  |  Branch (406:6): [True: 1, False: 0]
  ------------------
  407|      1|		config->errmsg = buffer;
  408|      1|	return r;
  409|      1|}
scconf_parse_string:
  412|      1|{
  413|      1|	static char buffer[256];
  414|      1|	scconf_parser p;
  415|      1|	int r;
  416|       |
  417|      1|	memset(&p, 0, sizeof(p));
  418|      1|	p.config = config;
  419|      1|	p.block = config->root;
  420|      1|	p.line = 1;
  421|      1|	p.nested_blocks = 0;
  422|       |
  423|      1|	if (!scconf_lex_parse_string(&p, string)) {
  ------------------
  |  Branch (423:6): [True: 0, False: 1]
  ------------------
  424|      0|		snprintf(buffer, sizeof(buffer),
  425|      0|				"Failed to parse configuration string");
  426|      0|		r = -1;
  427|      1|	} else if (p.error) {
  ------------------
  |  Branch (427:13): [True: 0, False: 1]
  ------------------
  428|      0|		strlcpy(buffer, p.emesg, sizeof(buffer));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  429|      0|		r = 0;
  430|      1|	} else {
  431|      1|		r = 1;
  432|      1|	}
  433|       |
  434|      1|	scconf_parse_reset_state(&p);
  435|       |
  436|      1|	if (r <= 0)
  ------------------
  |  Branch (436:6): [True: 0, False: 1]
  ------------------
  437|      0|		config->errmsg = buffer;
  438|      1|	return r;
  439|      1|}
parse.c:scconf_item_add_internal:
   95|      2|{
   96|      2|	scconf_item *item;
   97|       |
   98|      2|	if (type == SCCONF_ITEM_TYPE_VALUE) {
  ------------------
  |  |   44|      2|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (98:6): [True: 1, False: 1]
  ------------------
   99|       |		/* if item with same key already exists, use it */
  100|      1|		item = scconf_item_find(parser);
  101|      1|		if (item) {
  ------------------
  |  Branch (101:7): [True: 0, False: 1]
  ------------------
  102|      0|			free(parser->key);
  103|      0|			parser->key = NULL;
  104|      0|			parser->current_item = item;
  105|      0|			return item;
  106|      0|		}
  107|      1|	}
  108|      2|	item = calloc(1, sizeof(scconf_item));
  109|      2|	if (!item) {
  ------------------
  |  Branch (109:6): [True: 0, False: 2]
  ------------------
  110|      0|		return NULL;
  111|      0|	}
  112|      2|	item->type = type;
  113|       |
  114|      2|	item->key = parser->key;
  115|      2|	parser->key = NULL;
  116|       |
  117|      2|	if (parser->last_item) {
  ------------------
  |  Branch (117:6): [True: 0, False: 2]
  ------------------
  118|      0|		parser->last_item->next = item;
  119|      2|	} else {
  120|      2|		parser->block->items = item;
  121|      2|	}
  122|      2|	parser->current_item = parser->last_item = item;
  123|      2|	return item;
  124|      2|}
parse.c:scconf_item_find:
   81|      1|{
   82|      1|	scconf_item *item;
   83|       |
   84|      1|	for (item = parser->block->items; item; item = item->next) {
  ------------------
  |  Branch (84:36): [True: 0, False: 1]
  ------------------
   85|      0|		if (item && item->type == SCCONF_ITEM_TYPE_VALUE
  ------------------
  |  |   44|      0|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (85:7): [True: 0, False: 0]
  |  Branch (85:15): [True: 0, False: 0]
  ------------------
   86|      0|			   	&& item->key && parser->key
  ------------------
  |  Branch (86:11): [True: 0, False: 0]
  |  Branch (86:24): [True: 0, False: 0]
  ------------------
   87|      0|			   	&& strcasecmp(item->key, parser->key) == 0) {
  ------------------
  |  Branch (87:11): [True: 0, False: 0]
  ------------------
   88|      0|			return item;
   89|      0|		}
   90|      0|	}
   91|      1|	return item;
   92|      1|}
parse.c:scconf_block_add_internal:
  173|      1|{
  174|      1|	scconf_block *block;
  175|      1|	scconf_item *item;
  176|       |
  177|      1|	item = scconf_item_add_internal(parser, SCCONF_ITEM_TYPE_BLOCK);
  ------------------
  |  |   43|      1|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  178|      1|	if (!item) {
  ------------------
  |  Branch (178:6): [True: 0, False: 1]
  ------------------
  179|      0|		return;
  180|      0|	}
  181|       |
  182|      1|	block = calloc(1, sizeof(scconf_block));
  183|      1|	if (!block) {
  ------------------
  |  Branch (183:6): [True: 0, False: 1]
  ------------------
  184|      0|		return;
  185|      0|	}
  186|      1|	block->parent = parser->block;
  187|      1|	item->value.block = block;
  188|       |
  189|      1|	if (!parser->name) {
  ------------------
  |  Branch (189:6): [True: 0, False: 1]
  ------------------
  190|      0|		scconf_list_add(&parser->name, "");
  191|      0|	}
  192|      1|	block->name = parser->name;
  193|      1|	parser->name = NULL;
  194|       |
  195|      1|	parser->block = block;
  196|       |	parser->last_item = NULL;
  197|      1|}
parse.c:scconf_parse_reset_state:
  231|      3|{
  232|      3|	if (parser) {
  ------------------
  |  Branch (232:6): [True: 3, False: 0]
  ------------------
  233|      3|		if (parser->key) {
  ------------------
  |  Branch (233:7): [True: 0, False: 3]
  ------------------
  234|      0|			free(parser->key);
  235|      0|		}
  236|      3|		scconf_list_destroy(parser->name);
  237|       |
  238|      3|		parser->key = NULL;
  239|       |		parser->name = NULL;
  240|      3|		parser->state = 0;
  241|      3|	}
  242|      3|}
parse.c:scconf_parse_parent:
  219|      1|{
  220|      1|	parser->block = parser->block->parent;
  221|       |
  222|      1|	parser->last_item = parser->block->items;
  223|      1|	if (parser->last_item) {
  ------------------
  |  Branch (223:6): [True: 1, False: 0]
  ------------------
  224|      1|		while (parser->last_item->next) {
  ------------------
  |  Branch (224:10): [True: 0, False: 1]
  ------------------
  225|      0|			parser->last_item = parser->last_item->next;
  226|      0|		}
  227|      1|	}
  228|      1|}

scconf_new:
   37|      1|{
   38|      1|	scconf_context *config;
   39|       |
   40|      1|	config = calloc(1, sizeof(scconf_context));
   41|      1|	if (!config) {
  ------------------
  |  Branch (41:6): [True: 0, False: 1]
  ------------------
   42|      0|		return NULL;
   43|      0|	}
   44|      1|	config->filename = filename ? strdup(filename) : NULL;
  ------------------
  |  Branch (44:21): [True: 1, False: 0]
  ------------------
   45|      1|	config->root = calloc(1, sizeof(scconf_block));
   46|      1|	if (!config->root) {
  ------------------
  |  Branch (46:6): [True: 0, False: 1]
  ------------------
   47|      0|		if (config->filename) {
  ------------------
  |  Branch (47:7): [True: 0, False: 0]
  ------------------
   48|      0|			free(config->filename);
   49|      0|		}
   50|      0|		free(config);
   51|      0|		return NULL;
   52|      0|	}
   53|      1|	return config;
   54|      1|}
scconf_find_blocks:
   87|     49|{
   88|     49|	scconf_block **blocks = NULL, **tmp;
   89|     49|	int alloc_size, size;
   90|     49|	scconf_item *item;
   91|       |
   92|     49|	if (!block) {
  ------------------
  |  Branch (92:6): [True: 3, False: 46]
  ------------------
   93|      3|		block = config->root;
   94|      3|	}
   95|     49|	if (!item_name) {
  ------------------
  |  Branch (95:6): [True: 0, False: 49]
  ------------------
   96|      0|		return NULL;
   97|      0|	}
   98|     49|	size = 0;
   99|     49|	alloc_size = 10;
  100|     49|	tmp = (scconf_block **) realloc(blocks, sizeof(scconf_block *) * alloc_size);
  101|     49|	if (!tmp) {
  ------------------
  |  Branch (101:6): [True: 0, False: 49]
  ------------------
  102|      0|		free(blocks);
  103|      0|		return NULL;
  104|      0|	}
  105|     49|	blocks = tmp;
  106|       |
  107|     98|	for (item = block->items; item; item = item->next) {
  ------------------
  |  Branch (107:28): [True: 49, False: 49]
  ------------------
  108|     49|		if (item->type == SCCONF_ITEM_TYPE_BLOCK &&
  ------------------
  |  |   43|     98|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (108:7): [True: 3, False: 46]
  ------------------
  109|      3|		    strcasecmp(item_name, item->key) == 0) {
  ------------------
  |  Branch (109:7): [True: 3, False: 0]
  ------------------
  110|      3|			if (!item->value.block)
  ------------------
  |  Branch (110:8): [True: 0, False: 3]
  ------------------
  111|      0|				continue;
  112|      3|			if (key && strcasecmp(key, item->value.block->name->data)) {
  ------------------
  |  Branch (112:8): [True: 3, False: 0]
  |  Branch (112:15): [True: 2, False: 1]
  ------------------
  113|      2|				continue;
  114|      2|			}
  115|      1|			if (size + 1 >= alloc_size) {
  ------------------
  |  Branch (115:8): [True: 0, False: 1]
  ------------------
  116|      0|				alloc_size *= 2;
  117|      0|				tmp = (scconf_block **) realloc(blocks, sizeof(scconf_block *) * alloc_size);
  118|      0|				if (!tmp) {
  ------------------
  |  Branch (118:9): [True: 0, False: 0]
  ------------------
  119|      0|					free(blocks);
  120|      0|					return NULL;
  121|      0|				}
  122|      0|				blocks = tmp;
  123|      0|			}
  124|      1|			blocks[size++] = item->value.block;
  125|      1|		}
  126|     49|	}
  127|     49|	blocks[size] = NULL;
  128|     49|	return blocks;
  129|     49|}
scconf_find_list:
  132|      7|{
  133|      7|	scconf_item *item;
  134|       |
  135|      7|	if (!block)
  ------------------
  |  Branch (135:6): [True: 0, False: 7]
  ------------------
  136|      0|		return NULL;
  137|       |
  138|     13|	for (item = block->items; item; item = item->next)
  ------------------
  |  Branch (138:28): [True: 7, False: 6]
  ------------------
  139|      7|		if (item->type == SCCONF_ITEM_TYPE_VALUE && strcasecmp(option, item->key) == 0)
  ------------------
  |  |   44|     14|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (139:7): [True: 7, False: 0]
  |  Branch (139:47): [True: 1, False: 6]
  ------------------
  140|      1|			return item->value.list;
  141|      6|	return NULL;
  142|      7|}
scconf_get_str:
  145|      2|{
  146|      2|	const scconf_list *list;
  147|       |
  148|      2|	list = scconf_find_list(block, option);
  149|      2|	if (!list)
  ------------------
  |  Branch (149:6): [True: 2, False: 0]
  ------------------
  150|      2|		return def;
  151|       |
  152|       |	/* ignore non 'auto-configured' values */
  153|      0|	if (*list->data == '@' && *(list->data + strlen(list->data) - 1) == '@')
  ------------------
  |  Branch (153:6): [True: 0, False: 0]
  |  Branch (153:28): [True: 0, False: 0]
  ------------------
  154|      0|		return def;
  155|       |
  156|      0|	return list->data;
  157|      0|}
scconf_get_int:
  160|      1|{
  161|      1|	const scconf_list *list;
  162|      1|	long res;
  163|       |
  164|      1|	list = scconf_find_list(block, option);
  165|      1|	if (!list) {
  ------------------
  |  Branch (165:6): [True: 1, False: 0]
  ------------------
  166|      1|		return def;
  167|      1|	}
  168|      0|	res = strtol(list->data, NULL, 0);
  169|      0|	if (res <= INT_MAX) {
  ------------------
  |  Branch (169:6): [True: 0, False: 0]
  ------------------
  170|      0|		return (int)res;
  171|      0|	}
  172|      0|	return def;
  173|      0|}
scconf_get_bool:
  176|      3|{
  177|      3|	const scconf_list *list;
  178|       |
  179|      3|	list = scconf_find_list(block, option);
  180|      3|	if (!list) {
  ------------------
  |  Branch (180:6): [True: 3, False: 0]
  ------------------
  181|      3|		return def;
  182|      3|	}
  183|      0|	return toupper((int) *list->data) == 'T' || toupper((int) *list->data) == 'Y';
  ------------------
  |  Branch (183:9): [True: 0, False: 0]
  |  Branch (183:46): [True: 0, False: 0]
  ------------------
  184|      3|}
scconf_list_add:
  319|      3|{
  320|      3|	scconf_list *rec, **tmp;
  321|       |
  322|      3|	rec = calloc(1, sizeof(scconf_list));
  323|      3|	if (!rec) {
  ------------------
  |  Branch (323:6): [True: 0, False: 3]
  ------------------
  324|      0|		return NULL;
  325|      0|	}
  326|      3|	rec->data = value ? strdup(value) : NULL;
  ------------------
  |  Branch (326:14): [True: 3, False: 0]
  ------------------
  327|       |
  328|      3|	if (!*list) {
  ------------------
  |  Branch (328:6): [True: 2, False: 1]
  ------------------
  329|      2|		*list = rec;
  330|      2|	} else {
  331|      2|		for (tmp = list; *tmp; tmp = &(*tmp)->next);
  ------------------
  |  Branch (331:20): [True: 1, False: 1]
  ------------------
  332|      1|		*tmp = rec;
  333|      1|	}
  334|      3|	return rec;
  335|      3|}
scconf_list_destroy:
  350|      3|{
  351|      3|	scconf_list *next;
  352|       |
  353|      3|	while (list) {
  ------------------
  |  Branch (353:9): [True: 0, False: 3]
  ------------------
  354|      0|		next = list->next;
  355|      0|		if (list->data) {
  ------------------
  |  Branch (355:7): [True: 0, False: 0]
  ------------------
  356|      0|			free(list->data);
  357|      0|		}
  358|      0|		free(list);
  359|      0|		list = next;
  360|      0|	}
  361|      3|}

scconf_lex_parse:
  181|      1|{
  182|      1|	FILE *fp;
  183|      1|	BUFHAN bhan;
  184|      1|	int ret;
  185|       |
  186|      1|	fp = fopen(filename, "r");
  187|      1|	if (!fp) {
  ------------------
  |  Branch (187:6): [True: 1, False: 0]
  ------------------
  188|      1|		parser->error = 1;
  189|      1|		snprintf(parser->emesg, sizeof(parser->emesg),
  190|      1|			 "File %s can't be opened\n", filename);
  191|      1|		return 0;
  192|      1|	}
  193|      0|	buf_init(&bhan, fp, (char *) NULL);
  194|      0|	ret = scconf_lex_engine(parser, &bhan);
  195|      0|	fclose(fp);
  196|      0|	return ret;
  197|      1|}
scconf_lex_parse_string:
  200|      1|{
  201|      1|	BUFHAN bhan;
  202|      1|	int ret;
  203|       |
  204|       |	buf_init(&bhan, (FILE *) NULL, string);
  205|      1|	ret = scconf_lex_engine(parser, &bhan);
  206|      1|	return ret;
  207|      1|}
sclex.c:buf_init:
   44|      1|{
   45|      1|	bp->fp = fp;
   46|      1|	bp->saved_char = 0;
   47|      1|	bp->buf = malloc(256);
   48|      1|	if (bp->buf) {
  ------------------
  |  Branch (48:6): [True: 1, False: 0]
  ------------------
   49|      1|		bp->bufmax = 256;
   50|      1|		bp->buf[0] = '\0';
   51|      1|	} else
   52|      0|		bp->bufmax = 0;
   53|      1|	bp->bufcur = 0;
   54|      1|	bp->saved_string = saved_string;
   55|      1|}
sclex.c:scconf_lex_engine:
  126|      1|{
  127|      1|	int this_char;
  128|       |
  129|     18|	while (1) {
  ------------------
  |  Branch (129:9): [True: 18, Folded]
  ------------------
  130|     18|		switch (this_char = buf_nextch(bp)) {
  131|      0|		case '#':
  ------------------
  |  Branch (131:3): [True: 0, False: 18]
  ------------------
  132|       |			/* comment till end of line */
  133|      0|			buf_eat_till(bp, '#', "\r\n");
  134|      0|			scconf_parse_token(parser, TOKEN_TYPE_COMMENT, bp->buf);
  ------------------
  |  |   31|      0|#define TOKEN_TYPE_COMMENT	0
  ------------------
  135|      0|			buf_zero(bp);
  136|      0|			continue;
  137|      0|		case '\n':
  ------------------
  |  Branch (137:3): [True: 0, False: 18]
  ------------------
  138|      0|			scconf_parse_token(parser, TOKEN_TYPE_NEWLINE, NULL);
  ------------------
  |  |   32|      0|#define TOKEN_TYPE_NEWLINE	1
  ------------------
  139|      0|			continue;
  140|      7|		case ' ':
  ------------------
  |  Branch (140:3): [True: 7, False: 11]
  ------------------
  141|      7|		case '\t':
  ------------------
  |  Branch (141:3): [True: 0, False: 18]
  ------------------
  142|      7|		case '\r':
  ------------------
  |  Branch (142:3): [True: 0, False: 18]
  ------------------
  143|       |			/* eat up whitespace */
  144|      7|			continue;
  145|      1|		case ',':
  ------------------
  |  Branch (145:3): [True: 1, False: 17]
  ------------------
  146|      2|		case '{':
  ------------------
  |  Branch (146:3): [True: 1, False: 17]
  ------------------
  147|      2|			if (parser->nested_blocks >= DEPTH_LIMIT) {
  ------------------
  |  |   36|      2|#define DEPTH_LIMIT 16
  ------------------
  |  Branch (147:8): [True: 0, False: 2]
  ------------------
  148|       |				/* reached the limit, this whole block */
  149|      0|				scconf_skip_block(parser);
  150|      0|				continue;
  151|      0|			}
  152|       |			/* fall through */
  153|      3|		case '}':
  ------------------
  |  Branch (153:3): [True: 1, False: 17]
  ------------------
  154|      4|		case '=':
  ------------------
  |  Branch (154:3): [True: 1, False: 17]
  ------------------
  155|      5|		case ';':
  ------------------
  |  Branch (155:3): [True: 1, False: 17]
  ------------------
  156|      5|			buf_addch(bp, (char) this_char);
  157|      5|			scconf_parse_token(parser, TOKEN_TYPE_PUNCT, bp->buf);
  ------------------
  |  |   34|      5|#define TOKEN_TYPE_PUNCT	3
  ------------------
  158|      5|			buf_zero(bp);
  159|      5|			continue;
  160|      0|		case '"':
  ------------------
  |  Branch (160:3): [True: 0, False: 18]
  ------------------
  161|      0|			buf_eat_till(bp, (char) this_char, "\"\r\n");
  162|      0|			buf_addch(bp, (char) buf_nextch(bp));
  163|      0|			scconf_parse_token(parser, TOKEN_TYPE_STRING, bp->buf);
  ------------------
  |  |   33|      0|#define TOKEN_TYPE_STRING	2
  ------------------
  164|      0|			buf_zero(bp);
  165|      0|			continue;
  166|      1|		case EOF:
  ------------------
  |  Branch (166:3): [True: 1, False: 17]
  ------------------
  167|      1|			break;
  168|      5|		default:
  ------------------
  |  Branch (168:3): [True: 5, False: 13]
  ------------------
  169|      5|			buf_eat_till(bp, (char) this_char, ";, \t\r\n");
  170|      5|			scconf_parse_token(parser, TOKEN_TYPE_STRING, bp->buf);
  ------------------
  |  |   33|      5|#define TOKEN_TYPE_STRING	2
  ------------------
  171|      5|			buf_zero(bp);
  172|      5|			continue;
  173|     18|		}
  174|      1|		break;
  175|     18|	}
  176|      1|	buf_finished(bp);
  177|      1|	return 1;
  178|      1|}
sclex.c:buf_nextch:
   73|     51|{
   74|     51|	int saved;
   75|       |
   76|     51|	if (bp->saved_char) {
  ------------------
  |  Branch (76:6): [True: 5, False: 46]
  ------------------
   77|      5|		saved = bp->saved_char;
   78|      5|		bp->saved_char = 0;
   79|      5|		return saved;
   80|      5|	}
   81|     46|	if (bp->saved_string) {
  ------------------
  |  Branch (81:6): [True: 46, False: 0]
  ------------------
   82|     46|		if (*(bp->saved_string) == '\0')
  ------------------
  |  Branch (82:7): [True: 1, False: 45]
  ------------------
   83|      1|			return EOF;
   84|     45|		saved = (unsigned char) (*(bp->saved_string++));
   85|     45|		return saved;
   86|     46|	} else {
   87|      0|		saved = fgetc(bp->fp);
   88|      0|		return saved;
   89|      0|	}
   90|     46|}
sclex.c:buf_eat_till:
  101|      5|{
  102|      5|	int i;
  103|       |
  104|      5|	if (start) {
  ------------------
  |  Branch (104:6): [True: 5, False: 0]
  ------------------
  105|      5|		buf_addch(bp, start);
  106|      5|	}
  107|     33|	while (1) {
  ------------------
  |  Branch (107:9): [True: 33, Folded]
  ------------------
  108|     33|		i = buf_nextch(bp);
  109|     33|		if (i == EOF)
  ------------------
  |  Branch (109:7): [True: 0, False: 33]
  ------------------
  110|      0|			return;
  111|     33|		if (strchr(end, i)) {
  ------------------
  |  Branch (111:7): [True: 5, False: 28]
  ------------------
  112|      5|			bp->saved_char = i;
  113|      5|			return;
  114|      5|		}
  115|     28|		buf_addch(bp, (char) i);
  116|     28|	}
  117|      5|}
sclex.c:buf_zero:
  120|     10|{
  121|     10|	bp->bufcur = 0;
  122|     10|	bp->buf[0] = '\0';
  123|     10|}
sclex.c:buf_addch:
   58|     38|{
   59|     38|	if (bp->bufcur + 1 >= bp->bufmax) {
  ------------------
  |  Branch (59:6): [True: 0, False: 38]
  ------------------
   60|      0|		char *p = (char *) realloc(bp->buf, bp->bufmax + 256);
   61|      0|		if (!p)
  ------------------
  |  Branch (61:7): [True: 0, False: 0]
  ------------------
   62|      0|			return;
   63|      0|		bp->bufmax += 256;
   64|      0|		bp->buf = p;
   65|      0|	}
   66|     38|	if (bp->buf) {
  ------------------
  |  Branch (66:6): [True: 38, False: 0]
  ------------------
   67|     38|		bp->buf[bp->bufcur++] = ch;
   68|     38|		bp->buf[bp->bufcur] = '\0';
   69|     38|	}
   70|     38|}
sclex.c:buf_finished:
   93|      1|{
   94|      1|	if (bp->buf) {
  ------------------
  |  Branch (94:6): [True: 1, False: 0]
  ------------------
   95|      1|		free(bp->buf);
   96|       |		bp->buf = NULL;
   97|      1|	}
   98|      1|}

LLVMFuzzerTestOneInput:
   32|    538|{
   33|    538|    if (!ctx)
  ------------------
  |  Branch (33:9): [True: 1, False: 537]
  ------------------
   34|      1|        sc_establish_context(&ctx, "fuzz");
   35|       |
   36|    538|    if (outlen < Size*2) {
  ------------------
  |  Branch (36:9): [True: 259, False: 279]
  ------------------
   37|    259|        unsigned char *p = realloc(out, Size*2);
   38|    259|        if (p) {
  ------------------
  |  Branch (38:13): [True: 259, False: 0]
  ------------------
   39|    259|            out = p;
   40|    259|            outlen = Size*2;
   41|    259|        }
   42|    259|    }
   43|       |
   44|    538|    if (inlen < Size) {
  ------------------
  |  Branch (44:9): [True: 538, False: 0]
  ------------------
   45|    538|        unsigned char *p = realloc(in, Size);
   46|    538|        if (p) {
  ------------------
  |  Branch (46:13): [True: 538, False: 0]
  ------------------
   47|    538|            in = p;
   48|    538|        }
   49|    538|    }
   50|    538|    memcpy(in, Data, Size);
   51|       |
   52|    538|    sc_asn1_sig_value_sequence_to_rs(ctx,
   53|    538|            Data, Size,
   54|    538|            out, outlen);
   55|       |
   56|    538|    unsigned char *p = NULL;
   57|    538|    size_t plen = 0;
   58|    538|    sc_asn1_sig_value_rs_to_sequence(ctx,
   59|    538|            in, Size,
   60|    538|            &p, &plen);
   61|    538|    free(p);
   62|       |
   63|    538|    return 0;
   64|    538|}

