list_init:
  240|      1|int list_init(list_t *simclist_restrict l) {
  241|      1|    if (l == NULL) {
  ------------------
  |  Branch (241:9): [True: 0, False: 1]
  ------------------
  242|      0|        return -1;
  243|      0|    }
  244|       |
  245|      1|    memset(l, 0, sizeof *l);
  246|       |
  247|      1|    seed_random();
  248|       |
  249|      1|    l->numels = 0;
  250|       |
  251|       |    /* head/tail sentinels and mid pointer */
  252|      1|    l->head_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  253|      1|    l->tail_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  254|      1|    if (l->tail_sentinel == NULL || l->head_sentinel == NULL) {
  ------------------
  |  Branch (254:9): [True: 0, False: 1]
  |  Branch (254:37): [True: 0, False: 1]
  ------------------
  255|      0|        return -1;
  256|      0|    }
  257|      1|    l->head_sentinel->next = l->tail_sentinel;
  258|      1|    l->tail_sentinel->prev = l->head_sentinel;
  259|      1|    l->head_sentinel->prev = l->tail_sentinel->next = l->mid = NULL;
  260|      1|    l->head_sentinel->data = l->tail_sentinel->data = NULL;
  261|       |
  262|       |    /* iteration attributes */
  263|      1|    l->iter_active = 0;
  264|      1|    l->iter_pos = 0;
  265|      1|    l->iter_curentry = NULL;
  266|       |
  267|       |    /* free-list attributes */
  268|      1|    l->spareelsnum = 0;
  269|      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
  ------------------
  270|      1|    if (l->spareels == NULL) {
  ------------------
  |  Branch (270:9): [True: 0, False: 1]
  ------------------
  271|      0|        return -1;
  272|      0|    }
  273|       |
  274|       |#ifdef SIMCLIST_WITH_THREADS
  275|       |    l->threadcount = 0;
  276|       |#endif
  277|       |
  278|      1|    if (0 != list_attributes_setdefaults(l)) {
  ------------------
  |  Branch (278:9): [True: 0, False: 1]
  ------------------
  279|      0|        return -1;
  280|      0|    }
  281|       |
  282|      1|    assert(list_repOk(l));
  283|      1|    assert(list_attrOk(l));
  284|       |
  285|      1|    return 0;
  286|      1|}
list_attributes_seeker:
  330|      1|int list_attributes_seeker(list_t *simclist_restrict l, element_seeker seeker_fun) {
  331|      1|    if (l == NULL) return -1;
  ------------------
  |  Branch (331:9): [True: 0, False: 1]
  ------------------
  332|       |
  333|      1|    l->attrs.seeker = seeker_fun;
  334|      1|    assert(list_attrOk(l));
  335|       |
  336|      1|    return 0;
  337|      1|}
simclist.c:seed_random:
  217|      1|static simclist_inline void seed_random() {
  218|      1|    if (random_seed == 0) {
  ------------------
  |  Branch (218:9): [True: 1, False: 0]
  ------------------
  219|      1|#ifndef _WIN32
  220|      1|        random_seed = (unsigned)getpid() ^ (unsigned)time(NULL);
  221|       |#else
  222|       |        random_seed = (unsigned)GetCurrentProcessId() ^ (unsigned)time(NULL);
  223|       |#endif
  224|      1|    }
  225|      1|}
simclist.c:list_attributes_setdefaults:
  300|      1|int list_attributes_setdefaults(list_t *simclist_restrict l) {
  301|      1|    l->attrs.comparator = NULL;
  302|      1|    l->attrs.seeker = NULL;
  303|       |
  304|       |    /* also free() element data when removing and element from the list */
  305|      1|    l->attrs.meter = NULL;
  306|      1|    l->attrs.copy_data = 0;
  307|       |
  308|      1|    l->attrs.hasher = NULL;
  309|       |
  310|       |    /* serializer/unserializer */
  311|      1|    l->attrs.serializer = NULL;
  312|      1|    l->attrs.unserializer = NULL;
  313|       |
  314|      1|    assert(list_attrOk(l));
  315|       |
  316|      1|    return 0;
  317|      1|}

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

sc_get_asepcos_driver:
 1086|      1|{
 1087|      1|	return sc_get_driver();
 1088|      1|}
card-asepcos.c:sc_get_driver:
 1064|      1|{
 1065|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1065:6): [True: 1, False: 0]
  ------------------
 1066|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1067|      1|	asepcos_ops = *iso_ops;
 1068|      1|	asepcos_ops.match_card        = asepcos_match_card;
 1069|      1|	asepcos_ops.init              = asepcos_init;
 1070|      1|	asepcos_ops.select_file       = asepcos_select_file;
 1071|      1|	asepcos_ops.set_security_env  = asepcos_set_security_env;
 1072|      1|	asepcos_ops.decipher          = asepcos_decipher;
 1073|      1|	asepcos_ops.compute_signature = asepcos_compute_signature;
 1074|      1|	asepcos_ops.create_file       = asepcos_create_file;
 1075|      1|	asepcos_ops.delete_file       = asepcos_delete_file;
 1076|      1|	asepcos_ops.list_files        = asepcos_list_files;
 1077|      1|	asepcos_ops.card_ctl          = asepcos_card_ctl;
 1078|      1|	asepcos_ops.pin_cmd           = asepcos_pin_cmd;
 1079|      1|	asepcos_ops.logout            = asepcos_logout;
 1080|      1|	asepcos_ops.card_reader_lock_obtained = asepcos_card_reader_lock_obtained;
 1081|       |
 1082|      1|	return &asepcos_drv;
 1083|      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:
 2149|      1|{
 2150|      1|	return sc_get_driver();
 2151|      1|}
card-authentic.c:sc_get_driver:
 2114|      1|{
 2115|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2116|       |
 2117|      1|	if (!iso_ops)
  ------------------
  |  Branch (2117:6): [True: 1, False: 0]
  ------------------
 2118|      1|		iso_ops = iso_drv->ops;
 2119|       |
 2120|      1|	authentic_ops = *iso_ops;
 2121|       |
 2122|      1|	authentic_ops.match_card = authentic_match_card;
 2123|      1|	authentic_ops.init = authentic_init;
 2124|      1|	authentic_ops.finish = authentic_finish;
 2125|      1|	authentic_ops.read_binary = authentic_read_binary;
 2126|      1|	authentic_ops.write_binary = authentic_write_binary;
 2127|      1|	authentic_ops.update_binary = authentic_update_binary;
 2128|      1|	authentic_ops.erase_binary = authentic_erase_binary;
 2129|       |	/* authentic_ops.resize_file = authentic_resize_file; */
 2130|      1|	authentic_ops.select_file = authentic_select_file;
 2131|       |	/* get_response: Untested */
 2132|      1|	authentic_ops.get_challenge = authentic_get_challenge;
 2133|      1|	authentic_ops.set_security_env = authentic_set_security_env;
 2134|       |	/* decipher: Untested */
 2135|      1|	authentic_ops.decipher = authentic_decipher;
 2136|       |	/* authentic_ops.compute_signature = authentic_compute_signature; */
 2137|      1|	authentic_ops.create_file = authentic_create_file;
 2138|      1|	authentic_ops.delete_file = authentic_delete_file;
 2139|      1|	authentic_ops.card_ctl = authentic_card_ctl;
 2140|      1|	authentic_ops.process_fci = authentic_process_fci;
 2141|      1|	authentic_ops.pin_cmd = authentic_pin_cmd;
 2142|      1|	authentic_ops.card_reader_lock_obtained = authentic_card_reader_lock_obtained;
 2143|       |
 2144|      1|	return &authentic_drv;
 2145|      1|}

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

sc_get_cac_driver:
 1911|      2|{
 1912|      2|	return sc_get_driver();
 1913|      2|}
card-cac.c:sc_get_driver:
 1885|      2|{
 1886|      2|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1887|       |
 1888|      2|	cac_ops = *iso_drv->ops;
 1889|      2|	cac_ops.match_card = cac_match_card;
 1890|      2|	cac_ops.init = cac_init;
 1891|      2|	cac_ops.finish = cac_finish;
 1892|       |
 1893|      2|	cac_ops.select_file =  cac_select_file; /* need to record object type */
 1894|      2|	cac_ops.get_challenge = cac_get_challenge;
 1895|      2|	cac_ops.read_binary = cac_read_binary;
 1896|       |	/* CAC driver is read only */
 1897|      2|	cac_ops.write_binary = NULL;
 1898|      2|	cac_ops.set_security_env = cac_set_security_env;
 1899|      2|	cac_ops.restore_security_env = cac_restore_security_env;
 1900|      2|	cac_ops.compute_signature = cac_compute_signature;
 1901|      2|	cac_ops.decipher =  cac_decipher;
 1902|      2|	cac_ops.card_ctl = cac_card_ctl;
 1903|      2|	cac_ops.pin_cmd = cac_pin_cmd;
 1904|      2|	cac_ops.logout = cac_logout;
 1905|       |
 1906|      2|	return &cac_drv;
 1907|      2|}

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

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

sc_get_cedulauy_driver:
  292|      1|{
  293|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  294|       |
  295|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (295:6): [True: 1, False: 0]
  ------------------
  296|      1|		iso_ops = iso_drv->ops;
  297|       |
  298|      1|	cedulauy_ops = *iso_ops;
  299|      1|	cedulauy_ops.match_card = cedulauy_match_card;
  300|      1|	cedulauy_ops.init = cedulauy_init;
  301|      1|	cedulauy_ops.select_file = cedulauy_select_file;
  302|      1|	cedulauy_ops.set_security_env = cedulauy_set_security_env;
  303|      1|	cedulauy_ops.compute_signature = cedulauy_compute_signature;
  304|      1|	cedulauy_ops.decipher = NULL; /* the signing key is sign-only */
  305|      1|	cedulauy_ops.get_challenge = cedulauy_get_challenge;
  306|      1|	cedulauy_ops.logout = cedulauy_logout;
  307|      1|	cedulauy_ops.card_reader_lock_obtained = cedulauy_card_reader_lock_obtained;
  308|       |
  309|      1|	return &cedulauy_drv;
  310|      1|}

sc_get_coolkey_driver:
 2467|      1|{
 2468|      1|	return sc_get_driver();
 2469|      1|}
card-coolkey.c:sc_get_driver:
 2440|      1|{
 2441|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2442|       |
 2443|      1|	coolkey_ops = *iso_drv->ops;
 2444|      1|	coolkey_ops.match_card = coolkey_match_card;
 2445|      1|	coolkey_ops.init = coolkey_init;
 2446|      1|	coolkey_ops.finish = coolkey_finish;
 2447|       |
 2448|      1|	coolkey_ops.select_file =  coolkey_select_file; /* need to record object type */
 2449|      1|	coolkey_ops.get_challenge = coolkey_get_challenge;
 2450|      1|	coolkey_ops.read_binary = coolkey_read_binary;
 2451|      1|	coolkey_ops.write_binary = coolkey_write_binary;
 2452|      1|	coolkey_ops.set_security_env = coolkey_set_security_env;
 2453|      1|	coolkey_ops.restore_security_env = coolkey_restore_security_env;
 2454|      1|	coolkey_ops.compute_signature = coolkey_compute_crypt;
 2455|      1|	coolkey_ops.decipher =  coolkey_compute_crypt;
 2456|      1|	coolkey_ops.card_ctl = coolkey_card_ctl;
 2457|      1|	coolkey_ops.check_sw = coolkey_check_sw;
 2458|      1|	coolkey_ops.pin_cmd = coolkey_pin_cmd;
 2459|      1|	coolkey_ops.logout = coolkey_logout;
 2460|      1|	coolkey_ops.card_reader_lock_obtained = coolkey_card_reader_lock_obtained;
 2461|       |
 2462|      1|	return &coolkey_drv;
 2463|      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:
 2301|      1|{
 2302|      1|	return get_dnie_driver();
 2303|      1|}
card-dnie.c:get_dnie_driver:
 2238|      1|{
 2239|      1|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 2240|       |
 2241|       |	/* memcpy() from standard iso7816 declared operations */
 2242|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2242:6): [True: 1, False: 0]
  ------------------
 2243|      1|		iso_ops = iso_drv->ops;
 2244|      1|	dnie_ops = *iso_drv->ops;
 2245|       |
 2246|       |	/* fill card specific function pointers */
 2247|       |	/* NULL means that function is not supported neither by DNIe nor iso7816.c */
 2248|       |	/* if pointer is omitted, default ISO7816 function will be used */
 2249|       |
 2250|       |	/* initialization */
 2251|      1|	dnie_ops.match_card	= dnie_match_card;
 2252|      1|	dnie_ops.init		= dnie_init;
 2253|      1|	dnie_ops.finish		= dnie_finish;
 2254|       |
 2255|       |	/* iso7816-4 functions */
 2256|      1|	dnie_ops.read_binary	= dnie_read_binary;
 2257|      1|	dnie_ops.write_binary	= NULL;
 2258|      1|	dnie_ops.update_binary	= NULL;
 2259|      1|	dnie_ops.erase_binary	= NULL;
 2260|      1|	dnie_ops.read_record	= NULL;
 2261|      1|	dnie_ops.write_record	= NULL;
 2262|      1|	dnie_ops.append_record	= NULL;
 2263|      1|	dnie_ops.update_record	= NULL;
 2264|      1|	dnie_ops.select_file	= dnie_select_file;
 2265|      1|	dnie_ops.get_challenge	= dnie_get_challenge;
 2266|       |
 2267|       |	/* iso7816-8 functions */
 2268|      1|	dnie_ops.verify		= NULL;
 2269|      1|	dnie_ops.logout		= dnie_logout;
 2270|       |	/* dnie_ops.restore_security_env */
 2271|      1|	dnie_ops.set_security_env = dnie_set_security_env;
 2272|      1|	dnie_ops.decipher	= dnie_decipher;
 2273|      1|	dnie_ops.compute_signature = dnie_compute_signature;
 2274|      1|	dnie_ops.change_reference_data = NULL;
 2275|      1|	dnie_ops.reset_retry_counter = NULL;
 2276|       |
 2277|       |	/* iso7816-9 functions */
 2278|      1|	dnie_ops.create_file	= NULL;
 2279|      1|	dnie_ops.delete_file	= NULL;
 2280|      1|	dnie_ops.list_files	= dnie_list_files;
 2281|      1|	dnie_ops.check_sw	= dnie_check_sw;
 2282|      1|	dnie_ops.card_ctl	= dnie_card_ctl;
 2283|      1|	dnie_ops.process_fci	= dnie_process_fci;
 2284|       |	/* dnie_ops.construct_fci */
 2285|      1|	dnie_ops.pin_cmd	= dnie_pin_cmd;
 2286|      1|	dnie_ops.get_data	= NULL;
 2287|      1|	dnie_ops.put_data	= NULL;
 2288|      1|	dnie_ops.delete_record	= NULL;
 2289|       |
 2290|      1|	return &dnie_driver;
 2291|      1|}

sc_get_dtrust_driver:
 1056|      1|{
 1057|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1057:6): [True: 1, False: 0]
  ------------------
 1058|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1059|       |
 1060|      1|	dtrust_ops = *iso_ops;
 1061|      1|	dtrust_ops.match_card = dtrust_match_card;
 1062|      1|	dtrust_ops.init = dtrust_init;
 1063|      1|	dtrust_ops.finish = dtrust_finish;
 1064|      1|	dtrust_ops.pin_cmd = dtrust_pin_cmd;
 1065|      1|	dtrust_ops.set_security_env = dtrust_set_security_env;
 1066|      1|	dtrust_ops.compute_signature = dtrust_compute_signature;
 1067|      1|	dtrust_ops.decipher = dtrust_decipher;
 1068|      1|	dtrust_ops.logout = dtrust_logout;
 1069|       |
 1070|      1|	return &dtrust_drv;
 1071|      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:
 1579|      1|{
 1580|      1|	return sc_get_driver();
 1581|      1|}
card-entersafe.c:sc_get_driver:
 1553|      1|{
 1554|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1555|       |
 1556|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1556:6): [True: 1, False: 0]
  ------------------
 1557|      1|		iso_ops = iso_drv->ops;
 1558|       |
 1559|      1|	entersafe_ops = *iso_drv->ops;
 1560|      1|	entersafe_ops.match_card = entersafe_match_card;
 1561|      1|	entersafe_ops.init = entersafe_init;
 1562|      1|	entersafe_ops.read_binary = entersafe_read_binary;
 1563|      1|	entersafe_ops.write_binary = NULL;
 1564|      1|	entersafe_ops.update_binary = entersafe_update_binary;
 1565|      1|	entersafe_ops.select_file = entersafe_select_file;
 1566|      1|	entersafe_ops.restore_security_env = entersafe_restore_security_env;
 1567|      1|	entersafe_ops.set_security_env = entersafe_set_security_env;
 1568|      1|	entersafe_ops.decipher = entersafe_decipher;
 1569|      1|	entersafe_ops.compute_signature = entersafe_compute_signature;
 1570|      1|	entersafe_ops.create_file = entersafe_create_file;
 1571|       |	entersafe_ops.delete_file = NULL;
 1572|      1|	entersafe_ops.pin_cmd = entersafe_pin_cmd;
 1573|      1|	entersafe_ops.card_ctl = entersafe_card_ctl_2048;
 1574|      1|	entersafe_ops.process_fci = entersafe_process_fci;
 1575|      1|	return &entersafe_drv;
 1576|      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:
 3322|      1|{
 3323|      1|	return sc_get_driver();
 3324|      1|}
card-epass2003.c:sc_get_driver:
 3289|      1|{
 3290|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3291|       |
 3292|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (3292:6): [True: 1, False: 0]
  ------------------
 3293|      1|		iso_ops = iso_drv->ops;
 3294|       |
 3295|      1|	epass2003_ops = *iso_ops;
 3296|       |
 3297|      1|	epass2003_ops.match_card = epass2003_match_card;
 3298|      1|	epass2003_ops.init = epass2003_init;
 3299|      1|	epass2003_ops.finish = epass2003_finish;
 3300|      1|	epass2003_ops.write_binary = NULL;
 3301|      1|	epass2003_ops.write_record = NULL;
 3302|      1|	epass2003_ops.select_file = epass2003_select_file;
 3303|       |	epass2003_ops.get_response = NULL;
 3304|      1|	epass2003_ops.restore_security_env = epass2003_restore_security_env;
 3305|      1|	epass2003_ops.set_security_env = epass2003_set_security_env;
 3306|      1|	epass2003_ops.decipher = epass2003_decipher;
 3307|      1|	epass2003_ops.compute_signature = epass2003_decipher;
 3308|      1|	epass2003_ops.create_file = epass2003_create_file;
 3309|      1|	epass2003_ops.delete_file = epass2003_delete_file;
 3310|      1|	epass2003_ops.list_files = epass2003_list_files;
 3311|      1|	epass2003_ops.card_ctl = epass2003_card_ctl;
 3312|      1|	epass2003_ops.process_fci = epass2003_process_fci;
 3313|      1|	epass2003_ops.construct_fci = epass2003_construct_fci;
 3314|      1|	epass2003_ops.pin_cmd = epass2003_pin_cmd;
 3315|      1|	epass2003_ops.check_sw = epass2003_check_sw;
 3316|      1|	epass2003_ops.get_challenge = epass2003_get_challenge;
 3317|      1|	epass2003_ops.logout = epass2003_logout;
 3318|      1|	return &epass2003_drv;
 3319|      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:
 1203|      1|{
 1204|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1204:6): [True: 0, False: 1]
  ------------------
 1205|      0|		iso_ops = sc_get_iso7816_driver()->ops;
 1206|       |
 1207|      1|	cryptoflex_ops = *iso_ops;
 1208|      1|	cryptoflex_ops.match_card = cryptoflex_match_card;
 1209|      1|	cryptoflex_ops.init = flex_init;
 1210|      1|	cryptoflex_ops.finish = flex_finish;
 1211|      1|	cryptoflex_ops.process_fci = cryptoflex_process_file_attrs;
 1212|      1|	cryptoflex_ops.construct_fci = cryptoflex_construct_file_attrs;
 1213|      1|	cryptoflex_ops.select_file = flex_select_file;
 1214|      1|	cryptoflex_ops.list_files = cryptoflex_list_files;
 1215|      1|	cryptoflex_ops.delete_file = flex_delete_file;
 1216|      1|	cryptoflex_ops.create_file = flex_create_file;
 1217|      1|	cryptoflex_ops.card_ctl = flex_card_ctl;
 1218|      1|	cryptoflex_ops.set_security_env = flex_set_security_env;
 1219|      1|	cryptoflex_ops.restore_security_env = flex_restore_security_env;
 1220|      1|	cryptoflex_ops.compute_signature = cryptoflex_compute_signature;
 1221|      1|	cryptoflex_ops.decipher = flex_decipher;
 1222|      1|	cryptoflex_ops.pin_cmd = flex_pin_cmd;
 1223|      1|	cryptoflex_ops.logout = flex_logout;
 1224|      1|	return &cryptoflex_drv;
 1225|      1|}
sc_get_cyberflex_driver:
 1228|      1|{
 1229|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1229:6): [True: 1, False: 0]
  ------------------
 1230|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1231|       |
 1232|      1|	cyberflex_ops = *iso_ops;
 1233|      1|	cyberflex_ops.match_card = cyberflex_match_card;
 1234|      1|	cyberflex_ops.init = flex_init;
 1235|      1|	cyberflex_ops.finish = flex_finish;
 1236|      1|	cyberflex_ops.process_fci = cyberflex_process_file_attrs;
 1237|      1|	cyberflex_ops.construct_fci = cyberflex_construct_file_attrs;
 1238|      1|	cyberflex_ops.select_file = flex_select_file;
 1239|      1|	cyberflex_ops.list_files = cyberflex_list_files;
 1240|      1|	cyberflex_ops.delete_file = flex_delete_file;
 1241|      1|	cyberflex_ops.create_file = flex_create_file;
 1242|      1|	cyberflex_ops.card_ctl = flex_card_ctl;
 1243|      1|	cyberflex_ops.set_security_env = flex_set_security_env;
 1244|      1|	cyberflex_ops.restore_security_env = flex_restore_security_env;
 1245|      1|	cyberflex_ops.compute_signature = cyberflex_compute_signature;
 1246|      1|	cyberflex_ops.decipher = flex_decipher;
 1247|      1|	cyberflex_ops.pin_cmd = flex_pin_cmd;
 1248|      1|	cyberflex_ops.logout = flex_logout;
 1249|      1|	return &cyberflex_drv;
 1250|      1|}

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

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

sc_get_iasecc_driver:
 3638|      1|{
 3639|      1|	return sc_get_driver();
 3640|      1|}
card-iasecc.c:sc_get_driver:
 3591|      1|{
 3592|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3593|       |
 3594|      1|	if (!iso_ops)
  ------------------
  |  Branch (3594:6): [True: 1, False: 0]
  ------------------
 3595|      1|		iso_ops = iso_drv->ops;
 3596|       |
 3597|      1|	iasecc_ops = *iso_ops;
 3598|       |
 3599|      1|	iasecc_ops.match_card = iasecc_match_card;
 3600|      1|	iasecc_ops.init = iasecc_init;
 3601|      1|	iasecc_ops.finish = iasecc_finish;
 3602|      1|	iasecc_ops.read_binary = iasecc_read_binary;
 3603|       |	/*	write_binary: ISO7816 implementation works	*/
 3604|       |	/*	update_binary: ISO7816 implementation works	*/
 3605|      1|	iasecc_ops.erase_binary = iasecc_erase_binary;
 3606|       |	/*	resize_binary	*/
 3607|       |	/* 	read_record: Untested	*/
 3608|       |	/*	write_record: Untested	*/
 3609|       |	/*	append_record: Untested	*/
 3610|       |	/*	update_record: Untested	*/
 3611|      1|	iasecc_ops.select_file = iasecc_select_file;
 3612|       |	/*	get_response: Untested	*/
 3613|      1|	iasecc_ops.get_challenge = iasecc_get_challenge;
 3614|      1|	iasecc_ops.logout = iasecc_logout;
 3615|       |	/*	restore_security_env	*/
 3616|      1|	iasecc_ops.set_security_env = iasecc_set_security_env;
 3617|      1|	iasecc_ops.decipher = iasecc_decipher;
 3618|      1|	iasecc_ops.compute_signature = iasecc_compute_signature;
 3619|      1|	iasecc_ops.create_file = iasecc_create_file;
 3620|      1|	iasecc_ops.delete_file = iasecc_delete_file;
 3621|       |	/*	list_files	*/
 3622|      1|	iasecc_ops.check_sw = iasecc_check_sw;
 3623|      1|	iasecc_ops.card_ctl = iasecc_card_ctl;
 3624|      1|	iasecc_ops.process_fci = iasecc_process_fci;
 3625|       |	/*	construct_fci: Not needed	*/
 3626|      1|	iasecc_ops.pin_cmd = iasecc_pin_cmd;
 3627|       |	/*	get_data: Not implemented	*/
 3628|       |	/*	put_data: Not implemented	*/
 3629|       |	/*	delete_record: Not implemented	*/
 3630|       |
 3631|      1|	iasecc_ops.read_public_key = iasecc_read_public_key;
 3632|       |
 3633|      1|	return &iasecc_drv;
 3634|      1|}

sc_get_idprime_driver:
 1281|      1|{
 1282|      1|	return sc_get_driver();
 1283|      1|}
card-idprime.c:sc_get_driver:
 1258|      1|{
 1259|      1|	if (iso_ops == NULL) {
  ------------------
  |  Branch (1259:6): [True: 1, False: 0]
  ------------------
 1260|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1261|      1|	}
 1262|       |
 1263|      1|	idprime_ops = *iso_ops;
 1264|      1|	idprime_ops.match_card = idprime_match_card;
 1265|      1|	idprime_ops.init = idprime_init;
 1266|      1|	idprime_ops.finish = idprime_finish;
 1267|       |
 1268|      1|	idprime_ops.read_binary = idprime_read_binary;
 1269|      1|	idprime_ops.select_file = idprime_select_file;
 1270|      1|	idprime_ops.card_ctl = idprime_card_ctl;
 1271|      1|	idprime_ops.set_security_env = idprime_set_security_env;
 1272|      1|	idprime_ops.compute_signature = idprime_compute_signature;
 1273|      1|	idprime_ops.decipher = idprime_decipher;
 1274|       |
 1275|      1|	idprime_ops.get_challenge = idprime_get_challenge;
 1276|       |
 1277|      1|	return &idprime_drv;
 1278|      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:
  523|      1|{
  524|      1|	return sc_get_driver();
  525|      1|}
card-itacns.c:sc_get_driver:
  504|      1|{
  505|      1|	if (!default_ops)
  ------------------
  |  Branch (505:6): [True: 1, False: 0]
  ------------------
  506|      1|		default_ops = sc_get_iso7816_driver()->ops;
  507|      1|	itacns_ops = *default_ops;
  508|      1|	itacns_ops.match_card = itacns_match_card;
  509|      1|	itacns_ops.init = itacns_init;
  510|      1|	itacns_ops.finish = itacns_finish;
  511|      1|	itacns_ops.set_security_env = itacns_set_security_env;
  512|      1|	itacns_ops.restore_security_env = itacns_restore_security_env;
  513|      1|	itacns_ops.pin_cmd = itacns_pin_cmd;
  514|      1|	itacns_ops.read_binary = itacns_read_binary;
  515|      1|	itacns_ops.list_files = itacns_list_files;
  516|      1|	itacns_ops.select_file = itacns_select_file;
  517|      1|	itacns_ops.card_ctl = itacns_card_ctl;
  518|      1|	itacns_ops.get_challenge = itacns_get_challenge;
  519|      1|	return &itacns_drv;
  520|      1|}

sc_get_jpki_driver:
  382|      1|{
  383|      1|	return sc_get_driver();
  384|      1|}
card-jpki.c:sc_get_driver:
  363|      1|{
  364|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  365|       |
  366|      1|	jpki_ops = *iso_drv->ops;
  367|      1|	jpki_ops.match_card = jpki_match_card;
  368|      1|	jpki_ops.init = jpki_init;
  369|      1|	jpki_ops.finish = jpki_finish;
  370|      1|	jpki_ops.select_file = jpki_select_file;
  371|      1|	jpki_ops.pin_cmd = jpki_pin_cmd;
  372|      1|	jpki_ops.set_security_env = jpki_set_security_env;
  373|      1|	jpki_ops.compute_signature = jpki_compute_signature;
  374|      1|	jpki_ops.card_reader_lock_obtained = jpki_card_reader_lock_obtained;
  375|      1|	jpki_ops.logout = jpki_logout;
  376|       |
  377|      1|	return &jpki_drv;
  378|      1|}

sc_get_lteid_driver:
  555|      1|{
  556|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  557|       |
  558|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (558:6): [True: 1, False: 0]
  ------------------
  559|      1|		iso_ops = iso_drv->ops;
  560|       |
  561|      1|	lteid_ops = *iso_ops;
  562|      1|	lteid_ops.init = lteid_init;
  563|      1|	lteid_ops.finish = lteid_finish;
  564|      1|	lteid_ops.set_security_env = lteid_set_security_env;
  565|      1|	lteid_ops.compute_signature = lteid_compute_signature;
  566|      1|	lteid_ops.pin_cmd = lteid_pin_cmd;
  567|      1|	lteid_ops.logout = lteid_logout;
  568|      1|	lteid_ops.process_fci = lteid_process_fci;
  569|       |
  570|      1|	return &lteid_drv;
  571|      1|}

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

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

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

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

sc_get_npa_driver:
  810|      1|{
  811|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  812|       |
  813|      1|	npa_ops = *iso_drv->ops;
  814|      1|	npa_ops.match_card = npa_match_card;
  815|      1|	npa_ops.init = npa_init;
  816|      1|	npa_ops.finish = npa_finish;
  817|      1|	npa_ops.set_security_env = npa_set_security_env;
  818|      1|	npa_ops.pin_cmd = npa_pin_cmd;
  819|      1|	npa_ops.logout = npa_logout;
  820|       |
  821|      1|	return &npa_drv;
  822|      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:
 2319|      1|{
 2320|      1|	return sc_get_driver();
 2321|      1|}
card-oberthur.c:sc_get_driver:
 2288|      1|{
 2289|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (2289:6): [True: 1, False: 0]
  ------------------
 2290|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2291|       |
 2292|      1|	auth_ops = *iso_ops;
 2293|      1|	auth_ops.match_card = auth_match_card;
 2294|      1|	auth_ops.init = auth_init;
 2295|      1|	auth_ops.finish = auth_finish;
 2296|      1|	auth_ops.select_file = auth_select_file;
 2297|      1|	auth_ops.list_files = auth_list_files;
 2298|      1|	auth_ops.delete_file = auth_delete_file;
 2299|      1|	auth_ops.create_file = auth_create_file;
 2300|      1|	auth_ops.read_binary = auth_read_binary;
 2301|      1|	auth_ops.update_binary = auth_update_binary;
 2302|      1|	auth_ops.read_record = auth_read_record;
 2303|      1|	auth_ops.delete_record = auth_delete_record;
 2304|      1|	auth_ops.card_ctl = auth_card_ctl;
 2305|      1|	auth_ops.set_security_env = auth_set_security_env;
 2306|      1|	auth_ops.restore_security_env = auth_restore_security_env;
 2307|      1|	auth_ops.compute_signature = auth_compute_signature;
 2308|      1|	auth_ops.decipher = auth_decipher;
 2309|      1|	auth_ops.process_fci = auth_process_fci;
 2310|      1|	auth_ops.pin_cmd = auth_pin_cmd;
 2311|      1|	auth_ops.logout = auth_logout;
 2312|      1|	auth_ops.check_sw = auth_check_sw;
 2313|      1|	return &auth_drv;
 2314|      1|}

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

sc_get_piv_driver:
 6570|      1|{
 6571|      1|	return sc_get_driver();
 6572|      1|}
card-piv.c:sc_get_driver:
 6543|      1|{
 6544|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6545|       |
 6546|      1|	piv_ops = *iso_drv->ops;
 6547|      1|	piv_ops.match_card = piv_match_card;
 6548|      1|	piv_ops.init = piv_init;
 6549|      1|	piv_ops.finish = piv_finish;
 6550|       |
 6551|      1|	piv_ops.select_file = piv_select_file; /* must use get/put, could emulate? */
 6552|      1|	piv_ops.get_challenge = piv_get_challenge;
 6553|      1|	piv_ops.logout = piv_logout;
 6554|      1|	piv_ops.read_binary = piv_read_binary;
 6555|      1|	piv_ops.write_binary = piv_write_binary;
 6556|      1|	piv_ops.set_security_env = piv_set_security_env;
 6557|      1|	piv_ops.restore_security_env = piv_restore_security_env;
 6558|      1|	piv_ops.compute_signature = piv_compute_signature;
 6559|      1|	piv_ops.decipher = piv_decipher;
 6560|      1|	piv_ops.check_sw = piv_check_sw;
 6561|      1|	piv_ops.card_ctl = piv_card_ctl;
 6562|      1|	piv_ops.pin_cmd = piv_pin_cmd;
 6563|      1|	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 6564|       |
 6565|      1|	return &piv_drv;
 6566|      1|}

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

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

sc_get_sc_hsm_driver:
 1978|      1|{
 1979|      1|	return sc_get_driver();
 1980|      1|}
card-sc-hsm.c:sc_get_driver:
 1942|      1|{
 1943|      1|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1944|       |
 1945|      1|	if (iso_ops == NULL)
  ------------------
  |  Branch (1945:6): [True: 1, False: 0]
  ------------------
 1946|      1|		iso_ops = iso_drv->ops;
 1947|       |
 1948|      1|	sc_hsm_ops                   = *iso_drv->ops;
 1949|      1|	sc_hsm_ops.match_card        = sc_hsm_match_card;
 1950|      1|	sc_hsm_ops.select_file       = sc_hsm_select_file;
 1951|      1|	sc_hsm_ops.get_challenge     = sc_hsm_get_challenge;
 1952|      1|	sc_hsm_ops.read_binary       = sc_hsm_read_binary;
 1953|      1|	sc_hsm_ops.update_binary     = sc_hsm_update_binary;
 1954|      1|	sc_hsm_ops.list_files        = sc_hsm_list_files;
 1955|      1|	sc_hsm_ops.create_file       = sc_hsm_create_file;
 1956|      1|	sc_hsm_ops.delete_file       = sc_hsm_delete_file;
 1957|      1|	sc_hsm_ops.set_security_env  = sc_hsm_set_security_env;
 1958|      1|	sc_hsm_ops.compute_signature = sc_hsm_compute_signature;
 1959|      1|	sc_hsm_ops.decipher          = sc_hsm_decipher;
 1960|      1|	sc_hsm_ops.init              = sc_hsm_init;
 1961|      1|	sc_hsm_ops.finish            = sc_hsm_finish;
 1962|      1|	sc_hsm_ops.card_ctl          = sc_hsm_card_ctl;
 1963|      1|	sc_hsm_ops.pin_cmd           = sc_hsm_pin_cmd;
 1964|      1|	sc_hsm_ops.logout            = sc_hsm_logout;
 1965|       |
 1966|       |	/* no record oriented file services */
 1967|      1|	sc_hsm_ops.read_record       = NULL;
 1968|      1|	sc_hsm_ops.write_record      = NULL;
 1969|      1|	sc_hsm_ops.append_record     = NULL;
 1970|      1|	sc_hsm_ops.update_record     = NULL;
 1971|       |
 1972|      1|	return &sc_hsm_drv;
 1973|      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:
  305|      1|{
  306|       |	/* Save ISO ops for delegation, then override what we handle. */
  307|      1|	iso_ops = sc_get_iso7816_driver()->ops;
  308|      1|	srbeid_ops = *iso_ops;
  309|      1|	srbeid_ops.match_card = srbeid_match_card;
  310|      1|	srbeid_ops.init = srbeid_init;
  311|      1|	srbeid_ops.select_file = srbeid_select_file;
  312|      1|	srbeid_ops.set_security_env = srbeid_set_security_env;
  313|      1|	srbeid_ops.compute_signature = srbeid_compute_signature;
  314|      1|	srbeid_ops.decipher = srbeid_decipher;
  315|       |
  316|      1|	return &srbeid_drv;
  317|      1|}

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

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

sc_get_conf_block:
 1445|      1|{
 1446|      1|	int i;
 1447|      1|	scconf_block *conf_block = NULL;
 1448|       |
 1449|      2|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (1449:14): [True: 1, False: 1]
  ------------------
 1450|      1|		scconf_block **blocks;
 1451|       |
 1452|      1|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], name1, name2);
 1453|      1|		if (blocks != NULL) {
  ------------------
  |  Branch (1453:7): [True: 1, False: 0]
  ------------------
 1454|      1|			conf_block = blocks[0];
 1455|      1|			free(blocks);
 1456|      1|		}
 1457|      1|		if (conf_block != NULL && priority)
  ------------------
  |  Branch (1457:7): [True: 0, False: 1]
  |  Branch (1457:29): [True: 0, False: 0]
  ------------------
 1458|      0|			break;
 1459|      1|	}
 1460|      1|	return conf_block;
 1461|      1|}

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

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

sc_get_iso7816_driver:
 1485|     44|{
 1486|     44|	return &iso_driver;
 1487|     44|}

sc_do_log:
   58|  8.99k|{
   59|  8.99k|	va_list ap;
   60|       |
   61|  8.99k|	va_start(ap, format);
   62|  8.99k|	sc_do_log_va(ctx, level, file, line, func, 0, format, ap);
   63|       |	va_end(ap);
   64|  8.99k|}
sc_do_log_color:
   67|  1.96k|{
   68|  1.96k|	va_list ap;
   69|       |
   70|  1.96k|	va_start(ap, format);
   71|  1.96k|	sc_do_log_va(ctx, level, file, line, func, color, format, ap);
   72|       |	va_end(ap);
   73|  1.96k|}
sc_dump_hex:
  412|    882|{
  413|    882|	static char dump_buf[0x1000];
  414|    882|	size_t ii, size = sizeof(dump_buf) - 0x10;
  415|    882|	size_t offs = 0;
  416|       |
  417|    882|	memset(dump_buf, 0, sizeof(dump_buf));
  418|    882|	if (in == NULL)
  ------------------
  |  Branch (418:6): [True: 0, False: 882]
  ------------------
  419|      0|		return dump_buf;
  420|       |
  421|   332k|	for (ii=0; ii<count; ii++) {
  ------------------
  |  Branch (421:13): [True: 331k, False: 736]
  ------------------
  422|   331k|		if (ii && !(ii%16))   {
  ------------------
  |  Branch (422:7): [True: 331k, False: 736]
  |  Branch (422:13): [True: 20.2k, False: 310k]
  ------------------
  423|  20.2k|			if (!(ii%48))
  ------------------
  |  Branch (423:8): [True: 6.70k, False: 13.5k]
  ------------------
  424|  6.70k|				snprintf(dump_buf + offs, size - offs, "\n");
  425|  13.5k|			else
  426|  13.5k|				snprintf(dump_buf + offs, size - offs, " ");
  427|  20.2k|			offs = strlen(dump_buf);
  428|  20.2k|		}
  429|       |
  430|   331k|		snprintf(dump_buf + offs, size - offs, "%02X", *(in + ii));
  431|   331k|		offs += 2;
  432|       |
  433|   331k|		if (offs > size)
  ------------------
  |  Branch (433:7): [True: 146, False: 331k]
  ------------------
  434|    146|			break;
  435|   331k|	}
  436|       |
  437|    882|	if (ii<count)
  ------------------
  |  Branch (437:6): [True: 146, False: 736]
  ------------------
  438|    146|		snprintf(dump_buf + offs, sizeof(dump_buf) - offs, "....\n");
  439|       |
  440|    882|	return dump_buf;
  441|    882|}
log.c:sc_do_log_va:
  124|  10.9k|{
  125|       |#ifdef _WIN32
  126|       |	SYSTEMTIME st;
  127|       |#else
  128|  10.9k|	struct tm *tm;
  129|  10.9k|	struct timeval tv;
  130|  10.9k|	char time_string[40];
  131|  10.9k|#endif
  132|       |
  133|  10.9k|	if (!ctx || ctx->debug < level)
  ------------------
  |  Branch (133:6): [True: 0, False: 10.9k]
  |  Branch (133:14): [True: 10.9k, False: 0]
  ------------------
  134|  10.9k|		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:
 1084|      1|{
 1085|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1085:6): [True: 0, False: 1]
  ------------------
 1086|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1087|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)
  ------------------
  |  Branch (1087:6): [True: 0, False: 1]
  |  Branch (1087:33): [True: 0, False: 0]
  ------------------
 1088|      0|		return ctx->thread_ctx->create_mutex(mutex);
 1089|      1|	else
 1090|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1091|      1|}
sc_mutex_lock:
 1094|      1|{
 1095|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1095:6): [True: 0, False: 1]
  ------------------
 1096|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1097|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->lock_mutex != NULL)
  ------------------
  |  Branch (1097:6): [True: 0, False: 1]
  |  Branch (1097:33): [True: 0, False: 0]
  ------------------
 1098|      0|		return ctx->thread_ctx->lock_mutex(mutex);
 1099|      1|	else
 1100|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1101|      1|}
sc_mutex_unlock:
 1104|      1|{
 1105|      1|	if (ctx == NULL)
  ------------------
  |  Branch (1105:6): [True: 0, False: 1]
  ------------------
 1106|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1107|      1|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->unlock_mutex != NULL)
  ------------------
  |  Branch (1107:6): [True: 0, False: 1]
  |  Branch (1107:33): [True: 0, False: 0]
  ------------------
 1108|      0|		return ctx->thread_ctx->unlock_mutex(mutex);
 1109|      1|	else
 1110|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1111|      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|     50|{
   88|     50|	scconf_block **blocks = NULL, **tmp;
   89|     50|	int alloc_size, size;
   90|     50|	scconf_item *item;
   91|       |
   92|     50|	if (!block) {
  ------------------
  |  Branch (92:6): [True: 3, False: 47]
  ------------------
   93|      3|		block = config->root;
   94|      3|	}
   95|     50|	if (!item_name) {
  ------------------
  |  Branch (95:6): [True: 0, False: 50]
  ------------------
   96|      0|		return NULL;
   97|      0|	}
   98|     50|	size = 0;
   99|     50|	alloc_size = 10;
  100|     50|	tmp = (scconf_block **) realloc(blocks, sizeof(scconf_block *) * alloc_size);
  101|     50|	if (!tmp) {
  ------------------
  |  Branch (101:6): [True: 0, False: 50]
  ------------------
  102|      0|		free(blocks);
  103|      0|		return NULL;
  104|      0|	}
  105|     50|	blocks = tmp;
  106|       |
  107|    100|	for (item = block->items; item; item = item->next) {
  ------------------
  |  Branch (107:28): [True: 50, False: 50]
  ------------------
  108|     50|		if (item->type == SCCONF_ITEM_TYPE_BLOCK &&
  ------------------
  |  |   43|    100|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (108:7): [True: 3, False: 47]
  ------------------
  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|     50|	}
  127|     50|	blocks[size] = NULL;
  128|     50|	return blocks;
  129|     50|}
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|    501|{
   33|    501|    if (!ctx)
  ------------------
  |  Branch (33:9): [True: 1, False: 500]
  ------------------
   34|      1|        sc_establish_context(&ctx, "fuzz");
   35|       |
   36|    501|    if (outlen < Size*2) {
  ------------------
  |  Branch (36:9): [True: 247, False: 254]
  ------------------
   37|    247|        unsigned char *p = realloc(out, Size*2);
   38|    247|        if (p) {
  ------------------
  |  Branch (38:13): [True: 247, False: 0]
  ------------------
   39|    247|            out = p;
   40|    247|            outlen = Size*2;
   41|    247|        } else {
   42|      0|            return 0;
   43|      0|        }
   44|    247|    }
   45|       |
   46|    501|    if (inlen < Size) {
  ------------------
  |  Branch (46:9): [True: 247, False: 254]
  ------------------
   47|    247|        unsigned char *p = realloc(in, Size);
   48|    247|        if (p) {
  ------------------
  |  Branch (48:13): [True: 247, False: 0]
  ------------------
   49|    247|            in = p;
   50|    247|            inlen = Size;
   51|    247|        } else {
   52|      0|            return 0;
   53|      0|        }
   54|    247|    }
   55|    501|    memcpy(in, Data, Size);
   56|       |
   57|    501|    sc_asn1_sig_value_sequence_to_rs(ctx,
   58|    501|            Data, Size,
   59|    501|            out, outlen);
   60|       |
   61|    501|    unsigned char *p = NULL;
   62|    501|    size_t plen = 0;
   63|    501|    sc_asn1_sig_value_rs_to_sequence(ctx,
   64|    501|            in, Size,
   65|    501|            &p, &plen);
   66|    501|    free(p);
   67|       |
   68|    501|    return 0;
   69|    501|}

